stable bugfix release 2.1.2: priority level settings for all other hooks, preventing them from being zeroed at save == URGENCY

git-svn-id: https://plugins.svn.wordpress.org/footnotes/tags/2.1.2@2421553 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
pewgeuges 2020-11-19 14:03:48 +00:00
parent 362d9e60c6
commit 65668e0754
28 changed files with 1479 additions and 728 deletions

View file

@ -89,7 +89,8 @@ class MCI_Footnotes_Layout_Init {
* Registers all sub menu pages for the new main menu.
*
* @author Stefan Herndler
* @since 2.0.2
* @since 1.5.0
* Claimed it was added for 2.0.2 while already present since 1.5.0 2020-11-19T1201+0100
* @see http://codex.wordpress.org/Function_Reference/add_menu_page
*/
public function registerMainMenu() {
@ -209,4 +210,4 @@ class MCI_Footnotes_Layout_Init {
);
exit;
}
}
}

View file

@ -5,6 +5,10 @@
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*
* Updated for 2.1.2 added version # of settings.css for cache busting
* ############ update line 200 after changes to settings.css
* Last modified 2020-11-19T1456+0100
*/
@ -194,9 +198,20 @@ abstract class MCI_Footnotes_LayoutEngine {
// add WordPress color picker layout
wp_enqueue_style('wp-color-picker');
// add WordPress color picker function
wp_enqueue_script('wp-color-picker');
wp_enqueue_script('wp-color-picker');
// register stylesheet
wp_register_style('mci-footnotes-admin-styles', plugins_url('../../css/settings.css', __FILE__));
// added version after changes started to settings.css from 2.1.2 on:
wp_register_style(
'mci-footnotes-admin-styles',
plugins_url('../../css/settings.css', __FILE__),
'',
'2.1.2'
);
// UPDATE version # when making changes to settings.css, FOR CACHE BUSTING
// add stylesheet to the output
wp_enqueue_style('mci-footnotes-admin-styles');
}
@ -484,4 +499,4 @@ abstract class MCI_Footnotes_LayoutEngine {
$l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"], $p_in_Min, $p_int_Max);
}
} // end of class
} // end of class

View file

@ -6,7 +6,12 @@
* @author Stefan Herndler
* @since 1.5.0 14.09.14 14:47
*
* Edited for v2.0.4 2020-11-01T0509+0100
* Edited for:
* 2.0.4 2020-11-01T0509+0100
* 2.1.0 2020-11-08T2148+0100
* 2.1.1 2020-11-16T2152+0100
*
* Last modified: 2020-11-16T2152+0100
*/
/**
@ -80,7 +85,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
*/
protected function getMetaBoxes() {
return array(
// Change string "%s styling" to "Footnotes styling":
// Change string "%s styling" to "Footnotes styling" to fix layout in WPv5.5:
$this->addMetaBox("settings", "styling", __("Footnotes styling", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Styling"),
$this->addMetaBox("settings", "reference-container", __("References Container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "ReferenceContainer"),
// Leave intact since this is not localized:
@ -113,6 +118,11 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
"post_end" => __("at the end of the post", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"widget" => __("in the widget area", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
);
// options for Yes/No select box:
$l_arr_Enabled = array(
"yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
);
// load template file
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-reference-container");
@ -123,7 +133,19 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
"name" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME),
"label-collapse" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, __("Collapse references by default", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"collapse" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE),
"collapse" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, $l_arr_Enabled),
"label-symbol" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, __("Display a backlink symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"symbol" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, $l_arr_Enabled),
"label-startpage" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE, __("Display on start page too", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"startpage" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE, $l_arr_Enabled),
"label-3column" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, __("Three-column layout", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"3column" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, $l_arr_Enabled),
"label-switch" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH, __("Symbol appended, not prepended", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"switch" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH, $l_arr_Enabled),
"label-position" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __("Where shall the reference container appear", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_Positions)
@ -242,7 +264,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
* @since 1.5.0
*/
public function Other() {
// options for the Footnotes to be replaced in excerpt
// options for Yes/No select box:
$l_arr_Enabled = array(
"yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
@ -270,11 +292,19 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
* @since 1.5.0
*/
public function Superscript() {
// options for Yes/No select box:
$l_arr_Enabled = array(
"yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
);
// load template file
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-superscript");
// replace all placeholders
$l_obj_Template->replace(
array(
"label-superscript" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, __("Enable superscript for footnote referrers", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"superscript" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, $l_arr_Enabled),
"label-before" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE, __("Before Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"before" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE),
@ -293,7 +323,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
* @since 1.5.2
*/
public function MouseOverBox() {
// options for the Footnotes to be replaced in excerpt
// options for Yes/No select box:
$l_arr_Enabled = array(
"yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
@ -317,12 +347,18 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
"label-enable" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __("Enable the mouse-over box", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $l_arr_Enabled),
"label-alternative" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, __("Use alternative tooltip implementation", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"alternative" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, $l_arr_Enabled),
"label-activate-excerpt" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, __("Display only an excerpt", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"activate-excerpt" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, $l_arr_Enabled),
"label-excerpt-length" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, __("Maximum characters for the excerpt", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"excerpt-length" => $this->addTextBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH),
"label-readon" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL, __("Read on button label", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"readon" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL),
"label-position" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION, __("Position", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION, $l_arr_Position),
@ -375,8 +411,10 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
* @since 1.5.0
*
* Edited heading for v2.0.4
* The former 'hyperlink arrow' became 'prepended arrow' in v2.0.3 after
* a user complaint about missing backlinking semantics of the footnote number.
*
* The former 'hyperlink arrow', incompatible with combined identical footnotes,
* became 'prepended arrow' in v2.0.3 after a user complaint about missing backlinking semantics
* of the footnote number.
*/
public function HyperlinkArrow() {
// load template file
@ -435,40 +473,56 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
*
* @author Stefan Herndler
* @since 1.5.5
*
* Edited for:
* 2.1.1 add priority level setting for the_content 2020-11-16T2152+0100
* 2.2.0 add priority level settings for the other hooks 2020-11-19T1421+0100
*/
public function lookupHooks() {
// load template file
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "expert-lookup");
// replace all placeholders
// priority level was initially hard-coded default
// shows "9223372036854775807" in the numbox
// empty should be interpreted as PHP_INT_MAX,
// but a numbox cannot be set to empty: <https://github.com/Modernizr/Modernizr/issues/171>
// define -1 as PHP_INT_MAX instead
$l_obj_Template->replace(
array(
"description" => __("The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. Default 9223372036854775807 or -1 is lowest priority, 0 is highest. For the reference container to sit above related posts, the priority level of the_content hook may need to be at most 1200. For Footnotes to work when a glossary plugin is active, a higher priority of 1000 may be needed. Another priority level for the_content with proven efficiency is 10.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"head-hook" => __("WordPress hook function name", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"head-checkbox" => __("Activate", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"head-numbox" => __("Priority level", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"head-url" => __("WordPress documentation", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"label-the-title" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_TITLE, "the_title"),
"the-title" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_TITLE),
"url-the-title" => "http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title",
"priority-the-title" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL, -1, PHP_INT_MAX),
"url-the-title" => "https://developer.wordpress.org/reference/hooks/the_title/",
"label-the-content" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_CONTENT, "the_content"),
"the-content" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_CONTENT),
"url-the-content" => "http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content",
"priority-the-content" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL, -1, PHP_INT_MAX),
"url-the-content" => "https://developer.wordpress.org/reference/hooks/the_content/",
"label-the-excerpt" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_EXCERPT, "the_excerpt"),
"the-excerpt" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_EXCERPT),
"url-the-excerpt" => "http://codex.wordpress.org/Function_Reference/the_excerpt",
"priority-the-excerpt" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL, -1, PHP_INT_MAX),
"url-the-excerpt" => "https://developer.wordpress.org/reference/functions/the_excerpt/",
"label-widget-title" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE, "widget_title"),
"widget-title" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE),
"url-widget-title" => "http://codex.wordpress.org/Plugin_API/Filter_Reference/widget_title",
"priority-widget-title" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL, -1, PHP_INT_MAX),
"url-widget-title" => "https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_title",
"label-widget-text" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT, "widget_text"),
"widget-text" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT),
"url-widget-text" => "http://codex.wordpress.org/Plugin_API/Filter_Reference/widget_text",
"label-post-object" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_POST, "the_post"),
"post-object" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_POST),
"url-post-object" => "http://codex.wordpress.org/Plugin_API/Filter_Reference/the_post"
"priority-widget-text" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL, -1, PHP_INT_MAX),
"url-widget-text" => "https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_text",
)
);
// display template with replaced placeholders

View file

@ -1,18 +1,21 @@
<?php
/**
* Includes the main Class of the Plugin.
*
* IMPORTANT: In registerPublic(), keep plugin version # up to date for cache busting.
*
* ******************************************************************************************************
* IMPORTANT: In registerPublic() line 134: Please keep plugin version # up to date for cache busting. *
* ******************************************************************************************************
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*
* Edited for v2.0.0: Added jQueryUI from CDN 2020-10-26T1907+0100
*
* Edited for v1.6.5: Replaced deprecated function create_function()
* Edited for v2.0.0: Added jQueryUI from Cloudflare 2020-10-26T1907+0100
* Edited for v2.0.3: Added style sheet versioning 2020-10-29T1413+0100
* Edited for v2.0.4: Added jQuery UI from WordPress 2020-11-01T1902+0100
*
* Last modified: 2020-11-05T0638+0100
*
* Continual update of version number.
*/
@ -46,12 +49,12 @@ class MCI_Footnotes {
MCI_Footnotes_WYSIWYG::registerHooks();
// register general hooks
MCI_Footnotes_Hooks::registerHooks();
// initialize the Plugin Dashboard
$this->initializeDashboard();
// initialize the Plugin Task
$this->initializeTask();
// Register all Public Stylesheets and Scripts
add_action('init', array($this, 'registerPublic'));
// Enqueue all Public Stylesheets and Scripts
@ -65,14 +68,14 @@ class MCI_Footnotes {
*
* @author Stefan Herndler
* @since 1.5.0
*
* Edited for 1.6.5: replaced deprecated function create_function()
*
* Contributed by Felipe Lavín Z. Thankfully acknowledged.
*
* create_function() was deprecated in PHP 7.2:
* <https://wordpress.org/support/topic/deprecated-in-php-7-2-function-create_function-is-deprecated/>
* See also: <https://wordpress.org/support/topic/deprecated-function-create_function-14/>
*
* Edited for 1.6.5: replaced deprecated function create_function()
*
* Contributed by Felipe Lavín Z. Thankfully acknowledged.
*
* create_function() was deprecated in PHP 7.2:
* <https://wordpress.org/support/topic/deprecated-in-php-7-2-function-create_function-is-deprecated/>
* See also: <https://wordpress.org/support/topic/deprecated-function-create_function-14/>
*/
public function initializeWidgets() {
register_widget("MCI_Footnotes_Widget_ReferenceContainer");
@ -104,28 +107,60 @@ class MCI_Footnotes {
*
* @author Stefan Herndler
* @since 1.5.0
*
* Updated for v2.0.4 by adding jQueryUI from WordPress following @check2020de:
*
* Updated for v2.0.0 adding jQuery UI
* Updated for v2.0.4 by adding jQuery UI from WordPress following @check2020de:
* <https://wordpress.org/support/topic/gdpr-issue-with-jquery/>
* See <https://wordpress.stackexchange.com/questions/273986/correct-way-to-enqueue-jquery-ui>
*
*
* jQueryUI re-enables the tooltip infobox disabled when WPv5.5 was released.
*/
public function registerPublic() {
// add the jQuery plugin (already registered by WordPress)
wp_enqueue_script( 'jquery' );
// Add jQueryUI: 'no need to enqueue -core, because dependencies are set'
wp_enqueue_script( 'jquery-ui-widget' );
wp_enqueue_script( 'jquery-ui-mouse' );
wp_enqueue_script( 'jquery-ui-accordion' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
wp_enqueue_script( 'jquery-ui-slider' );
// Add jQuery tools:
wp_enqueue_script('mci-footnotes-js-jquery-tools', plugins_url('../js/jquery.tools.min.js', __FILE__));
// IMPORTANT: up-to-date plugin version number for cache busting.
wp_enqueue_style('mci-footnotes-css-public', plugins_url('../css/public.css', __FILE__), '', '2.0.5rc1');
//### SCRIPTS
// These are only enqueued if the jQuery tooltips are enabled.
// If alternative tooltips are enabled, these libraries are not needed.
// Scroll animation doesnt seem to need even jQuery Core or it gets it from elsewhere.
if (!MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE))) {
// enqueue the jQuery plugin registered by WordPress:
wp_enqueue_script( 'jquery' );
// enqueue jQuery UI libraries registered by WordPress, needed for tooltips:
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-widget' );
wp_enqueue_script( 'jquery-ui-position' );
wp_enqueue_script( 'jquery-ui-tooltip' );
// enqueue jQuery Tools: redacted jQuery.browser, completed minification; added versioning 2020-11-18T2150+0100
wp_enqueue_script('mci-footnotes-js-jquery-tools', plugins_url('../js/jquery.tools.min.js', __FILE__), '', '2.1.1');
// Alternatively, fetch jQuery UI from cdnjs.cloudflare.com:
// Used to add jQuery UI following @vonpiernik:
// <https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13456762>:
// This was enabled in Footnotes v2.0.0 through v2.0.3.
// Re-added for 2.0.9d1 / 2.1.1d0 to look whether it can fix a broken tooltip display. 2020-11-07T1601+0100/2020-11-08T2246+0100
//wp_register_script( 'jQueryUI', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js', null, null, false ); // in header 2020-11-09T2003+0100
//wp_enqueue_script( 'jQueryUI' );
// This is then needed instead of the above first instance:
// Add jQuery Tools and finish adding jQueryUI: 2020-11-08T1638+0100/2020-11-08T2246+0100
//wp_enqueue_script('mci-footnotes-js-jquery-tools', plugins_url('../js/jquery.tools.min.js', __FILE__), ['jQueryUI']);
}
//### STYLES
// IMPORTANT: up-to-date plugin version number NEEDED FOR CACHE BUSTING:
wp_enqueue_style(
'mci-footnotes-css-public',
plugins_url('../css/public.css', __FILE__),
'',
'2.1.2'
);
}
}

View file

@ -5,14 +5,26 @@
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 10:43
*
* Edited for v2.0.4 2020-11-02T2115+0100
*
* Edited for:
* 2.0.4 restore arrow settings 2020-11-02T2115+0100
* 2.0.7 remove hook the_post 2020-11-06T1342+0100
* 2.1.0 add read-on button label customization 2020-11-08T2149+0100
* 2.1.1 fix tooltips on site by alternative 2020-11-11T1819+0100
* 2.1.1 fix disabling backlink symbol 2020-11-16T2021+0100
* 2.1.1 fix superscript by making it optional
* 2.1.1 fix start pages by option to hide ref container
* 2.1.1 fix ref container by option restoring 3-column layout
* 2.1.1 fix ref container by option to switch index/symbol 2020-11-16T2022+0100
* 2.1.1 fix ref container positioning by priority level 2020-11-17T0205+0100
*
* Last modified: 2020-11-17T0311+0100
*/
/**
* The class loads all Settings from each WordPress Settings container.
* It a Setting is not defined yet the default value will be used.
* It a Setting is not defined yet, the default value will be used.
* Each Setting will be validated and sanitized when loaded from the container.
*
* @author Stefan Herndler
@ -20,6 +32,11 @@
*/
class MCI_Footnotes_Settings {
/**
* SETTINGS CONTAINER KEY DEFINITIONS
*/
/**
* Settings Container Key for the label of the reference container.
*
@ -155,6 +172,16 @@ class MCI_Footnotes_Settings {
*/
const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED = "footnote_inputfield_custom_mouse_over_box_enabled";
/**
* Settings Container Key for alternative tooltip implementation
*
* @since 2.2.0
* @var string
*
* 2020-11-11T1817+0100
*/
const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE = "footnote_inputfield_custom_mouse_over_box_alternative";
/**
* Settings Container Key for the mouse-over box to display only an excerpt.
*
@ -165,7 +192,7 @@ class MCI_Footnotes_Settings {
const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED = "footnote_inputfield_custom_mouse_over_box_excerpt_enabled";
/**
* Settings Container Key for the mouse-over box to define the max. length of the enabled expert.
* Settings Container Key for the mouse-over box to define the max. length of the enabled excerpt.
*
* @author Stefan Herndler
* @since 1.5.4
@ -336,13 +363,37 @@ class MCI_Footnotes_Settings {
const C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT = "footnote_inputfield_expert_lookup_widget_text";
/**
* Settings Container Key the activation of the_post hook.
* Settings Container Key for the label of the 'Read on' button in truncated tooltips
*
* @author Stefan Herndler
* @since 1.5.5
* @since 2.1.0
* @var string
*
* 2020-11-08T2106+0100
*/
const C_BOOL_EXPERT_LOOKUP_THE_POST = "footnote_inputfield_expert_lookup_the_post";
const C_STR_FOOTNOTES_TOOLTIP_READON_LABEL = "footnote_inputfield_readon_label";
/**
* Settings Container Keys of options fixing default layout
*
* @since 2.1.1
* @var string
*
* 2020-11-16T0859+0100
*/
const C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS = "footnotes_inputfield_referrer_superscript_tags";
const C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = "footnotes_inputfield_reference_container_backlink_symbol_enable";
const C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE = "footnotes_inputfield_reference_container_start_page_enable";
const C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = "footnotes_inputfield_reference_container_3column_layout_enable";
const C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = "footnotes_inputfield_reference_container_backlink_symbol_switch";
const C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_title_priority_level";
const C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_content_priority_level";
const C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_excerpt_priority_level";
const C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_widget_title_priority_level";
const C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_widget_text_priority_level";
/**
* Stores a singleton reference of this class.
@ -370,14 +421,22 @@ class MCI_Footnotes_Settings {
* @var array
*/
private $a_arr_Default = array(
"footnotes_storage" => array(
self::C_STR_REFERENCE_CONTAINER_NAME => 'References',
self::C_BOOL_REFERENCE_CONTAINER_COLLAPSE => '',
self::C_STR_REFERENCE_CONTAINER_POSITION => 'post_end',
// Identical footnotes should not be combined by default
// Identical footnotes should not be combined by default
// as long as the feature raises criticism for malfunctioning:
// <https://wordpress.org/support/topic/too-many-errors-18/>
self::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES => '',
self::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE => 'yes',
self::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE => 'yes',
self::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE => '',
self::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH => '',
self::C_STR_FOOTNOTES_SHORT_CODE_START => '((',
self::C_STR_FOOTNOTES_SHORT_CODE_END => '))',
self::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED => '',
@ -386,37 +445,89 @@ class MCI_Footnotes_Settings {
self::C_STR_FOOTNOTES_LOVE => 'no',
self::C_BOOL_FOOTNOTES_IN_EXCERPT => 'yes',
self::C_BOOL_FOOTNOTES_EXPERT_MODE => 'no'
),
"footnotes_storage_custom" => array(
self::C_STR_FOOTNOTES_STYLING_BEFORE => '',
self::C_STR_FOOTNOTES_STYLING_AFTER => ')',
self::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL => 'Continue reading',
self::C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS => 'yes',
// The default footnote referrer surroundings should be square brackets:
// * as in English typesetting;
// * for better UX thanks to a more button-like appearance;
// * for stylistic consistency with the expand-collapse button
self::C_STR_FOOTNOTES_STYLING_BEFORE => '[',
self::C_STR_FOOTNOTES_STYLING_AFTER => ']',
self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED => 'yes',
self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED => 'no',
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH => 150,
self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION => 'top right',
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X => 10,
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y => 10,
self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE => '',
// The mouse over content truncation should be enabled by default
// to raise awareness of the functionality and to prevent the screen
// from being filled at mouse-over, and to allow the Continue reading:
self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED => 'yes',
// The truncation length is raised from 150 to 200 chars:
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH => 200,
// The default position should not be lateral because of the risk
// the box gets squeezed between note anchor at line end and window edge,
// and top because reading at the bottom of the window is more likely:
self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION => 'top center',
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X => 0,
// The vertical offset must be negative for the box not to cover
// the current line of text (web coordinates origin is top left):
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y => -7,
self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR => '',
self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND => '#fff7a7',
// The mouse over box shouldnt feature a colored background
// by default, due to diverging user preferences. White is neutral:
self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND => '#ffffff',
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH => 1,
self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR => '#cccc99',
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS => 3,
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH => 0,
// The mouse over box corners mustnt be rounded as that is outdated:
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS => 0,
// The width should be limited to start with, for the box to have shape:
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH => 450,
self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR => '#666666',
self::C_STR_HYPERLINK_ARROW => '&#8593;',
self::C_STR_HYPERLINK_ARROW_USER_DEFINED => '',
self::C_STR_CUSTOM_CSS => ''
),
// These should all be enabled by default.
// See <https://wordpress.org/support/topic/more-feature-ideas/>
"footnotes_storage_expert" => array(
self::C_BOOL_EXPERT_LOOKUP_THE_TITLE => 'yes',
// Titles should all be enabled by default to prevent users from
// thinking at first that the feature is broken in post titles.
// See <https://wordpress.org/support/topic/more-feature-ideas/>
// Yet in titles, footnotes are functionally pointless in WordPress.
self::C_BOOL_EXPERT_LOOKUP_THE_TITLE => '',
self::C_BOOL_EXPERT_LOOKUP_THE_CONTENT => 'yes',
self::C_BOOL_EXPERT_LOOKUP_THE_EXCERPT => 'yes',
self::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE => 'yes',
self::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE => '',
self::C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT => 'yes',
self::C_BOOL_EXPERT_LOOKUP_THE_POST => 'yes'
// initially hard-coded default
// shows "9223372036854775807" in the numbox
// empty should be interpreted as PHP_INT_MAX,
// but a numbox cannot be set to empty: <https://github.com/Modernizr/Modernizr/issues/171>
// define -1 as PHP_INT_MAX instead
self::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL => PHP_INT_MAX,
self::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL => PHP_INT_MAX,
self::C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL => PHP_INT_MAX,
self::C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL => PHP_INT_MAX,
self::C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL => PHP_INT_MAX,
)
);
/**

View file

@ -5,13 +5,19 @@
* @filesource
* @author Stefan Herndler
* @since 1.5.0
*
*
* Edited for v2.0.0 and following.
*
* Edited for v2.0.5: Autoload / infinite scroll support added thanks to code from
*
* 2.0.5: Autoload / infinite scroll support added thanks to code from
* @docteurfitness <https://wordpress.org/support/topic/auto-load-post-compatibility-update/>
*
* Last modified 2020-11-05T0524+0100
*
* 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
*
* Last modified 2020-11-18T0138+0100
*/
// If called directly, abort:
@ -57,20 +63,37 @@ class MCI_Footnotes_Task {
*
* @author Stefan Herndler
* @since 1.5.0
*
* Edited for v2.0.5 2020-11-02T0330+0100 2020-11-04T2006+0100
*
* Explicitly setting all priority to (default) "10" instead of lowest "PHP_INT_MAX",
* especially for the_content, makes the footnotes reference container display
* beneath the content and above other features added by other plugins.
*
* Edited for:
* 2.0.5 through v2.0.7 changes to priority 2020-11-02T0330+0100..2020-11-06T1344+0100
* 2.2.0 add settings for all hooks 2020-11-19T1248+0100
*
* Explicitly setting the_content priority to "10" instead of lowest "PHP_INT_MAX",
* 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.
* Requested by users: <https://wordpress.org/support/topic/change-the-position-5/>
* Documentation: <https://codex.wordpress.org/Plugin_API/#Hook_in_your_Filter>
*
* But then, the blog engine calls this plugin in the editor, as reported in:
* <https://wordpress.org/support/topic/blogs-all-messed-up/>
* <https://wordpress.org/support/topic/change-the-position-5/#post-13612697>
* Default remains PHP_INT_MAX.
* PHP_INT_MAX can be reset by leaving the number box empty.
*/
public function registerHooks() {
// 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 leaving the input field empty:
$p_int_TheTitlePriority = !empty($p_int_TheTitlePriority ) ? $p_int_TheTitlePriority : PHP_INT_MAX;
$p_int_TheContentPriority = !empty($p_int_TheContentPriority ) ? $p_int_TheContentPriority : PHP_INT_MAX;
$p_int_TheExcerptPriority = !empty($p_int_TheExcerptPriority ) ? $p_int_TheExcerptPriority : PHP_INT_MAX;
$p_int_WidgetTitlePriority = !empty($p_int_WidgetTitlePriority) ? $p_int_WidgetTitlePriority : PHP_INT_MAX;
$p_int_WidgetTextPriority = !empty($p_int_WidgetTextPriority ) ? $p_int_WidgetTextPriority : PHP_INT_MAX;
// append custom css to the header
add_filter('wp_head', array($this, "wp_head"), PHP_INT_MAX);
@ -78,23 +101,30 @@ class MCI_Footnotes_Task {
add_filter('wp_footer', array($this, "wp_footer"), PHP_INT_MAX);
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_TITLE))) {
add_filter('the_title', array($this, "the_title"), PHP_INT_MAX);
}
add_filter('the_title', array($this, "the_title"), $p_int_TheTitlePriority);
}
// custom priority level for reference container relative positioning; default PHP_INT_MAX:
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_CONTENT))) {
add_filter('the_content', array($this, "the_content"), PHP_INT_MAX);
}
add_filter('the_content', array($this, "the_content"), $p_int_TheContentPriority);
}
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_EXCERPT))) {
add_filter('the_excerpt', array($this, "the_excerpt"), PHP_INT_MAX);
add_filter('the_excerpt', array($this, "the_excerpt"), $p_int_TheExcerptPriority);
}
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE))) {
add_filter('widget_title', array($this, "widget_title"), PHP_INT_MAX);
add_filter('widget_title', array($this, "widget_title"), $p_int_WidgetTitlePriority);
}
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT))) {
add_filter('widget_text', array($this, "widget_text"), PHP_INT_MAX);
}
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_POST))) {
add_filter('the_post', array($this, "the_post"), PHP_INT_MAX);
}
add_filter('widget_text', array($this, "widget_text"), $p_int_WidgetTextPriority);
}
// REMOVED the_post HOOK 2020-11-08T1839+0100
//
//
// reset stored footnotes when displaying the header
self::$a_arr_Footnotes = array();
self::$a_bool_AllowLoveMe = true;
@ -118,7 +148,12 @@ class MCI_Footnotes_Task {
<style type="text/css" media="screen">
<?php
echo MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS);
echo '.footnote_tooltip { display: none; padding: 12px; font-size: 13px;';
if (!MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE))) {
echo "\r\n.home .footnotes_reference_container { display: none; }\r\n";
}
echo '.footnote_tooltip {';
if (!empty($l_str_Color)) {
printf(" color: %s;", $l_str_Color);
}
@ -145,7 +180,19 @@ class MCI_Footnotes_Task {
echo '}';
?>
</style>
<?php
<?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";
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";
echo "\t\tdocument.getElementById(footnoteTooltipId).classList.remove('shown');\r\n";
echo "\t\tdocument.getElementById(footnoteTooltipId).classList.add('hidden');\r\n";
echo "\t}\r\n";
echo "</script>\r\n";
};
}
/**
@ -325,13 +372,17 @@ class MCI_Footnotes_Task {
* @return string
*/
public function search($p_str_Content, $p_bool_ConvertHtmlChars, $p_bool_HideFootnotesText) {
// post ID to make everything unique wrt archive view and infinite scroll
global $l_int_PostID;
$l_int_PostID = get_the_id();
// post ID to make everything unique wrt infinite scroll and archive view
global $l_int_PostId;
$l_int_PostId = get_the_id();
// contains the index for the next footnote on this page
$l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
// contains the starting position for the lookup of a footnote
$l_int_PosStart = 0;
// 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);
@ -351,7 +402,11 @@ class MCI_Footnotes_Task {
if (!$p_bool_HideFootnotesText) {
// load template file
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "footnote");
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");
}
$l_obj_TemplateTooltip = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "tooltip");
} else {
$l_obj_Template = null;
@ -376,63 +431,83 @@ class MCI_Footnotes_Task {
}
// calculate the length of the footnote
$l_int_Length = $l_int_PosEnd - $l_int_PosStart;
// get footnote text
$l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag));
// Text to be displayed instead of the footnote
$l_str_FootnoteReplaceText = "";
// display the footnote as mouse-over box
// display the footnote referrers and the tooltips:
if (!$p_bool_HideFootnotesText) {
$l_str_Index = MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
$l_int_Index = MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// display only an excerpt of the footnotes text if enabled
$l_str_ExcerptText = $l_str_FootnoteText;
$l_bool_EnableExcerpt = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED));
$l_int_MaxLength = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH));
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) {
$l_str_ExcerptText = substr($l_str_DummyText, 0, $l_int_MaxLength);
$l_str_ExcerptText = substr($l_str_ExcerptText, 0, strrpos($l_str_ExcerptText, ' '));
// Removed hyperlink navigation on user request, but left <a> element for style.
$l_str_ExcerptText .= '&nbsp;&#x2026; ' . sprintf(__("%scontinue%s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '<a class="continue" onclick="footnote_moveToAnchor_' . $l_int_PostID . '(\'footnote_plugin_reference_' . $l_int_PostID . '_' . $l_str_Index . '\');">', '</a>');
$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 .= '&nbsp;&#x2026; ';
$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>';
}
}
// fill the footnotes template templates/public/footnote.html
// define the HTML element to use for the referrers:
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS))) {
$l_str_Element = 'sup';
} else {
$l_str_Element = 'span';
}
// fill in 'templates/public/footnote.html':
$l_obj_Template->replace(
array(
"post_id" => $l_int_PostID,
"id" => $l_str_Index,
"post_id" => $l_int_PostId,
"id" => $l_int_Index,
"element" => $l_str_Element,
"before" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE),
"index" => $l_str_Index,
"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 : "",
)
);
$l_str_FootnoteReplaceText = $l_obj_Template->getContent();
// reset the template
$l_obj_Template->reload();
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED))) {
$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));
// fill in the tooltip template templates/public/tooltip.html
// fill in 'templates/public/tooltip.html':
$l_obj_TemplateTooltip->replace(
array(
"post_id" => $l_int_PostID,
"id" => $l_str_Index,
"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
"offset-x" => !empty($l_int_OffsetX) ? $l_int_OffsetX : 0,
)
);
$l_str_FootnoteReplaceText .= $l_obj_TemplateTooltip->getContent();
if (!MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE))) {
$l_str_FootnoteReplaceText .= $l_obj_TemplateTooltip->getContent();
}
$l_obj_TemplateTooltip->reload();
}
}
// replace the footnote with the template
$p_str_Content = substr_replace($p_str_Content, $l_str_FootnoteReplaceText, $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
// add footnote only if not empty
if (!empty($l_str_FootnoteText)) {
// set footnote to the output box at the end
@ -455,88 +530,218 @@ class MCI_Footnotes_Task {
* @author Stefan Herndler
* @since 1.5.0
* @return string
*
* 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
*/
public function ReferenceContainer() {
// post ID to make everything unique wrt archive view and infinite scroll
global $l_int_PostID;
$l_int_PostID = get_the_id();
// post ID to make everything unique wrt infinite scroll and archive view:
global $l_int_PostId;
$l_int_PostId = get_the_id();
// no footnotes has been replaced on this page
if (empty(self::$a_arr_Footnotes)) {
return "";
}
// 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;
// FOOTNOTE INDEX BACKLINK SYMBOL
// check if arrow is enabled:
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE))) {
// 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 {
// if it is, set it to empty:
$l_str_Arrow = "";
$l_str_FootnoteArrow = "";
}
// load template file
$l_str_Body = "";
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body");
// REFERENCE CONTAINER TABLE ROW TEMPLATE LOAD
// line breaks for source readability:
$l_str_Body = "\r\n\r\n";
// when combine identical is turned on, another template is needed:
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
// In the combined template, identifiers only are clickable.
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body-combi");
} else {
// when 3-column layout is turned on (only valid if combining is turned off):
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE))) {
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body-3column");
} else {
// when switch symbol and index is turned on (only valid if 3-column is disabled):
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH))) {
$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");
}
}
}
// FILL IN THE TEMPLATE
// loop through all footnotes found in the page
for ($l_str_Index = 0; $l_str_Index < count(self::$a_arr_Footnotes); $l_str_Index++) {
for ($l_int_Index = 0; $l_int_Index < count(self::$a_arr_Footnotes); $l_int_Index++) {
// TEXT COLUMN
// get footnote text
$l_str_FootnoteText = self::$a_arr_Footnotes[$l_str_Index];
$l_str_FootnoteText = self::$a_arr_Footnotes[$l_int_Index];
// if footnote is empty, get to the next one
// With combine identical turned on, identicals will be deleted and are skipped:
if (empty($l_str_FootnoteText)) {
continue;
}
// get footnote index
$l_str_FirstFootnoteIndex = ($l_str_Index + 1);
$l_str_FootnoteIndex = MCI_Footnotes_Convert::Index(($l_str_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// check if it isn't the last footnote in the array
if ($l_str_FirstFootnoteIndex < count(self::$a_arr_Footnotes) && MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
// get all footnotes that I haven't passed yet
for ($l_str_CheckIndex = $l_str_FirstFootnoteIndex; $l_str_CheckIndex < count(self::$a_arr_Footnotes); $l_str_CheckIndex++) {
// check if a further footnote is the same as the actual one
if ($l_str_FootnoteText == self::$a_arr_Footnotes[$l_str_CheckIndex]) {
// set the further footnote as empty so it won't be displayed later
self::$a_arr_Footnotes[$l_str_CheckIndex] = "";
// add the footnote index to the actual index
$l_str_FootnoteIndex .= ", " . MCI_Footnotes_Convert::Index(($l_str_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// INDEX COLUMN WITH ONE BACKLINK PER TABLE ROW
// Standard behavior appropriate for combine identical TURNED OFF
// generate content of footnote index cell
$l_int_FirstFootnoteIndex = ($l_int_Index + 1);
// get the footnote index string and
// keep supporting legacy index placeholder:
$l_str_FootnoteIndex = MCI_Footnotes_Convert::Index(($l_int_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// SUPPORT FOR COMBINE IDENTICAL: COMPOSING ENUMERATED BACKLINKS
$l_str_FootnoteBacklinks = "";
if ( MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
$l_str_FootnoteId = $l_str_FootnoteIndex;
// The dedicated template enumerating backlinks uses a new placeholder:
$l_str_FootnoteBacklinks = '<a 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_str_FootnoteArrow;
$l_str_FootnoteBacklinks .= $l_str_FootnoteId . '</a>';
// If that is the only footnote with this text, were done.
}
// CHECK IF COMBINE IDENTICAL IS TURNED ON, and
// check if it isn't the last footnote in the array:
if ($l_int_FirstFootnoteIndex < count(self::$a_arr_Footnotes) && MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
// 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++) {
// check if a further footnote is the same as the actual one:
if ($l_str_FootnoteText == self::$a_arr_Footnotes[$l_int_CheckIndex]) {
// if so, set the further footnote as empty so it won't be displayed later:
self::$a_arr_Footnotes[$l_int_CheckIndex] = "";
// HERE GOES THE FRAGMENT IDENTIFIER AND THE BACKLINK TOO:
// add the footnote index to the actual index:
// 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));
// keep on composing the backlinks enumeration:
$l_str_FootnoteBacklinks .= ', <a 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_str_FootnoteArrow;
$l_str_FootnoteBacklinks .= $l_str_FootnoteId . '</a>';
// this legacy is not used:
//$l_str_FootnoteIndex .= ', ' . MCI_Footnotes_Convert::Index(($l_int_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
}
}
}
// replace all placeholders in the template templates/public/reference-container-body.html
// replace all placeholders in 'templates/public/reference-container-body.html'
// or in 'templates/public/reference-container-body-combi.html'
$l_obj_Template->replace(
array(
"post_id" => $l_int_PostID,
"id" => MCI_Footnotes_Convert::Index($l_str_FirstFootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)),
"arrow" => $l_str_Arrow,
"index" => $l_str_FootnoteIndex,
"text" => $l_str_FootnoteText
// placeholder used in all templates:
"text" => $l_str_FootnoteText,
// 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)),
// used in standard layout WITH COMBINED IDENTICALS TURNED ON:
"backlinks" => $l_str_FootnoteBacklinks,
// Legacy placeholders for use in legacy layout templates:
"arrow" => $l_str_FootnoteArrow,
"index" => $l_str_FootnoteIndex,
)
);
$l_str_Body .= $l_obj_Template->getContent();
// extra line breaks for page source legibility:
$footnote_item_temp = $l_obj_Template->getContent();
$footnote_item_temp .= "\r\n\r\n";
$l_str_Body .= $footnote_item_temp;
$l_str_Body .= "\r\n\r\n";
$l_obj_Template->reload();
}
// load template file templates/public/reference-container.html
// load 'templates/public/reference-container.html':
$l_obj_TemplateContainer = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container");
$l_obj_TemplateContainer->replace(
array(
"post_id" => $l_int_PostID,
"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
"content" => $l_str_Body,
)
);
// free all found footnotes if reference container will be displayed
self::$a_arr_Footnotes = array();
return $l_obj_TemplateContainer->getContent();
}
}