2016-06-29 12:54:05 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Includes the core function of the Plugin - Search and Replace the Footnotes.
|
|
|
|
|
*
|
|
|
|
|
* @filesource
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
2020-11-12 18:17:28 +00:00
|
|
|
|
*
|
2020-11-01 05:41:22 +00:00
|
|
|
|
* Edited for v2.0.0 and following.
|
2020-11-12 18:17:28 +00:00
|
|
|
|
*
|
2020-12-03 17:38:14 +00:00
|
|
|
|
* 2.0.5 Autoload / infinite scroll support added thanks to code from
|
2020-11-05 02:34:35 +00:00
|
|
|
|
* @docteurfitness <https://wordpress.org/support/topic/auto-load-post-compatibility-update/>
|
2020-11-12 18:17:28 +00:00
|
|
|
|
*
|
2020-12-03 17:38:14 +00:00
|
|
|
|
* 2.0.9 DISABLED the_post HOOK 2020-11-08T1839+0100
|
|
|
|
|
* 2.1.0 promoted the 'Continue reading' button from localization to customization 2020-11-08T2146+0100
|
|
|
|
|
* 2.1.1 combining identical footnotes: fixed dead links 2020-11-14T2233+0100
|
|
|
|
|
* 2.1.1 options fixing ref container layout and referrer vertical alignment 2020-11-16T2024+0100
|
|
|
|
|
* 2.1.1 option fixing ref container relative position 2020-11-17T0254+0100
|
|
|
|
|
* 2.1.2 options for the other hooks 2020-11-19T1849+0100
|
2020-12-06 16:30:14 +00:00
|
|
|
|
* 2.1.4 fix line wrapping of URLs based on pattern, not link element 2020-11-25T0837+0100
|
|
|
|
|
* 2.1.4 fix issues with link elements by making them optional 2020-11-26T1051+0100
|
|
|
|
|
* 2.1.4 support appending arrow when combining identicals is on 2020-11-26T1633+0100
|
|
|
|
|
* 2.1.4 disable or select backlink separator and terminator 2020-11-28T1048+0100
|
|
|
|
|
* 2.1.4 optional line breaks to stack enumerated backlinks 2020-11-28T1049+0100
|
|
|
|
|
* 2.1.4 ref container column width and tooltip font size settings 2020-12-03T0954+0100
|
|
|
|
|
* 2.1.4 scroll offset and duration settings 2020-12-05T0538+0100
|
|
|
|
|
* 2.1.4 tooltip display duration settings 2020-12-06T1320+0100
|
2020-11-24 11:01:34 +00:00
|
|
|
|
*
|
2020-12-06 22:07:52 +00:00
|
|
|
|
* Last modified: 2020-12-06T2248+0100
|
2016-06-29 12:54:05 +00:00
|
|
|
|
*/
|
2020-11-01 05:41:22 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// If called directly, abort:
|
|
|
|
|
defined( 'ABSPATH' ) or die;
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Looks for Footnotes short codes and replaces them. Also displays the Reference Container.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
*/
|
|
|
|
|
class MCI_Footnotes_Task {
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Contains all footnotes found on current public page.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
public static $a_arr_Footnotes = array();
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Flag if the display of 'LOVE FOOTNOTES' is allowed on the current public page.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
public static $a_bool_AllowLoveMe = true;
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Prefix for the Footnote html element ID.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.8
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
public static $a_str_Prefix = "";
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Register WordPress Hooks to replace Footnotes in the content of a public page.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
2020-11-12 18:17:28 +00:00
|
|
|
|
*
|
2020-11-20 05:40:03 +00:00
|
|
|
|
* Edited for:
|
|
|
|
|
* 2.0.5 through v2.0.7 changes to priority 2020-11-02T0330+0100..2020-11-06T1344+0100
|
2020-11-24 11:01:34 +00:00
|
|
|
|
* 2.1.1 add setting for the_content
|
2020-11-24 09:22:27 +00:00
|
|
|
|
* 2.1.2 add settings for 4 other hooks 2020-11-19T1248+0100
|
2020-11-12 18:17:28 +00:00
|
|
|
|
*
|
2020-11-24 09:22:27 +00:00
|
|
|
|
* Setting the_content priority to "10" instead of PHP_INT_MAX i.e. 9223372036854775807
|
2020-11-20 05:40:03 +00:00
|
|
|
|
* makes the footnotes reference container display beneath the post and above other
|
|
|
|
|
* features added by other plugins, e.g. related post lists and social buttons.
|
2020-11-24 11:01:34 +00:00
|
|
|
|
* For YARPP to display related posts below the Footnotes reference container,
|
|
|
|
|
* priority needs to be at least 1200.
|
2020-11-05 02:34:35 +00:00
|
|
|
|
* Requested by users: <https://wordpress.org/support/topic/change-the-position-5/>
|
|
|
|
|
* Documentation: <https://codex.wordpress.org/Plugin_API/#Hook_in_your_Filter>
|
2020-11-19 20:34:45 +00:00
|
|
|
|
*
|
2020-11-20 05:40:03 +00:00
|
|
|
|
* Default remains PHP_INT_MAX.
|
|
|
|
|
* PHP_INT_MAX cannot be reset by leaving the number box empty. because browsers
|
|
|
|
|
* (WebKit) don’t allow it, so we must resort to -1.
|
2020-10-27 11:56:49 +00:00
|
|
|
|
*/
|
|
|
|
|
public function registerHooks() {
|
2020-11-20 05:40:03 +00:00
|
|
|
|
|
|
|
|
|
// get values from settings:
|
|
|
|
|
$p_int_TheTitlePriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL));
|
|
|
|
|
$p_int_TheContentPriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL));
|
|
|
|
|
$p_int_TheExcerptPriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL));
|
|
|
|
|
$p_int_WidgetTitlePriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL));
|
|
|
|
|
$p_int_WidgetTextPriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL));
|
|
|
|
|
|
|
|
|
|
// PHP_INT_MAX can be set by -1:
|
|
|
|
|
$p_int_TheTitlePriority = ($p_int_TheTitlePriority == -1) ? PHP_INT_MAX : $p_int_TheTitlePriority ;
|
|
|
|
|
$p_int_TheContentPriority = ($p_int_TheContentPriority == -1) ? PHP_INT_MAX : $p_int_TheContentPriority ;
|
|
|
|
|
$p_int_TheExcerptPriority = ($p_int_TheExcerptPriority == -1) ? PHP_INT_MAX : $p_int_TheExcerptPriority ;
|
|
|
|
|
$p_int_WidgetTitlePriority = ($p_int_WidgetTitlePriority == -1) ? PHP_INT_MAX : $p_int_WidgetTitlePriority;
|
|
|
|
|
$p_int_WidgetTextPriority = ($p_int_WidgetTextPriority == -1) ? PHP_INT_MAX : $p_int_WidgetTextPriority ;
|
|
|
|
|
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// append custom css to the header
|
2020-11-06 14:20:33 +00:00
|
|
|
|
add_filter('wp_head', array($this, "wp_head"), PHP_INT_MAX);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// append the love and share me slug to the footer
|
2020-11-06 14:20:33 +00:00
|
|
|
|
add_filter('wp_footer', array($this, "wp_footer"), PHP_INT_MAX);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_TITLE))) {
|
2020-11-20 05:40:03 +00:00
|
|
|
|
add_filter('the_title', array($this, "the_title"), $p_int_TheTitlePriority);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// custom priority level for reference container relative positioning; default PHP_INT_MAX:
|
2016-06-29 12:54:05 +00:00
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_CONTENT))) {
|
2020-11-18 00:47:53 +00:00
|
|
|
|
add_filter('the_content', array($this, "the_content"), $p_int_TheContentPriority);
|
2020-11-19 20:34:45 +00:00
|
|
|
|
}
|
2020-11-20 05:40:03 +00:00
|
|
|
|
|
2016-06-29 12:54:05 +00:00
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_EXCERPT))) {
|
2020-11-20 05:40:03 +00:00
|
|
|
|
add_filter('the_excerpt', array($this, "the_excerpt"), $p_int_TheExcerptPriority);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE))) {
|
2020-11-20 05:40:03 +00:00
|
|
|
|
add_filter('widget_title', array($this, "widget_title"), $p_int_WidgetTitlePriority);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT))) {
|
2020-11-20 05:40:03 +00:00
|
|
|
|
add_filter('widget_text', array($this, "widget_text"), $p_int_WidgetTextPriority);
|
2020-11-19 20:34:45 +00:00
|
|
|
|
}
|
2020-11-20 05:40:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// REMOVED the_post HOOK 2020-11-08T1839+0100
|
2020-11-19 20:34:45 +00:00
|
|
|
|
//
|
2020-11-08 17:54:50 +00:00
|
|
|
|
//
|
2020-11-20 05:40:03 +00:00
|
|
|
|
|
|
|
|
|
|
2016-06-29 12:54:05 +00:00
|
|
|
|
// reset stored footnotes when displaying the header
|
|
|
|
|
self::$a_arr_Footnotes = array();
|
|
|
|
|
self::$a_bool_AllowLoveMe = true;
|
2020-10-27 11:56:49 +00:00
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Outputs the custom css to the header of the public page.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
*/
|
|
|
|
|
public function wp_head() {
|
2020-12-03 07:55:27 +00:00
|
|
|
|
|
|
|
|
|
// tooltip:
|
|
|
|
|
$l_str_FontSizeEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED));
|
|
|
|
|
$l_str_FontSizeScalar = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR);
|
|
|
|
|
$l_str_FontSizeUnit = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT);
|
|
|
|
|
|
2016-06-29 12:54:05 +00:00
|
|
|
|
$l_str_Color = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR);
|
|
|
|
|
$l_str_Background = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND);
|
2020-12-03 07:55:27 +00:00
|
|
|
|
|
2016-06-29 12:54:05 +00:00
|
|
|
|
$l_int_BorderWidth = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH);
|
|
|
|
|
$l_str_BorderColor = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR);
|
|
|
|
|
$l_int_BorderRadius = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS);
|
2020-12-03 07:55:27 +00:00
|
|
|
|
|
2016-06-29 12:54:05 +00:00
|
|
|
|
$l_int_MaxWidth = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH);
|
2020-12-03 07:55:27 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_str_BoxShadowColor = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR);
|
2020-12-03 07:55:27 +00:00
|
|
|
|
|
|
|
|
|
// ref container first column width:
|
2020-12-03 17:38:14 +00:00
|
|
|
|
$l_bool_ColumnWidthEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED));
|
2020-12-03 07:55:27 +00:00
|
|
|
|
$l_int_ColumnWidthScalar = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR);
|
|
|
|
|
$l_str_ColumnWidthUnit = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_UNIT);
|
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
$l_bool_ColumnMaxWidthEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED));
|
|
|
|
|
$l_int_ColumnMaxWidthScalar = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR);
|
|
|
|
|
$l_str_ColumnMaxWidthUnit = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT);
|
|
|
|
|
|
2020-12-03 07:55:27 +00:00
|
|
|
|
if (!empty($l_int_ColumnWidthScalar)) {
|
|
|
|
|
if ($l_str_ColumnWidthUnit == '%') {
|
|
|
|
|
if ($l_int_ColumnWidthScalar > 100) {
|
|
|
|
|
$l_int_ColumnWidthScalar = 100;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$l_int_ColumnWidthScalar = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($l_int_ColumnMaxWidthScalar)) {
|
|
|
|
|
if ($l_str_ColumnMaxWidthUnit == '%') {
|
|
|
|
|
if ($l_int_ColumnMaxWidthScalar > 100) {
|
|
|
|
|
$l_int_ColumnMaxWidthScalar = 100;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$l_int_ColumnMaxWidthScalar = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
?>
|
2020-12-03 07:55:27 +00:00
|
|
|
|
<style type="text/css" media="all">
|
2016-06-29 12:54:05 +00:00
|
|
|
|
<?php
|
2020-11-16 20:57:15 +00:00
|
|
|
|
|
2020-12-03 07:55:27 +00:00
|
|
|
|
// display ref container on home page:
|
2020-11-17 02:14:21 +00:00
|
|
|
|
if (!MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE))) {
|
2020-12-03 07:55:27 +00:00
|
|
|
|
echo ".home .footnotes_reference_container { display: none; }\r\n";
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// ref container first column width:
|
|
|
|
|
if ( $l_bool_ColumnWidthEnabled || $l_bool_ColumnMaxWidthEnabled ) {
|
|
|
|
|
echo ".footnote-reference-container { table-layout: fixed; }";
|
2020-12-03 07:55:27 +00:00
|
|
|
|
echo ".footnote_plugin_index, .footnote_plugin_index_combi {";
|
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
if ( $l_bool_ColumnWidthEnabled ) {
|
|
|
|
|
echo " width: $l_int_ColumnWidthScalar$l_str_ColumnWidthUnit !important;";
|
|
|
|
|
}
|
|
|
|
|
if ( $l_bool_ColumnMaxWidthEnabled ) {
|
|
|
|
|
echo " max-width: $l_int_ColumnMaxWidthScalar$l_str_ColumnMaxWidthUnit !important;";
|
|
|
|
|
}
|
2020-12-03 07:55:27 +00:00
|
|
|
|
echo '}';
|
2020-11-16 20:57:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// tooltip:
|
2020-11-11 20:49:44 +00:00
|
|
|
|
echo '.footnote_tooltip {';
|
2020-12-03 07:55:27 +00:00
|
|
|
|
|
|
|
|
|
echo ' font-size: ';
|
|
|
|
|
if($l_str_FontSizeEnabled) {
|
|
|
|
|
echo $l_str_FontSizeScalar . $l_str_FontSizeUnit;
|
|
|
|
|
} else {
|
|
|
|
|
echo 'inherit';
|
|
|
|
|
}
|
|
|
|
|
echo ' !important;';
|
|
|
|
|
|
2016-06-29 12:54:05 +00:00
|
|
|
|
if (!empty($l_str_Color)) {
|
2020-11-24 09:22:27 +00:00
|
|
|
|
printf(" color: %s !important;", $l_str_Color);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (!empty($l_str_Background)) {
|
2020-11-24 09:22:27 +00:00
|
|
|
|
printf(" background-color: %s !important;", $l_str_Background);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (!empty($l_int_BorderWidth) && intval($l_int_BorderWidth) > 0) {
|
2020-11-24 09:22:27 +00:00
|
|
|
|
printf(" border-width: %dpx !important; border-style: solid !important;", $l_int_BorderWidth);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (!empty($l_str_BorderColor)) {
|
2020-11-24 09:22:27 +00:00
|
|
|
|
printf(" border-color: %s !important;", $l_str_BorderColor);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (!empty($l_int_BorderRadius) && intval($l_int_BorderRadius) > 0) {
|
2020-11-24 09:22:27 +00:00
|
|
|
|
printf(" border-radius: %dpx !important;", $l_int_BorderRadius);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (!empty($l_int_MaxWidth) && intval($l_int_MaxWidth) > 0) {
|
2020-11-24 09:22:27 +00:00
|
|
|
|
printf(" max-width: %dpx !important;", $l_int_MaxWidth);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (!empty($l_str_BoxShadowColor)) {
|
|
|
|
|
printf(" -webkit-box-shadow: 2px 2px 11px %s;", $l_str_BoxShadowColor);
|
|
|
|
|
printf(" -moz-box-shadow: 2px 2px 11px %s;", $l_str_BoxShadowColor);
|
|
|
|
|
printf(" box-shadow: 2px 2px 11px %s;", $l_str_BoxShadowColor);
|
|
|
|
|
}
|
|
|
|
|
echo '}';
|
2020-11-24 09:22:27 +00:00
|
|
|
|
|
|
|
|
|
// set custom CSS to override settings, not conversely:
|
|
|
|
|
echo MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS);
|
|
|
|
|
|
|
|
|
|
?>
|
2020-11-12 18:17:28 +00:00
|
|
|
|
</style>
|
2020-11-11 20:49:44 +00:00
|
|
|
|
<?php
|
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE))) {
|
|
|
|
|
echo '<script content="text/javascript">' . "\r\n";
|
2020-11-12 18:17:28 +00:00
|
|
|
|
echo "\tfunction footnoteTooltipShow(footnoteTooltipId) {\r\n";
|
|
|
|
|
echo "\t\tdocument.getElementById(footnoteTooltipId).classList.remove('hidden');\r\n";
|
|
|
|
|
echo "\t\tdocument.getElementById(footnoteTooltipId).classList.add('shown');\r\n";
|
|
|
|
|
echo "\t}\r\n";
|
|
|
|
|
echo "\tfunction footnoteTooltipHide(footnoteTooltipId) { \r\n";
|
2020-11-13 16:54:31 +00:00
|
|
|
|
echo "\t\tdocument.getElementById(footnoteTooltipId).classList.remove('shown');\r\n";
|
|
|
|
|
echo "\t\tdocument.getElementById(footnoteTooltipId).classList.add('hidden');\r\n";
|
|
|
|
|
echo "\t}\r\n";
|
2020-11-11 20:49:44 +00:00
|
|
|
|
echo "</script>\r\n";
|
|
|
|
|
};
|
2020-10-27 11:56:49 +00:00
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Displays the 'LOVE FOOTNOTES' slug if enabled.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
*/
|
|
|
|
|
public function wp_footer() {
|
2016-06-29 12:54:05 +00:00
|
|
|
|
if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "footer") {
|
|
|
|
|
echo $this->ReferenceContainer();
|
|
|
|
|
}
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// get setting for love and share this plugin
|
|
|
|
|
$l_str_LoveMeIndex = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE);
|
|
|
|
|
// check if the admin allows to add a link to the footer
|
|
|
|
|
if (empty($l_str_LoveMeIndex) || strtolower($l_str_LoveMeIndex) == "no" || !self::$a_bool_AllowLoveMe) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// set a hyperlink to the word "footnotes" in the Love slug
|
|
|
|
|
$l_str_LinkedName = sprintf('<a href="http://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration:none;">%s</a>',MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME);
|
|
|
|
|
// get random love me text
|
|
|
|
|
if (strtolower($l_str_LoveMeIndex) == "random") {
|
|
|
|
|
$l_str_LoveMeIndex = "text-" . rand(1,3);
|
|
|
|
|
}
|
|
|
|
|
switch ($l_str_LoveMeIndex) {
|
|
|
|
|
case "text-1":
|
|
|
|
|
$l_str_LoveMeText = sprintf(__('I %s %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, $l_str_LinkedName);
|
|
|
|
|
break;
|
|
|
|
|
case "text-2":
|
|
|
|
|
$l_str_LoveMeText = sprintf(__('this site uses the awesome %s Plugin', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName);
|
|
|
|
|
break;
|
|
|
|
|
case "text-3":
|
|
|
|
|
default:
|
|
|
|
|
$l_str_LoveMeText = sprintf(__('extra smooth %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
echo sprintf('<div style="text-align:center; color:#acacac;">%s</div>', $l_str_LoveMeText);
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Replaces footnotes in the post/page title.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @param string $p_str_Content Widget content.
|
|
|
|
|
* @return string Content with replaced footnotes.
|
|
|
|
|
*/
|
|
|
|
|
public function the_title($p_str_Content) {
|
|
|
|
|
// appends the reference container if set to "post_end"
|
|
|
|
|
return $this->exec($p_str_Content, false);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Replaces footnotes in the content of the current page/post.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @param string $p_str_Content Page/Post content.
|
|
|
|
|
* @return string Content with replaced footnotes.
|
|
|
|
|
*/
|
|
|
|
|
public function the_content($p_str_Content) {
|
|
|
|
|
// appends the reference container if set to "post_end"
|
|
|
|
|
return $this->exec($p_str_Content, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "post_end" ? true : false);
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Replaces footnotes in the excerpt of the current page/post.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @param string $p_str_Content Page/Post content.
|
|
|
|
|
* @return string Content with replaced footnotes.
|
|
|
|
|
*/
|
|
|
|
|
public function the_excerpt($p_str_Content) {
|
|
|
|
|
return $this->exec($p_str_Content, false, !MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT)));
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Replaces footnotes in the widget title.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @param string $p_str_Content Widget content.
|
|
|
|
|
* @return string Content with replaced footnotes.
|
|
|
|
|
*/
|
|
|
|
|
public function widget_title($p_str_Content) {
|
|
|
|
|
// appends the reference container if set to "post_end"
|
|
|
|
|
return $this->exec($p_str_Content, false);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Replaces footnotes in the content of the current widget.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @param string $p_str_Content Widget content.
|
|
|
|
|
* @return string Content with replaced footnotes.
|
|
|
|
|
*/
|
|
|
|
|
public function widget_text($p_str_Content) {
|
|
|
|
|
// appends the reference container if set to "post_end"
|
|
|
|
|
return $this->exec($p_str_Content, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "post_end" ? true : false);
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Replaces footnotes in each Content var of the current Post object.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.4
|
|
|
|
|
* @param array|WP_Post $p_mixed_Posts
|
|
|
|
|
*/
|
2020-11-09 19:09:54 +00:00
|
|
|
|
public function the_post(&$p_mixed_Posts) {
|
|
|
|
|
// single WP_Post object received
|
|
|
|
|
if (!is_array($p_mixed_Posts)) {
|
|
|
|
|
$p_mixed_Posts = $this->replacePostObject($p_mixed_Posts);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// array of WP_Post objects received
|
|
|
|
|
for($l_int_Index = 0; $l_int_Index < count($p_mixed_Posts); $l_int_Index++) {
|
|
|
|
|
$p_mixed_Posts[$l_int_Index] = $this->replacePostObject($p_mixed_Posts[$l_int_Index]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Replace all Footnotes in a WP_Post object.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.6
|
|
|
|
|
* @param WP_Post $p_obj_Post
|
|
|
|
|
* @return WP_Post
|
|
|
|
|
*/
|
|
|
|
|
private function replacePostObject($p_obj_Post) {
|
|
|
|
|
//MCI_Footnotes_Convert::debug($p_obj_Post);
|
|
|
|
|
$p_obj_Post->post_content = $this->exec($p_obj_Post->post_content);
|
|
|
|
|
$p_obj_Post->post_content_filtered = $this->exec($p_obj_Post->post_content_filtered);
|
|
|
|
|
$p_obj_Post->post_excerpt = $this->exec($p_obj_Post->post_excerpt);
|
|
|
|
|
return $p_obj_Post;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Replaces all footnotes that occur in the given content.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @param string $p_str_Content Any string that may contain footnotes to be replaced.
|
|
|
|
|
* @param bool $p_bool_OutputReferences Appends the Reference Container to the output if set to true, default true.
|
|
|
|
|
* @param bool $p_bool_HideFootnotesText Hide footnotes found in the string.
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function exec($p_str_Content, $p_bool_OutputReferences = false, $p_bool_HideFootnotesText = false) {
|
|
|
|
|
// replace all footnotes in the content, settings are converted to html characters
|
|
|
|
|
$p_str_Content = $this->search($p_str_Content, true, $p_bool_HideFootnotesText);
|
|
|
|
|
// replace all footnotes in the content, settings are NOT converted to html characters
|
|
|
|
|
$p_str_Content = $this->search($p_str_Content, false, $p_bool_HideFootnotesText);
|
|
|
|
|
|
|
|
|
|
// append the reference container
|
|
|
|
|
if ($p_bool_OutputReferences) {
|
|
|
|
|
$p_str_Content = $p_str_Content . $this->ReferenceContainer();
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// take a look if the LOVE ME slug should NOT be displayed on this page/post, remove the short code if found
|
|
|
|
|
if (strpos($p_str_Content, MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG) !== false) {
|
|
|
|
|
self::$a_bool_AllowLoveMe = false;
|
|
|
|
|
$p_str_Content = str_replace(MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG, "", $p_str_Content);
|
|
|
|
|
}
|
|
|
|
|
// return the content with replaced footnotes and optional reference container append
|
|
|
|
|
return $p_str_Content;
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Replaces all footnotes in the given content and appends them to the static property.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @param string $p_str_Content Content to be searched for footnotes.
|
|
|
|
|
* @param bool $p_bool_ConvertHtmlChars html encode settings, default true.
|
|
|
|
|
* @param bool $p_bool_HideFootnotesText Hide footnotes found in the string.
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function search($p_str_Content, $p_bool_ConvertHtmlChars, $p_bool_HideFootnotesText) {
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-13 16:54:31 +00:00
|
|
|
|
// post ID to make everything unique wrt infinite scroll and archive view
|
2020-11-14 21:40:09 +00:00
|
|
|
|
global $l_int_PostId;
|
2020-11-24 09:22:27 +00:00
|
|
|
|
$l_int_PostId = get_the_id();
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// contains the index for the next footnote on this page
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// contains the starting position for the lookup of a footnote
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_int_PosStart = 0;
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// get start and end tag for the footnotes short code
|
|
|
|
|
$l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START);
|
|
|
|
|
$l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END);
|
|
|
|
|
if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
|
|
|
|
|
$l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED);
|
|
|
|
|
$l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED);
|
|
|
|
|
}
|
|
|
|
|
// decode html special chars
|
|
|
|
|
if ($p_bool_ConvertHtmlChars) {
|
|
|
|
|
$l_str_StartingTag = htmlspecialchars($l_str_StartingTag);
|
|
|
|
|
$l_str_EndingTag = htmlspecialchars($l_str_EndingTag);
|
|
|
|
|
}
|
|
|
|
|
// if footnotes short code is empty, return the content without changes
|
|
|
|
|
if (empty($l_str_StartingTag) || empty($l_str_EndingTag)) {
|
|
|
|
|
return $p_str_Content;
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
if (!$p_bool_HideFootnotesText) {
|
|
|
|
|
// load template file
|
2020-11-11 20:49:44 +00:00
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE))) {
|
|
|
|
|
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "footnote-alternative");
|
|
|
|
|
} else {
|
|
|
|
|
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "footnote");
|
|
|
|
|
}
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_obj_TemplateTooltip = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "tooltip");
|
|
|
|
|
} else {
|
|
|
|
|
$l_obj_Template = null;
|
|
|
|
|
$l_obj_TemplateTooltip = null;
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// search footnotes short codes in the content
|
|
|
|
|
do {
|
|
|
|
|
// get first occurrence of the footnote short code [start]
|
|
|
|
|
$i_int_len_Content = strlen($p_str_Content);
|
|
|
|
|
if ($l_int_PosStart > $i_int_len_Content) $l_int_PosStart = $i_int_len_Content;
|
|
|
|
|
$l_int_PosStart = strpos($p_str_Content, $l_str_StartingTag, $l_int_PosStart);
|
|
|
|
|
// no short code found, stop here
|
|
|
|
|
if ($l_int_PosStart === false) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// get first occurrence of a footnote short code [end]
|
|
|
|
|
$l_int_PosEnd = strpos($p_str_Content, $l_str_EndingTag, $l_int_PosStart);
|
|
|
|
|
// no short code found, stop here
|
|
|
|
|
if ($l_int_PosEnd === false) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// calculate the length of the footnote
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_int_Length = $l_int_PosEnd - $l_int_PosStart;
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// get footnote text
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag));
|
|
|
|
|
|
2020-11-25 07:47:45 +00:00
|
|
|
|
// fix line wrapping of URLs (hyperlinked or not) based on pattern, not link element,
|
|
|
|
|
// to prevent them from hanging out of the tooltip in non-Unicode-compliant user agents
|
2020-12-06 22:07:52 +00:00
|
|
|
|
// spare however values of the href and the src arguments!
|
2020-11-25 07:47:45 +00:00
|
|
|
|
// see public.css
|
2020-12-06 22:07:52 +00:00
|
|
|
|
$l_str_FootnoteText = preg_replace( '#(?<!href=.)(?<!src=.)(https?://[^\\s<]+)#', '<span class="footnote_url_wrap">$1</span>', $l_str_FootnoteText );
|
2020-11-25 07:47:45 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// Text to be displayed instead of the footnote
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_str_FootnoteReplaceText = "";
|
|
|
|
|
|
2020-11-16 20:57:15 +00:00
|
|
|
|
// display the footnote referrers and the tooltips:
|
2020-10-27 11:56:49 +00:00
|
|
|
|
if (!$p_bool_HideFootnotesText) {
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_int_Index = MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
|
|
|
|
// display only an excerpt of the footnotes text if enabled
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_str_ExcerptText = $l_str_FootnoteText;
|
2016-06-29 12:54:05 +00:00
|
|
|
|
$l_bool_EnableExcerpt = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED));
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_int_MaxLength = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH));
|
|
|
|
|
|
2016-06-29 12:54:05 +00:00
|
|
|
|
if ($l_bool_EnableExcerpt) {
|
|
|
|
|
$l_str_DummyText = strip_tags($l_str_FootnoteText);
|
|
|
|
|
if (is_int($l_int_MaxLength) && strlen($l_str_DummyText) > $l_int_MaxLength) {
|
2020-11-16 20:57:15 +00:00
|
|
|
|
$l_str_ExcerptText = substr($l_str_DummyText, 0, $l_int_MaxLength);
|
|
|
|
|
$l_str_ExcerptText = substr($l_str_ExcerptText, 0, strrpos($l_str_ExcerptText, ' '));
|
|
|
|
|
$l_str_ExcerptText .= ' … ';
|
|
|
|
|
$l_str_ExcerptText .= '<span class="footnote_tooltip_continue" ';
|
|
|
|
|
$l_str_ExcerptText .= 'onclick="footnote_moveToAnchor_' . $l_int_PostId;
|
|
|
|
|
$l_str_ExcerptText .= '(\'footnote_plugin_reference_' . $l_int_PostId;
|
|
|
|
|
$l_str_ExcerptText .= '_' . $l_int_Index . '\');">';
|
|
|
|
|
$l_str_ExcerptText .= MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL);
|
|
|
|
|
$l_str_ExcerptText .= '</span>';
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-16 20:57:15 +00:00
|
|
|
|
// define the HTML element to use for the referrers:
|
2020-11-17 02:14:21 +00:00
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS))) {
|
2020-11-25 23:40:45 +00:00
|
|
|
|
$l_str_SupSpan = 'sup';
|
2020-11-16 20:57:15 +00:00
|
|
|
|
} else {
|
2020-11-25 23:40:45 +00:00
|
|
|
|
$l_str_SupSpan = 'span';
|
2020-11-16 20:57:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 09:54:41 +00:00
|
|
|
|
// determine whether the link element is used, see below in ReferenceContainer()
|
|
|
|
|
$l_str_LinkSpan = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED)) ? 'a' : 'span';
|
|
|
|
|
|
|
|
|
|
|
2020-11-14 21:40:09 +00:00
|
|
|
|
// fill in 'templates/public/footnote.html':
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_obj_Template->replace(
|
|
|
|
|
array(
|
2020-11-25 23:40:45 +00:00
|
|
|
|
"post_id" => $l_int_PostId,
|
|
|
|
|
"id" => $l_int_Index,
|
2020-11-26 09:54:41 +00:00
|
|
|
|
"link-start" => $l_str_LinkSpan == 'a' ? '<a>' : '',
|
|
|
|
|
"link-end" => $l_str_LinkSpan == 'a' ? '</a>' : '',
|
2020-11-25 23:40:45 +00:00
|
|
|
|
"sup-span" => $l_str_SupSpan,
|
|
|
|
|
"before" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE),
|
|
|
|
|
"index" => $l_int_Index,
|
|
|
|
|
"after" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER),
|
|
|
|
|
"text" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED)) ? $l_str_ExcerptText : "",
|
2020-10-27 11:56:49 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$l_str_FootnoteReplaceText = $l_obj_Template->getContent();
|
2020-11-12 18:17:28 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// reset the template
|
|
|
|
|
$l_obj_Template->reload();
|
2020-12-06 12:46:45 +00:00
|
|
|
|
if (
|
|
|
|
|
MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED)) &&
|
|
|
|
|
!MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE))
|
|
|
|
|
) {
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_int_OffsetY = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y));
|
|
|
|
|
$l_int_OffsetX = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X));
|
2020-12-06 12:46:45 +00:00
|
|
|
|
$l_int_FadeInDelay = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY ));
|
|
|
|
|
$l_int_FadeInDuration = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION ));
|
|
|
|
|
$l_int_FadeOutDelay = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY ));
|
|
|
|
|
$l_int_FadeOutDuration = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION));
|
2020-11-12 18:17:28 +00:00
|
|
|
|
|
2020-11-14 21:40:09 +00:00
|
|
|
|
// fill in 'templates/public/tooltip.html':
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_obj_TemplateTooltip->replace(
|
|
|
|
|
array(
|
2020-12-06 12:46:45 +00:00
|
|
|
|
"post_id" => $l_int_PostId,
|
|
|
|
|
"id" => $l_int_Index,
|
|
|
|
|
"position" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION),
|
|
|
|
|
"offset-y" => !empty($l_int_OffsetY) ? $l_int_OffsetY : 0,
|
|
|
|
|
"offset-x" => !empty($l_int_OffsetX) ? $l_int_OffsetX : 0,
|
|
|
|
|
"fade-in-delay" => !empty($l_int_FadeInDelay ) ? $l_int_FadeInDelay : 0,
|
|
|
|
|
"fade-in-duration" => !empty($l_int_FadeInDuration ) ? $l_int_FadeInDuration : 0,
|
|
|
|
|
"fade-out-delay" => !empty($l_int_FadeOutDelay ) ? $l_int_FadeOutDelay : 0,
|
|
|
|
|
"fade-out-duration" => !empty($l_int_FadeOutDuration) ? $l_int_FadeOutDuration : 0,
|
2020-10-27 11:56:49 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
2020-12-06 12:46:45 +00:00
|
|
|
|
$l_str_FootnoteReplaceText .= $l_obj_TemplateTooltip->getContent();
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_obj_TemplateTooltip->reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// replace the footnote with the template
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$p_str_Content = substr_replace($p_str_Content, $l_str_FootnoteReplaceText, $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// add footnote only if not empty
|
|
|
|
|
if (!empty($l_str_FootnoteText)) {
|
|
|
|
|
// set footnote to the output box at the end
|
|
|
|
|
self::$a_arr_Footnotes[] = $l_str_FootnoteText;
|
|
|
|
|
// increase footnote index
|
|
|
|
|
$l_int_FootnoteIndex++;
|
|
|
|
|
}
|
|
|
|
|
// add offset to the new starting position
|
|
|
|
|
$l_int_PosStart += $l_int_Length + strlen($l_str_EndingTag);
|
|
|
|
|
$l_int_PosStart = $l_int_Length + strlen($l_str_FootnoteReplaceText);
|
|
|
|
|
} while (true);
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// return content
|
|
|
|
|
return $p_str_Content;
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Generates the reference container.
|
|
|
|
|
*
|
|
|
|
|
* @author Stefan Herndler
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
* @return string
|
2020-11-14 21:40:09 +00:00
|
|
|
|
*
|
|
|
|
|
* Edited for 2.0.6: fixed line breaking behavior in footnote # clusters
|
|
|
|
|
* Edited for 2.1.1: fixed fragment IDs and backlinks with combine identical turned on 2020-11-14T1808+0100
|
2020-10-27 11:56:49 +00:00
|
|
|
|
*/
|
|
|
|
|
public function ReferenceContainer() {
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-25 23:40:45 +00:00
|
|
|
|
// no footnotes have been replaced on this page:
|
2020-10-27 11:56:49 +00:00
|
|
|
|
if (empty(self::$a_arr_Footnotes)) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-25 23:40:45 +00:00
|
|
|
|
/**
|
|
|
|
|
* INFINITE SCROLL / AUTOLOAD, ARCHIVE VIEW
|
2020-11-26 09:54:41 +00:00
|
|
|
|
*
|
2020-11-25 23:40:45 +00:00
|
|
|
|
* Multiple posts are appended to each other, functions and IDs must be disambiguated.
|
|
|
|
|
* Contributed by @docteurfitness <https://wordpress.org/support/topic/auto-load-post-compatibility-update/>
|
|
|
|
|
* @since 2.0.5
|
|
|
|
|
*
|
|
|
|
|
* post ID to make everything unique wrt infinite scroll and archive view:
|
|
|
|
|
*/
|
|
|
|
|
global $l_int_PostId;
|
|
|
|
|
$l_int_PostId = get_the_id();
|
|
|
|
|
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-25 23:40:45 +00:00
|
|
|
|
/**
|
|
|
|
|
* OPTIONAL LINK ELEMENT FOR FOOTNOTE REFERRERS AND BACKLINKS
|
2020-11-26 09:54:41 +00:00
|
|
|
|
*
|
2020-11-25 23:40:45 +00:00
|
|
|
|
* STYLING:
|
|
|
|
|
* Link color is preferred for referrers and backlinks.
|
|
|
|
|
* Setting a global link color is a common feature in WordPress themes.
|
|
|
|
|
* CSS does not support identifiers for link colors (color: link | hover | active | visited)
|
|
|
|
|
* These are only supported as pseudo-classes of the link element.
|
|
|
|
|
* Hence the link element must be present for styling purposes.
|
|
|
|
|
* But styling these elements with the link color is not universally preferred.
|
|
|
|
|
* If not, the very presence of the link elements may need to be avoided.
|
2020-11-26 09:54:41 +00:00
|
|
|
|
*
|
2020-11-25 23:40:45 +00:00
|
|
|
|
* FUNCTIONALITY:
|
|
|
|
|
* Although widely used for that purpose, hyperlinks are disliked for footnote linking.
|
|
|
|
|
* Browsers may need to be prevented from logging these clicks in the browsing history,
|
|
|
|
|
* as logging compromises the usability of the 'return to previous' button in browsers.
|
|
|
|
|
* For that purpose, and for scroll animation, this linking is performed by JavaScript.
|
2020-11-26 09:54:41 +00:00
|
|
|
|
*
|
2020-11-25 23:40:45 +00:00
|
|
|
|
* The link elements have been added and are present @since 2.0.0.
|
|
|
|
|
* Then the link addresses were removed @since 2.0.4.
|
|
|
|
|
* Then the presence of <a> elements was made optional
|
2020-12-06 16:30:14 +00:00
|
|
|
|
* @since 2.1.4
|
2020-11-25 23:40:45 +00:00
|
|
|
|
* 2020-11-25T1306+0100
|
|
|
|
|
*/
|
2020-11-26 09:54:41 +00:00
|
|
|
|
$l_str_LinkSpan = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED)) ? 'a' : 'span';
|
|
|
|
|
|
|
|
|
|
|
2020-11-28 09:58:23 +00:00
|
|
|
|
/**
|
|
|
|
|
* FOOTNOTE INDEX BACKLINK SYMBOL
|
|
|
|
|
*
|
|
|
|
|
* The backlink symbol has been removed for 2.0.0 along with column 2 of the reference container.
|
|
|
|
|
* On user request, an arrow is prepended @since 2.0.3, and the setting is restored @since 2.0.4.
|
|
|
|
|
* @since 2.1.1 a select box allows to disable the symbol instead of customizing it to invisible.
|
|
|
|
|
*/
|
2020-11-18 00:47:53 +00:00
|
|
|
|
// check if arrow is enabled:
|
2020-11-17 02:14:21 +00:00
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE))) {
|
2020-11-16 20:57:15 +00:00
|
|
|
|
|
|
|
|
|
// get html arrow
|
|
|
|
|
$l_str_Arrow = MCI_Footnotes_Convert::getArrow(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW));
|
|
|
|
|
// set html arrow to the first one if invalid index defined
|
|
|
|
|
if (is_array($l_str_Arrow)) {
|
|
|
|
|
$l_str_Arrow = MCI_Footnotes_Convert::getArrow(0);
|
|
|
|
|
}
|
|
|
|
|
// get user defined arrow
|
|
|
|
|
$l_str_ArrowUserDefined = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED);
|
|
|
|
|
if (!empty($l_str_ArrowUserDefined)) {
|
|
|
|
|
$l_str_Arrow = $l_str_ArrowUserDefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wrap the arrow in a @media print { display:hidden } span:
|
|
|
|
|
$l_str_FootnoteArrow = '<span class="footnote_index_arrow">';
|
|
|
|
|
$l_str_FootnoteArrow .= $l_str_Arrow . '</span>';
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2020-11-25 23:40:45 +00:00
|
|
|
|
// if it is not, set arrow to empty:
|
2020-11-28 09:58:23 +00:00
|
|
|
|
$l_str_Arrow = '';
|
|
|
|
|
$l_str_FootnoteArrow = '';
|
2020-11-16 20:57:15 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-28 09:58:23 +00:00
|
|
|
|
/**
|
2020-11-30 06:17:43 +00:00
|
|
|
|
* BACKLINK SEPARATOR
|
2020-11-28 09:58:23 +00:00
|
|
|
|
*
|
2020-11-30 06:17:43 +00:00
|
|
|
|
* Initially a comma was appended in this algorithm for enumerations.
|
|
|
|
|
* The comma in enumerations is not generally preferred.
|
2020-12-06 16:30:14 +00:00
|
|
|
|
* @since 2.1.4 the separator is optional, has options, and is customizable:
|
2020-11-28 09:58:23 +00:00
|
|
|
|
*/
|
2020-11-30 06:17:43 +00:00
|
|
|
|
// check if it is even enabled:
|
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_SEPARATOR_ENABLED))) {
|
|
|
|
|
// if so, check if it is customized:
|
|
|
|
|
$l_str_Separator = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_CUSTOM);
|
|
|
|
|
if (empty($l_str_Separator)) {
|
|
|
|
|
// if it is not, check which option is on:
|
|
|
|
|
$l_str_SeparatorOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_OPTION);
|
|
|
|
|
switch ($l_str_SeparatorOption) {
|
|
|
|
|
case 'comma' : $l_str_Separator = ','; break;
|
|
|
|
|
case 'semicolon': $l_str_Separator = ';'; break;
|
|
|
|
|
case 'en_dash' : $l_str_Separator = ' –'; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$l_str_Separator = '';
|
2020-11-28 09:58:23 +00:00
|
|
|
|
}
|
2020-11-30 06:17:43 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* BACKLINK TERMINATOR
|
|
|
|
|
*
|
|
|
|
|
* Initially a dot was appended in the table row template.
|
|
|
|
|
* @since 2.0.6 a dot after footnote numbers is discarded as not localizable;
|
|
|
|
|
* making it optional was envisaged.
|
2020-12-06 16:30:14 +00:00
|
|
|
|
* @since 2.1.4 the terminator is optional, has options, and is customizable:
|
2020-11-30 06:17:43 +00:00
|
|
|
|
*/
|
|
|
|
|
// check if it is even enabled:
|
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_TERMINATOR_ENABLED))) {
|
|
|
|
|
// if so, check if it is customized:
|
|
|
|
|
$l_str_Terminator = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_CUSTOM);
|
|
|
|
|
if (empty($l_str_Terminator)) {
|
|
|
|
|
// if it is not, check which option is on:
|
|
|
|
|
$l_str_TerminatorOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_OPTION);
|
|
|
|
|
switch ($l_str_TerminatorOption) {
|
|
|
|
|
case 'period' : $l_str_Terminator = '.'; break;
|
|
|
|
|
case 'parenthesis': $l_str_Terminator = ')'; break;
|
|
|
|
|
case 'colon' : $l_str_Terminator = ':'; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2020-11-28 09:58:23 +00:00
|
|
|
|
$l_str_Terminator = '';
|
|
|
|
|
}
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-28 09:58:23 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* LINE BREAKS
|
|
|
|
|
*
|
|
|
|
|
* The backlinks of combined footnotes are generally preferred in an enumeration.
|
|
|
|
|
* But when few footnotes are identical, stacking the items in list form is better.
|
|
|
|
|
* Variable number length and proportional character width require explicit line breaks.
|
|
|
|
|
* Otherwise, an ordinary space character offering a line break opportunity is inserted.
|
|
|
|
|
*/
|
|
|
|
|
$l_str_LineBreak = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED)) ? '<br />' : ' ';
|
|
|
|
|
|
|
|
|
|
/**
|
2020-11-30 06:17:43 +00:00
|
|
|
|
* For maintenance and support, table rows in the reference container should be
|
2020-11-28 09:58:23 +00:00
|
|
|
|
* separated by an empty line. So we add these line breaks for source readability.
|
|
|
|
|
* Before the first table row (breaks between rows are ~200 lines below):
|
|
|
|
|
*/
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_str_Body = "\r\n\r\n";
|
2020-11-16 20:57:15 +00:00
|
|
|
|
|
2020-11-28 09:58:23 +00:00
|
|
|
|
|
|
|
|
|
// REFERENCE CONTAINER TABLE ROW TEMPLATE LOAD
|
|
|
|
|
|
2020-11-26 17:15:21 +00:00
|
|
|
|
// when combining identical footnotes is turned on, another template is needed:
|
2020-11-14 21:40:09 +00:00
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
|
2020-11-26 17:15:21 +00:00
|
|
|
|
// the combining template allows for backlink clusters and supports cell clicking for single notes:
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body-combi");
|
2020-11-16 20:57:15 +00:00
|
|
|
|
|
2020-11-14 21:40:09 +00:00
|
|
|
|
} else {
|
2020-11-16 20:57:15 +00:00
|
|
|
|
|
2020-11-26 17:15:21 +00:00
|
|
|
|
// when 3-column layout is turned on (only available if combining is turned off):
|
2020-11-17 02:14:21 +00:00
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE))) {
|
2020-11-16 20:57:15 +00:00
|
|
|
|
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body-3column");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2020-11-26 17:15:21 +00:00
|
|
|
|
// when switch symbol and index is turned on, and combining and 3-columns are off:
|
2020-11-17 02:14:21 +00:00
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH))) {
|
2020-11-16 20:57:15 +00:00
|
|
|
|
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body-switch");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// default is the standard template:
|
|
|
|
|
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-14 21:40:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 17:15:21 +00:00
|
|
|
|
// SET SWITCH FLAG INDEPENDENTLY
|
|
|
|
|
|
|
|
|
|
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH))) {
|
|
|
|
|
|
|
|
|
|
$l_bool_SymbolSwitch = true;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$l_bool_SymbolSwitch = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-11-14 21:40:09 +00:00
|
|
|
|
// FILL IN THE TEMPLATE
|
2020-10-27 11:56:49 +00:00
|
|
|
|
|
|
|
|
|
// loop through all footnotes found in the page
|
2020-11-14 21:40:09 +00:00
|
|
|
|
for ($l_int_Index = 0; $l_int_Index < count(self::$a_arr_Footnotes); $l_int_Index++) {
|
|
|
|
|
|
|
|
|
|
// TEXT COLUMN
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// get footnote text
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_str_FootnoteText = self::$a_arr_Footnotes[$l_int_Index];
|
2020-10-27 11:56:49 +00:00
|
|
|
|
// if footnote is empty, get to the next one
|
2020-11-14 21:40:09 +00:00
|
|
|
|
// With combine identical turned on, identicals will be deleted and are skipped:
|
2020-10-27 11:56:49 +00:00
|
|
|
|
if (empty($l_str_FootnoteText)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
|
|
|
|
// INDEX COLUMN WITH ONE BACKLINK PER TABLE ROW
|
|
|
|
|
|
2020-11-26 17:15:21 +00:00
|
|
|
|
// Standard behavior appropriate for combining identicals turned off
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-05 18:00:18 +00:00
|
|
|
|
// generate content of footnote index cell
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_int_FirstFootnoteIndex = ($l_int_Index + 1);
|
|
|
|
|
|
|
|
|
|
// get the footnote index string and
|
2020-11-12 18:17:28 +00:00
|
|
|
|
// keep supporting legacy index placeholder:
|
2020-11-16 20:57:15 +00:00
|
|
|
|
$l_str_FootnoteIndex = MCI_Footnotes_Convert::Index(($l_int_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-26 17:15:21 +00:00
|
|
|
|
// SUPPORT FOR COMBINING IDENTICALS: COMPOSE ENUMERATED BACKLINKS
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-16 20:57:15 +00:00
|
|
|
|
if ( MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-16 20:57:15 +00:00
|
|
|
|
$l_str_FootnoteId = $l_str_FootnoteIndex;
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-24 09:22:27 +00:00
|
|
|
|
// in case the footnote is unique:
|
2020-11-25 23:40:45 +00:00
|
|
|
|
$l_str_FootnoteReference = "<$l_str_LinkSpan";
|
|
|
|
|
$l_str_FootnoteReference .= ' id="footnote_plugin_reference_';
|
2020-11-24 09:22:27 +00:00
|
|
|
|
$l_str_FootnoteReference .= $l_int_PostId;
|
|
|
|
|
$l_str_FootnoteReference .= "_$l_str_FootnoteId\"";
|
|
|
|
|
$l_str_FootnoteReference .= ' class="footnote_backlink"';
|
|
|
|
|
|
|
|
|
|
// the click event goes in the table cell:
|
|
|
|
|
$l_str_BacklinkEvent = ' onclick="footnote_moveToAnchor_' . $l_int_PostId;
|
|
|
|
|
$l_str_BacklinkEvent .= "('footnote_plugin_tooltip_$l_int_PostId";
|
|
|
|
|
$l_str_BacklinkEvent .= "_$l_str_FootnoteId');\"";
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-11-24 09:22:27 +00:00
|
|
|
|
// the dedicated template enumerating backlinks uses another variable:
|
|
|
|
|
$l_str_FootnoteBacklinks = $l_str_FootnoteReference;
|
|
|
|
|
$l_str_FootnoteBacklinks .= $l_str_BacklinkEvent;
|
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// continue both single note and notes cluster, depending on switch option status:
|
2020-11-26 17:15:21 +00:00
|
|
|
|
if ($l_bool_SymbolSwitch) {
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
$l_str_FootnoteReference .= ">$l_str_FootnoteId$l_str_FootnoteArrow";
|
|
|
|
|
$l_str_FootnoteBacklinks .= ">$l_str_FootnoteId$l_str_FootnoteArrow";
|
2020-11-26 17:15:21 +00:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
$l_str_FootnoteReference .= ">$l_str_FootnoteArrow$l_str_FootnoteId";
|
|
|
|
|
$l_str_FootnoteBacklinks .= ">$l_str_FootnoteArrow$l_str_FootnoteId";
|
2020-11-26 17:15:21 +00:00
|
|
|
|
|
|
|
|
|
}
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// If that is the only footnote with this text, we’re nearly done.
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// check if it isn't the last footnote in the array:
|
|
|
|
|
if ($l_int_FirstFootnoteIndex < count(self::$a_arr_Footnotes)) {
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// get all footnotes that haven't passed yet:
|
|
|
|
|
for ($l_int_CheckIndex = $l_int_FirstFootnoteIndex; $l_int_CheckIndex < count(self::$a_arr_Footnotes); $l_int_CheckIndex++) {
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// check if a further footnote is the same as the actual one:
|
|
|
|
|
if ($l_str_FootnoteText == self::$a_arr_Footnotes[$l_int_CheckIndex]) {
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// if so, set the further footnote as empty so it won't be displayed later:
|
|
|
|
|
self::$a_arr_Footnotes[$l_int_CheckIndex] = "";
|
2020-11-24 09:22:27 +00:00
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// cancel the event altogether:
|
|
|
|
|
$l_str_BacklinkEvent = "";
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// HERE GOES THE FRAGMENT IDENTIFIER AND THE BACKLINK TOO:
|
|
|
|
|
// add the footnote index to the actual index:
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// update the footnote ID:
|
|
|
|
|
$l_str_FootnoteId = MCI_Footnotes_Convert::Index(($l_int_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
// resume composing the backlinks enumeration:
|
|
|
|
|
$l_str_FootnoteBacklinks .= "$l_str_Separator</$l_str_LinkSpan>";
|
|
|
|
|
$l_str_FootnoteBacklinks .= "$l_str_LineBreak<$l_str_LinkSpan";
|
|
|
|
|
$l_str_FootnoteBacklinks .= ' id="footnote_plugin_reference_';
|
|
|
|
|
$l_str_FootnoteBacklinks .= $l_int_PostId;
|
|
|
|
|
$l_str_FootnoteBacklinks .= "_$l_str_FootnoteId";
|
|
|
|
|
$l_str_FootnoteBacklinks .= '" class="footnote_backlink" ';
|
|
|
|
|
$l_str_FootnoteBacklinks .= 'onclick="footnote_moveToAnchor_' . $l_int_PostId;
|
|
|
|
|
$l_str_FootnoteBacklinks .= "('footnote_plugin_tooltip_$l_int_PostId";
|
|
|
|
|
$l_str_FootnoteBacklinks .= "_$l_str_FootnoteId');\">";
|
|
|
|
|
$l_str_FootnoteBacklinks .= $l_bool_SymbolSwitch ? '' : $l_str_FootnoteArrow;
|
|
|
|
|
$l_str_FootnoteBacklinks .= $l_str_FootnoteId;
|
|
|
|
|
$l_str_FootnoteBacklinks .= $l_bool_SymbolSwitch ? $l_str_FootnoteArrow : '';
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-12-03 17:38:14 +00:00
|
|
|
|
}
|
2020-10-27 11:56:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 17:38:14 +00:00
|
|
|
|
|
|
|
|
|
$l_str_FootnoteReference .= "$l_str_Terminator</$l_str_LinkSpan>";
|
|
|
|
|
$l_str_FootnoteBacklinks .= "$l_str_Terminator</$l_str_LinkSpan>";
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
}
|
2020-11-12 18:17:28 +00:00
|
|
|
|
|
2020-12-06 22:07:52 +00:00
|
|
|
|
// line wrapping of URLs already fixed, see above
|
2020-11-26 09:54:41 +00:00
|
|
|
|
|
2020-11-14 21:40:09 +00:00
|
|
|
|
// replace all placeholders in 'templates/public/reference-container-body.html'
|
|
|
|
|
// or in 'templates/public/reference-container-body-combi.html'
|
2020-11-24 09:22:27 +00:00
|
|
|
|
// or in 'templates/public/reference-container-body-3column.html'
|
|
|
|
|
// or in 'templates/public/reference-container-body-switch.html'
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_obj_Template->replace(
|
|
|
|
|
array(
|
2020-11-14 21:40:09 +00:00
|
|
|
|
// placeholder used in all templates:
|
2020-11-12 18:17:28 +00:00
|
|
|
|
"text" => $l_str_FootnoteText,
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
|
|
|
|
// used in standard layout W/O COMBINED FOOTNOTES:
|
|
|
|
|
"post_id" => $l_int_PostId,
|
|
|
|
|
"id" => MCI_Footnotes_Convert::Index($l_int_FirstFootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)),
|
2020-11-25 23:40:45 +00:00
|
|
|
|
"link-start" => $l_str_LinkSpan == 'a' ? '<a>' : '',
|
|
|
|
|
"link-end" => $l_str_LinkSpan == 'a' ? '</a>' : '',
|
|
|
|
|
"link-span" => $l_str_LinkSpan,
|
2020-11-28 09:58:23 +00:00
|
|
|
|
"terminator" => $l_str_Terminator,
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
|
|
|
|
// used in standard layout WITH COMBINED IDENTICALS TURNED ON:
|
2020-11-24 09:22:27 +00:00
|
|
|
|
"pointer" => empty($l_str_BacklinkEvent) ? '' : ' pointer',
|
|
|
|
|
"event" => $l_str_BacklinkEvent,
|
|
|
|
|
"backlinks" => empty($l_str_BacklinkEvent) ? $l_str_FootnoteBacklinks : $l_str_FootnoteReference,
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
|
|
|
|
// Legacy placeholders for use in legacy layout templates:
|
2020-11-16 20:57:15 +00:00
|
|
|
|
"arrow" => $l_str_FootnoteArrow,
|
2020-11-06 04:04:30 +00:00
|
|
|
|
"index" => $l_str_FootnoteIndex,
|
2020-10-27 11:56:49 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
|
|
|
|
$l_str_Body .= $l_obj_Template->getContent();
|
2020-11-16 20:57:15 +00:00
|
|
|
|
|
2020-11-25 23:40:45 +00:00
|
|
|
|
// extra line breaks for page source readability:
|
2020-11-14 21:40:09 +00:00
|
|
|
|
$l_str_Body .= "\r\n\r\n";
|
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_obj_Template->reload();
|
2020-11-14 21:40:09 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
|
2020-12-05 04:48:09 +00:00
|
|
|
|
// get scroll offset and duration settings:
|
|
|
|
|
$l_int_ScrollOffset = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET);
|
|
|
|
|
$l_int_ScrollDuration = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION);
|
2020-12-06 12:46:45 +00:00
|
|
|
|
|
2020-11-14 21:40:09 +00:00
|
|
|
|
// load 'templates/public/reference-container.html':
|
2020-10-27 11:56:49 +00:00
|
|
|
|
$l_obj_TemplateContainer = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container");
|
|
|
|
|
$l_obj_TemplateContainer->replace(
|
|
|
|
|
array(
|
2020-12-05 04:48:09 +00:00
|
|
|
|
"post_id" => $l_int_PostId,
|
|
|
|
|
"label" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME),
|
|
|
|
|
"button-style" => !MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)) ? 'display: none;' : '',
|
|
|
|
|
"style" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)) ? 'display: none;' : '',
|
|
|
|
|
"content" => $l_str_Body,
|
|
|
|
|
"scroll-offset" => ($l_int_ScrollOffset / 100),
|
|
|
|
|
"scroll-duration" => $l_int_ScrollDuration,
|
2020-10-27 11:56:49 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// free all found footnotes if reference container will be displayed
|
|
|
|
|
self::$a_arr_Footnotes = array();
|
2020-11-12 18:17:28 +00:00
|
|
|
|
|
2020-10-27 11:56:49 +00:00
|
|
|
|
return $l_obj_TemplateContainer->getContent();
|
|
|
|
|
}
|
2016-06-29 12:54:05 +00:00
|
|
|
|
}
|