From 7f5499723b5d0d8c4bc7eb3f7850b8ee0ac64c73 Mon Sep 17 00:00:00 2001 From: pewgeuges <73141620+pewgeuges@users.noreply.github.com> Date: Thu, 18 Feb 2021 19:56:44 +0000 Subject: [PATCH] traceability update 2.5.6d1 revert space indent to tab. git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2477300 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- class/config.php | 110 +- class/dashboard/init.php | 360 +- class/dashboard/layout.php | 966 ++-- class/dashboard/subpage-main.php | 2238 ++++----- class/hooks.php | 138 +- class/init.php | 606 +-- class/language.php | 164 +- class/settings.php | 2294 ++++----- class/task.php | 4358 ++++++++--------- class/template.php | 402 +- class/widgets/reference-container.php | 120 +- css/dev-common.css | 250 +- css/dev-layout-entry-content.css | 64 +- css/dev-layout-main-content.css | 64 +- css/dev-layout-reference-container.css | 54 +- css/dev-tooltips-alternative.css | 38 +- css/dev-tooltips.css | 32 +- css/settings.css | 136 +- footnotes.php | 42 +- js/jquery.tools.js | 848 ++-- js/wysiwyg-editor.js | 128 +- .../dashboard/customize-css-migration.html | 24 +- templates/dashboard/customize-css-new.html | 18 +- templates/dashboard/customize-css.html | 14 +- .../dashboard/customize-hyperlink-arrow.html | 20 +- .../dashboard/customize-superscript.html | 44 +- templates/dashboard/diagnostics.html | 70 +- templates/dashboard/editor-button.html | 114 +- templates/dashboard/expert-lookup.html | 88 +- .../dashboard/mouse-over-box-appearance.html | 60 +- .../dashboard/mouse-over-box-dimensions.html | 12 +- .../dashboard/mouse-over-box-display.html | 22 +- .../dashboard/mouse-over-box-position.html | 28 +- templates/dashboard/mouse-over-box-text.html | 32 +- .../dashboard/mouse-over-box-timing.html | 36 +- .../dashboard/mouse-over-box-truncation.html | 28 +- templates/dashboard/other-plugins.html | 134 +- templates/dashboard/settings-excerpts.html | 14 +- templates/dashboard/settings-love.html | 20 +- templates/dashboard/settings-numbering.html | 22 +- .../settings-reference-container.html | 218 +- templates/dashboard/settings-scrolling.html | 68 +- templates/dashboard/settings-start-end.html | 98 +- templates/public/footnote-alternative.html | 38 +- templates/public/footnote.html | 32 +- .../reference-container-body-3column.html | 50 +- .../reference-container-body-combi.html | 20 +- .../reference-container-body-switch.html | 30 +- .../public/reference-container-body.html | 40 +- templates/public/reference-container.html | 154 +- templates/public/tooltip.html | 28 +- 51 files changed, 7494 insertions(+), 7494 deletions(-) diff --git a/class/config.php b/class/config.php index 96612d5..cb9b7bd 100644 --- a/class/config.php +++ b/class/config.php @@ -9,7 +9,7 @@ * Edited for: * 2.0.4 add Public Plugin name for dashboard heading 2020-11-01T0452+0100 * - * Last modified: 2020-12-08T2032+0100 + * Last modified: 2021-02-18T2027+0100 */ @@ -21,63 +21,63 @@ */ class MCI_Footnotes_Config { - /** - * Internal Plugin name. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - const C_STR_PLUGIN_NAME = "footnotes"; + /** + * Internal Plugin name. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_PLUGIN_NAME = "footnotes"; - /** - * Public Plugin name. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - * - * edited classes for v2.0.4 - */ - const C_STR_PLUGIN_PUBLIC_NAME = ''; + /** + * Public Plugin name. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + * + * edited classes for v2.0.4 + */ + const C_STR_PLUGIN_PUBLIC_NAME = ''; - /** - * Public Plugin name for dashboard heading - * - * After properly displaying in dashboard headings until WPv5.4, the above started - * in WPv5.5 being torn apart as if the headline was text-align:justify and not - * the last line. That ugly display bug badly affected the plugin’s communication. - * The only working solution found so far is using position:fixed in one heading - * that isn’t translated, and dropping the logo in another, translatable heading. - * - * @since 2.0.4 - * @var string - */ - const C_STR_PLUGIN_HEADING_NAME = 'footnotes'; + /** + * Public Plugin name for dashboard heading + * + * After properly displaying in dashboard headings until WPv5.4, the above started + * in WPv5.5 being torn apart as if the headline was text-align:justify and not + * the last line. That ugly display bug badly affected the plugin’s communication. + * The only working solution found so far is using position:fixed in one heading + * that isn’t translated, and dropping the logo in another, translatable heading. + * + * @since 2.0.4 + * @var string + */ + const C_STR_PLUGIN_HEADING_NAME = 'footnotes'; - /** - * Html tag for the LOVE symbol. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - const C_STR_LOVE_SYMBOL = ''; + /** + * Html tag for the LOVE symbol. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_LOVE_SYMBOL = ''; - /** - * HTML code for the 'love' symbol used in dashboard heading - * - * @since 2.0.4 - * @var string - */ - const C_STR_LOVE_SYMBOL_HEADING = ''; + /** + * HTML code for the 'love' symbol used in dashboard heading + * + * @since 2.0.4 + * @var string + */ + const C_STR_LOVE_SYMBOL_HEADING = ''; - /** - * Short code to DON'T display the 'LOVE ME' slug on certain pages. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - const C_STR_NO_LOVE_SLUG = '[[no footnotes: love]]'; + /** + * Short code to DON'T display the 'LOVE ME' slug on certain pages. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_NO_LOVE_SLUG = '[[no footnotes: love]]'; } diff --git a/class/dashboard/init.php b/class/dashboard/init.php index 0bafb42..2adbbbf 100644 --- a/class/dashboard/init.php +++ b/class/dashboard/init.php @@ -16,197 +16,197 @@ */ class MCI_Footnotes_Layout_Init { - /** - * Slug for the Plugin main menu. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - const C_STR_MAIN_MENU_SLUG = "mfmmf"; + /** + * Slug for the Plugin main menu. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_MAIN_MENU_SLUG = "mfmmf"; - /** - * Plugin main menu name. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - const C_STR_MAIN_MENU_TITLE = "ManFisher"; + /** + * Plugin main menu name. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_MAIN_MENU_TITLE = "ManFisher"; - /** - * - * @author Stefan Herndler - * @since 1.5.0 - * @var array - */ - private $a_arr_SubPageClasses = array(); + /** + * + * @author Stefan Herndler + * @since 1.5.0 + * @var array + */ + private $a_arr_SubPageClasses = array(); - /** - * Class Constructor. Initializes all WordPress hooks for the Plugin Settings. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function __construct() { - // iterate through each class define in the current script - foreach(get_declared_classes() as $l_str_ClassName) { - // accept only child classes of the layout engine - if(is_subclass_of($l_str_ClassName, 'MCI_Footnotes_LayoutEngine')) { - /** @var MCI_Footnotes_LayoutEngine $l_obj_Class */ - $l_obj_Class = new $l_str_ClassName(); - // append new instance of the layout engine sub class - $this->a_arr_SubPageClasses[$l_obj_Class->getPriority()] = $l_obj_Class; - } - } - ksort($this->a_arr_SubPageClasses); + /** + * Class Constructor. Initializes all WordPress hooks for the Plugin Settings. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function __construct() { + // iterate through each class define in the current script + foreach(get_declared_classes() as $l_str_ClassName) { + // accept only child classes of the layout engine + if(is_subclass_of($l_str_ClassName, 'MCI_Footnotes_LayoutEngine')) { + /** @var MCI_Footnotes_LayoutEngine $l_obj_Class */ + $l_obj_Class = new $l_str_ClassName(); + // append new instance of the layout engine sub class + $this->a_arr_SubPageClasses[$l_obj_Class->getPriority()] = $l_obj_Class; + } + } + ksort($this->a_arr_SubPageClasses); - // register hooks/actions - add_action('admin_init', array($this, 'initializeSettings')); - add_action('admin_menu', array($this, 'registerMainMenu')); - // register AJAX callbacks for Plugin information - add_action("wp_ajax_nopriv_footnotes_getPluginInfo", array($this, "getPluginMetaInformation")); - add_action("wp_ajax_footnotes_getPluginInfo", array($this, "getPluginMetaInformation")); - } + // register hooks/actions + add_action('admin_init', array($this, 'initializeSettings')); + add_action('admin_menu', array($this, 'registerMainMenu')); + // register AJAX callbacks for Plugin information + add_action("wp_ajax_nopriv_footnotes_getPluginInfo", array($this, "getPluginMetaInformation")); + add_action("wp_ajax_footnotes_getPluginInfo", array($this, "getPluginMetaInformation")); + } - /** - * Initializes all sub pages and registers the settings. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function initializeSettings() { - MCI_Footnotes_Settings::instance()->RegisterSettings(); - // iterate though each sub class of the layout engine and register their sections - /** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */ - foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) { - $l_obj_LayoutEngineSubClass->registerSections(); - } - } + /** + * Initializes all sub pages and registers the settings. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function initializeSettings() { + MCI_Footnotes_Settings::instance()->RegisterSettings(); + // iterate though each sub class of the layout engine and register their sections + /** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */ + foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) { + $l_obj_LayoutEngineSubClass->registerSections(); + } + } - /** - * Registers the new main menu for the WordPress dashboard. - * Registers all sub menu pages for the new main menu. - * - * @author Stefan Herndler - * @since 1.5.0 - * @see http://codex.wordpress.org/Function_Reference/add_menu_page - */ - public function registerMainMenu() { - global $menu; - // iterate through each main menu - foreach($menu as $l_arr_MainMenu) { - // iterate through each main menu attribute - foreach($l_arr_MainMenu as $l_str_Attribute) { - // main menu already added, append sub pages and stop - if ($l_str_Attribute == self::C_STR_MAIN_MENU_SLUG) { - $this->registerSubPages(); - return; - } - } - } + /** + * Registers the new main menu for the WordPress dashboard. + * Registers all sub menu pages for the new main menu. + * + * @author Stefan Herndler + * @since 1.5.0 + * @see http://codex.wordpress.org/Function_Reference/add_menu_page + */ + public function registerMainMenu() { + global $menu; + // iterate through each main menu + foreach($menu as $l_arr_MainMenu) { + // iterate through each main menu attribute + foreach($l_arr_MainMenu as $l_str_Attribute) { + // main menu already added, append sub pages and stop + if ($l_str_Attribute == self::C_STR_MAIN_MENU_SLUG) { + $this->registerSubPages(); + return; + } + } + } - // add a new main menu page to the WordPress dashboard - add_menu_page( - self::C_STR_MAIN_MENU_TITLE, // page title - self::C_STR_MAIN_MENU_TITLE, // menu title - 'manage_options', // capability - self::C_STR_MAIN_MENU_SLUG, // menu slug - array($this, "displayOtherPlugins"), // function - plugins_url('footnotes/img/main-menu.png'), // icon url - null // position - ); - $this->registerSubPages(); - } + // add a new main menu page to the WordPress dashboard + add_menu_page( + self::C_STR_MAIN_MENU_TITLE, // page title + self::C_STR_MAIN_MENU_TITLE, // menu title + 'manage_options', // capability + self::C_STR_MAIN_MENU_SLUG, // menu slug + array($this, "displayOtherPlugins"), // function + plugins_url('footnotes/img/main-menu.png'), // icon url + null // position + ); + $this->registerSubPages(); + } - /** - * Registers all SubPages for this Plugin. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - private function registerSubPages() { - // first registered sub menu page MUST NOT contain a unique slug suffix - // iterate though each sub class of the layout engine and register their sub page - /** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */ - foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) { - $l_obj_LayoutEngineSubClass->registerSubPage(); - } - } + /** + * Registers all SubPages for this Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function registerSubPages() { + // first registered sub menu page MUST NOT contain a unique slug suffix + // iterate though each sub class of the layout engine and register their sub page + /** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */ + foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) { + $l_obj_LayoutEngineSubClass->registerSubPage(); + } + } - /** - * Displays other Plugins from the developers. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function displayOtherPlugins() { - printf("

"); - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "manfisher"); - echo $l_obj_Template->getContent(); + /** + * Displays other Plugins from the developers. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function displayOtherPlugins() { + printf("

"); + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "manfisher"); + echo $l_obj_Template->getContent(); - printf('visit Mark Cheret'); - printf("

"); - - printf(''); - } + printf('visit Mark Cheret'); + printf("

"); - /** - * AJAX call. returns a JSON string containing meta information about a specific WordPress Plugin. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function getPluginMetaInformation() { - // get plugin internal name from POST data - $l_str_PluginName = array_key_exists("plugin", $_POST) ? $_POST["plugin"] : null; - if (empty($l_str_PluginName)) { - echo json_encode(array("error" => "Plugin name invalid.")); - exit; - } - $l_str_Url = "https://api.wordpress.org/plugins/info/1.0/".$l_str_PluginName.".json"; - // call URL and collect data - $l_arr_Response = wp_remote_get($l_str_Url); - // check if response is valid - if (is_wp_error($l_arr_Response)) { - echo json_encode(array("error" => "Error receiving Plugin Information from WordPress.")); - exit; - } - if (!array_key_exists("body", $l_arr_Response)) { - echo json_encode(array("error" => "Error reading WordPress API response message.")); - exit; - } - // get the body of the response - $l_str_Response = $l_arr_Response["body"]; - // get plugin object - $l_arr_Plugin = json_decode($l_str_Response, true); - if (empty($l_arr_Plugin)) { - echo json_encode(array("error" => "Error reading Plugin meta information.
URL: " . $l_str_Url . "
Response: " . $l_str_Response)); - exit; - } + printf(''); + } - $l_int_NumRatings = array_key_exists("num_ratings", $l_arr_Plugin) ? intval($l_arr_Plugin["num_ratings"]) : 0; - $l_int_Rating = array_key_exists("rating", $l_arr_Plugin) ? floatval($l_arr_Plugin["rating"]) : 0.0; - $l_int_Stars = round(5 * $l_int_Rating / 100.0, 1); + /** + * AJAX call. returns a JSON string containing meta information about a specific WordPress Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function getPluginMetaInformation() { + // get plugin internal name from POST data + $l_str_PluginName = array_key_exists("plugin", $_POST) ? $_POST["plugin"] : null; + if (empty($l_str_PluginName)) { + echo json_encode(array("error" => "Plugin name invalid.")); + exit; + } + $l_str_Url = "https://api.wordpress.org/plugins/info/1.0/".$l_str_PluginName.".json"; + // call URL and collect data + $l_arr_Response = wp_remote_get($l_str_Url); + // check if response is valid + if (is_wp_error($l_arr_Response)) { + echo json_encode(array("error" => "Error receiving Plugin Information from WordPress.")); + exit; + } + if (!array_key_exists("body", $l_arr_Response)) { + echo json_encode(array("error" => "Error reading WordPress API response message.")); + exit; + } + // get the body of the response + $l_str_Response = $l_arr_Response["body"]; + // get plugin object + $l_arr_Plugin = json_decode($l_str_Response, true); + if (empty($l_arr_Plugin)) { + echo json_encode(array("error" => "Error reading Plugin meta information.
URL: " . $l_str_Url . "
Response: " . $l_str_Response)); + exit; + } - // return Plugin information as JSON encoded string - echo json_encode( - array( - "error" => "", - "PluginDescription" => array_key_exists("short_description", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["short_description"]) : "Error reading Plugin information", - "PluginAuthor" => array_key_exists("author", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["author"]) : "unknown", - "PluginRatingText" => $l_int_Stars . " " . __("rating based on", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . " " . $l_int_NumRatings . " " . __("ratings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "PluginRating1" => $l_int_Stars >= 0.5 ? "star-full" : "star-empty", - "PluginRating2" => $l_int_Stars >= 1.5 ? "star-full" : "star-empty", - "PluginRating3" => $l_int_Stars >= 2.5 ? "star-full" : "star-empty", - "PluginRating4" => $l_int_Stars >= 3.5 ? "star-full" : "star-empty", - "PluginRating5" => $l_int_Stars >= 4.5 ? "star-full" : "star-empty", - "PluginRating" => $l_int_NumRatings, - "PluginLastUpdated" => array_key_exists("last_updated", $l_arr_Plugin) ? $l_arr_Plugin["last_updated"] : "unknown", - "PluginDownloads" => array_key_exists("downloaded", $l_arr_Plugin) ? $l_arr_Plugin["downloaded"] : "---" - ) - ); - exit; - } + $l_int_NumRatings = array_key_exists("num_ratings", $l_arr_Plugin) ? intval($l_arr_Plugin["num_ratings"]) : 0; + $l_int_Rating = array_key_exists("rating", $l_arr_Plugin) ? floatval($l_arr_Plugin["rating"]) : 0.0; + $l_int_Stars = round(5 * $l_int_Rating / 100.0, 1); + + // return Plugin information as JSON encoded string + echo json_encode( + array( + "error" => "", + "PluginDescription" => array_key_exists("short_description", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["short_description"]) : "Error reading Plugin information", + "PluginAuthor" => array_key_exists("author", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["author"]) : "unknown", + "PluginRatingText" => $l_int_Stars . " " . __("rating based on", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . " " . $l_int_NumRatings . " " . __("ratings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "PluginRating1" => $l_int_Stars >= 0.5 ? "star-full" : "star-empty", + "PluginRating2" => $l_int_Stars >= 1.5 ? "star-full" : "star-empty", + "PluginRating3" => $l_int_Stars >= 2.5 ? "star-full" : "star-empty", + "PluginRating4" => $l_int_Stars >= 3.5 ? "star-full" : "star-empty", + "PluginRating5" => $l_int_Stars >= 4.5 ? "star-full" : "star-empty", + "PluginRating" => $l_int_NumRatings, + "PluginLastUpdated" => array_key_exists("last_updated", $l_arr_Plugin) ? $l_arr_Plugin["last_updated"] : "unknown", + "PluginDownloads" => array_key_exists("downloaded", $l_arr_Plugin) ? $l_arr_Plugin["downloaded"] : "---" + ) + ); + exit; + } } diff --git a/class/dashboard/layout.php b/class/dashboard/layout.php index 0a04acb..57b63c9 100644 --- a/class/dashboard/layout.php +++ b/class/dashboard/layout.php @@ -6,7 +6,7 @@ * @author Stefan Herndler * @since 1.5.0 12.09.14 10:56 * - * @lastmodified 2021-02-16T0101+0100 + * @lastmodified 2021-02-18T2021+0100 * * @since 2.1.2 add versioning of settings.css for cache busting 2020-11-19T1456+0100 * @since 2.1.4 automate passing version number for cache busting 2020-11-30T0648+0100 @@ -25,528 +25,528 @@ */ abstract class MCI_Footnotes_LayoutEngine { - /** - * Stores the Hook connection string for the child sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var null|string - */ - protected $a_str_SubPageHook = null; + /** + * Stores the Hook connection string for the child sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var null|string + */ + protected $a_str_SubPageHook = null; - /** - * Stores all Sections for the child sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var array - */ - protected $a_arr_Sections = array(); + /** + * Stores all Sections for the child sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var array + */ + protected $a_arr_Sections = array(); - /** - * Returns a Priority index. Lower numbers have a higher Priority. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return int - */ - abstract public function getPriority(); + /** + * Returns a Priority index. Lower numbers have a higher Priority. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return int + */ + abstract public function getPriority(); - /** - * Returns the unique slug of the child sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - */ - abstract protected function getSubPageSlug(); + /** + * Returns the unique slug of the child sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + abstract protected function getSubPageSlug(); - /** - * Returns the title of the child sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - */ - abstract protected function getSubPageTitle(); + /** + * Returns the title of the child sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + abstract protected function getSubPageTitle(); - /** - * Returns an array of all registered sections for a sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return array - */ - abstract protected function getSections(); + /** + * Returns an array of all registered sections for a sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return array + */ + abstract protected function getSections(); - /** - * Returns an array of all registered meta boxes. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return array - */ - abstract protected function getMetaBoxes(); + /** + * Returns an array of all registered meta boxes. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return array + */ + abstract protected function getMetaBoxes(); - /** - * Returns an array describing a sub page section. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_ID Unique ID suffix. - * @param string $p_str_Title Title of the section. - * @param int $p_int_SettingsContainerIndex Settings Container Index. - * @param bool $p_bool_hasSubmitButton Should a Submit Button be displayed for this section, default: true. - * @return array Array describing the section. - */ - protected function addSection($p_str_ID, $p_str_Title, $p_int_SettingsContainerIndex, $p_bool_hasSubmitButton = true) { - return array("id" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_ID, "title" => $p_str_Title, "submit" => $p_bool_hasSubmitButton, "container" => $p_int_SettingsContainerIndex); - } + /** + * Returns an array describing a sub page section. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_ID Unique ID suffix. + * @param string $p_str_Title Title of the section. + * @param int $p_int_SettingsContainerIndex Settings Container Index. + * @param bool $p_bool_hasSubmitButton Should a Submit Button be displayed for this section, default: true. + * @return array Array describing the section. + */ + protected function addSection($p_str_ID, $p_str_Title, $p_int_SettingsContainerIndex, $p_bool_hasSubmitButton = true) { + return array("id" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_ID, "title" => $p_str_Title, "submit" => $p_bool_hasSubmitButton, "container" => $p_int_SettingsContainerIndex); + } - /** - * Returns an array describing a meta box. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_SectionID Parent Section ID. - * @param string $p_str_ID Unique ID suffix. - * @param string $p_str_Title Title for the meta box. - * @param string $p_str_CallbackFunctionName Class method name for callback. - * @return array meta box description to be able to append a meta box to the output. - */ - protected function addMetaBox($p_str_SectionID, $p_str_ID, $p_str_Title, $p_str_CallbackFunctionName) { - return array( - "parent" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_SectionID, - "id" => $p_str_ID, - "title" => $p_str_Title, - "callback" => $p_str_CallbackFunctionName - ); - } + /** + * Returns an array describing a meta box. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SectionID Parent Section ID. + * @param string $p_str_ID Unique ID suffix. + * @param string $p_str_Title Title for the meta box. + * @param string $p_str_CallbackFunctionName Class method name for callback. + * @return array meta box description to be able to append a meta box to the output. + */ + protected function addMetaBox($p_str_SectionID, $p_str_ID, $p_str_Title, $p_str_CallbackFunctionName) { + return array( + "parent" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_SectionID, + "id" => $p_str_ID, + "title" => $p_str_Title, + "callback" => $p_str_CallbackFunctionName + ); + } - /** - * Registers a sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function registerSubPage() { - global $submenu; - // any sub menu for our main menu exists - if (array_key_exists(plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG), $submenu)) { - // iterate through all sub menu entries of the ManFisher main menu - foreach($submenu[plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG)] as $l_arr_SubMenu) { - if ($l_arr_SubMenu[2] == plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug())) { - // remove that sub menu and add it again to move it to the bottom - remove_submenu_page(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG .$this->getSubPageSlug()); - } - } - } + /** + * Registers a sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function registerSubPage() { + global $submenu; + // any sub menu for our main menu exists + if (array_key_exists(plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG), $submenu)) { + // iterate through all sub menu entries of the ManFisher main menu + foreach($submenu[plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG)] as $l_arr_SubMenu) { + if ($l_arr_SubMenu[2] == plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug())) { + // remove that sub menu and add it again to move it to the bottom + remove_submenu_page(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG .$this->getSubPageSlug()); + } + } + } - $this->a_str_SubPageHook = add_submenu_page( - MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, // parent slug - $this->getSubPageTitle(), // page title - $this->getSubPageTitle(), // menu title - 'manage_options', // capability - MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), // menu slug - array($this, 'displayContent') // function - ); - } + $this->a_str_SubPageHook = add_submenu_page( + MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, // parent slug + $this->getSubPageTitle(), // page title + $this->getSubPageTitle(), // menu title + 'manage_options', // capability + MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), // menu slug + array($this, 'displayContent') // function + ); + } - /** - * Registers all sections for a sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function registerSections() { - // iterate through each section - foreach($this->getSections() as $l_arr_Section) { - // append tab to the tab-array - $this->a_arr_Sections[$l_arr_Section["id"]] = $l_arr_Section; - add_settings_section( - $l_arr_Section["id"], // unique id - "", //$l_arr_Section["title"], // title - array($this, 'Description'), // callback function for the description - $l_arr_Section["id"] // parent sub page slug - ); - $this->registerMetaBoxes($l_arr_Section["id"]); - } - } + /** + * Registers all sections for a sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function registerSections() { + // iterate through each section + foreach($this->getSections() as $l_arr_Section) { + // append tab to the tab-array + $this->a_arr_Sections[$l_arr_Section["id"]] = $l_arr_Section; + add_settings_section( + $l_arr_Section["id"], // unique id + "", //$l_arr_Section["title"], // title + array($this, 'Description'), // callback function for the description + $l_arr_Section["id"] // parent sub page slug + ); + $this->registerMetaBoxes($l_arr_Section["id"]); + } + } - /** - * Registers all Meta boxes for a sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_ParentID Parent section unique id. - */ - private function registerMetaBoxes($p_str_ParentID) { - // iterate through each meta box - foreach($this->getMetaBoxes() as $l_arr_MetaBox) { - if ($l_arr_MetaBox["parent"] != $p_str_ParentID) { - continue; - } - add_meta_box( - $p_str_ParentID. "-" . $l_arr_MetaBox["id"], // unique id - $l_arr_MetaBox["title"], // meta box title - array($this, $l_arr_MetaBox["callback"]), // callback function to display (echo) the content - $p_str_ParentID, // post type = parent section id - 'main' // context - ); - } - } + /** + * Registers all Meta boxes for a sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_ParentID Parent section unique id. + */ + private function registerMetaBoxes($p_str_ParentID) { + // iterate through each meta box + foreach($this->getMetaBoxes() as $l_arr_MetaBox) { + if ($l_arr_MetaBox["parent"] != $p_str_ParentID) { + continue; + } + add_meta_box( + $p_str_ParentID. "-" . $l_arr_MetaBox["id"], // unique id + $l_arr_MetaBox["title"], // meta box title + array($this, $l_arr_MetaBox["callback"]), // callback function to display (echo) the content + $p_str_ParentID, // post type = parent section id + 'main' // context + ); + } + } - /** - * Append javascript and css files for specific sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - private function appendScripts() { - // enable meta boxes layout and close functionality - wp_enqueue_script('postbox'); - // add WordPress color picker layout - wp_enqueue_style('wp-color-picker'); - // add WordPress color picker function - wp_enqueue_script('wp-color-picker'); + /** + * Append javascript and css files for specific sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function appendScripts() { + // enable meta boxes layout and close functionality + wp_enqueue_script('postbox'); + // add WordPress color picker layout + wp_enqueue_style('wp-color-picker'); + // add WordPress color picker function + wp_enqueue_script('wp-color-picker'); - /** - * Registers and enqueues the dashboard stylesheet. - * - * - Bugfix: Stylesheets: minify to shrink the carbon footprint, increase speed and implement best practice, thanks to @docteurfitness issue report. - * - * @since 2.5.5 - * @date 2021-02-14T1928+0100 - * - * @reporter @docteurfitness - * @link https://wordpress.org/support/topic/simply-speed-optimisation/ - * - * See the public stylesheet enqueuing: - * @see class/init.php - * - * added version # after changes started to settings.css from 2.1.2 on. - * automated update of version number for cache busting. - * No need to use '-styles' in the handle, as '-css' is appended automatically. - */ - if ( C_BOOL_CSS_PRODUCTION_MODE === true ) { + /** + * Registers and enqueues the dashboard stylesheet. + * + * - Bugfix: Stylesheets: minify to shrink the carbon footprint, increase speed and implement best practice, thanks to @docteurfitness issue report. + * + * @since 2.5.5 + * @date 2021-02-14T1928+0100 + * + * @reporter @docteurfitness + * @link https://wordpress.org/support/topic/simply-speed-optimisation/ + * + * See the public stylesheet enqueuing: + * @see class/init.php + * + * added version # after changes started to settings.css from 2.1.2 on. + * automated update of version number for cache busting. + * No need to use '-styles' in the handle, as '-css' is appended automatically. + */ + if ( C_BOOL_CSS_PRODUCTION_MODE === true ) { - wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.min.css' ), array(), C_STR_FOOTNOTES_VERSION ); + wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.min.css' ), array(), C_STR_FOOTNOTES_VERSION ); - } else { + } else { - wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.css' ), array(), C_STR_FOOTNOTES_VERSION ); + wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.css' ), array(), C_STR_FOOTNOTES_VERSION ); - } + } - wp_enqueue_style('mci-footnotes-admin'); - } + wp_enqueue_style('mci-footnotes-admin'); + } - /** - * Displays the content of specific sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function displayContent() { - // register and enqueue scripts and styling - $this->appendScripts(); - // get current section - reset($this->a_arr_Sections); - $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections); - $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID]; - // store settings - $l_bool_SettingsUpdated = false; - if (array_key_exists("save-settings", $_POST)) { - if ($_POST["save-settings"] == "save") { - unset($_POST["save-settings"]); - unset($_POST["submit"]); - $l_bool_SettingsUpdated = $this->saveSettings(); - } - } + /** + * Displays the content of specific sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function displayContent() { + // register and enqueue scripts and styling + $this->appendScripts(); + // get current section + reset($this->a_arr_Sections); + $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections); + $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID]; + // store settings + $l_bool_SettingsUpdated = false; + if (array_key_exists("save-settings", $_POST)) { + if ($_POST["save-settings"] == "save") { + unset($_POST["save-settings"]); + unset($_POST["submit"]); + $l_bool_SettingsUpdated = $this->saveSettings(); + } + } - // display all sections and highlight the active section - echo '
'; - echo '
'; + // display all sections and highlight the active section + echo '
'; + echo '
'; - if ($l_bool_SettingsUpdated) { - echo sprintf('
%s
', __("Settings saved", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); - } + if ($l_bool_SettingsUpdated) { + echo sprintf('
%s
', __("Settings saved", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + } - // form to submit the active section - echo '
'; - //settings_fields($l_arr_ActiveSection["container"]); - echo ''; - // outputs the settings field of the active section - do_settings_sections($l_arr_ActiveSection["id"]); - do_meta_boxes($l_arr_ActiveSection["id"], 'main', NULL); + // form to submit the active section + echo ''; + //settings_fields($l_arr_ActiveSection["container"]); + echo ''; + // outputs the settings field of the active section + do_settings_sections($l_arr_ActiveSection["id"]); + do_meta_boxes($l_arr_ActiveSection["id"], 'main', NULL); - // add submit button to active section if defined - if ($l_arr_ActiveSection["submit"]) { - submit_button(); - } - // close the form to submit data - echo '
'; - // close container for the settings page - echo '
'; - // output special javascript for the expand/collapse function of the meta boxes - echo ''; - } + // add submit button to active section if defined + if ($l_arr_ActiveSection["submit"]) { + submit_button(); + } + // close the form to submit data + echo ''; + // close container for the settings page + echo '
'; + // output special javascript for the expand/collapse function of the meta boxes + echo ''; + } - /** - * Save all Plugin settings. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return bool - */ - private function saveSettings() { - $l_arr_newSettings = array(); - // get current section - reset($this->a_arr_Sections); - $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections); - $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID]; + /** + * Save all Plugin settings. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return bool + */ + private function saveSettings() { + $l_arr_newSettings = array(); + // get current section + reset($this->a_arr_Sections); + $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections); + $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID]; - // iterate through each value that has to be in the specific container - foreach(MCI_Footnotes_Settings::instance()->getDefaults($l_arr_ActiveSection["container"]) as $l_str_Key => $l_mixed_Value) { - // setting is available in the POST array, use it - if (array_key_exists($l_str_Key, $_POST)) { - $l_arr_newSettings[$l_str_Key] = $_POST[$l_str_Key]; - } else { - // setting is not defined in the POST array, define it to avoid the Default value - $l_arr_newSettings[$l_str_Key] = ""; - } - } - // update settings - return MCI_Footnotes_Settings::instance()->saveOptions($l_arr_ActiveSection["container"], $l_arr_newSettings); - } + // iterate through each value that has to be in the specific container + foreach(MCI_Footnotes_Settings::instance()->getDefaults($l_arr_ActiveSection["container"]) as $l_str_Key => $l_mixed_Value) { + // setting is available in the POST array, use it + if (array_key_exists($l_str_Key, $_POST)) { + $l_arr_newSettings[$l_str_Key] = $_POST[$l_str_Key]; + } else { + // setting is not defined in the POST array, define it to avoid the Default value + $l_arr_newSettings[$l_str_Key] = ""; + } + } + // update settings + return MCI_Footnotes_Settings::instance()->saveOptions($l_arr_ActiveSection["container"], $l_arr_newSettings); + } - /** - * Output the Description of a section. May be overwritten in any section. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function Description() { - // default no description will be displayed - } + /** + * Output the Description of a section. May be overwritten in any section. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Description() { + // default no description will be displayed + } - /** - * Loads specific setting and returns an array with the keys [id, name, value]. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_SettingKeyName Settings Array key name. - * @return array Contains Settings ID, Settings Name and Settings Value. - */ - protected function LoadSetting($p_str_SettingKeyName) { - // get current section - reset($this->a_arr_Sections); - $p_arr_Return = array(); - $p_arr_Return["id"] = sprintf('%s', $p_str_SettingKeyName); - $p_arr_Return["name"] = sprintf('%s', $p_str_SettingKeyName); - $p_arr_Return["value"] = esc_attr(MCI_Footnotes_Settings::instance()->get($p_str_SettingKeyName)); - return $p_arr_Return; - } + /** + * Loads specific setting and returns an array with the keys [id, name, value]. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingKeyName Settings Array key name. + * @return array Contains Settings ID, Settings Name and Settings Value. + */ + protected function LoadSetting($p_str_SettingKeyName) { + // get current section + reset($this->a_arr_Sections); + $p_arr_Return = array(); + $p_arr_Return["id"] = sprintf('%s', $p_str_SettingKeyName); + $p_arr_Return["name"] = sprintf('%s', $p_str_SettingKeyName); + $p_arr_Return["value"] = esc_attr(MCI_Footnotes_Settings::instance()->get($p_str_SettingKeyName)); + return $p_arr_Return; + } - /** - * Returns a line break to start a new line. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - */ - protected function addNewline() { - return '
'; - } + /** + * Returns a line break to start a new line. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + protected function addNewline() { + return '
'; + } - /** - * Returns a line break to have a space between two lines. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - */ - protected function addLineSpace() { - return '

'; - } + /** + * Returns a line break to have a space between two lines. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + protected function addLineSpace() { + return '

'; + } - /** - * Returns a simple text inside html text. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_Text Message to be surrounded with simple html tag (span). - * @return string - */ - protected function addText($p_str_Text) { - return sprintf('%s', $p_str_Text); - } + /** + * Returns a simple text inside html text. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Text Message to be surrounded with simple html tag (span). + * @return string + */ + protected function addText($p_str_Text) { + return sprintf('%s', $p_str_Text); + } - /** - * Returns the html tag for an input/select label. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_SettingName Name of the Settings key to connect the Label with the input/select field. - * @param string $p_str_Caption Label caption. - * @return string - * - * Edited 2020-12-01T0159+0100.. - * @since 2.1.6 no colon - */ - protected function addLabel($p_str_SettingName, $p_str_Caption) { - if (empty($p_str_Caption)) { - return ""; - } - // remove the colon causing localization issues with French, - // and with languages not using punctuation at all, - // and with languages using other punctuation marks instead of colon, - // e.g. Greek using a raised dot. - // In French, colon is preceded by a space, forcibly non-breaking, - // and narrow per new school. - // Add colon to label strings for inclusion in localization. - // Colon after label is widely preferred best practice, mandatory per style guides. - // - return sprintf('', $p_str_SettingName, $p_str_Caption); - // ^ here deleted colon 2020-12-08T1546+0100 - } + /** + * Returns the html tag for an input/select label. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to connect the Label with the input/select field. + * @param string $p_str_Caption Label caption. + * @return string + * + * Edited 2020-12-01T0159+0100.. + * @since 2.1.6 no colon + */ + protected function addLabel($p_str_SettingName, $p_str_Caption) { + if (empty($p_str_Caption)) { + return ""; + } + // remove the colon causing localization issues with French, + // and with languages not using punctuation at all, + // and with languages using other punctuation marks instead of colon, + // e.g. Greek using a raised dot. + // In French, colon is preceded by a space, forcibly non-breaking, + // and narrow per new school. + // Add colon to label strings for inclusion in localization. + // Colon after label is widely preferred best practice, mandatory per style guides. + // + return sprintf('', $p_str_SettingName, $p_str_Caption); + // ^ here deleted colon 2020-12-08T1546+0100 + } - /** - * Returns the html tag for an input [type = text]. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_SettingName Name of the Settings key to pre load the input field. - * @param int $p_str_MaxLength Maximum length of the input, default 999 characters. - * @param bool $p_bool_Readonly Set the input to be read only, default false. - * @param bool $p_bool_Hidden Set the input to be hidden, default false. - * @return string - */ - protected function addTextBox($p_str_SettingName, $p_str_MaxLength = 999, $p_bool_Readonly = false, $p_bool_Hidden = false) { - $l_str_Style = ""; - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingName); - if ($p_bool_Hidden) { - $l_str_Style .= 'display:none;'; - } - return sprintf('', - $l_arr_Data["name"], $l_arr_Data["id"], $p_str_MaxLength, - $l_str_Style, $l_arr_Data["value"], $p_bool_Readonly ? 'readonly="readonly"' : ''); - } + /** + * Returns the html tag for an input [type = text]. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre load the input field. + * @param int $p_str_MaxLength Maximum length of the input, default 999 characters. + * @param bool $p_bool_Readonly Set the input to be read only, default false. + * @param bool $p_bool_Hidden Set the input to be hidden, default false. + * @return string + */ + protected function addTextBox($p_str_SettingName, $p_str_MaxLength = 999, $p_bool_Readonly = false, $p_bool_Hidden = false) { + $l_str_Style = ""; + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + if ($p_bool_Hidden) { + $l_str_Style .= 'display:none;'; + } + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $p_str_MaxLength, + $l_str_Style, $l_arr_Data["value"], $p_bool_Readonly ? 'readonly="readonly"' : ''); + } - /** - * Returns the html tag for an input [type = checkbox]. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_SettingName Name of the Settings key to pre load the input field. - * @return string - */ - protected function addCheckbox($p_str_SettingName) { - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingName); - return sprintf('', - $l_arr_Data["name"], $l_arr_Data["id"], - MCI_Footnotes_Convert::toBool($l_arr_Data["value"]) ? 'checked="checked"' : ''); - } + /** + * Returns the html tag for an input [type = checkbox]. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre load the input field. + * @return string + */ + protected function addCheckbox($p_str_SettingName) { + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], + MCI_Footnotes_Convert::toBool($l_arr_Data["value"]) ? 'checked="checked"' : ''); + } - /** - * Returns the html tag for a select box. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_SettingName Name of the Settings key to pre select the current value. - * @param array $p_arr_Options Possible options to be selected. - * @return string - */ - protected function addSelectBox($p_str_SettingName, $p_arr_Options) { - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingName); - $l_str_Options = ""; + /** + * Returns the html tag for a select box. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre select the current value. + * @param array $p_arr_Options Possible options to be selected. + * @return string + */ + protected function addSelectBox($p_str_SettingName, $p_arr_Options) { + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + $l_str_Options = ""; - /* loop through all array keys */ - foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) { - $l_str_Options .= sprintf('', - $l_str_Value, - $l_arr_Data["value"] == $l_str_Value ? "selected" : "", - $l_str_Caption); - } - return sprintf('', - $l_arr_Data["name"], $l_arr_Data["id"], $l_str_Options); - } + /* loop through all array keys */ + foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) { + $l_str_Options .= sprintf('', + $l_str_Value, + $l_arr_Data["value"] == $l_str_Value ? "selected" : "", + $l_str_Caption); + } + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $l_str_Options); + } - /** - * Returns the html tag for a text area. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_SettingName Name of the Settings key to pre fill the text area. - * @return string - */ - protected function addTextArea($p_str_SettingName) { - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingName); - return sprintf('', - $l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]); - } + /** + * Returns the html tag for a text area. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre fill the text area. + * @return string + */ + protected function addTextArea($p_str_SettingName) { + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]); + } - /** - * Returns the html tag for an input [type = text] with color selection class. - * - * @author Stefan Herndler - * @since 1.5.6 - * @param string $p_str_SettingName Name of the Settings key to pre load the input field. - * @return string - */ - protected function addColorSelection($p_str_SettingName) { - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingName); - return sprintf('', - $l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]); - } + /** + * Returns the html tag for an input [type = text] with color selection class. + * + * @author Stefan Herndler + * @since 1.5.6 + * @param string $p_str_SettingName Name of the Settings key to pre load the input field. + * @return string + */ + protected function addColorSelection($p_str_SettingName) { + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]); + } - /** - * Returns the html tag for an input [type = num]. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_SettingName Name of the Settings key to pre load the input field. - * @param int $p_in_Min Minimum value. - * @param int $p_int_Max Maximum value. - * @param bool $p_bool_Deci true if 0.1 steps and floating to string, false if integer (default) - * @return string - * - * Edited: - * @since 2.1.4 step argument and number_format() to allow decimals 2020-12-03T0631+0100..2020-12-12T1110+0100 - */ - protected function addNumBox($p_str_SettingName, $p_in_Min, $p_int_Max, $p_bool_Deci = false ) { - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingName); + /** + * Returns the html tag for an input [type = num]. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre load the input field. + * @param int $p_in_Min Minimum value. + * @param int $p_int_Max Maximum value. + * @param bool $p_bool_Deci true if 0.1 steps and floating to string, false if integer (default) + * @return string + * + * Edited: + * @since 2.1.4 step argument and number_format() to allow decimals 2020-12-03T0631+0100..2020-12-12T1110+0100 + */ + protected function addNumBox($p_str_SettingName, $p_in_Min, $p_int_Max, $p_bool_Deci = false ) { + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); - if ($p_bool_Deci) { - $l_str_Value = number_format(floatval($l_arr_Data["value"]), 1); - return sprintf('', - $l_arr_Data["name"], $l_arr_Data["id"], $l_str_Value, $p_in_Min, $p_int_Max); - } else { - return sprintf('', - $l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"], $p_in_Min, $p_int_Max); - } - } + if ($p_bool_Deci) { + $l_str_Value = number_format(floatval($l_arr_Data["value"]), 1); + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $l_str_Value, $p_in_Min, $p_int_Max); + } else { + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"], $p_in_Min, $p_int_Max); + } + } } // end of class diff --git a/class/dashboard/subpage-main.php b/class/dashboard/subpage-main.php index cf4841f..cef5f63 100644 --- a/class/dashboard/subpage-main.php +++ b/class/dashboard/subpage-main.php @@ -7,7 +7,7 @@ * @since 1.5.0 14.09.14 14:47 * * - * @lastmodified 2021-02-17T1136+0100 + * @lastmodified 2021-02-18T2021+0100 * * @since 2.0.4 restore arrow settings 2020-11-01T0509+0100 * @since 2.1.0 read-on button label 2020-11-08T2148+0100 @@ -52,1122 +52,1122 @@ */ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { - /** - * Returns a Priority index. Lower numbers have a higher Priority. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return int - */ - public function getPriority() { - return 10; - } - - /** - * Returns the unique slug of the sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - */ - protected function getSubPageSlug() { - return "-" . MCI_Footnotes_Config::C_STR_PLUGIN_NAME; - } - - /** - * Returns the title of the sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - */ - protected function getSubPageTitle() { - return MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME; - } - - /** - * Returns an array of all registered sections for the sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return array - * - * Edited: - * @since 2.1.6 tabs reordered and renamed - * @link https://www.linkedin.com/pulse/20140610191154-4746170-configuration-vs-customization-when-and-why-would-i-implement-each - * - * @since 2.1.6 removed if statement around expert tab - */ - protected function getSections() { - $l_arr_Tabs = array(); - - // sync tab name with mirror in task.php: - $l_arr_Tabs[] = $this->addSection("settings", __("General settings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 0, true); - - // sync tab name with mirror in public function CustomCSSMigration(): - $l_arr_Tabs[] = $this->addSection("customize", __("Referrers and tooltips", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 1, true); - - $l_arr_Tabs[] = $this->addSection("expert", __("Scope and priority", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 2, true); - $l_arr_Tabs[] = $this->addSection("customcss", __("Custom CSS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 3, true); - $l_arr_Tabs[] = $this->addSection("how-to", __("Quick start guide", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false); - - return $l_arr_Tabs; - } - - /** - * Returns an array of all registered meta boxes for each section of the sub page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return array - * - * Edited for 2.0.0 and later. - * - * HyperlinkArrow meta box: - * @since 2.0.0 discontinued - * @since 2.0.4 restored to meet user demand for arrow symbol semantics - * @since 2.1.4 discontinued, content moved to Settings > Reference container > Display a backlink symbol - * - * @since 2.0.4 to reflect changes in meta box label display since WPv5.5 - * spans need position:fixed and become unlocalizable - * fix: logo is kept only in the label that doesn’t need to be translated: - * Change string "%s styling" to "Footnotes styling" to fix layout in WPv5.5 - * @see details in class/config.php - * - * @since 2.1.6 / 2.2.0 tabs reordered and renamed - */ - protected function getMetaBoxes() { - $l_arr_MetaBoxes = array(); - - // sync box name with mirror in task.php: - $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "start-end", __("Footnote start and end short codes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "StartEnd"); - $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "numbering", __("Footnotes numbering", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Numbering"); - $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "scrolling", __("Scrolling behavior", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Scrolling"); - $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "reference-container", __("Reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "ReferenceContainer"); - $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "excerpts", __("Footnotes in excerpts", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Excerpts"); - $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "love", MCI_Footnotes_Config::C_STR_PLUGIN_HEADING_NAME . ' ' . MCI_Footnotes_Config::C_STR_LOVE_SYMBOL_HEADING, "Love"); - - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "hyperlink-arrow", __("Backlink symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "HyperlinkArrow"); - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "superscript", __("Referrer typesetting and formatting", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Superscript"); - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box", __("Tooltips", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBox"); - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-position", __("Tooltip position", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxPosition"); - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-dimensions", __("Tooltip dimensions", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxDimensions"); - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-timing", __("Tooltip timing", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxTiming"); - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-truncation", __("Tooltip truncation", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxTruncation"); - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-text", __("Tooltip text", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxText"); - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-appearance", __("Tooltip appearance", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxAppearance"); - if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE))) { - $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "custom-css", __("Your existing Custom CSS code", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSS"); - } - - $l_arr_MetaBoxes[] = $this->addMetaBox("expert", "lookup", __("WordPress hooks with priority level", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "LookupHooks"); - - if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE))) { - $l_arr_MetaBoxes[] = $this->addMetaBox("customcss", "custom-css-migration", __("Your existing Custom CSS code", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSSMigration"); - } - $l_arr_MetaBoxes[] = $this->addMetaBox("customcss", "custom-css-new", __("Custom CSS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSSNew"); - - $l_arr_MetaBoxes[] = $this->addMetaBox("how-to", "help", __("Brief introduction in how to use the plugin", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Help"); - $l_arr_MetaBoxes[] = $this->addMetaBox("how-to", "donate", __("Help us to improve our Plugin", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Donate"); - - return $l_arr_MetaBoxes; - } - - /** - * Displays all settings for the reference container. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Completed: - * @since 2.1.4: layout and typography options 2020-11-30T0548+0100 - * @since 2.2.5 options for label element and label bottom border, thanks to @markhillyer 2020-12-18T1447+0100 - * @link https://wordpress.org/support/topic/how-do-i-eliminate-the-horizontal-line-beneath-the-reference-container-heading/ - */ - public function ReferenceContainer() { - - // options for the label element: - $l_arr_LabelElement = array( - "p" => __("paragraph", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "h2" => __("heading 2", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "h3" => __("heading 3", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "h4" => __("heading 4", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "h5" => __("heading 5", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "h6" => __("heading 6", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ); - // options for the positioning of the reference container - $l_arr_Positions = array( - "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), - "footer" => __("in the footer", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ); - // basic responsive page layout options: - $l_arr_PageLayoutOptions = array( - "none" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "reference-container" => __("to the reference container exclusively", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "entry-content" => __("to the div element starting below the post title", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "main-content" => __("to the main element including the post title", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ); - // options for the separating punctuation between backlinks: - $l_arr_Separators = array( - // Unicode character names are conventionally uppercase. - "comma" => __("COMMA", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "semicolon" => __("SEMICOLON", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "en_dash" => __("EN DASH", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) - ); - // options for the terminating punctuation after backlinks: - // The Unicode name of RIGHT PARENTHESIS was originally more accurate because - // this character is bidi-mirrored. Let’s use the Unicode 1.0 name. - // The wrong names were enforced in spite of Unicode, that subsequently scrambled to correct. - $l_arr_Terminators = array( - "period" => __("FULL STOP", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - // Unicode 1.0 name of RIGHT PARENTHESIS (represented as a left parenthesis in right-to-left scripts): - "parenthesis" => __("CLOSING PARENTHESIS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "colon" => __("COLON", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) - ); - // options for the first column width (per cent is a ratio, not a unit): - $l_arr_WidthUnits = array( - "%" => __("per cent", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "px" => __("pixels", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "rem" => __("root em", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "em" => __("em", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "vw" => __("viewport width", 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"); - // replace all placeholders - $l_obj_Template->replace( - array( - "label-name" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME, __("Heading:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "name" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME), - - "label-element" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, __("Heading’s HTML element:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "element" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, $l_arr_LabelElement), - - "label-border" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER, __("Border under the heading:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "border" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER, $l_arr_Enabled), - - "label-collapse" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, __("Collapse by default:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "collapse" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, $l_arr_Enabled), - - "label-position" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __("Default position:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_Positions), - "notice-position" => sprintf(__("To use the position shortcode, please set the position to: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '' . __("at the end of the post", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . ''), - - "label-shortcode" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE, __("Position shortcode:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "shortcode" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE), - "notice-shortcode" => __("If present in the content, any shortcode in this text box will be replaced with the reference container.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "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-margin-top" => $this->addLabel(MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_TOP_MARGIN, __("Top margin:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "margin-top" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_TOP_MARGIN, -500, 500), - "notice-margin-top" => __("pixels; may be negative", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-margin-bottom" => $this->addLabel(MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN, __("Bottom margin:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "margin-bottom" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN, -500, 500), - "notice-margin-bottom" => __("pixels; may be negative", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-page-layout" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT, __("Apply basic responsive page layout:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "page-layout" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT, $l_arr_PageLayoutOptions), - "notice-page-layout" => __("Most themes don’t need this fix.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-url-wrap" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_URL_WRAP_ENABLED, __("Allow URLs to line-wrap anywhere:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "url-wrap" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_URL_WRAP_ENABLED, $l_arr_Enabled), - "notice-url-wrap" => __("Unicode-conformant browsers don’t need this fix.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "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-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, $l_arr_Enabled), - "notice-symbol" => __("Please choose or input the symbol at the top of the next dashboard tab.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "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-3column" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, __("Backlink symbol in an extra column:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "3column" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, $l_arr_Enabled), - "notice-3column" => __("This legacy layout is available if identical footnotes are not combined.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-row-borders" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE, __("Borders around the table rows:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "row-borders" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE, $l_arr_Enabled), - - "label-separator" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_SEPARATOR_ENABLED, __("Add a separator when enumerating backlinks:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "separator-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_SEPARATOR_ENABLED, $l_arr_Enabled), - "separator-options" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_OPTION, $l_arr_Separators), - "separator-custom" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_CUSTOM), - "notice-separator" => __("Your input overrides the selection.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-terminator" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_TERMINATOR_ENABLED, __("Add a terminal punctuation to backlinks:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "terminator-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_TERMINATOR_ENABLED, $l_arr_Enabled), - "terminator-options" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_OPTION, $l_arr_Terminators), - "terminator-custom" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_CUSTOM), - "notice-terminator" => __("Your input overrides the selection.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-width" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED, __("Set backlinks column width:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "width-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED, $l_arr_Enabled), - "width-scalar" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR, 0, 500, true), - "width-unit" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_UNIT, $l_arr_WidthUnits), - "notice-width" => __("Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-max-width" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, __("Set backlinks column maximum width:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "max-width-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, $l_arr_Enabled), - "max-width-scalar" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR, 0, 500, true), - "max-width-unit" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT, $l_arr_WidthUnits), - "notice-max-width" => __("Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-line-break" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED, __("Stack backlinks when enumerating:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "line-break" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED, $l_arr_Enabled), - "notice-line-break" => __("This option adds a line break before each added backlink when identical footnotes are combined.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-link" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED, __("Use the link element for referrers and backlinks:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "link" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED, $l_arr_Enabled), - "notice-link" => __("The link element is needed to apply the theme’s link color.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "description-link" => __("If the link element is not desired for styling, a simple span is used instead when the above is set to No. The link addresses have been removed. Else footnote clicks are logged in the browsing history and make the back button unusable.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays all options for the footnotes start and end tag short codes - * Displays all options for the footnotes numbering - * Displays all options for the scrolling behavior - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Edited heading 2020-12-12T1412+0100 - * @since 2.2.0 start/end short codes: more predefined options 2020-12-12T1412+0100 - * @link https://wordpress.org/support/topic/doesnt-work-with-mailpoet/ - * @since 2.2.0 3 boxes for clarity 2020-12-12T1422+0100 - * @since 2.2.5 support for Ibid. notation thanks to @meglio 2020-12-17T2019+0100 - * @link https://wordpress.org/support/topic/add-support-for-ibid-notation/ - * @since 2.4.0 added warning about Block Editor escapement disruption 2021-01-02T2324+0100 - * @since 2.4.0 removed the HTML comment tag option 2021-01-02T2325+0100 - * @since 2.5.0 Shortcode syntax validation: add more information around the setting, thanks to @andreasra - * @link https://wordpress.org/support/topic/warning-unbalanced-footnote-start-tag-short-code-before/ - */ - public function StartEnd() { - // footnotes start tag short code options: - $l_arr_ShortCodeStart = array( - "((" => "((", - "(((" => "(((", - "{{" => "{{", - "{{{" => "{{{", - "[n]" => "[n]", - "[fn]" => "[fn]", - htmlspecialchars("") => htmlspecialchars(""), - "[ref]" => "[ref]", - htmlspecialchars("") => htmlspecialchars(""), - // Custom (user-defined) start and end tags bracketing the footnote text inline: - "userdefined" => __('custom short code', MCI_Footnotes_Config::C_STR_PLUGIN_NAME) - ); - // footnotes end tag short code options: - $l_arr_ShortCodeEnd = array( - "))" => "))", - ")))" => ")))", - "}}" => "}}", - "}}}" => "}}}", - "[/n]" => "[/n]", - "[/fn]" => "[/fn]", - htmlspecialchars("") => htmlspecialchars(""), - "[/ref]" => "[/ref]", - htmlspecialchars("") => htmlspecialchars(""), - // Custom (user-defined) start and end tags bracketing the footnote text inline: - "userdefined" => __("custom short code", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) - ); - // options for the syntax validation: - $l_arr_Enable = 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-start-end"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "description-escapement" => __("WARNING: Short codes with closing pointy brackets are disabled in the new WordPress Block Editor that disrupts the traditional balanced escapement applied by WordPress Classic Editor.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-short-code-start" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, __("Footnote start tag short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "short-code-start" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, $l_arr_ShortCodeStart), - "short-code-start-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED), - - "label-short-code-end" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, __("Footnote end tag short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "short-code-end" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, $l_arr_ShortCodeEnd), - "short-code-end-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED), - - // for script showing/hiding user defined text boxes: - "short-code-start-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, - "short-code-end-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, - "short-code-start-user-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED, - "short-code-end-user-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED, - - "description-parentheses" => __("WARNING: Although widespread industry standard, the double parentheses are problematic because they may occur in scripts embedded in the content and be mistaken as a short code.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - // option to enable syntax validation, label mirrored in task.php: - "label-syntax" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, __("Check for balanced shortcodes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "syntax" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, $l_arr_Enable), - "notice-syntax" => __("In the presence of a lone start tag shortcode, a warning displays below the post title.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "description-syntax" => __("If the start tag short code is ‘((’ or ‘(((’, it will not be reported as unbalanced if the following string contains braces hinting that it is a script.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function Numbering() { - // define some space for the output - $l_str_Space = "     "; - // options for the combination of identical footnotes - $l_arr_Enable = array( - "yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) - ); - // options for the numbering style of the footnotes: - $l_arr_CounterStyle = array( - "arabic_plain" => __("plain Arabic numbers", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, …", - "arabic_leading" => __("zero-padded Arabic numbers", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, …", - "latin_low" => __("lowercase Latin letters", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, …", - "latin_high" => __("uppercase Latin letters", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, …", - "romanic" => __("uppercase Roman numerals", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, …", - "roman_low" => __("lowercase Roman numerals", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "i, ii, iii, iv, v, …", - ); - - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-numbering"); - // replace all placeholders - $l_obj_Template->replace( - array( - "label-counter-style" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, __("Numbering style:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "counter-style" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, $l_arr_CounterStyle), - - // algorithmically combine identicals: - "label-identical" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES, __("Combine identical footnotes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "identical" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES, $l_arr_Enable), - "notice-identical" => __("This option may require copy-pasting footnotes in multiple instances.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - // Support for Ibid. notation added thanks to @meglio in . - "description-identical" => __("Even when footnotes are combined, footnote numbers keep incrementing. This avoids suboptimal referrer and backlink disambiguation using a secondary numbering system. The Ibid. notation and the op. cit. abbreviation followed by the current page number avoid repeating the footnote content. For changing sources, shortened citations may be used. Repeating full citations is also an opportunity to add details.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function Scrolling() { - - // options for enabling hard links for AMP compat: - $l_arr_Enable = 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-scrolling"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "label-scroll-offset" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET, __("Scroll offset:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "scroll-offset" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET, 0, 100), - "notice-scroll-offset" => __("per cent from the upper edge of the window", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-scroll-duration" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION, __("Scroll duration:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "scroll-duration" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION, 0, 20000), - "notice-scroll-duration" => __("milliseconds; instantly if hard links are enabled and JavaScript is disabled", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - // enable hard links for AMP compat: - "label-hard-links" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE, __("Enable hard links:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "hard-links" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE, $l_arr_Enable), - "notice-hard-links" => __("Hard links are indispensable for AMP compatibility and allow to link to footnotes.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-footnote" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG, __("Fragment identifier slug for footnotes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "footnote" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG), - "notice-footnote" => __("This will show up in the address bar after clicking on a hard-linked footnote referrer.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-referrer" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERRER_FRAGMENT_ID_SLUG, __("Fragment identifier slug for footnote referrers:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "referrer" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERRER_FRAGMENT_ID_SLUG), - "notice-referrer" => __("This will show up in the address bar after clicking on a hard-linked backlink.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-separator" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HARD_LINK_IDS_SEPARATOR, __("ID separator:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "separator" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_HARD_LINK_IDS_SEPARATOR), - "notice-separator" => __("May be empty or any string, for example _, - or +, to distinguish post number, container number and footnote number.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - // enable backlink tooltips: - "label-backlink-tooltips" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, __("Enable backlink tooltips:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "backlink-tooltips" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, $l_arr_Enable), - "notice-backlink-tooltips" => __("Hard backlinks get ordinary tooltips hinting to use the backbutton instead.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-backlink-tooltip-text" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT, __("Backlink tooltip text:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "backlink-tooltip-text" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT), - "notice-backlink-tooltip-text" => __("Default text is the keyboard shortcut, but you may wish to input a descriptive hint in your language.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays all settings for 'I love Footnotes'. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Edited: - * @since 2.2.0 position-sensitive placeholders to support more locales 2020-12-11T0432+0100 - * @since 2.2.0 more options 2020-12-11T0432+0100 - */ - public function Love() { - // options for the acknowledgment display in the footer: - $l_arr_Love = array( - // logo only: - "text-3" => sprintf('%s', MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), - // logo followed by heart symbol: - "text-4" => sprintf('%s %s', MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL), - // logo preceded by heart symbol: - "text-5" => sprintf('%s %s', MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), - // "I love Footnotes": placeholder %1$s is the 'footnotes' logogram, placeholder %2$s is a heart symbol. - "text-1" => sprintf(__('I %2$s %1$s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL), - // "This website uses Footnotes." - "text-6" => sprintf(__('This website uses %s.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), - // "This website uses the Footnotes plugin." - "text-7" => sprintf(__('This website uses the %s plugin.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), - // "This website uses the awesome Footnotes plugin." - "text-2" => sprintf(__('This website uses the awesome %s plugin.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), - "random" => __('randomly determined display of either mention', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - // "No display of any “Footnotes love” mention in the footer" - "no" => sprintf(__('no display of any “%1$s %2$s” mention in the footer', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL) - ); - - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-love"); - // replace all placeholders - $l_obj_Template->replace( - array( - "label-love" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, sprintf(__("Tell the world you’re using %s:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME)), - "love" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, $l_arr_Love), - - "label-no-love" => $this->addText(sprintf(__("Shortcode to inhibit the display of the %s mention on specific pages:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME)), - "no-love" => $this->addText(MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG) - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays the excerpt setting - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Edited heading 2020-12-12T1453+0100 - * @since 2.1.1 more settings and notices, thanks to @nikelaos - * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13687068 - * @link https://wordpress.org/support/topic/jquery-comes-up-in-feed-content/#post-13110879 - * @since 2.2.0 dedicated to the excerpt setting and its notices 2020-12-12T1454+0100 - */ - public function Excerpts() { - // 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-excerpts"); - // replace all placeholders - $l_obj_Template->replace( - array( - "label-excerpts" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, __("Display footnotes in excerpts:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "excerpts" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, $l_arr_Enabled), - "notice-excerpts" => __("The recommended value is No.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - // In some themes, the Advanced Excerpt plugin is indispensable to display footnotes in excerpts. - "description-excerpts" => sprintf(__("In some themes, the %s plugin is indispensable to display footnotes in excerpts. Footnotes cannot be disabled in excerpts. A workaround is to avoid footnotes in the first 55 words.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 'Advanced Excerpt'), - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays all settings for the footnote referrers - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Edited heading 2020-12-12T1513+0100 - * @since 2.1.1 option for superscript (optionally baseline referrers) - * @since 2.2.0 option for link element moved here 2020-12-12T1514+0100 - */ - 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) - ); - // options for superscript normalize scope: - $l_arr_NormalizeSuperscript = array( - "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "referrers" => __("Footnote referrers", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "all" => __("All superscript elements", 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, __("Display footnote referrers in superscript:", 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, __("At the start of the footnote referrers:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "before" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE), - - "label-after" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER, __("At the end of the footnote referrers:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "after" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER), - - "label-link" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED, __("Use the link element for referrers and backlinks:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "notice-link" => __("Please find this setting at the end of the reference container settings. The link element is needed to apply the theme’s link color.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-normalize" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, __("Normalize vertical alignment and font size:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "normalize" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, $l_arr_NormalizeSuperscript), - "notice-normalize" => __("Most themes don’t need this fix.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays all settings for the footnotes mouse-over box. - * - * @author Stefan Herndler - * @since 1.5.2 - * - * Edited: - * @since 2.2.0 5 parts to address increased settings number - * @since 2.2.5 position settings for alternative tooltips - */ - public function MouseOverBox() { - // 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, "mouse-over-box-display"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "label-enable" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __("Display tooltips:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $l_arr_Enabled), - "notice-enable" => __("Formatted text boxes allowing hyperlinks, displayed on mouse-over or tap and hold.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-alternative" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, __("Display alternative tooltips:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "alternative" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, $l_arr_Enabled), - "notice-alternative" => __("Intended to work around a configuration-related tooltip outage.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - // The placeholder is the name of the plugin as logogram “footnotes”. - "description-alternative" => sprintf(__("These alternative tooltips work around a website related jQuery UI outage. They are low-script but use the AMP incompatible onmouseover and onmouseout arguments, along with CSS transitions for fade-in/out. The very small script is inserted after Footnotes’ internal stylesheet. When this option is enabled, %s does not load jQuery UI nor jQuery Tools.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . ''), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function MouseOverBoxPosition() { - - // options for the Mouse-over box position - $l_arr_Position = array( - "top left" => __("top left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "top center" => __("top center", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "top right" => __("top right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "center right" => __("center right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "bottom right" => __("bottom right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "bottom center" => __("bottom center", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "bottom left" => __("bottom left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "center left" => __("center left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ); - // options for the alternative Mouse-over box position - $l_arr_AlternativePosition = array( - "top left" => __("top left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "top right" => __("top right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "bottom right" => __("bottom right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "bottom left" => __("bottom left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ); - - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "mouse-over-box-position"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "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), - "position-alternative" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION, $l_arr_AlternativePosition), - "notice-position" => __("The second column of settings boxes is for the alternative tooltips.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-offset-x" => $this->addLabel (MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, __("Horizontal offset:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "offset-x" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, -500, 500), - "offset-x-alternative" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X, -500, 500), - "notice-offset-x" => __("pixels; negative value for a leftwards offset; alternative tooltips: direction depends on position", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-offset-y" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, __("Vertical offset:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "offset-y" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, -500, 500), - "offset-y-alternative" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y, -500, 500), - "notice-offset-y" => __("pixels; negative value for an upwards offset; alternative tooltips: direction depends on position", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function MouseOverBoxDimensions() { - - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "mouse-over-box-dimensions"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "label-max-width" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, __("Maximum width:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "max-width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, 0, 1280), - "width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH, 0, 1280), - "notice-max-width" => __("pixels; set to 0 for jQuery tooltips without max width; alternative tooltips are given the value in the second box as fixed width.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function MouseOverBoxTiming() { - - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "mouse-over-box-timing"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "label-fade-in-delay" => $this->addLabel(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY, __("Fade-in delay:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "fade-in-delay" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY, 0, 20000), - "notice-fade-in-delay" => __("milliseconds", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-fade-in-duration" => $this->addLabel(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION, __("Fade-in duration:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "fade-in-duration" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION, 0, 20000), - "notice-fade-in-duration" => __("milliseconds", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-fade-out-delay" => $this->addLabel(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY, __("Fade-out delay:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "fade-out-delay" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY, 0, 20000), - "notice-fade-out-delay" => __("milliseconds", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-fade-out-duration" => $this->addLabel(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION, __("Fade-out duration:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "fade-out-duration" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION, 0, 20000), - "notice-fade-out-duration" => __("milliseconds", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function MouseOverBoxTruncation() { - // 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, "mouse-over-box-truncation"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "label-truncation" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, __("Truncate the note in the tooltip:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "truncation" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, $l_arr_Enabled), - - "label-max-length" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, __("Maximum number of characters in the tooltip:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "max-length" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, 3, 10000), - // The feature trims back until the last full word. - "notice-max-length" => __("No weird cuts.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "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), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function MouseOverBoxText() { - // 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, "mouse-over-box-text"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "description-delimiter" => __("Tooltips can display another content than the footnote entry in the reference container. The trigger is a shortcode in the footnote text separating the tooltip text from the note. That is consistent with what WordPress does for excerpts.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-delimiter" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER, __("Delimiter for dedicated tooltip text:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "delimiter" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER), - "notice-delimiter" => __("If the delimiter shortcode is present, the tooltip text will be the part before it.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-mirror" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, __("Mirror the tooltip in the reference container:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "mirror" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, $l_arr_Enabled), - "notice-mirror" => __("Tooltips may be harder to use on mobiles. This option allows to read it in the reference container.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-separator" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR, __("Separator between tooltip text and footnote text:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "separator" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR), - "notice-separator" => __("May be a simple space, or a line break <br />, or any string in your language.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "description-mirror" => __("Tooltips, even jQuery-driven, may be hard to consult on mobiles. This option allows to read the tooltip content in the reference container too.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function MouseOverBoxAppearance() { - // 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) - ); - // options for the font size unit: - $l_arr_FontSizeUnits = array( - "em" => __("em", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "rem" => __("rem", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "px" => __("pixels", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "pt" => __("points", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "pc" => __("picas", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "mm" => __("millimeters", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "%" => __("per cent", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ); - - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "mouse-over-box-appearance"); - // replace all placeholders - $l_obj_Template->replace( - array( - - "label-font-size" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED, __("Set font size:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "font-size-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED, $l_arr_Enabled), - "font-size-scalar" => $this->addNumBox(MCI_Footnotes_Settings::C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR, 0, 50, true), - "font-size-unit" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT, $l_arr_FontSizeUnits), - "notice-font-size" => __("By default, the font size is set to equal the surrounding text.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-color" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR, __("Text color:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "color" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR), - // To use default: Clear or leave empty. - "notice-color" => sprintf(__("To use the current theme’s default text color: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Clear or leave empty.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - "label-background" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND, __("Background color:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "background" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND), - // To use default: Clear or leave empty. - "notice-background" => sprintf(__("To use the current theme’s default background color: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Clear or leave empty.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - "label-border-width" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, __("Border width:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "border-width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, 0, 4, true), - "notice-border-width" => __("pixels; 0 for borderless", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-border-color" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR, __("Border color:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "border-color" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR), - // To use default: Clear or leave empty. - "notice-border-color" => sprintf(__("To use the current theme’s default border color: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Clear or leave empty.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - "label-border-radius" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, __("Rounded corner radius:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "border-radius" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, 0, 500), - "notice-border-radius" => __("pixels; 0 for sharp corners", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-box-shadow-color" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR, __("Box shadow color:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "box-shadow-color" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR), - // To use default: Clear or leave empty. - "notice-box-shadow-color" => sprintf(__("To use the current theme’s default box shadow color: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Clear or leave empty.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays all settings for the prepended symbol - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Edited heading for v2.0.4 - * - * 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. - * - * @since 2.1.4 moved to Settings > Reference container > Display a backlink symbol - * @since 2.2.1 and 2.2.4 back here - */ - public function HyperlinkArrow() { - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-hyperlink-arrow"); - // replace all placeholders - $l_obj_Template->replace( - array( - "label-symbol" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, __("Select or input the backlink symbol:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "symbol-options" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, MCI_Footnotes_Convert::getArrow()), - "symbol-custom" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED), - "notice-symbol" => __("Your input overrides the selection.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "description-symbol" => __("This symbol is used in the reference container. But this setting pre-existed under this tab and cannot be moved to another one.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays the custom css box. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Edited: - * @since 2.1.6 drop localized notices for CSS classes as the number increased to 16 - * list directly in the template, as CSS is in English anyway - * @see templates/dashboard/customize-css.html - * 2020-12-09T1113+0100 - * - * @since 2.2.2 migrate Custom CSS to a dedicated tab 2020-12-15T0506+0100 - * @since 2.3.0 say 'copy-paste' instead of 'cut and paste' since cutting is not needed 2020-12-27T1257+0100 - * @since 2.5.1 mention validity while visible, thanks to @rkupadhya bug report - */ - public function CustomCSS() { - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-css"); - // replace all placeholders - $l_obj_Template->replace( - array( - "label-css" => $this->addLabel(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS, __("Your existing Custom CSS code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "css" => $this->addTextArea(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS), - "description-css" => __('Custom CSS migrates to a dedicated tab. This text area is intended to keep your data safe, and the code remains valid while visible. Please copy-paste the content into the new text area under the new tab.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - // CSS classes are listed in the template. - // Localized notices are dropped to ease translators’ task. - - // "label-class-1" => ".footnote_plugin_tooltip_text", - // "class-1" => $this->addText(__("superscript, Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - // "label-class-2" => ".footnote_tooltip", - // "class-2" => $this->addText(__("mouse-over box, tooltip for each superscript", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - // "label-class-3" => ".footnote_plugin_index", - // "class-3" => $this->addText(__("1st column of the Reference Container, Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - // "label-class-4" => ".footnote_plugin_text", - // "class-4" => $this->addText(__("2nd column of the Reference Container, Footnote text", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)) - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function CustomCSSMigration() { - - // 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-css-migration"); - // replace all placeholders - $l_obj_Template->replace( - array( - "label-css" => $this->addLabel(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS, __("Your existing Custom CSS code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "css" => $this->addTextArea(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS), - "description-css" => __('Custom CSS migrates to a dedicated tab. This text area is intended to keep your data safe, and the code remains valid while visible. Please copy-paste the content into the new text area below. Set Show legacy to No. Save twice.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - - "label-show-legacy" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE, "Show legacy Custom CSS settings containers:"), - "show-legacy" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE, $l_arr_Enabled), - "notice-show-legacy" => __("Please set to No when you are done migrating, for the legacy Custom CSS containers to disappear.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - // The placeholder is the “Referrers and tooltips” settings tab name. - "description-show-legacy" => sprintf(__('The legacy Custom CSS under the %s tab and its mirror here are emptied, and the select box saved as No, when the settings tab is saved while the settings container is not displayed.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Referrers and tooltips", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - public function CustomCSSNew() { - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-css-new"); - // replace all placeholders - $l_obj_Template->replace( - array( - "css" => $this->addTextArea(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS_NEW), - - "headline" => $this->addText(__("Recommended CSS classes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays available Hooks to look for Footnote short codes. - * - * @author Stefan Herndler - * @since 1.5.5 - * - * Edited: - * @since 2.1.1 priority level setting for the_content 2020-11-16T2152+0100 - * @since 2.1.4 priority level settings for the other hooks 2020-11-19T1421+0100 - * - * 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: - * define -1 as PHP_INT_MAX instead - * - * @since 2.2.9 removed the warning about the widget text hook 2020-12-25T0348+0100 - * @since 2.2.9 added guidance for the widget text hook 2020-12-25T0353+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 - $l_obj_Template->replace( - array( - - "description-1" => __('The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "description-2" => sprintf(__('For the_content, this figure must be lower than %1$d so that certain strings added by a plugin running at %1$d may not be mistaken as a footnote. This makes also sure that the reference container displays above a feature inserted by a plugin running at %2$d.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 99, 1200), - "description-3" => sprintf(__('%1$d is lowest priority, %2$d is highest. To set priority level to lowest, set it to %3$d, interpreted as %1$d, the constant %4$s.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), PHP_INT_MAX, 0, -1, 'PHP_INT_MAX'), - "description-4" => __('The widget_text hook must be enabled either when footnotes are present in theme text widgets, or when Elementor accordions or toggles shall have a reference container per section. If they should not, this hook must be disabled.', 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), - "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), - "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), - "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), - "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), - "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 - echo $l_obj_Template->getContent(); - } - - /** - * Displays a short introduction of the Plugin. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function Help() { - global $g_obj_MCI_Footnotes; - // load footnotes starting and end tag - $l_arr_Footnote_StartingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START); - $l_arr_Footnote_EndingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END); - - if ($l_arr_Footnote_StartingTag["value"] == "userdefined" || $l_arr_Footnote_EndingTag["value"] == "userdefined") { - // load user defined starting and end tag - $l_arr_Footnote_StartingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED); - $l_arr_Footnote_EndingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED); - } - $l_str_Example = "Hello" . $l_arr_Footnote_StartingTag["value"] . - "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,". - " sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.". - " Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,". - " consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.". - " At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." - . $l_arr_Footnote_EndingTag["value"] . " World!"; - - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "how-to-help"); - // replace all placeholders - $l_obj_Template->replace( - array( - "label-start" => __("Start your footnote with the following short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "start" => $l_arr_Footnote_StartingTag["value"], - - "label-end" => __("…and end your footnote with this short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "end" => $l_arr_Footnote_EndingTag["value"], - - "example-code" => $l_str_Example, - "example-string" => "
" . __("will be displayed as:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "example" => $g_obj_MCI_Footnotes->a_obj_Task->exec($l_str_Example, true), - - "information" => sprintf(__("For further information please check out our %ssupport forum%s on WordPress.org.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '', '') - ) - ); - // call wp_head function to get the Styling of the mouse-over box - $g_obj_MCI_Footnotes->a_obj_Task->wp_head(); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } - - /** - * Displays all Donate button to support the developers. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function Donate() { - // load template file - $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "how-to-donate"); - // replace all placeholders - $l_obj_Template->replace( - array( - "caption" => __('Donate now',MCI_Footnotes_Config::C_STR_PLUGIN_NAME) - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } + /** + * Returns a Priority index. Lower numbers have a higher Priority. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return int + */ + public function getPriority() { + return 10; + } + + /** + * Returns the unique slug of the sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + protected function getSubPageSlug() { + return "-" . MCI_Footnotes_Config::C_STR_PLUGIN_NAME; + } + + /** + * Returns the title of the sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + protected function getSubPageTitle() { + return MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME; + } + + /** + * Returns an array of all registered sections for the sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return array + * + * Edited: + * @since 2.1.6 tabs reordered and renamed + * @link https://www.linkedin.com/pulse/20140610191154-4746170-configuration-vs-customization-when-and-why-would-i-implement-each + * + * @since 2.1.6 removed if statement around expert tab + */ + protected function getSections() { + $l_arr_Tabs = array(); + + // sync tab name with mirror in task.php: + $l_arr_Tabs[] = $this->addSection("settings", __("General settings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 0, true); + + // sync tab name with mirror in public function CustomCSSMigration(): + $l_arr_Tabs[] = $this->addSection("customize", __("Referrers and tooltips", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 1, true); + + $l_arr_Tabs[] = $this->addSection("expert", __("Scope and priority", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 2, true); + $l_arr_Tabs[] = $this->addSection("customcss", __("Custom CSS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 3, true); + $l_arr_Tabs[] = $this->addSection("how-to", __("Quick start guide", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false); + + return $l_arr_Tabs; + } + + /** + * Returns an array of all registered meta boxes for each section of the sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return array + * + * Edited for 2.0.0 and later. + * + * HyperlinkArrow meta box: + * @since 2.0.0 discontinued + * @since 2.0.4 restored to meet user demand for arrow symbol semantics + * @since 2.1.4 discontinued, content moved to Settings > Reference container > Display a backlink symbol + * + * @since 2.0.4 to reflect changes in meta box label display since WPv5.5 + * spans need position:fixed and become unlocalizable + * fix: logo is kept only in the label that doesn’t need to be translated: + * Change string "%s styling" to "Footnotes styling" to fix layout in WPv5.5 + * @see details in class/config.php + * + * @since 2.1.6 / 2.2.0 tabs reordered and renamed + */ + protected function getMetaBoxes() { + $l_arr_MetaBoxes = array(); + + // sync box name with mirror in task.php: + $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "start-end", __("Footnote start and end short codes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "StartEnd"); + $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "numbering", __("Footnotes numbering", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Numbering"); + $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "scrolling", __("Scrolling behavior", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Scrolling"); + $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "reference-container", __("Reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "ReferenceContainer"); + $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "excerpts", __("Footnotes in excerpts", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Excerpts"); + $l_arr_MetaBoxes[] = $this->addMetaBox("settings", "love", MCI_Footnotes_Config::C_STR_PLUGIN_HEADING_NAME . ' ' . MCI_Footnotes_Config::C_STR_LOVE_SYMBOL_HEADING, "Love"); + + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "hyperlink-arrow", __("Backlink symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "HyperlinkArrow"); + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "superscript", __("Referrer typesetting and formatting", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Superscript"); + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box", __("Tooltips", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBox"); + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-position", __("Tooltip position", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxPosition"); + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-dimensions", __("Tooltip dimensions", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxDimensions"); + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-timing", __("Tooltip timing", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxTiming"); + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-truncation", __("Tooltip truncation", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxTruncation"); + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-text", __("Tooltip text", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxText"); + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "mouse-over-box-appearance", __("Tooltip appearance", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBoxAppearance"); + if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE))) { + $l_arr_MetaBoxes[] = $this->addMetaBox("customize", "custom-css", __("Your existing Custom CSS code", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSS"); + } + + $l_arr_MetaBoxes[] = $this->addMetaBox("expert", "lookup", __("WordPress hooks with priority level", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "LookupHooks"); + + if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE))) { + $l_arr_MetaBoxes[] = $this->addMetaBox("customcss", "custom-css-migration", __("Your existing Custom CSS code", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSSMigration"); + } + $l_arr_MetaBoxes[] = $this->addMetaBox("customcss", "custom-css-new", __("Custom CSS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSSNew"); + + $l_arr_MetaBoxes[] = $this->addMetaBox("how-to", "help", __("Brief introduction in how to use the plugin", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Help"); + $l_arr_MetaBoxes[] = $this->addMetaBox("how-to", "donate", __("Help us to improve our Plugin", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Donate"); + + return $l_arr_MetaBoxes; + } + + /** + * Displays all settings for the reference container. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Completed: + * @since 2.1.4: layout and typography options 2020-11-30T0548+0100 + * @since 2.2.5 options for label element and label bottom border, thanks to @markhillyer 2020-12-18T1447+0100 + * @link https://wordpress.org/support/topic/how-do-i-eliminate-the-horizontal-line-beneath-the-reference-container-heading/ + */ + public function ReferenceContainer() { + + // options for the label element: + $l_arr_LabelElement = array( + "p" => __("paragraph", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "h2" => __("heading 2", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "h3" => __("heading 3", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "h4" => __("heading 4", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "h5" => __("heading 5", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "h6" => __("heading 6", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ); + // options for the positioning of the reference container + $l_arr_Positions = array( + "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), + "footer" => __("in the footer", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ); + // basic responsive page layout options: + $l_arr_PageLayoutOptions = array( + "none" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "reference-container" => __("to the reference container exclusively", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "entry-content" => __("to the div element starting below the post title", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "main-content" => __("to the main element including the post title", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ); + // options for the separating punctuation between backlinks: + $l_arr_Separators = array( + // Unicode character names are conventionally uppercase. + "comma" => __("COMMA", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "semicolon" => __("SEMICOLON", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "en_dash" => __("EN DASH", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + // options for the terminating punctuation after backlinks: + // The Unicode name of RIGHT PARENTHESIS was originally more accurate because + // this character is bidi-mirrored. Let’s use the Unicode 1.0 name. + // The wrong names were enforced in spite of Unicode, that subsequently scrambled to correct. + $l_arr_Terminators = array( + "period" => __("FULL STOP", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + // Unicode 1.0 name of RIGHT PARENTHESIS (represented as a left parenthesis in right-to-left scripts): + "parenthesis" => __("CLOSING PARENTHESIS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "colon" => __("COLON", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + // options for the first column width (per cent is a ratio, not a unit): + $l_arr_WidthUnits = array( + "%" => __("per cent", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "px" => __("pixels", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "rem" => __("root em", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "em" => __("em", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "vw" => __("viewport width", 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"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-name" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME, __("Heading:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "name" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME), + + "label-element" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, __("Heading’s HTML element:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "element" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, $l_arr_LabelElement), + + "label-border" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER, __("Border under the heading:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "border" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER, $l_arr_Enabled), + + "label-collapse" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, __("Collapse by default:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "collapse" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, $l_arr_Enabled), + + "label-position" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __("Default position:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_Positions), + "notice-position" => sprintf(__("To use the position shortcode, please set the position to: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '' . __("at the end of the post", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . ''), + + "label-shortcode" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE, __("Position shortcode:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "shortcode" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE), + "notice-shortcode" => __("If present in the content, any shortcode in this text box will be replaced with the reference container.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "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-margin-top" => $this->addLabel(MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_TOP_MARGIN, __("Top margin:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "margin-top" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_TOP_MARGIN, -500, 500), + "notice-margin-top" => __("pixels; may be negative", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-margin-bottom" => $this->addLabel(MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN, __("Bottom margin:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "margin-bottom" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN, -500, 500), + "notice-margin-bottom" => __("pixels; may be negative", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-page-layout" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT, __("Apply basic responsive page layout:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "page-layout" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT, $l_arr_PageLayoutOptions), + "notice-page-layout" => __("Most themes don’t need this fix.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-url-wrap" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_URL_WRAP_ENABLED, __("Allow URLs to line-wrap anywhere:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "url-wrap" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_URL_WRAP_ENABLED, $l_arr_Enabled), + "notice-url-wrap" => __("Unicode-conformant browsers don’t need this fix.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "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-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, $l_arr_Enabled), + "notice-symbol" => __("Please choose or input the symbol at the top of the next dashboard tab.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "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-3column" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, __("Backlink symbol in an extra column:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "3column" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, $l_arr_Enabled), + "notice-3column" => __("This legacy layout is available if identical footnotes are not combined.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-row-borders" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE, __("Borders around the table rows:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "row-borders" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE, $l_arr_Enabled), + + "label-separator" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_SEPARATOR_ENABLED, __("Add a separator when enumerating backlinks:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "separator-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_SEPARATOR_ENABLED, $l_arr_Enabled), + "separator-options" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_OPTION, $l_arr_Separators), + "separator-custom" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_CUSTOM), + "notice-separator" => __("Your input overrides the selection.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-terminator" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_TERMINATOR_ENABLED, __("Add a terminal punctuation to backlinks:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "terminator-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_TERMINATOR_ENABLED, $l_arr_Enabled), + "terminator-options" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_OPTION, $l_arr_Terminators), + "terminator-custom" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_CUSTOM), + "notice-terminator" => __("Your input overrides the selection.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-width" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED, __("Set backlinks column width:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "width-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED, $l_arr_Enabled), + "width-scalar" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR, 0, 500, true), + "width-unit" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_UNIT, $l_arr_WidthUnits), + "notice-width" => __("Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-max-width" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, __("Set backlinks column maximum width:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "max-width-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, $l_arr_Enabled), + "max-width-scalar" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR, 0, 500, true), + "max-width-unit" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT, $l_arr_WidthUnits), + "notice-max-width" => __("Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-line-break" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED, __("Stack backlinks when enumerating:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "line-break" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED, $l_arr_Enabled), + "notice-line-break" => __("This option adds a line break before each added backlink when identical footnotes are combined.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-link" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED, __("Use the link element for referrers and backlinks:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "link" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED, $l_arr_Enabled), + "notice-link" => __("The link element is needed to apply the theme’s link color.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "description-link" => __("If the link element is not desired for styling, a simple span is used instead when the above is set to No. The link addresses have been removed. Else footnote clicks are logged in the browsing history and make the back button unusable.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all options for the footnotes start and end tag short codes + * Displays all options for the footnotes numbering + * Displays all options for the scrolling behavior + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Edited heading 2020-12-12T1412+0100 + * @since 2.2.0 start/end short codes: more predefined options 2020-12-12T1412+0100 + * @link https://wordpress.org/support/topic/doesnt-work-with-mailpoet/ + * @since 2.2.0 3 boxes for clarity 2020-12-12T1422+0100 + * @since 2.2.5 support for Ibid. notation thanks to @meglio 2020-12-17T2019+0100 + * @link https://wordpress.org/support/topic/add-support-for-ibid-notation/ + * @since 2.4.0 added warning about Block Editor escapement disruption 2021-01-02T2324+0100 + * @since 2.4.0 removed the HTML comment tag option 2021-01-02T2325+0100 + * @since 2.5.0 Shortcode syntax validation: add more information around the setting, thanks to @andreasra + * @link https://wordpress.org/support/topic/warning-unbalanced-footnote-start-tag-short-code-before/ + */ + public function StartEnd() { + // footnotes start tag short code options: + $l_arr_ShortCodeStart = array( + "((" => "((", + "(((" => "(((", + "{{" => "{{", + "{{{" => "{{{", + "[n]" => "[n]", + "[fn]" => "[fn]", + htmlspecialchars("") => htmlspecialchars(""), + "[ref]" => "[ref]", + htmlspecialchars("") => htmlspecialchars(""), + // Custom (user-defined) start and end tags bracketing the footnote text inline: + "userdefined" => __('custom short code', MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + // footnotes end tag short code options: + $l_arr_ShortCodeEnd = array( + "))" => "))", + ")))" => ")))", + "}}" => "}}", + "}}}" => "}}}", + "[/n]" => "[/n]", + "[/fn]" => "[/fn]", + htmlspecialchars("") => htmlspecialchars(""), + "[/ref]" => "[/ref]", + htmlspecialchars("") => htmlspecialchars(""), + // Custom (user-defined) start and end tags bracketing the footnote text inline: + "userdefined" => __("custom short code", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + // options for the syntax validation: + $l_arr_Enable = 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-start-end"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "description-escapement" => __("WARNING: Short codes with closing pointy brackets are disabled in the new WordPress Block Editor that disrupts the traditional balanced escapement applied by WordPress Classic Editor.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-short-code-start" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, __("Footnote start tag short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "short-code-start" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, $l_arr_ShortCodeStart), + "short-code-start-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED), + + "label-short-code-end" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, __("Footnote end tag short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "short-code-end" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, $l_arr_ShortCodeEnd), + "short-code-end-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED), + + // for script showing/hiding user defined text boxes: + "short-code-start-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, + "short-code-end-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, + "short-code-start-user-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED, + "short-code-end-user-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED, + + "description-parentheses" => __("WARNING: Although widespread industry standard, the double parentheses are problematic because they may occur in scripts embedded in the content and be mistaken as a short code.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + // option to enable syntax validation, label mirrored in task.php: + "label-syntax" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, __("Check for balanced shortcodes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "syntax" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, $l_arr_Enable), + "notice-syntax" => __("In the presence of a lone start tag shortcode, a warning displays below the post title.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "description-syntax" => __("If the start tag short code is ‘((’ or ‘(((’, it will not be reported as unbalanced if the following string contains braces hinting that it is a script.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function Numbering() { + // define some space for the output + $l_str_Space = "     "; + // options for the combination of identical footnotes + $l_arr_Enable = array( + "yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + // options for the numbering style of the footnotes: + $l_arr_CounterStyle = array( + "arabic_plain" => __("plain Arabic numbers", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, …", + "arabic_leading" => __("zero-padded Arabic numbers", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, …", + "latin_low" => __("lowercase Latin letters", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, …", + "latin_high" => __("uppercase Latin letters", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, …", + "romanic" => __("uppercase Roman numerals", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, …", + "roman_low" => __("lowercase Roman numerals", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "i, ii, iii, iv, v, …", + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-numbering"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-counter-style" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, __("Numbering style:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "counter-style" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, $l_arr_CounterStyle), + + // algorithmically combine identicals: + "label-identical" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES, __("Combine identical footnotes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "identical" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES, $l_arr_Enable), + "notice-identical" => __("This option may require copy-pasting footnotes in multiple instances.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + // Support for Ibid. notation added thanks to @meglio in . + "description-identical" => __("Even when footnotes are combined, footnote numbers keep incrementing. This avoids suboptimal referrer and backlink disambiguation using a secondary numbering system. The Ibid. notation and the op. cit. abbreviation followed by the current page number avoid repeating the footnote content. For changing sources, shortened citations may be used. Repeating full citations is also an opportunity to add details.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function Scrolling() { + + // options for enabling hard links for AMP compat: + $l_arr_Enable = 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-scrolling"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "label-scroll-offset" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET, __("Scroll offset:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "scroll-offset" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET, 0, 100), + "notice-scroll-offset" => __("per cent from the upper edge of the window", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-scroll-duration" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION, __("Scroll duration:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "scroll-duration" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION, 0, 20000), + "notice-scroll-duration" => __("milliseconds; instantly if hard links are enabled and JavaScript is disabled", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + // enable hard links for AMP compat: + "label-hard-links" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE, __("Enable hard links:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "hard-links" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE, $l_arr_Enable), + "notice-hard-links" => __("Hard links are indispensable for AMP compatibility and allow to link to footnotes.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-footnote" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG, __("Fragment identifier slug for footnotes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "footnote" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG), + "notice-footnote" => __("This will show up in the address bar after clicking on a hard-linked footnote referrer.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-referrer" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERRER_FRAGMENT_ID_SLUG, __("Fragment identifier slug for footnote referrers:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "referrer" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERRER_FRAGMENT_ID_SLUG), + "notice-referrer" => __("This will show up in the address bar after clicking on a hard-linked backlink.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-separator" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HARD_LINK_IDS_SEPARATOR, __("ID separator:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "separator" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_HARD_LINK_IDS_SEPARATOR), + "notice-separator" => __("May be empty or any string, for example _, - or +, to distinguish post number, container number and footnote number.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + // enable backlink tooltips: + "label-backlink-tooltips" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, __("Enable backlink tooltips:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "backlink-tooltips" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, $l_arr_Enable), + "notice-backlink-tooltips" => __("Hard backlinks get ordinary tooltips hinting to use the backbutton instead.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-backlink-tooltip-text" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT, __("Backlink tooltip text:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "backlink-tooltip-text" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT), + "notice-backlink-tooltip-text" => __("Default text is the keyboard shortcut, but you may wish to input a descriptive hint in your language.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings for 'I love Footnotes'. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Edited: + * @since 2.2.0 position-sensitive placeholders to support more locales 2020-12-11T0432+0100 + * @since 2.2.0 more options 2020-12-11T0432+0100 + */ + public function Love() { + // options for the acknowledgment display in the footer: + $l_arr_Love = array( + // logo only: + "text-3" => sprintf('%s', MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), + // logo followed by heart symbol: + "text-4" => sprintf('%s %s', MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL), + // logo preceded by heart symbol: + "text-5" => sprintf('%s %s', MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), + // "I love Footnotes": placeholder %1$s is the 'footnotes' logogram, placeholder %2$s is a heart symbol. + "text-1" => sprintf(__('I %2$s %1$s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL), + // "This website uses Footnotes." + "text-6" => sprintf(__('This website uses %s.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), + // "This website uses the Footnotes plugin." + "text-7" => sprintf(__('This website uses the %s plugin.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), + // "This website uses the awesome Footnotes plugin." + "text-2" => sprintf(__('This website uses the awesome %s plugin.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), + "random" => __('randomly determined display of either mention', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + // "No display of any “Footnotes love” mention in the footer" + "no" => sprintf(__('no display of any “%1$s %2$s” mention in the footer', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL) + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-love"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-love" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, sprintf(__("Tell the world you’re using %s:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME)), + "love" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, $l_arr_Love), + + "label-no-love" => $this->addText(sprintf(__("Shortcode to inhibit the display of the %s mention on specific pages:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME)), + "no-love" => $this->addText(MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays the excerpt setting + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Edited heading 2020-12-12T1453+0100 + * @since 2.1.1 more settings and notices, thanks to @nikelaos + * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13687068 + * @link https://wordpress.org/support/topic/jquery-comes-up-in-feed-content/#post-13110879 + * @since 2.2.0 dedicated to the excerpt setting and its notices 2020-12-12T1454+0100 + */ + public function Excerpts() { + // 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-excerpts"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-excerpts" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, __("Display footnotes in excerpts:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "excerpts" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, $l_arr_Enabled), + "notice-excerpts" => __("The recommended value is No.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + // In some themes, the Advanced Excerpt plugin is indispensable to display footnotes in excerpts. + "description-excerpts" => sprintf(__("In some themes, the %s plugin is indispensable to display footnotes in excerpts. Footnotes cannot be disabled in excerpts. A workaround is to avoid footnotes in the first 55 words.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 'Advanced Excerpt'), + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings for the footnote referrers + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Edited heading 2020-12-12T1513+0100 + * @since 2.1.1 option for superscript (optionally baseline referrers) + * @since 2.2.0 option for link element moved here 2020-12-12T1514+0100 + */ + 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) + ); + // options for superscript normalize scope: + $l_arr_NormalizeSuperscript = array( + "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "referrers" => __("Footnote referrers", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "all" => __("All superscript elements", 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, __("Display footnote referrers in superscript:", 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, __("At the start of the footnote referrers:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "before" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE), + + "label-after" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER, __("At the end of the footnote referrers:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "after" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER), + + "label-link" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED, __("Use the link element for referrers and backlinks:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "notice-link" => __("Please find this setting at the end of the reference container settings. The link element is needed to apply the theme’s link color.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-normalize" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, __("Normalize vertical alignment and font size:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "normalize" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, $l_arr_NormalizeSuperscript), + "notice-normalize" => __("Most themes don’t need this fix.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings for the footnotes mouse-over box. + * + * @author Stefan Herndler + * @since 1.5.2 + * + * Edited: + * @since 2.2.0 5 parts to address increased settings number + * @since 2.2.5 position settings for alternative tooltips + */ + public function MouseOverBox() { + // 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, "mouse-over-box-display"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "label-enable" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __("Display tooltips:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $l_arr_Enabled), + "notice-enable" => __("Formatted text boxes allowing hyperlinks, displayed on mouse-over or tap and hold.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-alternative" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, __("Display alternative tooltips:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "alternative" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, $l_arr_Enabled), + "notice-alternative" => __("Intended to work around a configuration-related tooltip outage.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + // The placeholder is the name of the plugin as logogram “footnotes”. + "description-alternative" => sprintf(__("These alternative tooltips work around a website related jQuery UI outage. They are low-script but use the AMP incompatible onmouseover and onmouseout arguments, along with CSS transitions for fade-in/out. The very small script is inserted after Footnotes’ internal stylesheet. When this option is enabled, %s does not load jQuery UI nor jQuery Tools.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . ''), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function MouseOverBoxPosition() { + + // options for the Mouse-over box position + $l_arr_Position = array( + "top left" => __("top left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "top center" => __("top center", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "top right" => __("top right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "center right" => __("center right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "bottom right" => __("bottom right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "bottom center" => __("bottom center", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "bottom left" => __("bottom left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "center left" => __("center left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ); + // options for the alternative Mouse-over box position + $l_arr_AlternativePosition = array( + "top left" => __("top left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "top right" => __("top right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "bottom right" => __("bottom right", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "bottom left" => __("bottom left", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "mouse-over-box-position"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "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), + "position-alternative" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION, $l_arr_AlternativePosition), + "notice-position" => __("The second column of settings boxes is for the alternative tooltips.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-offset-x" => $this->addLabel (MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, __("Horizontal offset:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "offset-x" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, -500, 500), + "offset-x-alternative" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X, -500, 500), + "notice-offset-x" => __("pixels; negative value for a leftwards offset; alternative tooltips: direction depends on position", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-offset-y" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, __("Vertical offset:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "offset-y" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, -500, 500), + "offset-y-alternative" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y, -500, 500), + "notice-offset-y" => __("pixels; negative value for an upwards offset; alternative tooltips: direction depends on position", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function MouseOverBoxDimensions() { + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "mouse-over-box-dimensions"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "label-max-width" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, __("Maximum width:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "max-width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, 0, 1280), + "width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH, 0, 1280), + "notice-max-width" => __("pixels; set to 0 for jQuery tooltips without max width; alternative tooltips are given the value in the second box as fixed width.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function MouseOverBoxTiming() { + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "mouse-over-box-timing"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "label-fade-in-delay" => $this->addLabel(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY, __("Fade-in delay:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "fade-in-delay" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY, 0, 20000), + "notice-fade-in-delay" => __("milliseconds", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-fade-in-duration" => $this->addLabel(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION, __("Fade-in duration:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "fade-in-duration" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION, 0, 20000), + "notice-fade-in-duration" => __("milliseconds", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-fade-out-delay" => $this->addLabel(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY, __("Fade-out delay:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "fade-out-delay" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY, 0, 20000), + "notice-fade-out-delay" => __("milliseconds", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-fade-out-duration" => $this->addLabel(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION, __("Fade-out duration:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "fade-out-duration" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION, 0, 20000), + "notice-fade-out-duration" => __("milliseconds", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function MouseOverBoxTruncation() { + // 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, "mouse-over-box-truncation"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "label-truncation" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, __("Truncate the note in the tooltip:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "truncation" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, $l_arr_Enabled), + + "label-max-length" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, __("Maximum number of characters in the tooltip:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "max-length" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, 3, 10000), + // The feature trims back until the last full word. + "notice-max-length" => __("No weird cuts.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "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), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function MouseOverBoxText() { + // 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, "mouse-over-box-text"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "description-delimiter" => __("Tooltips can display another content than the footnote entry in the reference container. The trigger is a shortcode in the footnote text separating the tooltip text from the note. That is consistent with what WordPress does for excerpts.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-delimiter" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER, __("Delimiter for dedicated tooltip text:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "delimiter" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER), + "notice-delimiter" => __("If the delimiter shortcode is present, the tooltip text will be the part before it.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-mirror" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, __("Mirror the tooltip in the reference container:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "mirror" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, $l_arr_Enabled), + "notice-mirror" => __("Tooltips may be harder to use on mobiles. This option allows to read it in the reference container.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-separator" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR, __("Separator between tooltip text and footnote text:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "separator" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR), + "notice-separator" => __("May be a simple space, or a line break <br />, or any string in your language.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "description-mirror" => __("Tooltips, even jQuery-driven, may be hard to consult on mobiles. This option allows to read the tooltip content in the reference container too.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function MouseOverBoxAppearance() { + // 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) + ); + // options for the font size unit: + $l_arr_FontSizeUnits = array( + "em" => __("em", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "rem" => __("rem", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "px" => __("pixels", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "pt" => __("points", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "pc" => __("picas", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "mm" => __("millimeters", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "%" => __("per cent", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "mouse-over-box-appearance"); + // replace all placeholders + $l_obj_Template->replace( + array( + + "label-font-size" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED, __("Set font size:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "font-size-enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED, $l_arr_Enabled), + "font-size-scalar" => $this->addNumBox(MCI_Footnotes_Settings::C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR, 0, 50, true), + "font-size-unit" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT, $l_arr_FontSizeUnits), + "notice-font-size" => __("By default, the font size is set to equal the surrounding text.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-color" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR, __("Text color:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "color" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR), + // To use default: Clear or leave empty. + "notice-color" => sprintf(__("To use the current theme’s default text color: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Clear or leave empty.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + "label-background" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND, __("Background color:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "background" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND), + // To use default: Clear or leave empty. + "notice-background" => sprintf(__("To use the current theme’s default background color: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Clear or leave empty.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + "label-border-width" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, __("Border width:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "border-width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, 0, 4, true), + "notice-border-width" => __("pixels; 0 for borderless", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-border-color" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR, __("Border color:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "border-color" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR), + // To use default: Clear or leave empty. + "notice-border-color" => sprintf(__("To use the current theme’s default border color: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Clear or leave empty.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + "label-border-radius" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, __("Rounded corner radius:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "border-radius" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, 0, 500), + "notice-border-radius" => __("pixels; 0 for sharp corners", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-box-shadow-color" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR, __("Box shadow color:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "box-shadow-color" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR), + // To use default: Clear or leave empty. + "notice-box-shadow-color" => sprintf(__("To use the current theme’s default box shadow color: %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Clear or leave empty.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings for the prepended symbol + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Edited heading for v2.0.4 + * + * 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. + * + * @since 2.1.4 moved to Settings > Reference container > Display a backlink symbol + * @since 2.2.1 and 2.2.4 back here + */ + public function HyperlinkArrow() { + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-hyperlink-arrow"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-symbol" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, __("Select or input the backlink symbol:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "symbol-options" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, MCI_Footnotes_Convert::getArrow()), + "symbol-custom" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED), + "notice-symbol" => __("Your input overrides the selection.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "description-symbol" => __("This symbol is used in the reference container. But this setting pre-existed under this tab and cannot be moved to another one.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays the custom css box. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Edited: + * @since 2.1.6 drop localized notices for CSS classes as the number increased to 16 + * list directly in the template, as CSS is in English anyway + * @see templates/dashboard/customize-css.html + * 2020-12-09T1113+0100 + * + * @since 2.2.2 migrate Custom CSS to a dedicated tab 2020-12-15T0506+0100 + * @since 2.3.0 say 'copy-paste' instead of 'cut and paste' since cutting is not needed 2020-12-27T1257+0100 + * @since 2.5.1 mention validity while visible, thanks to @rkupadhya bug report + */ + public function CustomCSS() { + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-css"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-css" => $this->addLabel(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS, __("Your existing Custom CSS code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "css" => $this->addTextArea(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS), + "description-css" => __('Custom CSS migrates to a dedicated tab. This text area is intended to keep your data safe, and the code remains valid while visible. Please copy-paste the content into the new text area under the new tab.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + // CSS classes are listed in the template. + // Localized notices are dropped to ease translators’ task. + + // "label-class-1" => ".footnote_plugin_tooltip_text", + // "class-1" => $this->addText(__("superscript, Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + // "label-class-2" => ".footnote_tooltip", + // "class-2" => $this->addText(__("mouse-over box, tooltip for each superscript", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + // "label-class-3" => ".footnote_plugin_index", + // "class-3" => $this->addText(__("1st column of the Reference Container, Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + // "label-class-4" => ".footnote_plugin_text", + // "class-4" => $this->addText(__("2nd column of the Reference Container, Footnote text", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function CustomCSSMigration() { + + // 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-css-migration"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-css" => $this->addLabel(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS, __("Your existing Custom CSS code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "css" => $this->addTextArea(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS), + "description-css" => __('Custom CSS migrates to a dedicated tab. This text area is intended to keep your data safe, and the code remains valid while visible. Please copy-paste the content into the new text area below. Set Show legacy to No. Save twice.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-show-legacy" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE, "Show legacy Custom CSS settings containers:"), + "show-legacy" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE, $l_arr_Enabled), + "notice-show-legacy" => __("Please set to No when you are done migrating, for the legacy Custom CSS containers to disappear.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + // The placeholder is the “Referrers and tooltips” settings tab name. + "description-show-legacy" => sprintf(__('The legacy Custom CSS under the %s tab and its mirror here are emptied, and the select box saved as No, when the settings tab is saved while the settings container is not displayed.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Referrers and tooltips", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + public function CustomCSSNew() { + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-css-new"); + // replace all placeholders + $l_obj_Template->replace( + array( + "css" => $this->addTextArea(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS_NEW), + + "headline" => $this->addText(__("Recommended CSS classes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays available Hooks to look for Footnote short codes. + * + * @author Stefan Herndler + * @since 1.5.5 + * + * Edited: + * @since 2.1.1 priority level setting for the_content 2020-11-16T2152+0100 + * @since 2.1.4 priority level settings for the other hooks 2020-11-19T1421+0100 + * + * 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: + * define -1 as PHP_INT_MAX instead + * + * @since 2.2.9 removed the warning about the widget text hook 2020-12-25T0348+0100 + * @since 2.2.9 added guidance for the widget text hook 2020-12-25T0353+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 + $l_obj_Template->replace( + array( + + "description-1" => __('The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "description-2" => sprintf(__('For the_content, this figure must be lower than %1$d so that certain strings added by a plugin running at %1$d may not be mistaken as a footnote. This makes also sure that the reference container displays above a feature inserted by a plugin running at %2$d.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 99, 1200), + "description-3" => sprintf(__('%1$d is lowest priority, %2$d is highest. To set priority level to lowest, set it to %3$d, interpreted as %1$d, the constant %4$s.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), PHP_INT_MAX, 0, -1, 'PHP_INT_MAX'), + "description-4" => __('The widget_text hook must be enabled either when footnotes are present in theme text widgets, or when Elementor accordions or toggles shall have a reference container per section. If they should not, this hook must be disabled.', 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), + "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), + "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), + "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), + "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), + "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 + echo $l_obj_Template->getContent(); + } + + /** + * Displays a short introduction of the Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Help() { + global $g_obj_MCI_Footnotes; + // load footnotes starting and end tag + $l_arr_Footnote_StartingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START); + $l_arr_Footnote_EndingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END); + + if ($l_arr_Footnote_StartingTag["value"] == "userdefined" || $l_arr_Footnote_EndingTag["value"] == "userdefined") { + // load user defined starting and end tag + $l_arr_Footnote_StartingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED); + $l_arr_Footnote_EndingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED); + } + $l_str_Example = "Hello" . $l_arr_Footnote_StartingTag["value"] . + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,". + " sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.". + " Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,". + " consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.". + " At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." + . $l_arr_Footnote_EndingTag["value"] . " World!"; + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "how-to-help"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-start" => __("Start your footnote with the following short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "start" => $l_arr_Footnote_StartingTag["value"], + + "label-end" => __("…and end your footnote with this short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "end" => $l_arr_Footnote_EndingTag["value"], + + "example-code" => $l_str_Example, + "example-string" => "
" . __("will be displayed as:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "example" => $g_obj_MCI_Footnotes->a_obj_Task->exec($l_str_Example, true), + + "information" => sprintf(__("For further information please check out our %ssupport forum%s on WordPress.org.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '', '') + ) + ); + // call wp_head function to get the Styling of the mouse-over box + $g_obj_MCI_Footnotes->a_obj_Task->wp_head(); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all Donate button to support the developers. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Donate() { + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "how-to-donate"); + // replace all placeholders + $l_obj_Template->replace( + array( + "caption" => __('Donate now',MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } } diff --git a/class/hooks.php b/class/hooks.php index a54930e..ceb7147 100644 --- a/class/hooks.php +++ b/class/hooks.php @@ -18,77 +18,77 @@ */ class MCI_Footnotes_Hooks { - /** - * Registers all WordPress hooks. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public static function registerHooks() { - register_activation_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "activatePlugin")); - register_deactivation_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "deactivatePlugin")); - register_uninstall_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "uninstallPlugin")); - } + /** + * Registers all WordPress hooks. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public static function registerHooks() { + register_activation_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "activatePlugin")); + register_deactivation_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "deactivatePlugin")); + register_uninstall_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "uninstallPlugin")); + } - /** - * Executed when the Plugin gets activated. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public static function activatePlugin() { - // currently unused - } + /** + * Executed when the Plugin gets activated. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public static function activatePlugin() { + // currently unused + } - /** - * Executed when the Plugin gets deactivated. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public static function deactivatePlugin() { - // currently unused - } + /** + * Executed when the Plugin gets deactivated. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public static function deactivatePlugin() { + // currently unused + } - /** - * Executed when the Plugin gets uninstalled. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Edit: ClearAll didn’t actually work. - * @since 2.2.0 this function is not called any longer when deleting the plugin - */ - public static function uninstallPlugin() { - // WordPress User has to be logged in - if (!is_user_logged_in()) { - wp_die(__('You must be logged in to run this script.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); - } - // WordPress User needs the permission to (un)install plugins - if (!current_user_can('install_plugins')) { - wp_die(__('You do not have permission to run this script.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); - } - // deletes all settings and restore the default values - // MCI_Footnotes_Settings::instance()->ClearAll(); - } + /** + * Executed when the Plugin gets uninstalled. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Edit: ClearAll didn’t actually work. + * @since 2.2.0 this function is not called any longer when deleting the plugin + */ + public static function uninstallPlugin() { + // WordPress User has to be logged in + if (!is_user_logged_in()) { + wp_die(__('You must be logged in to run this script.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + } + // WordPress User needs the permission to (un)install plugins + if (!current_user_can('install_plugins')) { + wp_die(__('You do not have permission to run this script.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + } + // deletes all settings and restore the default values + // MCI_Footnotes_Settings::instance()->ClearAll(); + } - /** - * Add Links to the Plugin in the "installed Plugins" page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param array $p_arr_Links Current Links. - * @param string $p_str_PluginFileName Plugins init file name. - * @return array - */ - public static function PluginLinks($p_arr_Links, $p_str_PluginFileName) { - // append link to the WordPress Plugin page - $p_arr_Links[] = sprintf('%s', __('Support', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); - // append link to the Settings page - $p_arr_Links[] = sprintf('%s', admin_url('admin.php?page=mfmmf-footnotes'), __('Settings', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); - // append link to the PlayPal Donate function - $p_arr_Links[] = sprintf('%s', __('Donate', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); - // return new links - return $p_arr_Links; - } + /** + * Add Links to the Plugin in the "installed Plugins" page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param array $p_arr_Links Current Links. + * @param string $p_str_PluginFileName Plugins init file name. + * @return array + */ + public static function PluginLinks($p_arr_Links, $p_str_PluginFileName) { + // append link to the WordPress Plugin page + $p_arr_Links[] = sprintf('%s', __('Support', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + // append link to the Settings page + $p_arr_Links[] = sprintf('%s', admin_url('admin.php?page=mfmmf-footnotes'), __('Settings', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + // append link to the PlayPal Donate function + $p_arr_Links[] = sprintf('%s', __('Donate', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + // return new links + return $p_arr_Links; + } } diff --git a/class/init.php b/class/init.php index a2a1061..e007871 100644 --- a/class/init.php +++ b/class/init.php @@ -7,7 +7,7 @@ * @since 1.5.0 12.09.14 10:56 * * - * @lastmodified 2021-02-16T0258+0100 + * @lastmodified 2021-02-18T2023+0100 * * @since 1.6.5 Bugfix: Improve widgets registration, thanks to @felipelavinz code contribution. * @since 1.6.5 Update: Fix for deprecated PHP function create_function(), thanks to @psykonevro @daliasued bug reports, thanks to @felipelavinz code contribution. @@ -31,329 +31,329 @@ */ class MCI_Footnotes { - /** - * Reference to the Plugin Task object. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var null|MCI_Footnotes_Task - */ - public $a_obj_Task = null; + /** + * Reference to the Plugin Task object. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var null|MCI_Footnotes_Task + */ + public $a_obj_Task = null; - /** - * Template process and script / stylesheet load optimization. - * - * - Bugfix: Templates: optimize template load and processing based on settings, thanks to @misfist code contribution. - * - * @since 2.4.0 - * @date 2021-01-04T1355+0100 - * - * @author Patrizia Lutz @misfist - * - * @link https://wordpress.org/support/topic/template-override-filter/#post-13864301 - * @link https://github.com/misfist/footnotes/releases/tag/2.4.0d3 repository - * @link https://github.com/misfist/footnotes/compare/2.4.0%E2%80%A62.4.0d3 diff - * - * @var bool - * - * Streamline process depending on tooltip enabled status. - * Load tooltip inline script only if jQuery tooltips are enabled. - * Actual value depends on settings. - */ - public static $a_bool_TooltipsEnabled = false; - public static $a_bool_AlternativeTooltipsEnabled = false; + /** + * Template process and script / stylesheet load optimization. + * + * - Bugfix: Templates: optimize template load and processing based on settings, thanks to @misfist code contribution. + * + * @since 2.4.0 + * @date 2021-01-04T1355+0100 + * + * @author Patrizia Lutz @misfist + * + * @link https://wordpress.org/support/topic/template-override-filter/#post-13864301 + * @link https://github.com/misfist/footnotes/releases/tag/2.4.0d3 repository + * @link https://github.com/misfist/footnotes/compare/2.4.0%E2%80%A62.4.0d3 diff + * + * @var bool + * + * Streamline process depending on tooltip enabled status. + * Load tooltip inline script only if jQuery tooltips are enabled. + * Actual value depends on settings. + */ + public static $a_bool_TooltipsEnabled = false; + public static $a_bool_AlternativeTooltipsEnabled = false; - /** - * Executes the Plugin. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * - * - Bugfix: Improve widgets registration, thanks to @felipelavinz code contribution. - * - * @since 1.6.5 - * - * @contributor @felipelavinz - * @link https://github.com/media-competence-institute/footnotes/commit/87173d2980c7ff90e12ffee94ca7153e11163793 - * - * @see self::initializeWidgets() - */ - public function run() { - // register language - MCI_Footnotes_Language::registerHooks(); - // register Button hooks - MCI_Footnotes_WYSIWYG::registerHooks(); - // register general hooks - MCI_Footnotes_Hooks::registerHooks(); + /** + * Executes the Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * + * - Bugfix: Improve widgets registration, thanks to @felipelavinz code contribution. + * + * @since 1.6.5 + * + * @contributor @felipelavinz + * @link https://github.com/media-competence-institute/footnotes/commit/87173d2980c7ff90e12ffee94ca7153e11163793 + * + * @see self::initializeWidgets() + */ + public function run() { + // register language + MCI_Footnotes_Language::registerHooks(); + // register Button hooks + MCI_Footnotes_WYSIWYG::registerHooks(); + // register general hooks + MCI_Footnotes_Hooks::registerHooks(); - // initialize the Plugin Dashboard - $this->initializeDashboard(); - // initialize the Plugin Task - $this->initializeTask(); + // 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 - add_action('wp_enqueue_scripts', array($this, 'registerPublic')); - // Register all Widgets of the Plugin. - add_action('widgets_init', array($this, 'initializeWidgets')); - } + // Register all Public Stylesheets and Scripts + add_action('init', array($this, 'registerPublic')); + // Enqueue all Public Stylesheets and Scripts + add_action('wp_enqueue_scripts', array($this, 'registerPublic')); + // Register all Widgets of the Plugin. + add_action('widgets_init', array($this, 'initializeWidgets')); + } - /** - * Initializes all Widgets of the Plugin. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * - * - Update: Fix for deprecated PHP function create_function(), thanks to @psykonevro @daliasued bug reports, thanks to @felipelavinz code contribution - * - * @since 1.6.5 - * - * @contributor @felipelavinz - * @link https://github.com/media-competence-institute/footnotes/commit/87173d2980c7ff90e12ffee94ca7153e11163793 - * - * @reporter @psykonevro - * @link https://wordpress.org/support/topic/bug-function-create_function-is-deprecated/ - * @link https://wordpress.org/support/topic/deprecated-function-create_function-14/ - * - * @reporter @daliasued - * @link https://wordpress.org/support/topic/deprecated-function-create_function-14/#post-13312853 - * - * create_function() was deprecated in PHP 7.2.0 and removed in PHP 8.0.0. - * @link https://www.php.net/manual/en/function.create-function.php - * - * The fix is to move add_action() above into run(), - * and use the bare register_widget() here. - * @see self::run() - * - * Also, the visibility of initializeWidgets() is not private any longer. - */ - public function initializeWidgets() { - register_widget( "MCI_Footnotes_Widget_ReferenceContainer" ); - } + /** + * Initializes all Widgets of the Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * + * - Update: Fix for deprecated PHP function create_function(), thanks to @psykonevro @daliasued bug reports, thanks to @felipelavinz code contribution + * + * @since 1.6.5 + * + * @contributor @felipelavinz + * @link https://github.com/media-competence-institute/footnotes/commit/87173d2980c7ff90e12ffee94ca7153e11163793 + * + * @reporter @psykonevro + * @link https://wordpress.org/support/topic/bug-function-create_function-is-deprecated/ + * @link https://wordpress.org/support/topic/deprecated-function-create_function-14/ + * + * @reporter @daliasued + * @link https://wordpress.org/support/topic/deprecated-function-create_function-14/#post-13312853 + * + * create_function() was deprecated in PHP 7.2.0 and removed in PHP 8.0.0. + * @link https://www.php.net/manual/en/function.create-function.php + * + * The fix is to move add_action() above into run(), + * and use the bare register_widget() here. + * @see self::run() + * + * Also, the visibility of initializeWidgets() is not private any longer. + */ + public function initializeWidgets() { + register_widget( "MCI_Footnotes_Widget_ReferenceContainer" ); + } - /** - * Initializes the Dashboard of the Plugin and loads them. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - private function initializeDashboard() { - new MCI_Footnotes_Layout_Init(); - } + /** + * Initializes the Dashboard of the Plugin and loads them. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function initializeDashboard() { + new MCI_Footnotes_Layout_Init(); + } - /** - * Initializes the Plugin Task and registers the Task hooks. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - private function initializeTask() { - $this->a_obj_Task = new MCI_Footnotes_Task(); - $this->a_obj_Task->registerHooks(); - } + /** + * Initializes the Plugin Task and registers the Task hooks. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function initializeTask() { + $this->a_obj_Task = new MCI_Footnotes_Task(); + $this->a_obj_Task->registerHooks(); + } - /** - * Registers and enqueues scripts and stylesheets to the public pages. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * @since 2.0.0 Update: Tooltips: fix disabling bug by loading jQuery UI library, thanks to @rajinderverma @ericcorbett2 @honlapdavid @mmallett bug reports, thanks to @vonpiernik code contribution. - * @since 2.0.3 add versioning of public.css for cache busting 2020-10-29T1413+0100 - * @since 2.0.4 add jQuery UI from WordPress 2020-11-01T1902+0100 - * @since 2.1.4 automate passing version number for cache busting 2020-11-30T0646+0100 - * @since 2.1.4 optionally enqueue an extra stylesheet 2020-12-04T2231+0100 - */ - public function registerPublic() { + /** + * Registers and enqueues scripts and stylesheets to the public pages. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * @since 2.0.0 Update: Tooltips: fix disabling bug by loading jQuery UI library, thanks to @rajinderverma @ericcorbett2 @honlapdavid @mmallett bug reports, thanks to @vonpiernik code contribution. + * @since 2.0.3 add versioning of public.css for cache busting 2020-10-29T1413+0100 + * @since 2.0.4 add jQuery UI from WordPress 2020-11-01T1902+0100 + * @since 2.1.4 automate passing version number for cache busting 2020-11-30T0646+0100 + * @since 2.1.4 optionally enqueue an extra stylesheet 2020-12-04T2231+0100 + */ + public function registerPublic() { - /** - * Enqueues external scripts. - * - * - Bugfix: Libraries: optimize processes by loading external and internal scripts only if needed, thanks to @docteurfitness issue report. - * - * @since 2.5.5 - * @reporter @docteurfitness - * @link https://wordpress.org/support/topic/simply-speed-optimisation/ - * - * The condition about tooltips was missing, only the not-alternative-tooltips part was present. - */ + /** + * Enqueues external scripts. + * + * - Bugfix: Libraries: optimize processes by loading external and internal scripts only if needed, thanks to @docteurfitness issue report. + * + * @since 2.5.5 + * @reporter @docteurfitness + * @link https://wordpress.org/support/topic/simply-speed-optimisation/ + * + * The condition about tooltips was missing, only the not-alternative-tooltips part was present. + */ - /** - * Enqueues the jQuery library registered by WordPress. - * - * jQuery is also used for animated scrolling, so it should be loaded by default. - * The function wp_enqueue_script() avoids loading the same library multiple times. - */ - wp_enqueue_script( 'jquery' ); + /** + * Enqueues the jQuery library registered by WordPress. + * + * jQuery is also used for animated scrolling, so it should be loaded by default. + * The function wp_enqueue_script() avoids loading the same library multiple times. + */ + wp_enqueue_script( 'jquery' ); - // set conditions re-used for stylesheet enqueuing: - self::$a_bool_TooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED ) ); - self::$a_bool_AlternativeTooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ) ); + // set conditions re-used for stylesheet enqueuing: + self::$a_bool_TooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED ) ); + self::$a_bool_AlternativeTooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ) ); - if ( self::$a_bool_TooltipsEnabled && ! self::$a_bool_AlternativeTooltipsEnabled ) { + if ( self::$a_bool_TooltipsEnabled && ! self::$a_bool_AlternativeTooltipsEnabled ) { - /** - * Enqueues the jQuery Tools library shipped with the plugin. - * - * redacted jQuery.browser, completed minification; - * see full header in js/jquery.tools.js - * added versioning 2020-11-18T2150+0100 - * not use '-js' in the handle, is appended automatically - */ - wp_enqueue_script( - 'mci-footnotes-jquery-tools', - plugins_url('footnotes/js/jquery.tools.min.js'), - array(), - '1.2.7.redacted.2' - ); + /** + * Enqueues the jQuery Tools library shipped with the plugin. + * + * redacted jQuery.browser, completed minification; + * see full header in js/jquery.tools.js + * added versioning 2020-11-18T2150+0100 + * not use '-js' in the handle, is appended automatically + */ + wp_enqueue_script( + 'mci-footnotes-jquery-tools', + plugins_url('footnotes/js/jquery.tools.min.js'), + array(), + '1.2.7.redacted.2' + ); - /** - * Registers jQuery UI from the JavaScript Content Delivery Network. - * - * - Update: Tooltips: fix disabling bug by loading jQuery UI library, thanks to @rajinderverma @ericcorbett2 @honlapdavid @mmallett bug reports, thanks to @vonpiernik code contribution. - * - * @since 2.0.0 - * Alternatively, fetch jQuery UI from cdnjs.cloudflare.com: - * @since 2.0.0 add jQueryUI from Cloudflare 2020-10-26T1907+0100 - * Used to add jQuery UI following @vonpiernik: - * : - * - * - * jQueryUI re-enables the tooltip infobox disabled when WPv5.5 was released. - * - * Updated for v2.0.4 by adding jQuery UI from WordPress following @check2020de: - * - * See - * - * 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']); + /** + * Registers jQuery UI from the JavaScript Content Delivery Network. + * + * - Update: Tooltips: fix disabling bug by loading jQuery UI library, thanks to @rajinderverma @ericcorbett2 @honlapdavid @mmallett bug reports, thanks to @vonpiernik code contribution. + * + * @since 2.0.0 + * Alternatively, fetch jQuery UI from cdnjs.cloudflare.com: + * @since 2.0.0 add jQueryUI from Cloudflare 2020-10-26T1907+0100 + * Used to add jQuery UI following @vonpiernik: + * : + * + * + * jQueryUI re-enables the tooltip infobox disabled when WPv5.5 was released. + * + * Updated for v2.0.4 by adding jQuery UI from WordPress following @check2020de: + * + * See + * + * 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']); - /** - * Enqueues some jQuery UI libraries registered by WordPress. - * - * @since 2.0.4 add jQuery UI from WordPress 2020-11-01T1902+0100 - * If alternative tooltips are enabled, these libraries are not needed. - */ - wp_enqueue_script( 'jquery-ui-core' ); - wp_enqueue_script( 'jquery-ui-widget' ); - wp_enqueue_script( 'jquery-ui-position' ); - wp_enqueue_script( 'jquery-ui-tooltip' ); + /** + * Enqueues some jQuery UI libraries registered by WordPress. + * + * @since 2.0.4 add jQuery UI from WordPress 2020-11-01T1902+0100 + * If alternative tooltips are enabled, these libraries are not needed. + */ + wp_enqueue_script( 'jquery-ui-core' ); + wp_enqueue_script( 'jquery-ui-widget' ); + wp_enqueue_script( 'jquery-ui-position' ); + wp_enqueue_script( 'jquery-ui-tooltip' ); - } + } - /** - * Enables enqueuing a new-scheme stylesheet. - * - * @since 2.5.5 - * @date 2021-02-14T1512+0100 - * - * Enables enqueuing the formatted individual stylesheets if false. - * WARNING: This facility is designed for development and must NOT be used in production. - * - * The Boolean may be set at the bottom of the plugin’s main PHP file. - * @see footnotes.php - */ - if ( C_BOOL_CSS_PRODUCTION_MODE === true ) { + /** + * Enables enqueuing a new-scheme stylesheet. + * + * @since 2.5.5 + * @date 2021-02-14T1512+0100 + * + * Enables enqueuing the formatted individual stylesheets if false. + * WARNING: This facility is designed for development and must NOT be used in production. + * + * The Boolean may be set at the bottom of the plugin’s main PHP file. + * @see footnotes.php + */ + if ( C_BOOL_CSS_PRODUCTION_MODE === true ) { - /** - * Enqueues a minified united external stylesheet in production. - * - * - Update: Stylesheets: increase speed and energy efficiency by tailoring stylesheets to the needs of the instance, thanks to @docteurfitness design contribution. - * - Bugfix: Stylesheets: minify to shrink the carbon footprint, increase speed and implement best practice, thanks to @docteurfitness issue report. - * - * @since 2.5.5 - * @date 2021-02-14T1543+0100 - * - * @contributor @docteurfitness - * @link https://wordpress.org/support/topic/simply-speed-optimisation/ - * - * @reporter @docteurfitness - * @link https://wordpress.org/support/topic/simply-speed-optimisation/ - * - * The dashboard stylesheet is minified as-is. - * @see class/dashboard/layout.php - * - * @since 2.0.3 add versioning of public.css for cache busting. - * @date 2020-10-29T1413+0100 - * Plugin version number is needed for busting browser caches after each plugin update. - * @since 2.1.4 automate passing version number for cache busting. - * @date 2020-11-30T0646+0100 - * The constant C_STR_FOOTNOTES_VERSION is defined at start of footnotes.php. - * - * The media scope argument 'all' is the default. - * No need to use '-css' in the handle, as this is appended automatically. - */ - // set tooltip mode for use in stylesheet name: - if ( self::$a_bool_TooltipsEnabled ) { - if ( self::$a_bool_AlternativeTooltipsEnabled ) { - $l_str_TooltipMode = 'al'; - $l_str_TComplement = 'ternative-tooltips'; - } else { - $l_str_TooltipMode = 'jq'; - $l_str_TComplement = 'uery-tooltips'; - } - } else { - $l_str_TooltipMode = 'no'; - $l_str_TComplement = '-tooltips'; - } + /** + * Enqueues a minified united external stylesheet in production. + * + * - Update: Stylesheets: increase speed and energy efficiency by tailoring stylesheets to the needs of the instance, thanks to @docteurfitness design contribution. + * - Bugfix: Stylesheets: minify to shrink the carbon footprint, increase speed and implement best practice, thanks to @docteurfitness issue report. + * + * @since 2.5.5 + * @date 2021-02-14T1543+0100 + * + * @contributor @docteurfitness + * @link https://wordpress.org/support/topic/simply-speed-optimisation/ + * + * @reporter @docteurfitness + * @link https://wordpress.org/support/topic/simply-speed-optimisation/ + * + * The dashboard stylesheet is minified as-is. + * @see class/dashboard/layout.php + * + * @since 2.0.3 add versioning of public.css for cache busting. + * @date 2020-10-29T1413+0100 + * Plugin version number is needed for busting browser caches after each plugin update. + * @since 2.1.4 automate passing version number for cache busting. + * @date 2020-11-30T0646+0100 + * The constant C_STR_FOOTNOTES_VERSION is defined at start of footnotes.php. + * + * The media scope argument 'all' is the default. + * No need to use '-css' in the handle, as this is appended automatically. + */ + // set tooltip mode for use in stylesheet name: + if ( self::$a_bool_TooltipsEnabled ) { + if ( self::$a_bool_AlternativeTooltipsEnabled ) { + $l_str_TooltipMode = 'al'; + $l_str_TComplement = 'ternative-tooltips'; + } else { + $l_str_TooltipMode = 'jq'; + $l_str_TComplement = 'uery-tooltips'; + } + } else { + $l_str_TooltipMode = 'no'; + $l_str_TComplement = '-tooltips'; + } - // set basic responsive page layout mode for use in stylesheet name: - $l_str_PageLayoutOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT); - switch ( $l_str_PageLayoutOption ) { - case "reference-container": $l_str_LayoutMode = '1'; break; - case "entry-content" : $l_str_LayoutMode = '2'; break; - case "main-content" : $l_str_LayoutMode = '3'; break; - case "none": default: $l_str_LayoutMode = '0'; break; - } + // set basic responsive page layout mode for use in stylesheet name: + $l_str_PageLayoutOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT); + switch ( $l_str_PageLayoutOption ) { + case "reference-container": $l_str_LayoutMode = '1'; break; + case "entry-content" : $l_str_LayoutMode = '2'; break; + case "main-content" : $l_str_LayoutMode = '3'; break; + case "none": default: $l_str_LayoutMode = '0'; break; + } - // enqueue the tailored united minified stylesheet: - wp_enqueue_style( - 'mci-footnotes-' . $l_str_TooltipMode . $l_str_TComplement . '-pagelayout-' . $l_str_PageLayoutOption, - plugins_url( - MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/footnotes-' . $l_str_TooltipMode . 'ttbrpl' . $l_str_LayoutMode . '.min.css' - ), - array(), - C_STR_FOOTNOTES_VERSION, - 'all' - ); + // enqueue the tailored united minified stylesheet: + wp_enqueue_style( + 'mci-footnotes-' . $l_str_TooltipMode . $l_str_TComplement . '-pagelayout-' . $l_str_PageLayoutOption, + plugins_url( + MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/footnotes-' . $l_str_TooltipMode . 'ttbrpl' . $l_str_LayoutMode . '.min.css' + ), + array(), + C_STR_FOOTNOTES_VERSION, + 'all' + ); - } else { + } else { - /** - * Enqueues external stylesheets, ONLY in development now. - * - * @since 2.1.4 optionally enqueue an extra stylesheet. - * @date 2020-12-04T2231+0100 - * - * This optional layout fix is useful by lack of layout support. - */ - wp_enqueue_style( 'mci-footnotes-common', plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-common.css' ), array(), C_STR_FOOTNOTES_VERSION ); - wp_enqueue_style( 'mci-footnotes-tooltips', plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips.css' ), array(), C_STR_FOOTNOTES_VERSION ); - wp_enqueue_style( 'mci-footnotes-alternative', plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips-alternative.css' ), array(), C_STR_FOOTNOTES_VERSION ); + /** + * Enqueues external stylesheets, ONLY in development now. + * + * @since 2.1.4 optionally enqueue an extra stylesheet. + * @date 2020-12-04T2231+0100 + * + * This optional layout fix is useful by lack of layout support. + */ + wp_enqueue_style( 'mci-footnotes-common', plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-common.css' ), array(), C_STR_FOOTNOTES_VERSION ); + wp_enqueue_style( 'mci-footnotes-tooltips', plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips.css' ), array(), C_STR_FOOTNOTES_VERSION ); + wp_enqueue_style( 'mci-footnotes-alternative', plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips-alternative.css' ), array(), C_STR_FOOTNOTES_VERSION ); - $l_str_PageLayoutOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT); - if ($l_str_PageLayoutOption != 'none') { - wp_enqueue_style( - 'mci-footnotes-layout-' . $l_str_PageLayoutOption, - plugins_url( - MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-layout-' . $l_str_PageLayoutOption . '.css' - ), - array(), - C_STR_FOOTNOTES_VERSION, - 'all' - ); - } - } - } + $l_str_PageLayoutOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT); + if ($l_str_PageLayoutOption != 'none') { + wp_enqueue_style( + 'mci-footnotes-layout-' . $l_str_PageLayoutOption, + plugins_url( + MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-layout-' . $l_str_PageLayoutOption . '.css' + ), + array(), + C_STR_FOOTNOTES_VERSION, + 'all' + ); + } + } + } } diff --git a/class/language.php b/class/language.php index 2a16db7..6172cdf 100644 --- a/class/language.php +++ b/class/language.php @@ -7,7 +7,7 @@ * @since 1.5.0 14.09.14 17:47 * * - * @lastmodified 2021-02-08T1914+0100 + * @lastmodified 2021-02-18T2028+0100 * * @since 2.0.0 Bugfix: Localization: correct function call apply_filters() with all required arguments after PHP 7.1 promoted warning to error, thanks to @matkus2 bug report and code contribution. * @since 2.1.6 Bugfix: Localization: conform to WordPress plugin language file name scheme, thanks to @nikelaos bug report. @@ -21,88 +21,88 @@ */ class MCI_Footnotes_Language { - /** - * Register WordPress Hook. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public static function registerHooks() { - add_action('plugins_loaded', array("MCI_Footnotes_Language", "loadTextDomain")); - } + /** + * Register WordPress Hook. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public static function registerHooks() { + add_action('plugins_loaded', array("MCI_Footnotes_Language", "loadTextDomain")); + } - /** - * Loads the text domain for current WordPress language if exists. - * Otherwise fallback "en_GB" will be loaded. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * - * - Bugfix: Correct function call apply_filters() with all required arguments after PHP 7.1 promoted warning to error, thanks to @matkus2 bug report and code contribution. - * - * @since 2.0.0 - * @date 2020-10-26T1609+0100 - * - * @contributor @matkus2 - * @link https://wordpress.org/support/topic/error-missing-parameter-if-using-php-7-1-or-later/ - * - * Add 3rd (empty) argument in apply_filters() to prevent PHP from throwing an error: - * “Fatal error: Uncaught ArgumentCountError: Too few arguments to function apply_filters()” - * - * Yet get_locale() is defined w/o parameters in wp-includes/l10n.php:30, and - * apply_filters() is defined as apply_filters( $tag, $value ) in wp-includes/plugin.php:181. - * @link https://developer.wordpress.org/reference/functions/apply_filters/ - * - * But apply_filters() is defined with a 3rd parameter (and w/o the first one) in - * wp-includes/class-wp-hook.php:264, as public function apply_filters( $value, $args ). - * - * Taking it all together, probably the full function definition would be: - * public function apply_filters( $tag, $value, $args ). - * In the case of get_locale(), $args is empty. - * - * The bug was lurking in WP. PHP 7.1 promoted the warning to an error. - * @link https://www.php.net/manual/en/migration71.incompatible.php - * @link https://www.php.net/manual/en/migration71.incompatible.php#migration71.incompatible.too-few-arguments-exception - */ - public static function loadTextDomain() { + /** + * Loads the text domain for current WordPress language if exists. + * Otherwise fallback "en_GB" will be loaded. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * + * - Bugfix: Correct function call apply_filters() with all required arguments after PHP 7.1 promoted warning to error, thanks to @matkus2 bug report and code contribution. + * + * @since 2.0.0 + * @date 2020-10-26T1609+0100 + * + * @contributor @matkus2 + * @link https://wordpress.org/support/topic/error-missing-parameter-if-using-php-7-1-or-later/ + * + * Add 3rd (empty) argument in apply_filters() to prevent PHP from throwing an error: + * “Fatal error: Uncaught ArgumentCountError: Too few arguments to function apply_filters()” + * + * Yet get_locale() is defined w/o parameters in wp-includes/l10n.php:30, and + * apply_filters() is defined as apply_filters( $tag, $value ) in wp-includes/plugin.php:181. + * @link https://developer.wordpress.org/reference/functions/apply_filters/ + * + * But apply_filters() is defined with a 3rd parameter (and w/o the first one) in + * wp-includes/class-wp-hook.php:264, as public function apply_filters( $value, $args ). + * + * Taking it all together, probably the full function definition would be: + * public function apply_filters( $tag, $value, $args ). + * In the case of get_locale(), $args is empty. + * + * The bug was lurking in WP. PHP 7.1 promoted the warning to an error. + * @link https://www.php.net/manual/en/migration71.incompatible.php + * @link https://www.php.net/manual/en/migration71.incompatible.php#migration71.incompatible.too-few-arguments-exception + */ + public static function loadTextDomain() { - // if language file with localization exists: - if ( self::load( apply_filters( 'plugin_locale', get_locale(), '' ) ) ) { - return; - } - // else fall back to British English: - self::load( "en_GB" ); - } + // if language file with localization exists: + if ( self::load( apply_filters( 'plugin_locale', get_locale(), '' ) ) ) { + return; + } + // else fall back to British English: + self::load( "en_GB" ); + } - /** - * Loads a specific text domain. - * - * @author Stefan Herndler - * @since 1.5.1 - * @param string $p_str_LanguageCode Language Code to load a specific text domain. - * @return bool - * - * - * - Bugfix: Localization: conform to WordPress plugin language file name scheme, thanks to @nikelaos bug report. - * - * @since 2.1.6 - * @date 2020-12-08T1931+0100 - * - * @reporter @nikelaos - * @link https://wordpress.org/support/topic/more-feature-ideas/ - * - * That is done by using load_plugin_textdomain(): - * “The .mo file should be named based on the text domain with a dash, and then the locale exactly.” - * @see wp-includes/l10n.php:857 - */ - private static function load($p_str_LanguageCode) { - return load_plugin_textdomain( - MCI_Footnotes_Config::C_STR_PLUGIN_NAME, - // This argument only fills the gap left by a deprecated argument (since WP2.7): - false, - // The plugin basedir is provided; trailing slash would be clipped: - MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/languages' - ); - } + /** + * Loads a specific text domain. + * + * @author Stefan Herndler + * @since 1.5.1 + * @param string $p_str_LanguageCode Language Code to load a specific text domain. + * @return bool + * + * + * - Bugfix: Localization: conform to WordPress plugin language file name scheme, thanks to @nikelaos bug report. + * + * @since 2.1.6 + * @date 2020-12-08T1931+0100 + * + * @reporter @nikelaos + * @link https://wordpress.org/support/topic/more-feature-ideas/ + * + * That is done by using load_plugin_textdomain(): + * “The .mo file should be named based on the text domain with a dash, and then the locale exactly.” + * @see wp-includes/l10n.php:857 + */ + private static function load($p_str_LanguageCode) { + return load_plugin_textdomain( + MCI_Footnotes_Config::C_STR_PLUGIN_NAME, + // This argument only fills the gap left by a deprecated argument (since WP2.7): + false, + // The plugin basedir is provided; trailing slash would be clipped: + MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/languages' + ); + } } diff --git a/class/settings.php b/class/settings.php index 2ba15ae..08b007d 100644 --- a/class/settings.php +++ b/class/settings.php @@ -7,7 +7,7 @@ * @since 1.5.0 14.09.14 10:43 * * - * @lastmodified 2021-02-17T1136+0100 + * @lastmodified 2021-02-18T2024+0100 * * @since 2.0.4 restore arrow settings 2020-11-02T2115+0100 * @since 2.0.7 remove hook the_post 2020-11-06T1342+0100 @@ -66,1173 +66,1173 @@ */ class MCI_Footnotes_Settings { - /** - * Settings Container Key for the label of the reference container. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_REFERENCE_CONTAINER_NAME = "footnote_inputfield_references_label"; - - /** - * Settings Container Key to collapse the reference container by default. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - * The string is converted to Boolean false if 'no', true if 'yes'. - * @see MCI_Footnotes_Convert::toBool() - * The type in the variable name is useful to show the intention. - * @todo Eventually change misleading variable names C_BOOL_… to C_STR_… (that’s how Hungarian screws things up). - */ - const C_BOOL_REFERENCE_CONTAINER_COLLAPSE = "footnote_inputfield_collapse_references"; - - /** - * Settings Container Key for the position of the reference container. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_REFERENCE_CONTAINER_POSITION = "footnote_inputfield_reference_container_place"; - - /** - * Settings Container Key for combining identical footnotes. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_BOOL_COMBINE_IDENTICAL_FOOTNOTES = "footnote_inputfield_combine_identical"; - - /** - * Settings Container Key for the short code of the footnote’s start. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_FOOTNOTES_SHORT_CODE_START = "footnote_inputfield_placeholder_start"; - - /** - * Settings Container Key for the short code of the footnote’s end. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_FOOTNOTES_SHORT_CODE_END = "footnote_inputfield_placeholder_end"; - - /** - * Settings Container Key for the user-defined short code of the footnotes start. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED = "footnote_inputfield_placeholder_start_user_defined"; - - /** - * Settings Container Key for the user-defined short code of the footnotes end. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED = "footnote_inputfield_placeholder_end_user_defined"; - - /** - * Settings Container Key for the counter style of the footnotes. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_FOOTNOTES_COUNTER_STYLE = "footnote_inputfield_counter_style"; - - /** - * Settings Container Key for the 'I love footnotes' text. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_FOOTNOTES_LOVE = "footnote_inputfield_love"; - - /** - * Settings Container Key to look for footnotes in post excerpts. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_BOOL_FOOTNOTES_IN_EXCERPT = "footnote_inputfield_search_in_excerpt"; - - /** - * Settings Container Key for the Expert mode. - * - * @author Stefan Herndler - * @since 1.5.5 - * @var str - * - * @since 2.1.6 This setting removed as irrelevant since priority level settings need permanent visibility. - * @date 2020-12-09T2107+0100 - * - * Since the removal of the the_post hook, the tab is no danger zone any longer. - * All users, not experts only, need to be able to control relative positioning. - */ - const C_BOOL_FOOTNOTES_EXPERT_MODE = "footnote_inputfield_enable_expert_mode"; - - /** - * Settings Container Key for the string before the footnote referrer. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - * - * The default footnote referrer surroundings should be square brackets: - * - * - with respect to baseline footnote referrers new option; - * - as in English or US American typesetting; - * - for better UX thanks to a more button-like appearance; - * - for stylistic consistency with the expand-collapse button. - * - */ - const C_STR_FOOTNOTES_STYLING_BEFORE = "footnote_inputfield_custom_styling_before"; - - /** - * Settings Container Key for the string after the footnote referrer. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_FOOTNOTES_STYLING_AFTER = "footnote_inputfield_custom_styling_after"; - - /** - * Settings Container Key to enable the mouse-over box. - * - * @author Stefan Herndler - * @since 1.5.2 - * @var str - */ - const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED = "footnote_inputfield_custom_mouse_over_box_enabled"; - - /** - * Settings Container Key to enable the alternative tooltips. - * - * - Bugfix: Tooltips: optional alternative JS implementation with CSS transitions to fix configuration-related outage, thanks to @andreasra feedback. - * - * @since 2.1.1 - * @date 2020-11-11T1817+0100 - * - * @reporter @andreasra - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/page/2/#post-13632566 - * - * @var str - * - * These alternative tooltips work around a website related jQuery UI - * outage. They are low-script but use the AMP incompatible onmouseover - * and onmouseout arguments, along with CSS transitions for fade-in/out. - * The very small script is inserted after Footnotes’ internal stylesheet. - * - */ - const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE = "footnote_inputfield_custom_mouse_over_box_alternative"; - - /** - * Settings Container Key to enable tooltip truncation. - * - * @author Stefan Herndler - * @since 1.5.4 - * @var str - */ - 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 excerpt. - * - * @author Stefan Herndler - * @since 1.5.4 - * @var str - */ - const C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH = "footnote_inputfield_custom_mouse_over_box_excerpt_length"; - - /** - * Settings Container Key for the mouse-over box to define the position. - * - * @author Stefan Herndler - * @since 1.5.7 - * @var str - */ - const C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION = "footnote_inputfield_custom_mouse_over_box_position"; - - /** - * Settings Container Key for the mouse-over box to define the offset (x). - * - * @author Stefan Herndler - * @since 1.5.7 - * @var str - */ - const C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X = "footnote_inputfield_custom_mouse_over_box_offset_x"; - - /** - * Settings Container Key for the mouse-over box to define the offset (y). - * - * @author Stefan Herndler - * @since 1.5.7 - * @var str - */ - const C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y = "footnote_inputfield_custom_mouse_over_box_offset_y"; - - /** - * Settings Container Key for the mouse-over box to define the color. - * - * @author Stefan Herndler - * @since 1.5.6 - * @var str - */ - const C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR = "footnote_inputfield_custom_mouse_over_box_color"; - - /** - * Settings Container Key for the mouse-over box to define the background color. - * - * @author Stefan Herndler - * @since 1.5.6 - * @var str - */ - const C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND = "footnote_inputfield_custom_mouse_over_box_background"; - - /** - * Settings Container Key for the mouse-over box to define the border width. - * - * @author Stefan Herndler - * @since 1.5.6 - * @var str - */ - const C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH = "footnote_inputfield_custom_mouse_over_box_border_width"; - - /** - * Settings Container Key for the mouse-over box to define the border color. - * - * @author Stefan Herndler - * @since 1.5.6 - * @var str - */ - const C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR = "footnote_inputfield_custom_mouse_over_box_border_color"; - - /** - * Settings Container Key for the mouse-over box to define the border radius. - * - * @author Stefan Herndler - * @since 1.5.6 - * @var str - */ - const C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS = "footnote_inputfield_custom_mouse_over_box_border_radius"; - - /** - * Settings Container Key for the mouse-over box to define the max. width. - * - * @author Stefan Herndler - * @since 1.5.6 - * @var str - */ - const C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH = "footnote_inputfield_custom_mouse_over_box_max_width"; - - /** - * Settings Container Key for the mouse-over box to define the box-shadow color. - * - * @author Stefan Herndler - * @since 1.5.8 - * @var str - */ - const C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR = "footnote_inputfield_custom_mouse_over_box_shadow_color"; - - /** - * Settings Container Key for the backlink symbol selection. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_HYPERLINK_ARROW = "footnote_inputfield_custom_hyperlink_symbol"; - - /** - * Settings Container Key for the user-defined backlink symbol. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - */ - const C_STR_HYPERLINK_ARROW_USER_DEFINED = "footnote_inputfield_custom_hyperlink_symbol_user"; - - /** - * Settings Container Key for the Custom CSS. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var str - * - * @since 1.3.0 Adding: new settings tab for custom CSS settings. - */ - const C_STR_CUSTOM_CSS = "footnote_inputfield_custom_css"; - - /** - * Settings Container Key for the Custom CSS migrated to a dedicated tab. - * - * @since 2.2.2 Bugfix: Dashboard: Custom CSS: unearth text area and migrate to dedicated tab as designed. - * @date 2020-12-15T0520+0100 - * @var str - */ - const C_STR_CUSTOM_CSS_NEW = "footnote_inputfield_custom_css_new"; - - /** - * Settings Container Key to enable display of legacy Custom CSS metaboxes. - * - * @since 2.2.2 - * @date 2020-12-15T0520+0100 - * @var str - * - * @since 2.3.0 swap Boolean from 'migration complete' to 'show legacy' - * @date 2020-12-27T1233+0100 - * - * The Boolean must be false if its setting is contained in the container to be hidden, - * because when saving, all missing constants are emptied, and toBool() converts empty to false. - */ - const C_BOOL_CUSTOM_CSS_LEGACY_ENABLE = "footnote_inputfield_custom_css_legacy_enable"; - - /** - * Settings Container Key to enable the 'the_title' hook. - * - * @author Stefan Herndler - * @since 1.5.5 - * @var str - */ - const C_BOOL_EXPERT_LOOKUP_THE_TITLE = "footnote_inputfield_expert_lookup_the_title"; - - /** - * Settings Container Key to enable the 'the_content' hook. - * - * @author Stefan Herndler - * @since 1.5.5 - * @var str - */ - const C_BOOL_EXPERT_LOOKUP_THE_CONTENT = "footnote_inputfield_expert_lookup_the_content"; - - /** - * Settings Container Key to enable the 'the_excerpt' hook. - * - * @author Stefan Herndler - * @since 1.5.5 - * @var str - */ - const C_BOOL_EXPERT_LOOKUP_THE_EXCERPT = "footnote_inputfield_expert_lookup_the_excerpt"; - - /** - * Settings Container Key to enable the 'widget_title' hook. - * - * @author Stefan Herndler - * @since 1.5.5 - * @var str - */ - const C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE = "footnote_inputfield_expert_lookup_widget_title"; - - /** - * Settings Container Key to enable the 'widget_text' hook. - * - * @author Stefan Herndler - * @since 1.5.5 - * @var str - */ - const C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT = "footnote_inputfield_expert_lookup_widget_text"; - - /** - * Settings Container Key for the label of the Read-on button in truncated tooltips. - * - * - Adding: Tooltips: Read-on button: Label: configurable instead of localizable, thanks to @rovanov example provision. - * - * @since 2.1.0 - * @date 2020-11-08T2106+0100 - * - * @reporter @rovanov - * @link https://wordpress.org/support/topic/offset-x-axis-and-offset-y-axis-does-not-working/ - * - * @var str - */ - const C_STR_FOOTNOTES_TOOLTIP_READON_LABEL = "footnote_inputfield_readon_label"; - - /** - * Settings Container Key for the referrer element. - * - * - Bugfix: Referrers: new setting for vertical align: superscript (default) or baseline (optional), thanks to @cwbayer bug report. - * - * @since 2.1.1 - * @date 2020-11-16T0859+0100 - * - * @reporter @cwbayer - * @link https://wordpress.org/support/topic/footnote-number-in-text-superscript-disrupts-leading/ - * - * @var str - */ - const C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS = "footnotes_inputfield_referrer_superscript_tags"; - - /** - * Settings Container Key to enable the display of a backlink symbol. - * - * - Bugfix: Reference container: Backlink symbol: make optional, not suggest configuring it to invisible, thanks to @spaceling feedback. - * - * @since 2.1.1 - * - * @reporter @spaceling - * @link https://wordpress.org/support/topic/change-the-position-5/page/2/#post-13671138 - * - * @var str - */ - const C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = "footnotes_inputfield_reference_container_backlink_symbol_enable"; - - /** - * Settings Container Key to not display the reference container on the homepage. - * - * - Bugfix: Reference container: fix start pages by making its display optional, thanks to @dragon013 bug report. - * - * @since 2.1.1 - * - * @reporter @dragon013 - * @link https://wordpress.org/support/topic/possible-to-hide-it-from-start-page/ - * - * @var str - */ - const C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE = "footnotes_inputfield_reference_container_start_page_enable"; - - /** - * Settings Container Key to enable the legacy layout of the reference container. - * - * - Bugfix: Reference container: option to restore pre-2.0.0 layout with the backlink symbol in an extra column. - * - * @since 2.1.1 - * @var str - */ - const C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = "footnotes_inputfield_reference_container_3column_layout_enable"; - - /** - * Settings Container Key to get the backlink symbol switch side. - * - * - Bugfix: Reference container: option to append symbol (prepended by default), thanks to @spaceling code contribution. - * - * @since 2.1.1 - * @date 2020-11-16T2024+0100 - * - * @contributor @spaceling - * @link https://wordpress.org/support/topic/change-the-position-5/#post-13615994 - * - * @var str - */ - const C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = "footnotes_inputfield_reference_container_backlink_symbol_switch"; - - /** - * Settings Container Key for 'the_content' hook priority level. - * - * @since 2.1.1 - * @date 2020-11-16T0859+0100 - * - * @var str - */ - const C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_content_priority_level"; - - /** - * Settings Container Key for '' hook priority level - * - * @since 2.1.2 - * @date 2020-11-20T0620+0100 - * - * @var str - */ - const C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_title_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"; - const C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_excerpt_priority_level"; - - /** - * Settings Container Keys for the link element option - * Settings Container Keys for backlink typography and layout - * Settings Container Keys for tooltip font size - * Settings Container Keys for page layout support - * Settings Container Keys for scroll offset and duration - * Settings Container Keys for tooltip display durations - * - * @since 2.1.4 - * @var str|bool|int|flo - * - * 2020-11-26T1002+0100 - * 2020-11-30T0427+0100 - * 2020-12-03T0501+0100 - * 2020-12-05T0425+0100 - */ - - // link element option: - const C_BOOL_LINK_ELEMENT_ENABLED = "footnote_inputfield_link_element_enabled"; - - // backlink typography: - const C_BOOL_BACKLINKS_SEPARATOR_ENABLED = "footnotes_inputfield_backlinks_separator_enabled"; - const C_STR_BACKLINKS_SEPARATOR_OPTION = "footnotes_inputfield_backlinks_separator_option"; - const C_STR_BACKLINKS_SEPARATOR_CUSTOM = "footnotes_inputfield_backlinks_separator_custom"; - const C_BOOL_BACKLINKS_TERMINATOR_ENABLED = "footnotes_inputfield_backlinks_terminator_enabled"; - const C_STR_BACKLINKS_TERMINATOR_OPTION = "footnotes_inputfield_backlinks_terminator_option"; - const C_STR_BACKLINKS_TERMINATOR_CUSTOM = "footnotes_inputfield_backlinks_terminator_custom"; - - // backlink layout: - const C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED = "footnotes_inputfield_backlinks_column_width_enabled"; - const C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR = "footnotes_inputfield_backlinks_column_width_scalar"; - const C_STR_BACKLINKS_COLUMN_WIDTH_UNIT = "footnotes_inputfield_backlinks_column_width_unit"; - const C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED = "footnotes_inputfield_backlinks_column_max_width_enabled"; - const C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR = "footnotes_inputfield_backlinks_column_max_width_scalar"; - const C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT = "footnotes_inputfield_backlinks_column_max_width_unit"; - const C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED = "footnotes_inputfield_backlinks_line_breaks_enabled"; - - // tooltip font size: - // called mouse over box not tooltip for consistency - const C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED = "footnotes_inputfield_mouse_over_box_font_size_enabled"; - const C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR = "footnotes_inputfield_mouse_over_box_font_size_scalar"; - const C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT = "footnotes_inputfield_mouse_over_box_font_size_unit"; - - // page layout support: - const C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT = "footnotes_inputfield_page_layout_support"; - - /** - * Scroll offset and duration - * - * - Bugfix: Scroll offset: make configurable to fix site-dependent issues related to fixed headers. - * - Bugfix: Scroll duration: make configurable to conform to website content and style requirements. - * - * @since 2.1.4 - * @date 2020-12-05T0538+0100 - */ - // scroll offset and duration: - const C_INT_FOOTNOTES_SCROLL_OFFSET = "footnotes_inputfield_scroll_offset"; - const C_INT_FOOTNOTES_SCROLL_DURATION = "footnotes_inputfield_scroll_duration"; - - // tooltip display durations: - // called mouse over box not tooltip for consistency - const C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY = "footnotes_inputfield_mouse_over_box_fade_in_delay"; - const C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION = "footnotes_inputfield_mouse_over_box_fade_in_duration"; - const C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY = "footnotes_inputfield_mouse_over_box_fade_out_delay"; - const C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION = "footnotes_inputfield_mouse_over_box_fade_out_duration"; - - /** - * Settings Container Key for URL wrap option - * - * This is made optional because it causes weird line breaks. - * Unicode-compliant browsers break URLs at slashes. - * - * @since 2.1.6 - * @var str - * - * 2020-12-09T1554+0100..2020-12-13T1313+0100 - */ - const C_BOOL_FOOTNOTE_URL_WRAP_ENABLED = "footnote_inputfield_url_wrap_enabled"; - - /** - * Settings Container Key for reference container position shortcode - * - * @since 2.2.0 - * @var str - * - * 2020-12-13T2056+0100 - */ - const C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE = "footnote_inputfield_reference_container_position_shortcode"; - - /** - * Settings Container Keys for alternative tooltip position - * Settings Container Keys for reference container label element, thanks to @markhillyer - * @link https://wordpress.org/support/topic/how-do-i-eliminate-the-horizontal-line-beneath-the-reference-container-heading/ - * - * @since 2.2.5 - * @var int - * - * 2020-12-17T0746+0100 - * 2020-12-18T1509+0100 - */ - const C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION = "footnotes_inputfield_alternative_mouse_over_box_position"; - const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X = "footnotes_inputfield_alternative_mouse_over_box_offset_x"; - const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y = "footnotes_inputfield_alternative_mouse_over_box_offset_y"; - const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH = "footnotes_inputfield_alternative_mouse_over_box_width"; - - const C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT = "footnotes_inputfield_reference_container_label_element"; - const C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER = "footnotes_inputfield_reference_container_label_bottom_border"; - - /** - * Settings Container Key for table cell borders, thanks to @noobishh - * @link https://wordpress.org/support/topic/borders-25/ - * - * @since 2.2.10 - * @var str - * - * 2020-12-25T2311+0100 - */ - const C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE = "footnotes_inputfield_reference_container_row_borders_enable"; - - /** - * Settings container keys for reference container top and bottom margins - * Settings container keys for hard link enabling - * Settings container keys for hard link anchors in referrers and footnotes - * - * @since 2.3.0 - * @var int|bool|str - * - * 2020-12-29T0914+0100 - */ - const C_INT_REFERENCE_CONTAINER_TOP_MARGIN = "footnotes_inputfield_reference_container_top_margin"; - const C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN = "footnotes_inputfield_reference_container_bottom_margin"; - const C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE = "footnotes_inputfield_hard_links_enable"; - const C_STR_REFERRER_FRAGMENT_ID_SLUG = "footnotes_inputfield_referrer_fragment_id_slug"; - const C_STR_FOOTNOTE_FRAGMENT_ID_SLUG = "footnotes_inputfield_footnote_fragment_id_slug"; - const C_STR_HARD_LINK_IDS_SEPARATOR = "footnotes_inputfield_hard_link_ids_separator"; - - /** - * Settings container key for shortcode syntax validation. - * - * @since 2.4.0 - * @date 2021-01-01T0616+0100 - * - * @var str - */ - const C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE = "footnotes_inputfield_shortcode_syntax_validation_enable"; - - /** - * Settings container key to enable backlink tooltips. - * - * - Update: Reference container: Hard backlinks (optional): optional configurable tooltip hinting to use the backbutton instead, thanks to @theroninjedi47 bug report. - * - * @since 2.5.4 - * - * @reporter @theroninjedi47 - * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ - * - * When hard links are enabled, clicks on the backlinks are logged in the browsing history, - * along with clicks on the referrers. - * This tooltip hints to use the backbutton instead, so the history gets streamlined again. - * @link https://wordpress.org/support/topic/making-it-amp-compatible/#post-13837359 - * - * @var str - */ - const C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE = "footnotes_inputfield_backlink_tooltip_enable"; - - /** - * Settings container key to configure the backlink tooltip. - * - * - Update: Reference container: Hard backlinks (optional): optional configurable tooltip hinting to use the backbutton instead, thanks to @theroninjedi47 bug report. - * - * @since 2.5.4 - * - * @reporter @theroninjedi47 - * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ - * - * @var str - */ - const C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT = "footnotes_inputfield_backlink_tooltip_text"; - - /** - * Settings container key to configure the tooltip excerpt delimiter. - * - * - Update: Tooltips: ability to display dedicated content before `[[/tooltip]]`, thanks to @jbj2199 issue report. - * - * The first implementation used a fixed shortcode provided in the changelog. - * But Footnotes’ UI design policy is to make shortcodes freely configurable. - * @since 2.5.4 - * - * @reporter @jbj2199 - * @link https://wordpress.org/support/topic/change-tooltip-text/ - * - * Tooltips can display another content than the footnote entry - * in the reference container. The trigger is a shortcode in - * the footnote text separating the tooltip text from the note. - * That is consistent with what WordPress does for excerpts. - * - * @var str - */ - const C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER = "footnotes_inputfield_tooltip_excerpt_delimiter"; - - /** - * Settings container key to enable mirroring the tooltip excerpt in the reference container. - * - * @since 2.5.4 - * @var str - * - * Tooltips, even jQuery-driven, may be hard to consult on mobiles. - * This option allows to read the tooltip content in the reference container too. - * @link https://wordpress.org/support/topic/change-tooltip-text/#post-13935050 - * But this must not be the default behavior. - * @link https://wordpress.org/support/topic/change-tooltip-text/#post-13935488 - */ - const C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE = "footnotes_inputfield_tooltip_excerpt_mirror_enable"; - - /** - * Settings container key to configure the tooltip excerpt separator in the reference container. - * - * @since 2.5.4 - * @var str - */ - const C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR = "footnotes_inputfield_tooltip_excerpt_mirror_separator"; - - /** - * Settings container key to enable superscript style normalization. - * - * -Bugfix: Referrers: optional fixes to vertical alignment, font size and position (static) for in-theme consistency and cross-theme stability, thanks to @tomturowski bug report. - * - * @since 2.5.4 - * - * @reporter @tomturowski - * @link https://wordpress.org/support/topic/in-line-superscript-ref-rides-to-high/ - * - * @var str - */ - const C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT = "footnotes_inputfield_referrers_normal_superscript"; - - - /** - * SETTINGS STORAGE - */ - - /** - * Stores a singleton reference of this class. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var MCI_Footnotes_Settings - */ - private static $a_obj_Instance = null; - - /** - * Contains all Settings Container names. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var array - * - * Edited: - * 2.2.2 added tab for Custom CSS 2020-12-15T0740+0100 - * - * These are the storage container names, one per dashboard tab. - */ - private $a_arr_Container = array( - "footnotes_storage", - "footnotes_storage_custom", - "footnotes_storage_expert", - "footnotes_storage_custom_css", - ); - - /** - * Contains all Default Settings for each Settings Container. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var array - * - * Edited multiple times. - * - * @since 2.1.3 excerpt hook: disable by default, thanks to @nikelaos - * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13687068 - */ - private $a_arr_Default = array( - - "footnotes_storage" => array( - - self::C_STR_FOOTNOTES_SHORT_CODE_START => '((', - self::C_STR_FOOTNOTES_SHORT_CODE_END => '))', - self::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED => '', - self::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED => '', - - self::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE => 'yes', - - self::C_STR_FOOTNOTES_COUNTER_STYLE => 'arabic_plain', - self::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES => 'yes', - - self::C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE => 'no', - self::C_STR_REFERRER_FRAGMENT_ID_SLUG => 'r', - self::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG => 'f', - self::C_STR_HARD_LINK_IDS_SEPARATOR => '+', - self::C_INT_FOOTNOTES_SCROLL_OFFSET => 20, - self::C_INT_FOOTNOTES_SCROLL_DURATION => 380, - - // 2.5.4 fast-tracked: - self::C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE => 'yes', - self::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT => 'Alt+ ←', - - - self::C_STR_REFERENCE_CONTAINER_NAME => 'References', - self::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT => 'p', - self::C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER => 'yes', - self::C_BOOL_REFERENCE_CONTAINER_COLLAPSE => 'no', - - self::C_STR_REFERENCE_CONTAINER_POSITION => 'post_end', - self::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE => '[[references]]', - self::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE => 'yes', - - // whether to enqueue additional stylesheet: - self::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT => 'none', - - // top and bottom margins: - self::C_INT_REFERENCE_CONTAINER_TOP_MARGIN => 24, - self::C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN => 0, - - // table cell borders: - self::C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE => 'no', - - // backlink symbol: - self::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE => 'no', - self::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE => 'yes', - self::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH => 'no', - - // backlink separators and terminators are often not preferred. - // but a choice must be provided along with the ability to customize: - self::C_BOOL_BACKLINKS_SEPARATOR_ENABLED => 'yes', - self::C_STR_BACKLINKS_SEPARATOR_OPTION => 'comma', - self::C_STR_BACKLINKS_SEPARATOR_CUSTOM => '', - self::C_BOOL_BACKLINKS_TERMINATOR_ENABLED => 'no', - self::C_STR_BACKLINKS_TERMINATOR_OPTION => 'full_stop', - self::C_STR_BACKLINKS_TERMINATOR_CUSTOM => '', - - // set backlinks column width: - self::C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED => 'no', - self::C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR => '50', - self::C_STR_BACKLINKS_COLUMN_WIDTH_UNIT => 'px', - - // set backlinks column max. width: - self::C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED => 'no', - self::C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR => '140', - self::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT => 'px', - - // whether a
tag is inserted: - self::C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED => 'no', - - // whether to enable URL line wrapping: - self::C_BOOL_FOOTNOTE_URL_WRAP_ENABLED => 'yes', + /** + * Settings Container Key for the label of the reference container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_REFERENCE_CONTAINER_NAME = "footnote_inputfield_references_label"; + + /** + * Settings Container Key to collapse the reference container by default. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + * The string is converted to Boolean false if 'no', true if 'yes'. + * @see MCI_Footnotes_Convert::toBool() + * The type in the variable name is useful to show the intention. + * @todo Eventually change misleading variable names C_BOOL_… to C_STR_… (that’s how Hungarian screws things up). + */ + const C_BOOL_REFERENCE_CONTAINER_COLLAPSE = "footnote_inputfield_collapse_references"; + + /** + * Settings Container Key for the position of the reference container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_REFERENCE_CONTAINER_POSITION = "footnote_inputfield_reference_container_place"; + + /** + * Settings Container Key for combining identical footnotes. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_BOOL_COMBINE_IDENTICAL_FOOTNOTES = "footnote_inputfield_combine_identical"; + + /** + * Settings Container Key for the short code of the footnote’s start. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_FOOTNOTES_SHORT_CODE_START = "footnote_inputfield_placeholder_start"; + + /** + * Settings Container Key for the short code of the footnote’s end. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_FOOTNOTES_SHORT_CODE_END = "footnote_inputfield_placeholder_end"; + + /** + * Settings Container Key for the user-defined short code of the footnotes start. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED = "footnote_inputfield_placeholder_start_user_defined"; + + /** + * Settings Container Key for the user-defined short code of the footnotes end. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED = "footnote_inputfield_placeholder_end_user_defined"; + + /** + * Settings Container Key for the counter style of the footnotes. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_FOOTNOTES_COUNTER_STYLE = "footnote_inputfield_counter_style"; + + /** + * Settings Container Key for the 'I love footnotes' text. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_FOOTNOTES_LOVE = "footnote_inputfield_love"; + + /** + * Settings Container Key to look for footnotes in post excerpts. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_BOOL_FOOTNOTES_IN_EXCERPT = "footnote_inputfield_search_in_excerpt"; + + /** + * Settings Container Key for the Expert mode. + * + * @author Stefan Herndler + * @since 1.5.5 + * @var str + * + * @since 2.1.6 This setting removed as irrelevant since priority level settings need permanent visibility. + * @date 2020-12-09T2107+0100 + * + * Since the removal of the the_post hook, the tab is no danger zone any longer. + * All users, not experts only, need to be able to control relative positioning. + */ + const C_BOOL_FOOTNOTES_EXPERT_MODE = "footnote_inputfield_enable_expert_mode"; + + /** + * Settings Container Key for the string before the footnote referrer. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + * + * The default footnote referrer surroundings should be square brackets: + * + * - with respect to baseline footnote referrers new option; + * - as in English or US American typesetting; + * - for better UX thanks to a more button-like appearance; + * - for stylistic consistency with the expand-collapse button. + * + */ + const C_STR_FOOTNOTES_STYLING_BEFORE = "footnote_inputfield_custom_styling_before"; + + /** + * Settings Container Key for the string after the footnote referrer. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_FOOTNOTES_STYLING_AFTER = "footnote_inputfield_custom_styling_after"; + + /** + * Settings Container Key to enable the mouse-over box. + * + * @author Stefan Herndler + * @since 1.5.2 + * @var str + */ + const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED = "footnote_inputfield_custom_mouse_over_box_enabled"; + + /** + * Settings Container Key to enable the alternative tooltips. + * + * - Bugfix: Tooltips: optional alternative JS implementation with CSS transitions to fix configuration-related outage, thanks to @andreasra feedback. + * + * @since 2.1.1 + * @date 2020-11-11T1817+0100 + * + * @reporter @andreasra + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/page/2/#post-13632566 + * + * @var str + * + * These alternative tooltips work around a website related jQuery UI + * outage. They are low-script but use the AMP incompatible onmouseover + * and onmouseout arguments, along with CSS transitions for fade-in/out. + * The very small script is inserted after Footnotes’ internal stylesheet. + * + */ + const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE = "footnote_inputfield_custom_mouse_over_box_alternative"; + + /** + * Settings Container Key to enable tooltip truncation. + * + * @author Stefan Herndler + * @since 1.5.4 + * @var str + */ + 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 excerpt. + * + * @author Stefan Herndler + * @since 1.5.4 + * @var str + */ + const C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH = "footnote_inputfield_custom_mouse_over_box_excerpt_length"; + + /** + * Settings Container Key for the mouse-over box to define the position. + * + * @author Stefan Herndler + * @since 1.5.7 + * @var str + */ + const C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION = "footnote_inputfield_custom_mouse_over_box_position"; + + /** + * Settings Container Key for the mouse-over box to define the offset (x). + * + * @author Stefan Herndler + * @since 1.5.7 + * @var str + */ + const C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X = "footnote_inputfield_custom_mouse_over_box_offset_x"; + + /** + * Settings Container Key for the mouse-over box to define the offset (y). + * + * @author Stefan Herndler + * @since 1.5.7 + * @var str + */ + const C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y = "footnote_inputfield_custom_mouse_over_box_offset_y"; + + /** + * Settings Container Key for the mouse-over box to define the color. + * + * @author Stefan Herndler + * @since 1.5.6 + * @var str + */ + const C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR = "footnote_inputfield_custom_mouse_over_box_color"; + + /** + * Settings Container Key for the mouse-over box to define the background color. + * + * @author Stefan Herndler + * @since 1.5.6 + * @var str + */ + const C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND = "footnote_inputfield_custom_mouse_over_box_background"; + + /** + * Settings Container Key for the mouse-over box to define the border width. + * + * @author Stefan Herndler + * @since 1.5.6 + * @var str + */ + const C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH = "footnote_inputfield_custom_mouse_over_box_border_width"; + + /** + * Settings Container Key for the mouse-over box to define the border color. + * + * @author Stefan Herndler + * @since 1.5.6 + * @var str + */ + const C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR = "footnote_inputfield_custom_mouse_over_box_border_color"; + + /** + * Settings Container Key for the mouse-over box to define the border radius. + * + * @author Stefan Herndler + * @since 1.5.6 + * @var str + */ + const C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS = "footnote_inputfield_custom_mouse_over_box_border_radius"; + + /** + * Settings Container Key for the mouse-over box to define the max. width. + * + * @author Stefan Herndler + * @since 1.5.6 + * @var str + */ + const C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH = "footnote_inputfield_custom_mouse_over_box_max_width"; + + /** + * Settings Container Key for the mouse-over box to define the box-shadow color. + * + * @author Stefan Herndler + * @since 1.5.8 + * @var str + */ + const C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR = "footnote_inputfield_custom_mouse_over_box_shadow_color"; + + /** + * Settings Container Key for the backlink symbol selection. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_HYPERLINK_ARROW = "footnote_inputfield_custom_hyperlink_symbol"; + + /** + * Settings Container Key for the user-defined backlink symbol. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + */ + const C_STR_HYPERLINK_ARROW_USER_DEFINED = "footnote_inputfield_custom_hyperlink_symbol_user"; + + /** + * Settings Container Key for the Custom CSS. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var str + * + * @since 1.3.0 Adding: new settings tab for custom CSS settings. + */ + const C_STR_CUSTOM_CSS = "footnote_inputfield_custom_css"; + + /** + * Settings Container Key for the Custom CSS migrated to a dedicated tab. + * + * @since 2.2.2 Bugfix: Dashboard: Custom CSS: unearth text area and migrate to dedicated tab as designed. + * @date 2020-12-15T0520+0100 + * @var str + */ + const C_STR_CUSTOM_CSS_NEW = "footnote_inputfield_custom_css_new"; + + /** + * Settings Container Key to enable display of legacy Custom CSS metaboxes. + * + * @since 2.2.2 + * @date 2020-12-15T0520+0100 + * @var str + * + * @since 2.3.0 swap Boolean from 'migration complete' to 'show legacy' + * @date 2020-12-27T1233+0100 + * + * The Boolean must be false if its setting is contained in the container to be hidden, + * because when saving, all missing constants are emptied, and toBool() converts empty to false. + */ + const C_BOOL_CUSTOM_CSS_LEGACY_ENABLE = "footnote_inputfield_custom_css_legacy_enable"; + + /** + * Settings Container Key to enable the 'the_title' hook. + * + * @author Stefan Herndler + * @since 1.5.5 + * @var str + */ + const C_BOOL_EXPERT_LOOKUP_THE_TITLE = "footnote_inputfield_expert_lookup_the_title"; + + /** + * Settings Container Key to enable the 'the_content' hook. + * + * @author Stefan Herndler + * @since 1.5.5 + * @var str + */ + const C_BOOL_EXPERT_LOOKUP_THE_CONTENT = "footnote_inputfield_expert_lookup_the_content"; + + /** + * Settings Container Key to enable the 'the_excerpt' hook. + * + * @author Stefan Herndler + * @since 1.5.5 + * @var str + */ + const C_BOOL_EXPERT_LOOKUP_THE_EXCERPT = "footnote_inputfield_expert_lookup_the_excerpt"; + + /** + * Settings Container Key to enable the 'widget_title' hook. + * + * @author Stefan Herndler + * @since 1.5.5 + * @var str + */ + const C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE = "footnote_inputfield_expert_lookup_widget_title"; + + /** + * Settings Container Key to enable the 'widget_text' hook. + * + * @author Stefan Herndler + * @since 1.5.5 + * @var str + */ + const C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT = "footnote_inputfield_expert_lookup_widget_text"; + + /** + * Settings Container Key for the label of the Read-on button in truncated tooltips. + * + * - Adding: Tooltips: Read-on button: Label: configurable instead of localizable, thanks to @rovanov example provision. + * + * @since 2.1.0 + * @date 2020-11-08T2106+0100 + * + * @reporter @rovanov + * @link https://wordpress.org/support/topic/offset-x-axis-and-offset-y-axis-does-not-working/ + * + * @var str + */ + const C_STR_FOOTNOTES_TOOLTIP_READON_LABEL = "footnote_inputfield_readon_label"; + + /** + * Settings Container Key for the referrer element. + * + * - Bugfix: Referrers: new setting for vertical align: superscript (default) or baseline (optional), thanks to @cwbayer bug report. + * + * @since 2.1.1 + * @date 2020-11-16T0859+0100 + * + * @reporter @cwbayer + * @link https://wordpress.org/support/topic/footnote-number-in-text-superscript-disrupts-leading/ + * + * @var str + */ + const C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS = "footnotes_inputfield_referrer_superscript_tags"; + + /** + * Settings Container Key to enable the display of a backlink symbol. + * + * - Bugfix: Reference container: Backlink symbol: make optional, not suggest configuring it to invisible, thanks to @spaceling feedback. + * + * @since 2.1.1 + * + * @reporter @spaceling + * @link https://wordpress.org/support/topic/change-the-position-5/page/2/#post-13671138 + * + * @var str + */ + const C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = "footnotes_inputfield_reference_container_backlink_symbol_enable"; + + /** + * Settings Container Key to not display the reference container on the homepage. + * + * - Bugfix: Reference container: fix start pages by making its display optional, thanks to @dragon013 bug report. + * + * @since 2.1.1 + * + * @reporter @dragon013 + * @link https://wordpress.org/support/topic/possible-to-hide-it-from-start-page/ + * + * @var str + */ + const C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE = "footnotes_inputfield_reference_container_start_page_enable"; + + /** + * Settings Container Key to enable the legacy layout of the reference container. + * + * - Bugfix: Reference container: option to restore pre-2.0.0 layout with the backlink symbol in an extra column. + * + * @since 2.1.1 + * @var str + */ + const C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = "footnotes_inputfield_reference_container_3column_layout_enable"; + + /** + * Settings Container Key to get the backlink symbol switch side. + * + * - Bugfix: Reference container: option to append symbol (prepended by default), thanks to @spaceling code contribution. + * + * @since 2.1.1 + * @date 2020-11-16T2024+0100 + * + * @contributor @spaceling + * @link https://wordpress.org/support/topic/change-the-position-5/#post-13615994 + * + * @var str + */ + const C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = "footnotes_inputfield_reference_container_backlink_symbol_switch"; + + /** + * Settings Container Key for 'the_content' hook priority level. + * + * @since 2.1.1 + * @date 2020-11-16T0859+0100 + * + * @var str + */ + const C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_content_priority_level"; + + /** + * Settings Container Key for '' hook priority level + * + * @since 2.1.2 + * @date 2020-11-20T0620+0100 + * + * @var str + */ + const C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_title_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"; + const C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_excerpt_priority_level"; + + /** + * Settings Container Keys for the link element option + * Settings Container Keys for backlink typography and layout + * Settings Container Keys for tooltip font size + * Settings Container Keys for page layout support + * Settings Container Keys for scroll offset and duration + * Settings Container Keys for tooltip display durations + * + * @since 2.1.4 + * @var str|bool|int|flo + * + * 2020-11-26T1002+0100 + * 2020-11-30T0427+0100 + * 2020-12-03T0501+0100 + * 2020-12-05T0425+0100 + */ + + // link element option: + const C_BOOL_LINK_ELEMENT_ENABLED = "footnote_inputfield_link_element_enabled"; + + // backlink typography: + const C_BOOL_BACKLINKS_SEPARATOR_ENABLED = "footnotes_inputfield_backlinks_separator_enabled"; + const C_STR_BACKLINKS_SEPARATOR_OPTION = "footnotes_inputfield_backlinks_separator_option"; + const C_STR_BACKLINKS_SEPARATOR_CUSTOM = "footnotes_inputfield_backlinks_separator_custom"; + const C_BOOL_BACKLINKS_TERMINATOR_ENABLED = "footnotes_inputfield_backlinks_terminator_enabled"; + const C_STR_BACKLINKS_TERMINATOR_OPTION = "footnotes_inputfield_backlinks_terminator_option"; + const C_STR_BACKLINKS_TERMINATOR_CUSTOM = "footnotes_inputfield_backlinks_terminator_custom"; + + // backlink layout: + const C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED = "footnotes_inputfield_backlinks_column_width_enabled"; + const C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR = "footnotes_inputfield_backlinks_column_width_scalar"; + const C_STR_BACKLINKS_COLUMN_WIDTH_UNIT = "footnotes_inputfield_backlinks_column_width_unit"; + const C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED = "footnotes_inputfield_backlinks_column_max_width_enabled"; + const C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR = "footnotes_inputfield_backlinks_column_max_width_scalar"; + const C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT = "footnotes_inputfield_backlinks_column_max_width_unit"; + const C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED = "footnotes_inputfield_backlinks_line_breaks_enabled"; + + // tooltip font size: + // called mouse over box not tooltip for consistency + const C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED = "footnotes_inputfield_mouse_over_box_font_size_enabled"; + const C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR = "footnotes_inputfield_mouse_over_box_font_size_scalar"; + const C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT = "footnotes_inputfield_mouse_over_box_font_size_unit"; + + // page layout support: + const C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT = "footnotes_inputfield_page_layout_support"; + + /** + * Scroll offset and duration + * + * - Bugfix: Scroll offset: make configurable to fix site-dependent issues related to fixed headers. + * - Bugfix: Scroll duration: make configurable to conform to website content and style requirements. + * + * @since 2.1.4 + * @date 2020-12-05T0538+0100 + */ + // scroll offset and duration: + const C_INT_FOOTNOTES_SCROLL_OFFSET = "footnotes_inputfield_scroll_offset"; + const C_INT_FOOTNOTES_SCROLL_DURATION = "footnotes_inputfield_scroll_duration"; + + // tooltip display durations: + // called mouse over box not tooltip for consistency + const C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY = "footnotes_inputfield_mouse_over_box_fade_in_delay"; + const C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION = "footnotes_inputfield_mouse_over_box_fade_in_duration"; + const C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY = "footnotes_inputfield_mouse_over_box_fade_out_delay"; + const C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION = "footnotes_inputfield_mouse_over_box_fade_out_duration"; + + /** + * Settings Container Key for URL wrap option + * + * This is made optional because it causes weird line breaks. + * Unicode-compliant browsers break URLs at slashes. + * + * @since 2.1.6 + * @var str + * + * 2020-12-09T1554+0100..2020-12-13T1313+0100 + */ + const C_BOOL_FOOTNOTE_URL_WRAP_ENABLED = "footnote_inputfield_url_wrap_enabled"; + + /** + * Settings Container Key for reference container position shortcode + * + * @since 2.2.0 + * @var str + * + * 2020-12-13T2056+0100 + */ + const C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE = "footnote_inputfield_reference_container_position_shortcode"; + + /** + * Settings Container Keys for alternative tooltip position + * Settings Container Keys for reference container label element, thanks to @markhillyer + * @link https://wordpress.org/support/topic/how-do-i-eliminate-the-horizontal-line-beneath-the-reference-container-heading/ + * + * @since 2.2.5 + * @var int + * + * 2020-12-17T0746+0100 + * 2020-12-18T1509+0100 + */ + const C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION = "footnotes_inputfield_alternative_mouse_over_box_position"; + const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X = "footnotes_inputfield_alternative_mouse_over_box_offset_x"; + const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y = "footnotes_inputfield_alternative_mouse_over_box_offset_y"; + const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH = "footnotes_inputfield_alternative_mouse_over_box_width"; + + const C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT = "footnotes_inputfield_reference_container_label_element"; + const C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER = "footnotes_inputfield_reference_container_label_bottom_border"; + + /** + * Settings Container Key for table cell borders, thanks to @noobishh + * @link https://wordpress.org/support/topic/borders-25/ + * + * @since 2.2.10 + * @var str + * + * 2020-12-25T2311+0100 + */ + const C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE = "footnotes_inputfield_reference_container_row_borders_enable"; + + /** + * Settings container keys for reference container top and bottom margins + * Settings container keys for hard link enabling + * Settings container keys for hard link anchors in referrers and footnotes + * + * @since 2.3.0 + * @var int|bool|str + * + * 2020-12-29T0914+0100 + */ + const C_INT_REFERENCE_CONTAINER_TOP_MARGIN = "footnotes_inputfield_reference_container_top_margin"; + const C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN = "footnotes_inputfield_reference_container_bottom_margin"; + const C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE = "footnotes_inputfield_hard_links_enable"; + const C_STR_REFERRER_FRAGMENT_ID_SLUG = "footnotes_inputfield_referrer_fragment_id_slug"; + const C_STR_FOOTNOTE_FRAGMENT_ID_SLUG = "footnotes_inputfield_footnote_fragment_id_slug"; + const C_STR_HARD_LINK_IDS_SEPARATOR = "footnotes_inputfield_hard_link_ids_separator"; + + /** + * Settings container key for shortcode syntax validation. + * + * @since 2.4.0 + * @date 2021-01-01T0616+0100 + * + * @var str + */ + const C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE = "footnotes_inputfield_shortcode_syntax_validation_enable"; + + /** + * Settings container key to enable backlink tooltips. + * + * - Update: Reference container: Hard backlinks (optional): optional configurable tooltip hinting to use the backbutton instead, thanks to @theroninjedi47 bug report. + * + * @since 2.5.4 + * + * @reporter @theroninjedi47 + * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ + * + * When hard links are enabled, clicks on the backlinks are logged in the browsing history, + * along with clicks on the referrers. + * This tooltip hints to use the backbutton instead, so the history gets streamlined again. + * @link https://wordpress.org/support/topic/making-it-amp-compatible/#post-13837359 + * + * @var str + */ + const C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE = "footnotes_inputfield_backlink_tooltip_enable"; + + /** + * Settings container key to configure the backlink tooltip. + * + * - Update: Reference container: Hard backlinks (optional): optional configurable tooltip hinting to use the backbutton instead, thanks to @theroninjedi47 bug report. + * + * @since 2.5.4 + * + * @reporter @theroninjedi47 + * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ + * + * @var str + */ + const C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT = "footnotes_inputfield_backlink_tooltip_text"; + + /** + * Settings container key to configure the tooltip excerpt delimiter. + * + * - Update: Tooltips: ability to display dedicated content before `[[/tooltip]]`, thanks to @jbj2199 issue report. + * + * The first implementation used a fixed shortcode provided in the changelog. + * But Footnotes’ UI design policy is to make shortcodes freely configurable. + * @since 2.5.4 + * + * @reporter @jbj2199 + * @link https://wordpress.org/support/topic/change-tooltip-text/ + * + * Tooltips can display another content than the footnote entry + * in the reference container. The trigger is a shortcode in + * the footnote text separating the tooltip text from the note. + * That is consistent with what WordPress does for excerpts. + * + * @var str + */ + const C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER = "footnotes_inputfield_tooltip_excerpt_delimiter"; + + /** + * Settings container key to enable mirroring the tooltip excerpt in the reference container. + * + * @since 2.5.4 + * @var str + * + * Tooltips, even jQuery-driven, may be hard to consult on mobiles. + * This option allows to read the tooltip content in the reference container too. + * @link https://wordpress.org/support/topic/change-tooltip-text/#post-13935050 + * But this must not be the default behavior. + * @link https://wordpress.org/support/topic/change-tooltip-text/#post-13935488 + */ + const C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE = "footnotes_inputfield_tooltip_excerpt_mirror_enable"; + + /** + * Settings container key to configure the tooltip excerpt separator in the reference container. + * + * @since 2.5.4 + * @var str + */ + const C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR = "footnotes_inputfield_tooltip_excerpt_mirror_separator"; + + /** + * Settings container key to enable superscript style normalization. + * + * -Bugfix: Referrers: optional fixes to vertical alignment, font size and position (static) for in-theme consistency and cross-theme stability, thanks to @tomturowski bug report. + * + * @since 2.5.4 + * + * @reporter @tomturowski + * @link https://wordpress.org/support/topic/in-line-superscript-ref-rides-to-high/ + * + * @var str + */ + const C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT = "footnotes_inputfield_referrers_normal_superscript"; + + + /** + * SETTINGS STORAGE + */ + + /** + * Stores a singleton reference of this class. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var MCI_Footnotes_Settings + */ + private static $a_obj_Instance = null; + + /** + * Contains all Settings Container names. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var array + * + * Edited: + * 2.2.2 added tab for Custom CSS 2020-12-15T0740+0100 + * + * These are the storage container names, one per dashboard tab. + */ + private $a_arr_Container = array( + "footnotes_storage", + "footnotes_storage_custom", + "footnotes_storage_expert", + "footnotes_storage_custom_css", + ); + + /** + * Contains all Default Settings for each Settings Container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var array + * + * Edited multiple times. + * + * @since 2.1.3 excerpt hook: disable by default, thanks to @nikelaos + * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13687068 + */ + private $a_arr_Default = array( + + "footnotes_storage" => array( + + self::C_STR_FOOTNOTES_SHORT_CODE_START => '((', + self::C_STR_FOOTNOTES_SHORT_CODE_END => '))', + self::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED => '', + self::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED => '', + + self::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE => 'yes', + + self::C_STR_FOOTNOTES_COUNTER_STYLE => 'arabic_plain', + self::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES => 'yes', + + self::C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE => 'no', + self::C_STR_REFERRER_FRAGMENT_ID_SLUG => 'r', + self::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG => 'f', + self::C_STR_HARD_LINK_IDS_SEPARATOR => '+', + self::C_INT_FOOTNOTES_SCROLL_OFFSET => 20, + self::C_INT_FOOTNOTES_SCROLL_DURATION => 380, + + // 2.5.4 fast-tracked: + self::C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE => 'yes', + self::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT => 'Alt+ ←', + + + self::C_STR_REFERENCE_CONTAINER_NAME => 'References', + self::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT => 'p', + self::C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER => 'yes', + self::C_BOOL_REFERENCE_CONTAINER_COLLAPSE => 'no', + + self::C_STR_REFERENCE_CONTAINER_POSITION => 'post_end', + self::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE => '[[references]]', + self::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE => 'yes', + + // whether to enqueue additional stylesheet: + self::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT => 'none', + + // top and bottom margins: + self::C_INT_REFERENCE_CONTAINER_TOP_MARGIN => 24, + self::C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN => 0, + + // table cell borders: + self::C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE => 'no', + + // backlink symbol: + self::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE => 'no', + self::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE => 'yes', + self::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH => 'no', + + // backlink separators and terminators are often not preferred. + // but a choice must be provided along with the ability to customize: + self::C_BOOL_BACKLINKS_SEPARATOR_ENABLED => 'yes', + self::C_STR_BACKLINKS_SEPARATOR_OPTION => 'comma', + self::C_STR_BACKLINKS_SEPARATOR_CUSTOM => '', + self::C_BOOL_BACKLINKS_TERMINATOR_ENABLED => 'no', + self::C_STR_BACKLINKS_TERMINATOR_OPTION => 'full_stop', + self::C_STR_BACKLINKS_TERMINATOR_CUSTOM => '', + + // set backlinks column width: + self::C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED => 'no', + self::C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR => '50', + self::C_STR_BACKLINKS_COLUMN_WIDTH_UNIT => 'px', + + // set backlinks column max. width: + self::C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED => 'no', + self::C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR => '140', + self::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT => 'px', + + // whether a
tag is inserted: + self::C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED => 'no', + + // whether to enable URL line wrapping: + self::C_BOOL_FOOTNOTE_URL_WRAP_ENABLED => 'yes', - // whether to use link elements: - self::C_BOOL_LINK_ELEMENT_ENABLED => 'yes', + // whether to use link elements: + self::C_BOOL_LINK_ELEMENT_ENABLED => 'yes', - // excerpt should be disabled: - self::C_BOOL_FOOTNOTES_IN_EXCERPT => 'no', + // excerpt should be disabled: + self::C_BOOL_FOOTNOTES_IN_EXCERPT => 'no', - self::C_BOOL_FOOTNOTES_EXPERT_MODE => 'yes', + self::C_BOOL_FOOTNOTES_EXPERT_MODE => 'yes', - self::C_STR_FOOTNOTES_LOVE => 'no', + self::C_STR_FOOTNOTES_LOVE => 'no', - ), + ), - "footnotes_storage_custom" => array( + "footnotes_storage_custom" => array( - self::C_STR_HYPERLINK_ARROW => '↑', - self::C_STR_HYPERLINK_ARROW_USER_DEFINED => '', + self::C_STR_HYPERLINK_ARROW => '↑', + self::C_STR_HYPERLINK_ARROW_USER_DEFINED => '', - self::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL => 'Continue reading', + self::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL => 'Continue reading', - self::C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS => 'yes', + self::C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS => 'yes', - self::C_STR_FOOTNOTES_STYLING_BEFORE => '[', - self::C_STR_FOOTNOTES_STYLING_AFTER => ']', + 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_ENABLED => 'yes', - self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE => 'no', + self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE => 'no', - // 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 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 truncation length is raised from 150 to 200 chars: + self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH => 200, - // 2.5.4 fast-tracked: - self::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER => '[[/tooltip]]', - self::C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE => 'no', - self::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR => ' — ', - self::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT => 'no', + // 2.5.4 fast-tracked: + self::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER => '[[/tooltip]]', + self::C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE => 'no', + self::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR => ' — ', + self::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT => 'no', - // 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', + // 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_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, - // The width should be limited to start with, for the box to have shape: - self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH => 450, + // The width should be limited to start with, for the box to have shape: + self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH => 450, - // fixed width is for alternative tooltips, cannot reuse max-width nor offsets: - self::C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION => 'top right', - self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X => -50, - self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y => 24, - self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH => 400, + // fixed width is for alternative tooltips, cannot reuse max-width nor offsets: + self::C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION => 'top right', + self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X => -50, + self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y => 24, + self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH => 400, - // tooltip display durations: - // called mouse over box not tooltip for consistency - self::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY => 0, - self::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION => 200, - self::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY => 400, - self::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION => 200, + // tooltip display durations: + // called mouse over box not tooltip for consistency + self::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY => 0, + self::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION => 200, + self::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY => 400, + self::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION => 200, - // tooltip font size reset to legacy by default since 2.1.4; - // was set to inherit since 2.1.1 as it overrode custom CSS, - // is moved to settings since 2.1.4 2020-12-04T1023+0100 - self::C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED => 'yes', - self::C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR => 13, - self::C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT => 'px', - - self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR => '', - // The mouse over box shouldn’t 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', + // tooltip font size reset to legacy by default since 2.1.4; + // was set to inherit since 2.1.1 as it overrode custom CSS, + // is moved to settings since 2.1.4 2020-12-04T1023+0100 + self::C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED => 'yes', + self::C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR => 13, + self::C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT => 'px', + + self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR => '', + // The mouse over box shouldn’t 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', - // The mouse over box corners mustn’t be rounded as that is outdated: - self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS => 0, - - self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR => '#666666', - - // Custom CSS migrates to a dedicated tab: - self::C_STR_CUSTOM_CSS => '', - - ), - - "footnotes_storage_expert" => array( - - // These are checkboxes; keyword 'checked' is converted to Boolean true, - // empty string to false (default): - - // Titles should all be enabled by default to prevent users from - // thinking at first that the feature is broken in post titles. - // See - // Yet in titles, footnotes are still buggy, because WordPress - // uses the title string in menus and in the title element. - self::C_BOOL_EXPERT_LOOKUP_THE_TITLE => '', - - self::C_BOOL_EXPERT_LOOKUP_THE_CONTENT => 'checked', - - // And the_excerpt is disabled by default following @nikelaos in - // - // - self::C_BOOL_EXPERT_LOOKUP_THE_EXCERPT => '', - - self::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE => '', - - // The widget_text hook must be disabled by default, because it causes - // multiple reference containers to appear in Elementor accordions, but - // it must be enabled if multiple reference containers are desired, as - // in Elementor toggles. - self::C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT => '', - - // initially hard-coded default - // shows "9223372036854780000" instead of 9223372036854775807 in the numbox - // empty should be interpreted as PHP_INT_MAX, but a numbox cannot be set to empty: - // - // interpret -1 as PHP_INT_MAX instead - self::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL => PHP_INT_MAX, - - // Priority level of the_content and of widget_text as the only relevant - // hooks must be less than 99 because social buttons may yield scripts - // that contain the strings '((' and '))', i.e. the default footnote - // start and end short codes, causing issues with fake footnotes. - self::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL => 98, - 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 => 98, - - ), - - "footnotes_storage_custom_css" => array( - - self::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE => 'yes', - self::C_STR_CUSTOM_CSS_NEW => '', - - ), - - ); - - /** - * Contains all Settings from each Settings container as soon as this class is initialized. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var array - */ - private $a_arr_Settings = array(); - - /** - * Class Constructor. Loads all Settings from each WordPress Settings container. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - private function __construct() { - $this->loadAll(); - } - - /** - * Returns a singleton of this class. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return MCI_Footnotes_Settings - */ - public static function instance() { - // no instance defined yet, load it - if (self::$a_obj_Instance === null) { - self::$a_obj_Instance = new self(); - } - // return a singleton of this class - return self::$a_obj_Instance; - } - - /** - * Returns the name of a specified Settings Container. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param int $p_int_Index Settings Container Array Key Index. - * @return str Settings Container name. - */ - public function getContainer($p_int_Index) { - return $this->a_arr_Container[$p_int_Index]; - } - - /** - * Returns the default values of a specific Settings Container. - * - * @author Stefan Herndler - * @since 1.5.6 - * @param int $p_int_Index Settings Container Aray Key Index. - * @return array - */ - public function getDefaults($p_int_Index) { - return $this->a_arr_Default[$this->a_arr_Container[$p_int_Index]]; - } - - /** - * Loads all Settings from each Settings container. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - private function loadAll() { - // clear current settings - $this->a_arr_Settings = array(); - for ($i = 0; $i < count($this->a_arr_Container); $i++) { - // load settings - $this->a_arr_Settings = array_merge($this->a_arr_Settings, $this->Load($i)); - } - } - - /** - * Loads all Settings from specified Settings Container. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param int $p_int_Index Settings Container Array Key Index. - * @return array Settings loaded from Container of Default Settings if Settings Container is empty (first usage). - * - * @since ditched trimming whitespace from text box content in response to user request. - * @link https://wordpress.org/support/topic/leading-space-in-footnotes-tag/#post-5347966 - */ - private function Load($p_int_Index) { - // load all settings from container - $l_arr_Options = get_option($this->getContainer($p_int_Index)); - // load all default settings - $l_arr_Default = $this->a_arr_Default[$this->getContainer($p_int_Index)]; - - // no settings found, set them to their default value - if (empty($l_arr_Options)) { - return $l_arr_Default; - } - // iterate through all available settings ( = default values) - foreach($l_arr_Default as $l_str_Key => $l_str_Value) { - // available setting not found in the container - if (!array_key_exists($l_str_Key, $l_arr_Options)) { - // define the setting with its default value - $l_arr_Options[$l_str_Key] = $l_str_Value; - } - } - // iterate through each setting in the container - foreach($l_arr_Options as $l_str_Key => $l_str_Value) { - // remove all whitespace at the beginning and end of a setting - // trimming whitespace is ditched: - //$l_str_Value = trim($l_str_Value); - // write the sanitized value back to the setting container - $l_arr_Options[$l_str_Key] = $l_str_Value; - } - // return settings loaded from Container - return $l_arr_Options; - } - - /** - * Updates a whole Settings container. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param int $p_int_Index Index of the Settings container. - * @param array $p_arr_newValues new Settings. - * @return bool - */ - public function saveOptions($p_int_Index, $p_arr_newValues) { - if (update_option($this->getContainer($p_int_Index), $p_arr_newValues)) { - $this->loadAll(); - return true; - } - return false; - } - - /** - * Returns the value of specified Settings name. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_Key Settings Array Key name. - * @return mixed Value of the Setting on Success or Null in Settings name is invalid. - */ - public function get($p_str_Key) { - return array_key_exists($p_str_Key, $this->a_arr_Settings) ? $this->a_arr_Settings[$p_str_Key] : null; - } - - /** - * Deletes each Settings Container and loads the default values for each Settings Container. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * Edit: This didn’t actually work. - * @since 2.2.0 this function is not called any longer when deleting the plugin, - * to protect user data against loss, since manually updating a plugin is safer - * done by deleting and reinstalling (see the warning about database backup). - * 2020-12-13T1353+0100 - */ - public function ClearAll() { - // iterate through each Settings Container - for ($i = 0; $i < count($this->a_arr_Container); $i++) { - // delete the settings container - delete_option($this->getContainer($i)); - } - // set settings back to the default values - $this->a_arr_Settings = $this->a_arr_Default; - } - - /** - * Register all Settings Container for the Plugin Settings Page in the Dashboard. - * Settings Container Label will be the same as the Settings Container Name. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function RegisterSettings() { - // register all settings - for ($i = 0; $i < count($this->a_arr_Container); $i++) { - register_setting($this->getContainer($i), $this->getContainer($i)); - } - } + // The mouse over box corners mustn’t be rounded as that is outdated: + self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS => 0, + + self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR => '#666666', + + // Custom CSS migrates to a dedicated tab: + self::C_STR_CUSTOM_CSS => '', + + ), + + "footnotes_storage_expert" => array( + + // These are checkboxes; keyword 'checked' is converted to Boolean true, + // empty string to false (default): + + // Titles should all be enabled by default to prevent users from + // thinking at first that the feature is broken in post titles. + // See + // Yet in titles, footnotes are still buggy, because WordPress + // uses the title string in menus and in the title element. + self::C_BOOL_EXPERT_LOOKUP_THE_TITLE => '', + + self::C_BOOL_EXPERT_LOOKUP_THE_CONTENT => 'checked', + + // And the_excerpt is disabled by default following @nikelaos in + // + // + self::C_BOOL_EXPERT_LOOKUP_THE_EXCERPT => '', + + self::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE => '', + + // The widget_text hook must be disabled by default, because it causes + // multiple reference containers to appear in Elementor accordions, but + // it must be enabled if multiple reference containers are desired, as + // in Elementor toggles. + self::C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT => '', + + // initially hard-coded default + // shows "9223372036854780000" instead of 9223372036854775807 in the numbox + // empty should be interpreted as PHP_INT_MAX, but a numbox cannot be set to empty: + // + // interpret -1 as PHP_INT_MAX instead + self::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL => PHP_INT_MAX, + + // Priority level of the_content and of widget_text as the only relevant + // hooks must be less than 99 because social buttons may yield scripts + // that contain the strings '((' and '))', i.e. the default footnote + // start and end short codes, causing issues with fake footnotes. + self::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL => 98, + 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 => 98, + + ), + + "footnotes_storage_custom_css" => array( + + self::C_BOOL_CUSTOM_CSS_LEGACY_ENABLE => 'yes', + self::C_STR_CUSTOM_CSS_NEW => '', + + ), + + ); + + /** + * Contains all Settings from each Settings container as soon as this class is initialized. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var array + */ + private $a_arr_Settings = array(); + + /** + * Class Constructor. Loads all Settings from each WordPress Settings container. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function __construct() { + $this->loadAll(); + } + + /** + * Returns a singleton of this class. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return MCI_Footnotes_Settings + */ + public static function instance() { + // no instance defined yet, load it + if (self::$a_obj_Instance === null) { + self::$a_obj_Instance = new self(); + } + // return a singleton of this class + return self::$a_obj_Instance; + } + + /** + * Returns the name of a specified Settings Container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param int $p_int_Index Settings Container Array Key Index. + * @return str Settings Container name. + */ + public function getContainer($p_int_Index) { + return $this->a_arr_Container[$p_int_Index]; + } + + /** + * Returns the default values of a specific Settings Container. + * + * @author Stefan Herndler + * @since 1.5.6 + * @param int $p_int_Index Settings Container Aray Key Index. + * @return array + */ + public function getDefaults($p_int_Index) { + return $this->a_arr_Default[$this->a_arr_Container[$p_int_Index]]; + } + + /** + * Loads all Settings from each Settings container. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function loadAll() { + // clear current settings + $this->a_arr_Settings = array(); + for ($i = 0; $i < count($this->a_arr_Container); $i++) { + // load settings + $this->a_arr_Settings = array_merge($this->a_arr_Settings, $this->Load($i)); + } + } + + /** + * Loads all Settings from specified Settings Container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param int $p_int_Index Settings Container Array Key Index. + * @return array Settings loaded from Container of Default Settings if Settings Container is empty (first usage). + * + * @since ditched trimming whitespace from text box content in response to user request. + * @link https://wordpress.org/support/topic/leading-space-in-footnotes-tag/#post-5347966 + */ + private function Load($p_int_Index) { + // load all settings from container + $l_arr_Options = get_option($this->getContainer($p_int_Index)); + // load all default settings + $l_arr_Default = $this->a_arr_Default[$this->getContainer($p_int_Index)]; + + // no settings found, set them to their default value + if (empty($l_arr_Options)) { + return $l_arr_Default; + } + // iterate through all available settings ( = default values) + foreach($l_arr_Default as $l_str_Key => $l_str_Value) { + // available setting not found in the container + if (!array_key_exists($l_str_Key, $l_arr_Options)) { + // define the setting with its default value + $l_arr_Options[$l_str_Key] = $l_str_Value; + } + } + // iterate through each setting in the container + foreach($l_arr_Options as $l_str_Key => $l_str_Value) { + // remove all whitespace at the beginning and end of a setting + // trimming whitespace is ditched: + //$l_str_Value = trim($l_str_Value); + // write the sanitized value back to the setting container + $l_arr_Options[$l_str_Key] = $l_str_Value; + } + // return settings loaded from Container + return $l_arr_Options; + } + + /** + * Updates a whole Settings container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param int $p_int_Index Index of the Settings container. + * @param array $p_arr_newValues new Settings. + * @return bool + */ + public function saveOptions($p_int_Index, $p_arr_newValues) { + if (update_option($this->getContainer($p_int_Index), $p_arr_newValues)) { + $this->loadAll(); + return true; + } + return false; + } + + /** + * Returns the value of specified Settings name. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Key Settings Array Key name. + * @return mixed Value of the Setting on Success or Null in Settings name is invalid. + */ + public function get($p_str_Key) { + return array_key_exists($p_str_Key, $this->a_arr_Settings) ? $this->a_arr_Settings[$p_str_Key] : null; + } + + /** + * Deletes each Settings Container and loads the default values for each Settings Container. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * Edit: This didn’t actually work. + * @since 2.2.0 this function is not called any longer when deleting the plugin, + * to protect user data against loss, since manually updating a plugin is safer + * done by deleting and reinstalling (see the warning about database backup). + * 2020-12-13T1353+0100 + */ + public function ClearAll() { + // iterate through each Settings Container + for ($i = 0; $i < count($this->a_arr_Container); $i++) { + // delete the settings container + delete_option($this->getContainer($i)); + } + // set settings back to the default values + $this->a_arr_Settings = $this->a_arr_Default; + } + + /** + * Register all Settings Container for the Plugin Settings Page in the Dashboard. + * Settings Container Label will be the same as the Settings Container Name. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function RegisterSettings() { + // register all settings + for ($i = 0; $i < count($this->a_arr_Container); $i++) { + register_setting($this->getContainer($i), $this->getContainer($i)); + } + } } diff --git a/class/task.php b/class/task.php index 9389d9c..11d8c52 100644 --- a/class/task.php +++ b/class/task.php @@ -7,7 +7,7 @@ * @since 1.5.0 * * - * @lastmodified 2021-02-17T1754+0100 + * @lastmodified 2021-02-18T2023+0100 * * @since 2.0.0 Bugfix: various. * @since 2.0.4 Bugfix: Referrers and backlinks: remove hard links to streamline browsing history, thanks to @theroninjedi47 bug report. @@ -93,2185 +93,2185 @@ defined( 'ABSPATH' ) or die; */ class MCI_Footnotes_Task { - /** - * PROPERTIES - */ - - /** - * Contains all footnotes found on current public page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var array - */ - public static $a_arr_Footnotes = array(); - - /** - * 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; - - /** - * Prefix for the Footnote html element ID. - * - * @author Stefan Herndler - * @since 1.5.8 - * @var string - */ - public static $a_str_Prefix = ""; - - /** - * Infinite scroll / autoload or archive view - * - * - Bugfix: Infinite scroll: debug autoload by adding post ID, thanks to @docteurfitness code contribution - * - * @since 2.0.6 - * @var int - * - * @contributor @docteurfitness - * @link https://wordpress.org/support/topic/auto-load-post-compatibility-update/#post-13618833 - * - * @reporter @docteurfitness - * @link https://wordpress.org/support/topic/auto-load-post-compatibility-update/ - * - * As multiple posts are appended to each other, functions and fragment IDs must be disambiguated. - * post ID to make everything unique wrt infinite scroll and archive view: - */ - public static $a_int_PostId = 0; - - /** - * Multiple reference containers in content and widgets - * - * - Bugfix: Reference container, widget_text hook: support for multiple containers in a page, thanks to @justbecuz bug report. - * - * @since 2.2.9 - * @date 2020-12-25T0338+0100 - * - * @reporter @justbecuz - * @link https://wordpress.org/support/topic/reset-footnotes-to-1/ - * @link https://wordpress.org/support/topic/reset-footnotes-to-1/#post-13662830 - * - * @var int 1; incremented each time after a reference container is inserted - * - * This ID disambiguates multiple reference containers in a page - * as they may occur when the widget_text hook is active and the page - * is built with Elementor and has an accordion or similar toggle sections. - */ - public static $a_int_ReferenceContainerId = 1; - - /** - * Template process optimization - * - * - Bugfix: Templates: optimize template load and processing based on settings, thanks to @misfist code contribution. - * - * @since 2.4.0 - * @date 2021-01-04T1355+0100 - * - * @author Patrizia Lutz @misfist - * - * @link https://wordpress.org/support/topic/template-override-filter/#post-13864301 - * @link https://github.com/misfist/footnotes/releases/tag/2.4.0d3 repository - * @link https://github.com/misfist/footnotes/compare/2.4.0%E2%80%A62.4.0d3 diff - * - * @var bool - * - * Streamline process depending on tooltip enabled status. - * Load tooltip inline script only if jQuery tooltips are enabled. - * Actual value depends on settings. - */ - public static $a_bool_TooltipsEnabled = false; - public static $a_bool_AlternativeTooltipsEnabled = false; - - /** - * Hard links for AMP compatibility - * - * @since 2.0.0 Bugfix: footnote links script independent. - * - * - * - Bugfix: Referrers and backlinks: remove hard links to streamline browsing history, thanks to @theroninjedi47 bug report. - * - * @since 2.0.4 - * - * @reporter @theroninjedi47 - * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ - * - * - * - Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro bug report, thanks to @martinneumannat code contribution. - * - * @since 2.3.0 - * @var bool|str|int - * - * @contributor @martinneumannat - * @link https://wordpress.org/support/topic/making-it-amp-compatible/ - * - * @reporter @psykonevro - * @link https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/ - * - * The official AMP plugin strips off JavaScript, breaking Footnotes’ - * animated scrolling. - */ - public static $a_bool_HardLinksEnable = false; - public static $a_str_ReferrerLinkSlug = 'r'; - public static $a_str_FootnoteLinkSlug = 'f'; - public static $a_str_LinkIdsSeparator = '+'; - public static $a_str_PostContainerIdCompound = ''; - - /** - * Scroll offset - * - * - Bugfix: Scroll offset: make configurable to fix site-dependent issues related to fixed headers. - * - * @since 2.1.4 - * @date 2020-12-05T0538+0100 - * - * - * - Bugfix: Scroll offset: initialize to safer one third window height for more robustness, thanks to @lukashuggenberg bug report. - * - * @since 2.4.0 - * @date 2021-01-03T2055+0100 - * @date 2021-01-04T0504+0100 - * - * @reporter @lukashuggenberg - * @link https://wordpress.org/support/topic/2-2-6-breaks-all-footnotes/#post-13857922 - * - * @var int - * - * Websites may use high fixed headers not contracting at scroll. - * Scroll offset may now need to get into inline CSS. - * Hence it needs to be loaded twice, because priority levels may not match. - */ - public static $a_int_ScrollOffset = 34; - - /** - * Optional link element for footnote referrers and backlinks - * - * @since 2.0.0 add link elements along with hard links. - * - * - * - Bugfix: Referrers and backlinks: Styling: make link elements optional to fix issues, thanks to @docteurfitness issue report and code contribution. - * - * @since 2.1.4 - * @date 2020-11-25T1306+0100 - * @date 2020-11-26T1051+0100 - * - * @contributor @docteurfitness - * @link https://wordpress.org/support/topic/update-2-1-3/#post-13704194 - * - * @reporter @docteurfitness - * @link https://wordpress.org/support/topic/update-2-1-3/ - * - * - * - Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro bug report, thanks to @martinneumannat code contribution. - * - * @since 2.3.0 - * @date 2020-12-30T2313+0100 - * - * @contributor @martinneumannat - * @link https://wordpress.org/support/topic/making-it-amp-compatible/ - * - * @reporter @psykonevro - * @link https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/ - * - * 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. - * - * Link elements raise concerns, so that mitigating their proliferation may be desired. - * - * By contrast, due to an insufficiency in the CSS standard, coloring elements with the - * theme’s link color requires real link elements and cannot be done with named colors, - * as CSS does not support 'color: link|hover|active|visited', after the pseudo-classes - * of the link element. - * - * Yet styling these elements with the link color is not universally preferred, so that - * the very presence of these link elements may need to be avoided. - * - * @see self::$a_bool_HardLinksEnable - */ - public static $a_str_LinkSpan = 'span'; - public static $a_str_LinkOpenTag = ''; - public static $a_str_LinkCloseTag = ''; - - /** - * Dedicated tooltip text - * - * - Update: Tooltips: ability to display dedicated content before `[[/tooltip]]`, thanks to @jbj2199 issue report. - * - * @since 2.5.2 - * @date 2021-01-19T2223+0100 - * - * @reporter @jbj2199 - * @link https://wordpress.org/support/topic/change-tooltip-text/ - * - * Tooltips can display another content than the footnote entry - * in the reference container. The trigger is a shortcode in - * the footnote text separating the tooltip text from the note. - * That is consistent with what WordPress does for excerpts. - */ - public static $a_bool_MirrorTooltipText = false; - public static $a_str_TooltipShortcode = '[[/tooltip]]'; - public static $a_int_TooltipShortcodeLength = 12; - - /** - * Footnote delimiter syntax validation - * - * - Adding: Footnote delimiters: syntax validation for balanced footnote start and end tag short codes. - * - * @since 2.4.0 - * @date 2021-01-01T0227+0100 - * - * @var bool - * - * The algorithm first checks for balanced footnote opening and closing tag short codes. - * The first encountered error triggers the display of a warning below the post title. - * - * Unbalanced short codes have caused significant trouble because they are hard to detect. - * Any compiler or other tool reports syntax errors in the first place. Footnotes’ exception - * is considered a design flaw, and the feature is released as a bug fix after overdue 2.3.0 - * released in urgency to provide AMP compat before 2021. - */ - public static $a_bool_SyntaxErrorFlag = true; - - - - /** - * METHODS - */ - - /** - * Register WordPress Hooks to replace Footnotes in the content of a public page. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * @since 1.5.4 Adding: Hooks: support 'the_post' in response to user request for custom post types. - * @since 2.0.5 Bugfix: Reference container: fix relative position through priority level, thanks to @june01 @imeson @spaceling bug reports, thanks to @spaceling code contribution. - * @since 2.0.5 Update: Hooks: Default-enable all hooks to prevent footnotes from seeming broken in some parts. - * @since 2.0.6 Bugfix: Priority level back to PHP_INT_MAX (ref container positioning not this plugin’s responsibility). - * @since 2.0.7 BUGFIX: Hooks: Default-disable 'the_post', thanks to @spaceling @markcheret @nyamachi @whichgodsaves @spiralofhope2 @mmallett @andreasra @widecast @ymorin007 @tashi1es bug reports. - * @since 2.0.7 Bugfix: Set priority level back to 10 assuming it is unproblematic 2020-11-06T1344+0100. - * @since 2.0.8 Bugfix: Priority level back to PHP_INT_MAX (need to get in touch with other plugins). - * @since 2.1.0 UPDATE: Hooks: remove 'the_post', the plugin stops supporting this hook. - * @since 2.1.1 Bugfix: Dashboard: priority level setting for the_content hook, thanks to @imeson bug report. - * @since 2.1.2 Bugfix: Dashboard: priority level settings for all other hooks, thanks to @nikelaos bug report. - * @since 2.5.0 Bugfix: Hooks: support footnotes on category pages, thanks to @vitaefit bug report, thanks to @misfist code contribution. - * @since 2.5.1 Bugfix: Hooks: support footnotes in Popup Maker popups, thanks to @squatcher bug report. - */ - public function registerHooks() { - - /** - * Priority levels - * - * - Bugfix: Reference container: fix relative position through priority level, thanks to @june01 @imeson @spaceling bug reports, thanks to @spaceling code contribution. - * - * @since 2.0.5 - * @date 2020-11-02T0330+0100 - * @link https://codex.wordpress.org/Plugin_API/#Hook_in_your_Filter - * - * @contributor @spaceling - * @link https://wordpress.org/support/topic/change-the-position-5/#post-13608594 - * - * @reporter @june01 - * @link https://wordpress.org/support/topic/change-the-position-5/ - * - * @reporter @imeson - * @link https://wordpress.org/support/topic/change-the-position-5/#post-13538345 - * - * - * - Bugfix: Dashboard: priority level setting for the_content hook, thanks to @imeson bug report. - * - * @since 2.1.1 - * @date 2020-11-17T0254+0100 - * - * @reporter @imeson - * @link https://wordpress.org/support/topic/change-the-position-5/#post-13538345 - * - * - * - Bugfix: Dashboard: priority level settings for all other hooks, thanks to @nikelaos bug report. - * - * @since 2.1.2 - * @date 2020-11-19T1849+0100 - * - * @reporter @nikelaos - * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13676705 - * - * - * Setting the_content priority to 10 instead of PHP_INT_MAX i.e. 9223372036854775807 - * 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. - * - * For YARPP to display related posts below the Footnotes reference container, - * priority needs to be at least 1200 (i.e. 0 =< $l_int_TheContentPriority =< 1200). - * - * 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. - * @link https://github.com/Modernizr/Modernizr/issues/171 - */ - - // get values from settings: - $l_int_TheTitlePriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL)); - $l_int_TheContentPriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL)); - $l_int_TheExcerptPriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL)); - $l_int_WidgetTitlePriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL)); - $l_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: - $l_int_TheTitlePriority = ($l_int_TheTitlePriority == -1) ? PHP_INT_MAX : $l_int_TheTitlePriority ; - $l_int_TheContentPriority = ($l_int_TheContentPriority == -1) ? PHP_INT_MAX : $l_int_TheContentPriority ; - $l_int_TheExcerptPriority = ($l_int_TheExcerptPriority == -1) ? PHP_INT_MAX : $l_int_TheExcerptPriority ; - $l_int_WidgetTitlePriority = ($l_int_WidgetTitlePriority == -1) ? PHP_INT_MAX : $l_int_WidgetTitlePriority; - $l_int_WidgetTextPriority = ($l_int_WidgetTextPriority == -1) ? PHP_INT_MAX : $l_int_WidgetTextPriority ; - - - // append custom css to the header - add_filter('wp_head', array($this, "wp_head"), PHP_INT_MAX); - - // append the love and share me slug to the footer - 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"), $l_int_TheTitlePriority); - } - - // configurable priority level for reference container relative positioning; default 98: - 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"), $l_int_TheContentPriority); - - /** - * Hook for category pages - * - * - Bugfix: Hooks: support footnotes on category pages, thanks to @vitaefit bug report, thanks to @misfist code contribution. - * - * @since 2.5.0 - * @date 2021-01-05T1402+0100 - * - * @contributor @misfist - * @link https://wordpress.org/support/topic/footnote-doesntwork-on-category-page/#post-13864859 - * - * @reporter @vitaefit - * @link https://wordpress.org/support/topic/footnote-doesntwork-on-category-page/ - * - * Category pages can have rich HTML content in a term description with article status. - * For this to happen, WordPress’ built-in partial HTML blocker needs to be disabled. - * @link https://docs.woocommerce.com/document/allow-html-in-term-category-tag-descriptions/ - */ - add_filter('term_description', array($this, "the_content"), $l_int_TheContentPriority); - - /** - * Hook for popup maker popups - * - * - Bugfix: Hooks: support footnotes in Popup Maker popups, thanks to @squatcher bug report. - * - * @since 2.5.1 - * @date 2021-01-18T2038+0100 - * - * @reporter @squatcher - * @link https://wordpress.org/support/topic/footnotes-use-in-popup-maker/ - */ - add_filter('pum_popup_content', array($this, "the_content"), $l_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"), $l_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"), $l_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"), $l_int_WidgetTextPriority); - } - - - /** - * The the_post hook - * - * - Adding: Hooks: support 'the_post' in response to user request for custom post types. - * - * @since 1.5.4 - * @accountable @aricura - * @link https://wordpress.org/support/topic/doesnt-work-in-custon-post-types/#post-5339110 - * - * - * - Update: Hooks: Default-enable all hooks to prevent footnotes from seeming broken in some parts. - * - * @since 2.0.5 - * @accountable @pewgeuges - * - * - * - BUGFIX: Hooks: Default-disable 'the_post', thanks to @spaceling @markcheret @nyamachi @whichgodsaves @spiralofhope2 @mmallett @andreasra @widecast @ymorin007 @tashi1es bug reports. - * - * @since 2.0.7 - * @accountable @pewgeuges - * @link https://wordpress.org/support/topic/change-the-position-5/page/2/#post-13630114 - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/#post-13630303 - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/page/2/#post-13630799 - * @link https://wordpress.org/support/topic/no-footnotes-anymore/#post-13813233 - * - * @reporter @spaceling - * @link https://wordpress.org/support/topic/change-the-position-5/#post-13612697 - * - * @reporter @markcheret on behalf of W. Beinert - * @link https://wordpress.org/support/topic/footnotes-now-appear-in-summaries-even-though-this-is-marked-no/ - * - * @reporter @nyamachi - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/ - * - * @reporter @whichgodsaves - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/#post-13622694 - * - * @reporter @spiralofhope2 - * @link https://wordpress.org/support/topic/2-0-5-broken/ - * - * @reporter @mmallett - * @link https://wordpress.org/support/topic/2-0-5-broken/#post-13623208 - * - * @reporter @andreasra - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/#post-13624091 - * - * @reporter @widecast - * @link https://wordpress.org/support/topic/2-0-5-broken/#post-13626222 - * - * @reporter @ymorin007 - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/#post-13627050 - * - * @reporter @markcheret on behalf of L. Smith - * @link https://wordpress.org/support/topic/footnotes-appear-in-random-places-on-academic-website/ - * - * @reporter @tashi1es - * @link https://wordpress.org/support/topic/footnotes-appear-in-random-places-on-academic-website/#post-13630495 - * - * - * - UPDATE: Hooks: remove 'the_post', the plugin stops supporting this hook. - * - * @since 2.1.0 - * @date 2020-11-08T1839+0100 - * @accountable @pewgeuges - */ - - // reset stored footnotes when displaying the header - self::$a_arr_Footnotes = array(); - self::$a_bool_AllowLoveMe = true; - } - - /** - * Outputs the custom css to the header of the public page. - * - * @author Stefan Herndler - * @since 1.5.0 - * - * - * @since 2.1.1 Bugfix: Reference container: fix start pages by making its display optional, thanks to @dragon013 bug report. - * @since 2.1.1 Bugfix: Tooltips: optional alternative JS implementation with CSS transitions to fix configuration-related outage, thanks to @andreasra feedback. - * @since 2.1.3 raise settings priority to override theme stylesheets - * @since 2.1.4 Bugfix: Tooltips: Styling: fix font size issue by adding font size to settings with legacy as default. - * @since 2.1.4 Bugfix: Reference container: fix layout issues by moving backlink column width to settings. - * @since 2.2.5 Bugfix: Reference container: Label: make bottom border an option, thanks to @markhillyer issue report. - * @since 2.2.5 Bugfix: Reference container: Label: option to select paragraph or heading element, thanks to @markhillyer issue report. - * @since 2.3.0 Bugfix: Reference container: convert top padding to margin and make it a setting, thanks to @hamshe bug report. - * @since 2.5.4 Bugfix: Referrers: optional fixes to vertical alignment, font size and position (static) for in-theme consistency and cross-theme stability, thanks to @tomturowski bug report. - */ - public function wp_head() { - - // insert start tag without switching out of PHP: - echo "\r\n\r\n"; - - /** - * Alternative tooltip implementation relying on plain JS and CSS transitions. - * - * - Bugfix: Tooltips: optional alternative JS implementation with CSS transitions to fix configuration-related outage, thanks to @andreasra feedback. - * - * @since 2.1.1 - * - * @reporter @andreasra - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/page/2/#post-13632566 - * - * The script for alternative tooltips is printed formatted, not minified: - */ - if ( self::$a_bool_AlternativeTooltipsEnabled ) { - ?> + /** + * PROPERTIES + */ + + /** + * Contains all footnotes found on current public page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var array + */ + public static $a_arr_Footnotes = array(); + + /** + * 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; + + /** + * Prefix for the Footnote html element ID. + * + * @author Stefan Herndler + * @since 1.5.8 + * @var string + */ + public static $a_str_Prefix = ""; + + /** + * Infinite scroll / autoload or archive view + * + * - Bugfix: Infinite scroll: debug autoload by adding post ID, thanks to @docteurfitness code contribution + * + * @since 2.0.6 + * @var int + * + * @contributor @docteurfitness + * @link https://wordpress.org/support/topic/auto-load-post-compatibility-update/#post-13618833 + * + * @reporter @docteurfitness + * @link https://wordpress.org/support/topic/auto-load-post-compatibility-update/ + * + * As multiple posts are appended to each other, functions and fragment IDs must be disambiguated. + * post ID to make everything unique wrt infinite scroll and archive view: + */ + public static $a_int_PostId = 0; + + /** + * Multiple reference containers in content and widgets + * + * - Bugfix: Reference container, widget_text hook: support for multiple containers in a page, thanks to @justbecuz bug report. + * + * @since 2.2.9 + * @date 2020-12-25T0338+0100 + * + * @reporter @justbecuz + * @link https://wordpress.org/support/topic/reset-footnotes-to-1/ + * @link https://wordpress.org/support/topic/reset-footnotes-to-1/#post-13662830 + * + * @var int 1; incremented each time after a reference container is inserted + * + * This ID disambiguates multiple reference containers in a page + * as they may occur when the widget_text hook is active and the page + * is built with Elementor and has an accordion or similar toggle sections. + */ + public static $a_int_ReferenceContainerId = 1; + + /** + * Template process optimization + * + * - Bugfix: Templates: optimize template load and processing based on settings, thanks to @misfist code contribution. + * + * @since 2.4.0 + * @date 2021-01-04T1355+0100 + * + * @author Patrizia Lutz @misfist + * + * @link https://wordpress.org/support/topic/template-override-filter/#post-13864301 + * @link https://github.com/misfist/footnotes/releases/tag/2.4.0d3 repository + * @link https://github.com/misfist/footnotes/compare/2.4.0%E2%80%A62.4.0d3 diff + * + * @var bool + * + * Streamline process depending on tooltip enabled status. + * Load tooltip inline script only if jQuery tooltips are enabled. + * Actual value depends on settings. + */ + public static $a_bool_TooltipsEnabled = false; + public static $a_bool_AlternativeTooltipsEnabled = false; + + /** + * Hard links for AMP compatibility + * + * @since 2.0.0 Bugfix: footnote links script independent. + * + * + * - Bugfix: Referrers and backlinks: remove hard links to streamline browsing history, thanks to @theroninjedi47 bug report. + * + * @since 2.0.4 + * + * @reporter @theroninjedi47 + * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ + * + * + * - Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro bug report, thanks to @martinneumannat code contribution. + * + * @since 2.3.0 + * @var bool|str|int + * + * @contributor @martinneumannat + * @link https://wordpress.org/support/topic/making-it-amp-compatible/ + * + * @reporter @psykonevro + * @link https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/ + * + * The official AMP plugin strips off JavaScript, breaking Footnotes’ + * animated scrolling. + */ + public static $a_bool_HardLinksEnable = false; + public static $a_str_ReferrerLinkSlug = 'r'; + public static $a_str_FootnoteLinkSlug = 'f'; + public static $a_str_LinkIdsSeparator = '+'; + public static $a_str_PostContainerIdCompound = ''; + + /** + * Scroll offset + * + * - Bugfix: Scroll offset: make configurable to fix site-dependent issues related to fixed headers. + * + * @since 2.1.4 + * @date 2020-12-05T0538+0100 + * + * + * - Bugfix: Scroll offset: initialize to safer one third window height for more robustness, thanks to @lukashuggenberg bug report. + * + * @since 2.4.0 + * @date 2021-01-03T2055+0100 + * @date 2021-01-04T0504+0100 + * + * @reporter @lukashuggenberg + * @link https://wordpress.org/support/topic/2-2-6-breaks-all-footnotes/#post-13857922 + * + * @var int + * + * Websites may use high fixed headers not contracting at scroll. + * Scroll offset may now need to get into inline CSS. + * Hence it needs to be loaded twice, because priority levels may not match. + */ + public static $a_int_ScrollOffset = 34; + + /** + * Optional link element for footnote referrers and backlinks + * + * @since 2.0.0 add link elements along with hard links. + * + * + * - Bugfix: Referrers and backlinks: Styling: make link elements optional to fix issues, thanks to @docteurfitness issue report and code contribution. + * + * @since 2.1.4 + * @date 2020-11-25T1306+0100 + * @date 2020-11-26T1051+0100 + * + * @contributor @docteurfitness + * @link https://wordpress.org/support/topic/update-2-1-3/#post-13704194 + * + * @reporter @docteurfitness + * @link https://wordpress.org/support/topic/update-2-1-3/ + * + * + * - Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro bug report, thanks to @martinneumannat code contribution. + * + * @since 2.3.0 + * @date 2020-12-30T2313+0100 + * + * @contributor @martinneumannat + * @link https://wordpress.org/support/topic/making-it-amp-compatible/ + * + * @reporter @psykonevro + * @link https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/ + * + * 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. + * + * Link elements raise concerns, so that mitigating their proliferation may be desired. + * + * By contrast, due to an insufficiency in the CSS standard, coloring elements with the + * theme’s link color requires real link elements and cannot be done with named colors, + * as CSS does not support 'color: link|hover|active|visited', after the pseudo-classes + * of the link element. + * + * Yet styling these elements with the link color is not universally preferred, so that + * the very presence of these link elements may need to be avoided. + * + * @see self::$a_bool_HardLinksEnable + */ + public static $a_str_LinkSpan = 'span'; + public static $a_str_LinkOpenTag = ''; + public static $a_str_LinkCloseTag = ''; + + /** + * Dedicated tooltip text + * + * - Update: Tooltips: ability to display dedicated content before `[[/tooltip]]`, thanks to @jbj2199 issue report. + * + * @since 2.5.2 + * @date 2021-01-19T2223+0100 + * + * @reporter @jbj2199 + * @link https://wordpress.org/support/topic/change-tooltip-text/ + * + * Tooltips can display another content than the footnote entry + * in the reference container. The trigger is a shortcode in + * the footnote text separating the tooltip text from the note. + * That is consistent with what WordPress does for excerpts. + */ + public static $a_bool_MirrorTooltipText = false; + public static $a_str_TooltipShortcode = '[[/tooltip]]'; + public static $a_int_TooltipShortcodeLength = 12; + + /** + * Footnote delimiter syntax validation + * + * - Adding: Footnote delimiters: syntax validation for balanced footnote start and end tag short codes. + * + * @since 2.4.0 + * @date 2021-01-01T0227+0100 + * + * @var bool + * + * The algorithm first checks for balanced footnote opening and closing tag short codes. + * The first encountered error triggers the display of a warning below the post title. + * + * Unbalanced short codes have caused significant trouble because they are hard to detect. + * Any compiler or other tool reports syntax errors in the first place. Footnotes’ exception + * is considered a design flaw, and the feature is released as a bug fix after overdue 2.3.0 + * released in urgency to provide AMP compat before 2021. + */ + public static $a_bool_SyntaxErrorFlag = true; + + + + /** + * METHODS + */ + + /** + * Register WordPress Hooks to replace Footnotes in the content of a public page. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * @since 1.5.4 Adding: Hooks: support 'the_post' in response to user request for custom post types. + * @since 2.0.5 Bugfix: Reference container: fix relative position through priority level, thanks to @june01 @imeson @spaceling bug reports, thanks to @spaceling code contribution. + * @since 2.0.5 Update: Hooks: Default-enable all hooks to prevent footnotes from seeming broken in some parts. + * @since 2.0.6 Bugfix: Priority level back to PHP_INT_MAX (ref container positioning not this plugin’s responsibility). + * @since 2.0.7 BUGFIX: Hooks: Default-disable 'the_post', thanks to @spaceling @markcheret @nyamachi @whichgodsaves @spiralofhope2 @mmallett @andreasra @widecast @ymorin007 @tashi1es bug reports. + * @since 2.0.7 Bugfix: Set priority level back to 10 assuming it is unproblematic 2020-11-06T1344+0100. + * @since 2.0.8 Bugfix: Priority level back to PHP_INT_MAX (need to get in touch with other plugins). + * @since 2.1.0 UPDATE: Hooks: remove 'the_post', the plugin stops supporting this hook. + * @since 2.1.1 Bugfix: Dashboard: priority level setting for the_content hook, thanks to @imeson bug report. + * @since 2.1.2 Bugfix: Dashboard: priority level settings for all other hooks, thanks to @nikelaos bug report. + * @since 2.5.0 Bugfix: Hooks: support footnotes on category pages, thanks to @vitaefit bug report, thanks to @misfist code contribution. + * @since 2.5.1 Bugfix: Hooks: support footnotes in Popup Maker popups, thanks to @squatcher bug report. + */ + public function registerHooks() { + + /** + * Priority levels + * + * - Bugfix: Reference container: fix relative position through priority level, thanks to @june01 @imeson @spaceling bug reports, thanks to @spaceling code contribution. + * + * @since 2.0.5 + * @date 2020-11-02T0330+0100 + * @link https://codex.wordpress.org/Plugin_API/#Hook_in_your_Filter + * + * @contributor @spaceling + * @link https://wordpress.org/support/topic/change-the-position-5/#post-13608594 + * + * @reporter @june01 + * @link https://wordpress.org/support/topic/change-the-position-5/ + * + * @reporter @imeson + * @link https://wordpress.org/support/topic/change-the-position-5/#post-13538345 + * + * + * - Bugfix: Dashboard: priority level setting for the_content hook, thanks to @imeson bug report. + * + * @since 2.1.1 + * @date 2020-11-17T0254+0100 + * + * @reporter @imeson + * @link https://wordpress.org/support/topic/change-the-position-5/#post-13538345 + * + * + * - Bugfix: Dashboard: priority level settings for all other hooks, thanks to @nikelaos bug report. + * + * @since 2.1.2 + * @date 2020-11-19T1849+0100 + * + * @reporter @nikelaos + * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13676705 + * + * + * Setting the_content priority to 10 instead of PHP_INT_MAX i.e. 9223372036854775807 + * 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. + * + * For YARPP to display related posts below the Footnotes reference container, + * priority needs to be at least 1200 (i.e. 0 =< $l_int_TheContentPriority =< 1200). + * + * 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. + * @link https://github.com/Modernizr/Modernizr/issues/171 + */ + + // get values from settings: + $l_int_TheTitlePriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL)); + $l_int_TheContentPriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL)); + $l_int_TheExcerptPriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL)); + $l_int_WidgetTitlePriority = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL)); + $l_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: + $l_int_TheTitlePriority = ($l_int_TheTitlePriority == -1) ? PHP_INT_MAX : $l_int_TheTitlePriority ; + $l_int_TheContentPriority = ($l_int_TheContentPriority == -1) ? PHP_INT_MAX : $l_int_TheContentPriority ; + $l_int_TheExcerptPriority = ($l_int_TheExcerptPriority == -1) ? PHP_INT_MAX : $l_int_TheExcerptPriority ; + $l_int_WidgetTitlePriority = ($l_int_WidgetTitlePriority == -1) ? PHP_INT_MAX : $l_int_WidgetTitlePriority; + $l_int_WidgetTextPriority = ($l_int_WidgetTextPriority == -1) ? PHP_INT_MAX : $l_int_WidgetTextPriority ; + + + // append custom css to the header + add_filter('wp_head', array($this, "wp_head"), PHP_INT_MAX); + + // append the love and share me slug to the footer + 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"), $l_int_TheTitlePriority); + } + + // configurable priority level for reference container relative positioning; default 98: + 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"), $l_int_TheContentPriority); + + /** + * Hook for category pages + * + * - Bugfix: Hooks: support footnotes on category pages, thanks to @vitaefit bug report, thanks to @misfist code contribution. + * + * @since 2.5.0 + * @date 2021-01-05T1402+0100 + * + * @contributor @misfist + * @link https://wordpress.org/support/topic/footnote-doesntwork-on-category-page/#post-13864859 + * + * @reporter @vitaefit + * @link https://wordpress.org/support/topic/footnote-doesntwork-on-category-page/ + * + * Category pages can have rich HTML content in a term description with article status. + * For this to happen, WordPress’ built-in partial HTML blocker needs to be disabled. + * @link https://docs.woocommerce.com/document/allow-html-in-term-category-tag-descriptions/ + */ + add_filter('term_description', array($this, "the_content"), $l_int_TheContentPriority); + + /** + * Hook for popup maker popups + * + * - Bugfix: Hooks: support footnotes in Popup Maker popups, thanks to @squatcher bug report. + * + * @since 2.5.1 + * @date 2021-01-18T2038+0100 + * + * @reporter @squatcher + * @link https://wordpress.org/support/topic/footnotes-use-in-popup-maker/ + */ + add_filter('pum_popup_content', array($this, "the_content"), $l_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"), $l_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"), $l_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"), $l_int_WidgetTextPriority); + } + + + /** + * The the_post hook + * + * - Adding: Hooks: support 'the_post' in response to user request for custom post types. + * + * @since 1.5.4 + * @accountable @aricura + * @link https://wordpress.org/support/topic/doesnt-work-in-custon-post-types/#post-5339110 + * + * + * - Update: Hooks: Default-enable all hooks to prevent footnotes from seeming broken in some parts. + * + * @since 2.0.5 + * @accountable @pewgeuges + * + * + * - BUGFIX: Hooks: Default-disable 'the_post', thanks to @spaceling @markcheret @nyamachi @whichgodsaves @spiralofhope2 @mmallett @andreasra @widecast @ymorin007 @tashi1es bug reports. + * + * @since 2.0.7 + * @accountable @pewgeuges + * @link https://wordpress.org/support/topic/change-the-position-5/page/2/#post-13630114 + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/#post-13630303 + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/page/2/#post-13630799 + * @link https://wordpress.org/support/topic/no-footnotes-anymore/#post-13813233 + * + * @reporter @spaceling + * @link https://wordpress.org/support/topic/change-the-position-5/#post-13612697 + * + * @reporter @markcheret on behalf of W. Beinert + * @link https://wordpress.org/support/topic/footnotes-now-appear-in-summaries-even-though-this-is-marked-no/ + * + * @reporter @nyamachi + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/ + * + * @reporter @whichgodsaves + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/#post-13622694 + * + * @reporter @spiralofhope2 + * @link https://wordpress.org/support/topic/2-0-5-broken/ + * + * @reporter @mmallett + * @link https://wordpress.org/support/topic/2-0-5-broken/#post-13623208 + * + * @reporter @andreasra + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/#post-13624091 + * + * @reporter @widecast + * @link https://wordpress.org/support/topic/2-0-5-broken/#post-13626222 + * + * @reporter @ymorin007 + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/#post-13627050 + * + * @reporter @markcheret on behalf of L. Smith + * @link https://wordpress.org/support/topic/footnotes-appear-in-random-places-on-academic-website/ + * + * @reporter @tashi1es + * @link https://wordpress.org/support/topic/footnotes-appear-in-random-places-on-academic-website/#post-13630495 + * + * + * - UPDATE: Hooks: remove 'the_post', the plugin stops supporting this hook. + * + * @since 2.1.0 + * @date 2020-11-08T1839+0100 + * @accountable @pewgeuges + */ + + // reset stored footnotes when displaying the header + self::$a_arr_Footnotes = array(); + self::$a_bool_AllowLoveMe = true; + } + + /** + * Outputs the custom css to the header of the public page. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * + * @since 2.1.1 Bugfix: Reference container: fix start pages by making its display optional, thanks to @dragon013 bug report. + * @since 2.1.1 Bugfix: Tooltips: optional alternative JS implementation with CSS transitions to fix configuration-related outage, thanks to @andreasra feedback. + * @since 2.1.3 raise settings priority to override theme stylesheets + * @since 2.1.4 Bugfix: Tooltips: Styling: fix font size issue by adding font size to settings with legacy as default. + * @since 2.1.4 Bugfix: Reference container: fix layout issues by moving backlink column width to settings. + * @since 2.2.5 Bugfix: Reference container: Label: make bottom border an option, thanks to @markhillyer issue report. + * @since 2.2.5 Bugfix: Reference container: Label: option to select paragraph or heading element, thanks to @markhillyer issue report. + * @since 2.3.0 Bugfix: Reference container: convert top padding to margin and make it a setting, thanks to @hamshe bug report. + * @since 2.5.4 Bugfix: Referrers: optional fixes to vertical alignment, font size and position (static) for in-theme consistency and cross-theme stability, thanks to @tomturowski bug report. + */ + public function wp_head() { + + // insert start tag without switching out of PHP: + echo "\r\n\r\n"; + + /** + * Alternative tooltip implementation relying on plain JS and CSS transitions. + * + * - Bugfix: Tooltips: optional alternative JS implementation with CSS transitions to fix configuration-related outage, thanks to @andreasra feedback. + * + * @since 2.1.1 + * + * @reporter @andreasra + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/page/2/#post-13632566 + * + * The script for alternative tooltips is printed formatted, not minified: + */ + if ( self::$a_bool_AlternativeTooltipsEnabled ) { + ?> get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "footer") { - echo $this->ReferenceContainer(); - } - // 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('%s', 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,7); - } - switch ($l_str_LoveMeIndex) { - // options named wrt backcompat, simplest is default: - case "text-1": $l_str_LoveMeText = sprintf(__('I %2$s %1$s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL); break; - case "text-2": $l_str_LoveMeText = sprintf(__('This website uses the awesome %s plugin.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName); break; - case "text-4": $l_str_LoveMeText = sprintf('%s %s', $l_str_LinkedName, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL); break; - case "text-5": $l_str_LoveMeText = sprintf('%s %s', MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, $l_str_LinkedName); break; - case "text-6": $l_str_LoveMeText = sprintf(__('This website uses %s.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName); break; - case "text-7": $l_str_LoveMeText = sprintf(__('This website uses the %s plugin.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName); break; - case "text-3": default: $l_str_LoveMeText = sprintf('%s', $l_str_LinkedName); break; - } - echo sprintf('
%s
', $l_str_LoveMeText); - } - - /** - * 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); - } - - /** - * 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); - } - - /** - * 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))); - } - - /** - * 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); - } - - /** - * 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); - } - - /** - * 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 - */ - 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]); - } - } - - /** - * 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; - } - - /** - * 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 - * - * - * @since 2.2.0 Adding: Reference container: support for custom position shortcode, thanks to @hamshe issue report. - * @since 2.2.5 Bugfix: Reference container: delete position shortcode if unused because position may be widget or footer, thanks to @hamshe bug report. - */ - 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); - - /** - * Reference container customized positioning through shortcode - * - * - Adding: Reference container: support for custom position shortcode, thanks to @hamshe issue report. - * - * @since 2.2.0 - * @date 2020-12-13T2057+0100 - * - * @reporter @hamshe - * @link https://wordpress.org/support/topic/reference-container-in-elementor/ - * - * - * - Bugfix: Reference container: delete position shortcode if unused because position may be widget or footer, thanks to @hamshe bug report. - * - * @since 2.2.5 - * @date 2020-12-18T1434+0100 - * - * @reporter @hamshe - * @link https://wordpress.org/support/topic/reference-container-in-elementor/#post-13784126 - * - */ - // append the reference container or insert at shortcode: - $l_str_ReferenceContainerPositionShortcode = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE); - if ( empty( $l_str_ReferenceContainerPositionShortcode ) ) { - $l_str_ReferenceContainerPositionShortcode = '[[references]]'; - } - - if ( $p_bool_OutputReferences ) { - - if ( strpos( $p_str_Content, $l_str_ReferenceContainerPositionShortcode ) !== false ) { - - $p_str_Content = str_replace( $l_str_ReferenceContainerPositionShortcode, $this->ReferenceContainer(), $p_str_Content ); - - } else { - - $p_str_Content .= $this->ReferenceContainer(); - - } - - // increment the container ID: - self::$a_int_ReferenceContainerId++; - } - - // delete position shortcode should any remain: - $p_str_Content = str_replace( $l_str_ReferenceContainerPositionShortcode, '', $p_str_Content ); - - // 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 appended: - return $p_str_Content; - } - - /** - * 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 - * - * @since 2.0.0 various. - * @since 2.4.0 Adding: Footnote delimiters: syntax validation for balanced footnote start and end tag short codes. - * @since 2.5.0 Bugfix: Footnote delimiters: Syntax validation: exclude certain cases involving scripts, thanks to @andreasra bug report. - * @since 2.5.0 Bugfix: Footnote delimiters: Syntax validation: complete message with hint about setting, thanks to @andreasra bug report. - * @since 2.5.0 Bugfix: Footnote delimiters: Syntax validation: limit length of quoted string to 300 characters, thanks to @andreasra bug report. - */ - public function search($p_str_Content, $p_bool_ConvertHtmlChars, $p_bool_HideFootnotesText) { - - // post ID to make everything unique wrt infinite scroll and archive view - self::$a_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); - 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; - } - - /** - * Footnote delimiter syntax validation - * - * - Adding: Footnote delimiters: syntax validation for balanced footnote start and end tag short codes. - * - * @since 2.4.0 - * - * - * - Bugfix: Footnote delimiters: Syntax validation: exclude certain cases involving scripts, thanks to @andreasra bug report. - * - Bugfix: Footnote delimiters: Syntax validation: complete message with hint about setting, thanks to @andreasra bug report. - * - Bugfix: Footnote delimiters: Syntax validation: limit length of quoted string to 300 characters, thanks to @andreasra bug report. - * - * @since 2.5.0 - * @date 2021-01-07T0824+0100 - * - * @reporter @andreasra - * @link https://wordpress.org/support/topic/warning-unbalanced-footnote-start-tag-short-code-before/ - * - * - * If footnotes short codes are unbalanced, and syntax validation is not disabled, - * prepend a warning to the content; displays de facto beneath the post title. - */ - if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE))) { - - // make shortcodes conform to regex syntax: - $l_str_StartTagRegex = preg_replace( '#([\(\)\{\}\[\]\*\.\?\!])#', '\\\\$1', $l_str_StartingTag ); - $l_str_EndTagRegex = preg_replace( '#([\(\)\{\}\[\]\*\.\?\!])#', '\\\\$1', $l_str_EndingTag ); - - // apply different regex depending on whether start shortcode is double/triple opening parenthesis: - if ( $l_str_StartingTag == '((' || $l_str_StartingTag == '(((' ) { - - // this prevents from catching a script containing e.g. a double opening parenthesis: - $l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ')[^\{\}])*?)(' . $l_str_StartTagRegex . '|$)#s'; - - } else { - - // catch all only if the start shortcode is not double/triple opening parenthesis, i.e. is unlikely to occur in scripts: - $l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ').)*?)(' . $l_str_StartTagRegex . '|$)#s'; - } - - // check syntax and get error locations: - preg_match( $l_str_ValidationRegex, $p_str_Content, $p_arr_ErrorLocation ); - if ( empty( $p_arr_ErrorLocation ) ) { - self::$a_bool_SyntaxErrorFlag = false; - } - - // prevent generating and inserting the warning multiple times: - if ( self::$a_bool_SyntaxErrorFlag ) { - - // get plain text string for error location: - $l_str_ErrorSpotString = strip_tags( $p_arr_ErrorLocation[1] ); - - // limit string length to 300 characters: - if ( strlen( $l_str_ErrorSpotString ) > 300 ) { - $l_str_ErrorSpotString = substr( $l_str_ErrorSpotString, 0, 299 ) . '…'; - } - - // compose warning box: - $l_str_SyntaxErrorWarning = '

'; - $l_str_SyntaxErrorWarning .= __("WARNING: unbalanced footnote start tag short code found.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME); - $l_str_SyntaxErrorWarning .= '

'; - - // syntax validation setting in the dashboard under the General settings tab: - $l_str_SyntaxErrorWarning .= sprintf( __("If this warning is irrelevant, please disable the syntax validation feature in the dashboard under %s > %s > %s.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("General settings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Footnote start and end short codes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Check for balanced shortcodes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) ); - - $l_str_SyntaxErrorWarning .= '

'; - $l_str_SyntaxErrorWarning .= __("Unbalanced start tag short code found before:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME); - $l_str_SyntaxErrorWarning .= '

“'; - $l_str_SyntaxErrorWarning .= $l_str_ErrorSpotString; - $l_str_SyntaxErrorWarning .= '”

'; - - // prepend the warning box to the content: - $p_str_Content = $l_str_SyntaxErrorWarning . $p_str_Content; - - // checked, set flag to false to prevent duplicate warning: - self::$a_bool_SyntaxErrorFlag = false; - - return $p_str_Content; - } - } - - - // load referrer templates if footnotes text not hidden: - if (!$p_bool_HideFootnotesText) { - - // load footnote referrer template file: - if (self::$a_bool_AlternativeTooltipsEnabled) { - $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"); - } - - /** - * Call Boolean again for robustness when priority levels don’t match any longer. - * - * - Bugfix: Tooltips: fix display in Popup Maker popups by correcting a coding error. - * - * @since 2.5.4 - * @see self::add_filter('pum_popup_content', array($this, "the_content"), $l_int_TheContentPriority) - */ - self::$a_bool_TooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED)); - self::$a_bool_AlternativeTooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE)); - - // load tooltip inline script if jQuery tooltips are enabled: - if (self::$a_bool_TooltipsEnabled && ! self::$a_bool_AlternativeTooltipsEnabled) { - $l_obj_TemplateTooltip = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "tooltip"); - } - - } else { - $l_obj_Template = null; - $l_obj_TemplateTooltip = null; - } - - // search footnotes short codes in the content - do { - // get first occurrence of the footnote start tag short code: - $i_int_LenContent = strlen($p_str_Content); - if ($l_int_PosStart > $i_int_LenContent) $l_int_PosStart = $i_int_LenContent; - $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 the footnote end tag short code: - $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 - $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)); - - // get tooltip text if present: - self::$a_str_TooltipShortcode = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER); - self::$a_int_TooltipShortcodeLength = strlen( self::$a_str_TooltipShortcode ); - $l_int_TooltipTextLength = strpos( $l_str_FootnoteText, self::$a_str_TooltipShortcode ); - $l_bool_HasTooltipText = $l_int_TooltipTextLength === false ? false : true; - if ( $l_bool_HasTooltipText ) { - $l_str_TooltipText = substr( $l_str_FootnoteText, 0, $l_int_TooltipTextLength ); - } else { - $l_str_TooltipText = ''; - } - - /** - * URL line wrapping for Unicode non conformant browsers - * - * @since 2.1.1 (CSS) - * @since 2.1.4 (PHP) - * - * Despite Unicode recommends to line-wrap URLs at slashes, and Firefox follows - * the Unicode standard, Chrome does not, making long URLs hang out of tooltips - * or extend reference containers, so that the end is hidden outside the window - * and may eventually be viewed after we scroll horizontally or zoom out. It is - * up to the web page to make URLs breaking anywhere by wrapping them in a span - * that is assigned appropriate CSS properties and values. - * @see css/public.css - * - * - Bugfix: Tooltips: fix line breaking for hyperlinked URLs in Unicode-non-compliant user agents, thanks to @andreasra bug report. - * - * @since 2.1.1 - * - * @reporter @andreasra - * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/page/3/#post-13657398 - * - * - * - Bugfix: Reference container: fix width in mobile view by URL wrapping for Unicode-non-conformant browsers, thanks to @karolszakiel bug report. - * - * @since 2.1.3 - * @date 2020-11-23 - * - * @reporter @karolszakiel - * @link https://wordpress.org/support/topic/footnotes-on-mobile-phones/ - * - * - * - Bugfix: Reference container, tooltips: fix line wrapping of URLs (hyperlinked or not) based on pattern, not link element. - * - * @since 2.1.4 - * @date 2020-11-25T0837+0100 - * @link https://wordpress.org/support/topic/footnotes-on-mobile-phones/#post-13710682 - * - * - * - Bugfix: Reference container, tooltips: URL wrap: exclude image source too, thanks to @bjrnet21 bug report. - * - * @since 2.1.5 - * - * @reporter @bjrnet21 - * @link https://wordpress.org/support/topic/2-1-4-breaks-on-my-site-images-dont-show/ - * - * - * - Bugfix: Reference container, tooltips: URL wrap: fix regex, thanks to @a223123131 bug report. - * - * @since 2.1.6 - * @date 2020-12-09T1921+0100 - * - * @reporter @a223123131 - * @link https://wordpress.org/support/topic/broken-layout-starting-version-2-1-4/ - * - * Even ARIA labels may take a URL as value, so use \w=[\'"] as a catch-all 2020-12-10T1005+0100 - * - * - Bugfix: Dashboard: URL wrap: add option to properly enable/disable URL wrap. - * - * @since 2.1.6 - * @date 2020-12-09T1606+0100 - * - * - * - Bugfix: Reference container, tooltips: URL wrap: make the quotation mark optional wrt query parameters, thanks to @spiralofhope2 bug report. - * - * @since 2.2.6 - * @date 2020-12-23T0409+0100 - * - * @reporter @spiralofhope2 - * @link https://wordpress.org/support/topic/two-links-now-breaks-footnotes-with-blogtext/ - * - * - * - Bugfix: Reference container, tooltips: URL wrap: remove a bug introduced in the regex, thanks to @rjl20 @spaceling @lukashuggenberg @klusik @friedrichnorth @bernardzit bug reports. - * - * @since 2.2.7 - * @date 2020-12-23T1046+0100 - * - * @reporter @rjl20 - * @link https://wordpress.org/support/topic/two-links-now-breaks-footnotes-with-blogtext/#post-13825479 - * - * @reporter @spaceling - * @link https://wordpress.org/support/topic/two-links-now-breaks-footnotes-with-blogtext/#post-13825532 - * - * @reporter @lukashuggenberg - * @link https://wordpress.org/support/topic/2-2-6-breaks-all-footnotes/ - * - * @reporter @klusik - * @link https://wordpress.org/support/topic/2-2-6-breaks-all-footnotes/#post-13825885 - * - * @reporter @friedrichnorth - * @link https://wordpress.org/support/topic/footnotes-dont-show-after-update-to-2-2-6/ - * - * @reporter @bernardzit - * @link https://wordpress.org/support/topic/footnotes-dont-show-after-update-to-2-2-6/#post-13826029 - * - * - * @since 2.2.8 Bugfix: Reference container, tooltips: URL wrap: correctly make the quotation mark optional wrt query parameters, thanks to @spiralofhope2 bug report. - * @date 2020-12-23T1107+0100 - * - * Correct is duplicating the negative lookbehind w/o quotes: '(?get( MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_URL_WRAP_ENABLED ) ) ) { - - $l_str_FootnoteText = preg_replace( - '#(?$1
', - $l_str_FootnoteText - ); - } - - // Text to be displayed instead of the footnote - $l_str_FootnoteReplaceText = ""; - - // whether hard links are enabled: - if (self::$a_bool_HardLinksEnable) { - - // get the configurable parts: - self::$a_str_ReferrerLinkSlug = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERRER_FRAGMENT_ID_SLUG); - self::$a_str_FootnoteLinkSlug = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG); - self::$a_str_LinkIdsSeparator = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_HARD_LINK_IDS_SEPARATOR); - - // streamline ID concatenation: - self::$a_str_PostContainerIdCompound = self::$a_str_LinkIdsSeparator; - self::$a_str_PostContainerIdCompound .= self::$a_int_PostId; - self::$a_str_PostContainerIdCompound .= self::$a_str_LinkIdsSeparator; - self::$a_str_PostContainerIdCompound .= self::$a_int_ReferenceContainerId; - self::$a_str_PostContainerIdCompound .= self::$a_str_LinkIdsSeparator; - - } - - // display the footnote referrers and the tooltips: - if (!$p_bool_HideFootnotesText) { - $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 a truncated footnote text if option enabled: - $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)); - - // define excerpt text as footnote text by default: - $l_str_ExcerptText = $l_str_FootnoteText; - - /** - * Tooltip truncation - * - * - Adding: Tooltips: Read-on button: Label: configurable instead of localizable, thanks to @rovanov example provision. - * - * @since 2.1.0 - * @date 2020-11-08T2146+0100 - * - * @reporter @rovanov - * @link https://wordpress.org/support/topic/offset-x-axis-and-offset-y-axis-does-not-working/ - * - * If the tooltip truncation option is enabled, it’s done based on character count, - * and a trailing incomplete word is cropped. - * This is equivalent to the WordPress default excerpt generation, i.e. without a - * custom excerpt and without a delimiter. But WordPress does word count, usually 55. - */ - if (self::$a_bool_TooltipsEnabled && $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, ' ')); - $l_str_ExcerptText .= ' … <'; - $l_str_ExcerptText .= self::$a_bool_HardLinksEnable ? 'a' : 'span'; - $l_str_ExcerptText .= ' class="footnote_tooltip_continue" '; - $l_str_ExcerptText .= 'onclick="footnote_moveToAnchor_' . self::$a_int_PostId; - $l_str_ExcerptText .= '_' . self::$a_int_ReferenceContainerId; - $l_str_ExcerptText .= '(\'footnote_plugin_reference_' . self::$a_int_PostId; - $l_str_ExcerptText .= '_' . self::$a_int_ReferenceContainerId; - $l_str_ExcerptText .= "_$l_int_Index');\""; - - // if enabled, add the hard link fragment ID: - if (self::$a_bool_HardLinksEnable) { - - $l_str_ExcerptText .= ' href="#'; - $l_str_ExcerptText .= self::$a_str_FootnoteLinkSlug; - $l_str_ExcerptText .= self::$a_str_PostContainerIdCompound; - $l_str_ExcerptText .= $l_int_Index; - $l_str_ExcerptText .= '"'; - } - - $l_str_ExcerptText .= '>'; - - /** - * Configurable read-on button label - * - * - Adding: Tooltips: Read-on button: Label: configurable instead of localizable, thanks to @rovanov example provision. - * - * @since 2.1.0 - * @date 2020-11-08T2146+0100 - * - * @reporter @rovanov - * @link https://wordpress.org/support/topic/offset-x-axis-and-offset-y-axis-does-not-working/ - */ - $l_str_ExcerptText .= MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL); - - $l_str_ExcerptText .= self::$a_bool_HardLinksEnable ? '' : '
'; - } - } - - /** - * Referrers element superscript or baseline - * - * Referrers: new setting for vertical align: superscript (default) or baseline (optional), thanks to @cwbayer bug report - * @since 2.1.1 - * - * @reporter @cwbayer - * @link https://wordpress.org/support/topic/footnote-number-in-text-superscript-disrupts-leading/ - * - * 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_SupSpan = 'sup'; - - } else { - - $l_str_SupSpan = 'span'; - } - - // whether hard links are enabled: - if (self::$a_bool_HardLinksEnable) { - - self::$a_str_LinkSpan = 'a'; - self::$a_str_LinkCloseTag = ''; - // self::$a_str_LinkOpenTag will be defined as needed - - // compose hyperlink address (leading space is in template): - $l_str_FootnoteLinkArgument = 'href="#'; - $l_str_FootnoteLinkArgument .= self::$a_str_FootnoteLinkSlug; - $l_str_FootnoteLinkArgument .= self::$a_str_PostContainerIdCompound; - $l_str_FootnoteLinkArgument .= $l_int_Index; - $l_str_FootnoteLinkArgument .= '" class="footnote_hard_link"'; - - /** - * Compose fragment ID anchor with offset, for use in reference container. - * Empty span, child of empty span, to avoid tall dotted rectangles in browser. - */ - $l_str_ReferrerAnchorElement = ''; - - } else { - - /** - * Initialize hard link variables when hard links are disabled. - * - * - Bugfix: Process: initialize hard link address variables to empty string to fix 'undefined variable' bug, thanks to @a223123131 bug report. - * - * @since 2.4.0 - * @date 2021-01-04T1622+0100 - * - * @reporter @a223123131 - * @link https://wordpress.org/support/topic/wp_debug-php-notice/ - * - * If no hyperlink nor offset anchor is needed, initialize as empty. - */ - $l_str_FootnoteLinkArgument = ''; - $l_str_ReferrerAnchorElement = ''; - - // The link element is set independently as it may be needed for styling: - if ( MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED)) ) { - - self::$a_str_LinkSpan = 'a'; - self::$a_str_LinkOpenTag = ''; - self::$a_str_LinkCloseTag = ''; - - } - } - - // determine tooltip content: - if ( self::$a_bool_TooltipsEnabled ) { - $l_str_TooltipContent = $l_bool_HasTooltipText ? $l_str_TooltipText : $l_str_ExcerptText; - } else { - $l_str_TooltipContent = ''; - } - - // fill in 'templates/public/footnote.html': - $l_obj_Template->replace( - array( - "link-span" => self::$a_str_LinkSpan, - "post_id" => self::$a_int_PostId, - "container_id" => self::$a_int_ReferenceContainerId, - "note_id" => $l_int_Index, - "hard-link" => $l_str_FootnoteLinkArgument, - "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), - "anchor-element" => $l_str_ReferrerAnchorElement, - "text" => $l_str_TooltipContent, - ) - ); - $l_str_FootnoteReplaceText = $l_obj_Template->getContent(); - - // reset the template - $l_obj_Template->reload(); - - // if standard tooltips are enabled but alternative are not: - if (self::$a_bool_TooltipsEnabled && ! self::$a_bool_AlternativeTooltipsEnabled) { - - $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)); - $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)); - - // fill in 'templates/public/tooltip.html': - $l_obj_TemplateTooltip->replace( - array( - "post_id" => self::$a_int_PostId, - "container_id" => self::$a_int_ReferenceContainerId, - "note_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, - ) - ); - $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 - self::$a_arr_Footnotes[] = $l_str_FootnoteText; - // increase footnote index - $l_int_FootnoteIndex++; - } - - /** - * Fixes a footnotes numbering bug (happening under de facto rare circumstances). - * - * - Bugfix: Fixed occasional bug where footnote ordering could be out of sequence - * - * @since 1.6.4 - * @date 2016-06-29T0054+0000 - * @committer @dartiss - * @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class/task.php?rev=1445718 @dartiss’ class/task.php - * @link https://plugins.trac.wordpress.org/log/footnotes/trunk/class/task.php?rev=1445718 @dartiss re-added class/task.php - * @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class?rev=1445711 class/ w/o task.php - * @link https://plugins.trac.wordpress.org/changeset/1445711/footnotes/trunk/class @dartiss deleted class/task.php - * @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class/task.php?rev=1026210 @aricura’s latest class/task.php - * - * - * - Bugfix: Process: fix numbering bug impacting footnote #2 with footnote #1 close to start, thanks to @rumperuu bug report, thanks to @lolzim code contribution. - * - * @since 2.5.5 - * - * @contributor @lolzim - * @link https://wordpress.org/support/topic/footnotes-numbered-incorrectly/#post-14062032 - * - * @reporter @rumperuu - * @link https://wordpress.org/support/topic/footnotes-numbered-incorrectly/ - * - * This assignment was overridden by another one, causing the algorithm to jump back - * near the post start to a position calculated as the sum of the length of the last - * footnote and the length of the last footnote replace text. - * A bug disturbing the order of the footnotes depending on the text before the first - * footnote, the length of the first footnote and the length of the templates for the - * footnote and the tooltip. Moreover, it was causing non-trivial process garbage. - */ - // add offset to the new starting position - $l_int_PosStart += $l_int_Length + strlen($l_str_EndingTag); - - } while (true); - - // return content - return $p_str_Content; - } - - /** - * Generates the reference container. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - * - * @since 2.0.0 Update: remove backlink symbol along with column 2 of the reference container - * @since 2.0.3 Bugfix: prepend an arrow on user request - * @since 2.0.6 Bugfix: Reference container: fix line breaking behavior in footnote number clusters. - * @since 2.0.4 Bugfix: restore the arrow select and backlink symbol input settings - * @since 2.1.1 Bugfix: Referrers, reference container: Combining identical footnotes: fix dead links and ensure referrer-backlink bijectivity, thanks to @happyches bug report. - * @since 2.1.1 Bugfix: Reference container: Backlink symbol: make optional, not suggest configuring it to invisible, thanks to @spaceling feedback. - */ - public function ReferenceContainer() { - - // no footnotes have been replaced on this page: - if (empty(self::$a_arr_Footnotes)) { - return ""; - } - - - /** - * Footnote index backlink symbol - * - * - Bugfix: Reference container: Backlink symbol: make optional, not suggest configuring it to invisible, thanks to @spaceling feedback. - * - * @since 2.1.1 - * - * @reporter @spaceling - * @link https://wordpress.org/support/topic/change-the-position-5/page/2/#post-13671138 - * - * If the backlink symbol 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 = ''; - $l_str_FootnoteArrow .= $l_str_Arrow . ''; - - } else { - - // If the backlink symbol isn’t enabled, set it to empty: - $l_str_Arrow = ''; - $l_str_FootnoteArrow = ''; - - } - - - /** - * Backlink separator - * - * - Bugfix: Reference container: make separating and terminating punctuation optional and configurable, thanks to @docteurfitness issue report and code contribution. - * - * @since 2.1.4 - * @date 2020-11-28T1048+0100 - * - * @contributor @docteurfitness - * @link https://wordpress.org/support/topic/update-2-1-3/#post-13704194 - * - * @reporter @docteurfitness - * @link https://wordpress.org/support/topic/update-2-1-3/ - * - * Initially a comma was appended in this algorithm for enumerations. - * The comma in enumerations is not generally preferred. - */ - if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_SEPARATOR_ENABLED))) { - - // check if it is input-configured: - $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 = ''; - } - - /** - * 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. - * @since 2.1.4 the terminator is optional, has options, and is configurable: - */ - if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_TERMINATOR_ENABLED))) { - - // check if it is input-configured: - $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 { - - $l_str_Terminator = ''; - } - - - /** - * Line breaks - * - * - Bugfix: Reference container: Backlinks: fix stacked enumerations by adding optional line breaks. - * - * @since 2.1.4 - * @date 2020-11-28T1049+0100 - * - * 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)) ? '
' : ' '; - - /** - * For maintenance and support, table rows in the reference container should be - * 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): - */ - $l_str_Body = "\r\n\r\n"; - - - /** - * Reference container table row template load - * - * - Bugfix: Reference container: option to restore pre-2.0.0 layout with the backlink symbol in an extra column. - * - * @since 2.1.1 - * @date 2020-11-16T2024+0100 - */ - - // when combining identical footnotes 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))) { - // the combining template allows for backlink clusters and supports cell clicking for single notes: - $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 available 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, and combining and 3-columns are off: - 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"); - - } - } - } - - /** - * Switch backlink symbol and footnote number - * - * - Bugfix: Reference container: option to append symbol (prepended by default), thanks to @spaceling code contribution. - * - * @since 2.1.1 - * @date 2020-11-16T2024+0100 - * - * @contributor @spaceling - * @link https://wordpress.org/support/topic/change-the-position-5/#post-13615994 - * - * - * - Bugfix: Reference container: Backlink symbol: support for appending when combining identicals is on. - * - * @since 2.1.4 - * @date 2020-11-26T1633+0100 - */ - $l_bool_SymbolSwitch = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH)); - - // loop through all footnotes found in the page - for ($l_int_Index = 0; $l_int_Index < count(self::$a_arr_Footnotes); $l_int_Index++) { - - // get footnote text - $l_str_FootnoteText = self::$a_arr_Footnotes[$l_int_Index]; - - // if footnote is empty, go to the next one; - // With combine identicals turned on, identicals will be deleted and are skipped: - if (empty($l_str_FootnoteText)) { - continue; - } - - // 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_FootnoteId = MCI_Footnotes_Convert::Index(($l_int_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)); - - /** - * Case of only one backlink per table row - * - * If enabled, and for the case the footnote is single, compose hard link: - */ - // define anyway: - $l_str_HardLinkAddress = ''; - - if (self::$a_bool_HardLinksEnable) { - - /** - * Use-Backbutton-Hint tooltip, optional and configurable. - * - * - Update: Reference container: Hard backlinks (optional): optional configurable tooltip hinting to use the backbutton instead, thanks to @theroninjedi47 bug report. - * - * @since 2.5.4 - * - * @reporter @theroninjedi47 - * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ - * - * When hard links are enabled, clicks on the backlinks are logged in the browsing history. - * This tooltip hints to use the backbutton instead, so the history gets streamlined again. - * @link https://wordpress.org/support/topic/making-it-amp-compatible/#post-13837359 - */ - if ( MCI_Footnotes_Convert::toBool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE ) ) ) { - $l_str_UseBackbuttonHint = ' title="'; - $l_str_UseBackbuttonHint .= MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT); - $l_str_UseBackbuttonHint .= '"'; - } else { - $l_str_UseBackbuttonHint = ''; - } - - /** - * Compose fragment ID anchor with offset, for use in reference container. - * Empty span, child of empty span, to avoid tall dotted rectangles in browser. - */ - $l_str_FootnoteAnchorElement = ''; - - // compose optional hard link address: - $l_str_HardLinkAddress = ' href="#'; - $l_str_HardLinkAddress .= self::$a_str_ReferrerLinkSlug; - $l_str_HardLinkAddress .= self::$a_str_PostContainerIdCompound; - $l_str_HardLinkAddress .= $l_str_FootnoteId . '"'; - $l_str_HardLinkAddress .= $l_str_UseBackbuttonHint; - - // compose optional opening link tag with optional hard link, mandatory for instance: - self::$a_str_LinkOpenTag = 'get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) { - - // ID, optional hard link address, and class: - $l_str_FootnoteReference = '<' . self::$a_str_LinkSpan; - $l_str_FootnoteReference .= ' id="footnote_plugin_reference_'; - $l_str_FootnoteReference .= self::$a_int_PostId; - $l_str_FootnoteReference .= '_' . self::$a_int_ReferenceContainerId; - $l_str_FootnoteReference .= "_$l_str_FootnoteId\""; - if (self::$a_bool_HardLinksEnable) { - $l_str_FootnoteReference .= ' href="#'; - $l_str_FootnoteReference .= self::$a_str_ReferrerLinkSlug; - $l_str_FootnoteReference .= self::$a_str_PostContainerIdCompound; - $l_str_FootnoteReference .= $l_str_FootnoteId . '"'; - $l_str_FootnoteReference .= $l_str_UseBackbuttonHint; - } - $l_str_FootnoteReference .= ' class="footnote_backlink"'; - - // the click event goes in the table cell if footnote remains single: - $l_str_BacklinkEvent = ' onclick="footnote_moveToAnchor_'; - $l_str_BacklinkEvent .= self::$a_int_PostId; - $l_str_BacklinkEvent .= '_' . self::$a_int_ReferenceContainerId; - $l_str_BacklinkEvent .= "('footnote_plugin_tooltip_"; - $l_str_BacklinkEvent .= self::$a_int_PostId; - $l_str_BacklinkEvent .= '_' . self::$a_int_ReferenceContainerId; - $l_str_BacklinkEvent .= "_$l_str_FootnoteId');\""; - - - // the dedicated template enumerating backlinks uses another variable: - $l_str_FootnoteBacklinks = $l_str_FootnoteReference; - - // append the click event right to the backlink item for enumerations; - // else it goes in the table cell: - $l_str_FootnoteBacklinks .= $l_str_BacklinkEvent . '>'; - $l_str_FootnoteReference .= '>'; - - // append the optional offset anchor for hard links: - if (self::$a_bool_HardLinksEnable) { - $l_str_FootnoteReference .= $l_str_FootnoteAnchorElement; - $l_str_FootnoteBacklinks .= $l_str_FootnoteAnchorElement; - } - - // continue both single note and notes cluster, depending on switch option status: - if ($l_bool_SymbolSwitch) { - - $l_str_FootnoteReference .= "$l_str_FootnoteId$l_str_FootnoteArrow"; - $l_str_FootnoteBacklinks .= "$l_str_FootnoteId$l_str_FootnoteArrow"; - - } else { - - $l_str_FootnoteReference .= "$l_str_FootnoteArrow$l_str_FootnoteId"; - $l_str_FootnoteBacklinks .= "$l_str_FootnoteArrow$l_str_FootnoteId"; - - } - - // If that is the only footnote with this text, we’re almost done. - - // check if it isn't the last footnote in the array: - if ($l_int_FirstFootnoteIndex < count(self::$a_arr_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] = ""; - - // set the flag to true for the combined status: - $l_bool_FlagCombined = true; - - // 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)); - - // resume composing the backlinks enumeration: - $l_str_FootnoteBacklinks .= "$l_str_Separator'; - $l_str_FootnoteBacklinks .= $l_str_LineBreak; - $l_str_FootnoteBacklinks .= '<' . self::$a_str_LinkSpan; - $l_str_FootnoteBacklinks .= ' id="footnote_plugin_reference_'; - $l_str_FootnoteBacklinks .= self::$a_int_PostId; - $l_str_FootnoteBacklinks .= '_' . self::$a_int_ReferenceContainerId; - $l_str_FootnoteBacklinks .= "_$l_str_FootnoteId\""; - - // insert the optional hard link address: - if (self::$a_bool_HardLinksEnable) { - $l_str_FootnoteBacklinks .= ' href="#'; - $l_str_FootnoteBacklinks .= self::$a_str_ReferrerLinkSlug; - $l_str_FootnoteBacklinks .= self::$a_str_PostContainerIdCompound; - $l_str_FootnoteBacklinks .= $l_str_FootnoteId . '"'; - $l_str_FootnoteBacklinks .= $l_str_UseBackbuttonHint; - } - - $l_str_FootnoteBacklinks .= ' class="footnote_backlink"'; - $l_str_FootnoteBacklinks .= ' onclick="footnote_moveToAnchor_'; - $l_str_FootnoteBacklinks .= self::$a_int_PostId; - $l_str_FootnoteBacklinks .= '_' . self::$a_int_ReferenceContainerId; - $l_str_FootnoteBacklinks .= "('footnote_plugin_tooltip_"; - $l_str_FootnoteBacklinks .= self::$a_int_PostId; - $l_str_FootnoteBacklinks .= '_' . self::$a_int_ReferenceContainerId; - $l_str_FootnoteBacklinks .= "_$l_str_FootnoteId');\">"; - - // append the offset anchor for optional hard links: - if (self::$a_bool_HardLinksEnable) { - $l_str_FootnoteBacklinks .= ''; - } - - $l_str_FootnoteBacklinks .= $l_bool_SymbolSwitch ? '' : $l_str_FootnoteArrow; - $l_str_FootnoteBacklinks .= $l_str_FootnoteId; - $l_str_FootnoteBacklinks .= $l_bool_SymbolSwitch ? $l_str_FootnoteArrow : ''; - - } - } - } - - // append terminator and end tag: - $l_str_FootnoteReference .= $l_str_Terminator . ''; - $l_str_FootnoteBacklinks .= $l_str_Terminator . ''; - - } - - // line wrapping of URLs already fixed, see above - - // get reference container item text if tooltip text goes separate: - $l_int_TooltipTextLength = strpos( $l_str_FootnoteText, self::$a_str_TooltipShortcode ); - $l_bool_HasTooltipText = $l_int_TooltipTextLength === false ? false : true; - if ( $l_bool_HasTooltipText ) { - $l_str_NotTooltipText = substr( $l_str_FootnoteText, ( $l_int_TooltipTextLength + self::$a_int_TooltipShortcodeLength ) ); - self::$a_bool_MirrorTooltipText = MCI_Footnotes_Convert::toBool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE ) ); - if ( self::$a_bool_MirrorTooltipText ) { - $l_str_TooltipText = substr( $l_str_FootnoteText, 0, $l_int_TooltipTextLength ); - $l_str_ReferenceTextIntroducer = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR); - $l_str_ReferenceText = $l_str_TooltipText . $l_str_ReferenceTextIntroducer . $l_str_NotTooltipText; - } else { - $l_str_ReferenceText = $l_str_NotTooltipText; - } - } else { - $l_str_ReferenceText = $l_str_FootnoteText; - } - - // replace all placeholders in table row template: - $l_obj_Template->replace( - array( - - // placeholder used in all templates: - "text" => $l_str_ReferenceText, - - // used in standard layout W/O COMBINED FOOTNOTES: - "post_id" => self::$a_int_PostId, - "container_id" => self::$a_int_ReferenceContainerId, - "note_id" => MCI_Footnotes_Convert::Index($l_int_FirstFootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)), - "link-start" => self::$a_str_LinkOpenTag, - "link-end" => self::$a_str_LinkCloseTag, - "link-span" => self::$a_str_LinkSpan, - "terminator" => $l_str_Terminator, - "anchor-element" => $l_str_FootnoteAnchorElement, - "hard-link" => $l_str_HardLinkAddress, - - // used in standard layout WITH COMBINED IDENTICALS TURNED ON: - "pointer" => $l_bool_FlagCombined ? '' : ' pointer', - "event" => $l_bool_FlagCombined ? '' : $l_str_BacklinkEvent, - "backlinks" => $l_bool_FlagCombined ? $l_str_FootnoteBacklinks : $l_str_FootnoteReference, - - // Legacy placeholders for use in legacy layout templates: - "arrow" => $l_str_FootnoteArrow, - "index" => $l_str_FootnoteId, - ) - ); - - $l_str_Body .= $l_obj_Template->getContent(); - - // extra line breaks for page source readability: - $l_str_Body .= "\r\n\r\n"; - - $l_obj_Template->reload(); - - } - - // call again for robustness when priority levels don’t match any longer: - self::$a_int_ScrollOffset = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET)); - - // streamline: - $l_bool_CollapseDefault = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)); - - /** - * Reference container label - * - * - Bugfix: Reference container: Label: set empty label to U+202F NNBSP for more robustness, thanks to @lukashuggenberg feedback. - * - * @since 2.4.0 - * @date 2021-01-04T0504+0100 - * - * @reporter @lukashuggenberg - * - * Themes may drop-cap a first letter of initial paragraphs, like this label. - * In case of empty label that would apply to the left half button character. - * Hence the point in setting an empty label to U+202F NARROW NO-BREAK SPACE. - */ - $l_str_ReferenceContainerLabel = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME); - - // 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" => self::$a_int_PostId, - "container_id" => self::$a_int_ReferenceContainerId, - "element" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT), - "name" => empty($l_str_ReferenceContainerLabel) ? ' ' : $l_str_ReferenceContainerLabel, - "button-style" => !$l_bool_CollapseDefault ? 'display: none;' : '', - "style" => $l_bool_CollapseDefault ? 'display: none;' : '', - "content" => $l_str_Body, - "scroll-offset" => (self::$a_int_ScrollOffset / 100), - "scroll-duration" => intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION)), - ) - ); - - // free all found footnotes if reference container will be displayed - self::$a_arr_Footnotes = array(); - - return $l_obj_TemplateContainer->getContent(); - } + }; + } + + /** + * Displays the 'LOVE FOOTNOTES' slug if enabled. + * + * @author Stefan Herndler + * @since 1.5.0 + * + * + * @since 2.2.0 more options 2020-12-11T0506+0100 + */ + public function wp_footer() { + if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "footer") { + echo $this->ReferenceContainer(); + } + // 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('%s', 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,7); + } + switch ($l_str_LoveMeIndex) { + // options named wrt backcompat, simplest is default: + case "text-1": $l_str_LoveMeText = sprintf(__('I %2$s %1$s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL); break; + case "text-2": $l_str_LoveMeText = sprintf(__('This website uses the awesome %s plugin.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName); break; + case "text-4": $l_str_LoveMeText = sprintf('%s %s', $l_str_LinkedName, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL); break; + case "text-5": $l_str_LoveMeText = sprintf('%s %s', MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, $l_str_LinkedName); break; + case "text-6": $l_str_LoveMeText = sprintf(__('This website uses %s.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName); break; + case "text-7": $l_str_LoveMeText = sprintf(__('This website uses the %s plugin.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName); break; + case "text-3": default: $l_str_LoveMeText = sprintf('%s', $l_str_LinkedName); break; + } + echo sprintf('
%s
', $l_str_LoveMeText); + } + + /** + * 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); + } + + /** + * 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); + } + + /** + * 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))); + } + + /** + * 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); + } + + /** + * 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); + } + + /** + * 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 + */ + 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]); + } + } + + /** + * 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; + } + + /** + * 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 + * + * + * @since 2.2.0 Adding: Reference container: support for custom position shortcode, thanks to @hamshe issue report. + * @since 2.2.5 Bugfix: Reference container: delete position shortcode if unused because position may be widget or footer, thanks to @hamshe bug report. + */ + 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); + + /** + * Reference container customized positioning through shortcode + * + * - Adding: Reference container: support for custom position shortcode, thanks to @hamshe issue report. + * + * @since 2.2.0 + * @date 2020-12-13T2057+0100 + * + * @reporter @hamshe + * @link https://wordpress.org/support/topic/reference-container-in-elementor/ + * + * + * - Bugfix: Reference container: delete position shortcode if unused because position may be widget or footer, thanks to @hamshe bug report. + * + * @since 2.2.5 + * @date 2020-12-18T1434+0100 + * + * @reporter @hamshe + * @link https://wordpress.org/support/topic/reference-container-in-elementor/#post-13784126 + * + */ + // append the reference container or insert at shortcode: + $l_str_ReferenceContainerPositionShortcode = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE); + if ( empty( $l_str_ReferenceContainerPositionShortcode ) ) { + $l_str_ReferenceContainerPositionShortcode = '[[references]]'; + } + + if ( $p_bool_OutputReferences ) { + + if ( strpos( $p_str_Content, $l_str_ReferenceContainerPositionShortcode ) !== false ) { + + $p_str_Content = str_replace( $l_str_ReferenceContainerPositionShortcode, $this->ReferenceContainer(), $p_str_Content ); + + } else { + + $p_str_Content .= $this->ReferenceContainer(); + + } + + // increment the container ID: + self::$a_int_ReferenceContainerId++; + } + + // delete position shortcode should any remain: + $p_str_Content = str_replace( $l_str_ReferenceContainerPositionShortcode, '', $p_str_Content ); + + // 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 appended: + return $p_str_Content; + } + + /** + * 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 + * + * @since 2.0.0 various. + * @since 2.4.0 Adding: Footnote delimiters: syntax validation for balanced footnote start and end tag short codes. + * @since 2.5.0 Bugfix: Footnote delimiters: Syntax validation: exclude certain cases involving scripts, thanks to @andreasra bug report. + * @since 2.5.0 Bugfix: Footnote delimiters: Syntax validation: complete message with hint about setting, thanks to @andreasra bug report. + * @since 2.5.0 Bugfix: Footnote delimiters: Syntax validation: limit length of quoted string to 300 characters, thanks to @andreasra bug report. + */ + public function search($p_str_Content, $p_bool_ConvertHtmlChars, $p_bool_HideFootnotesText) { + + // post ID to make everything unique wrt infinite scroll and archive view + self::$a_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); + 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; + } + + /** + * Footnote delimiter syntax validation + * + * - Adding: Footnote delimiters: syntax validation for balanced footnote start and end tag short codes. + * + * @since 2.4.0 + * + * + * - Bugfix: Footnote delimiters: Syntax validation: exclude certain cases involving scripts, thanks to @andreasra bug report. + * - Bugfix: Footnote delimiters: Syntax validation: complete message with hint about setting, thanks to @andreasra bug report. + * - Bugfix: Footnote delimiters: Syntax validation: limit length of quoted string to 300 characters, thanks to @andreasra bug report. + * + * @since 2.5.0 + * @date 2021-01-07T0824+0100 + * + * @reporter @andreasra + * @link https://wordpress.org/support/topic/warning-unbalanced-footnote-start-tag-short-code-before/ + * + * + * If footnotes short codes are unbalanced, and syntax validation is not disabled, + * prepend a warning to the content; displays de facto beneath the post title. + */ + if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE))) { + + // make shortcodes conform to regex syntax: + $l_str_StartTagRegex = preg_replace( '#([\(\)\{\}\[\]\*\.\?\!])#', '\\\\$1', $l_str_StartingTag ); + $l_str_EndTagRegex = preg_replace( '#([\(\)\{\}\[\]\*\.\?\!])#', '\\\\$1', $l_str_EndingTag ); + + // apply different regex depending on whether start shortcode is double/triple opening parenthesis: + if ( $l_str_StartingTag == '((' || $l_str_StartingTag == '(((' ) { + + // this prevents from catching a script containing e.g. a double opening parenthesis: + $l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ')[^\{\}])*?)(' . $l_str_StartTagRegex . '|$)#s'; + + } else { + + // catch all only if the start shortcode is not double/triple opening parenthesis, i.e. is unlikely to occur in scripts: + $l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ').)*?)(' . $l_str_StartTagRegex . '|$)#s'; + } + + // check syntax and get error locations: + preg_match( $l_str_ValidationRegex, $p_str_Content, $p_arr_ErrorLocation ); + if ( empty( $p_arr_ErrorLocation ) ) { + self::$a_bool_SyntaxErrorFlag = false; + } + + // prevent generating and inserting the warning multiple times: + if ( self::$a_bool_SyntaxErrorFlag ) { + + // get plain text string for error location: + $l_str_ErrorSpotString = strip_tags( $p_arr_ErrorLocation[1] ); + + // limit string length to 300 characters: + if ( strlen( $l_str_ErrorSpotString ) > 300 ) { + $l_str_ErrorSpotString = substr( $l_str_ErrorSpotString, 0, 299 ) . '…'; + } + + // compose warning box: + $l_str_SyntaxErrorWarning = '

'; + $l_str_SyntaxErrorWarning .= __("WARNING: unbalanced footnote start tag short code found.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME); + $l_str_SyntaxErrorWarning .= '

'; + + // syntax validation setting in the dashboard under the General settings tab: + $l_str_SyntaxErrorWarning .= sprintf( __("If this warning is irrelevant, please disable the syntax validation feature in the dashboard under %s > %s > %s.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("General settings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Footnote start and end short codes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Check for balanced shortcodes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) ); + + $l_str_SyntaxErrorWarning .= '

'; + $l_str_SyntaxErrorWarning .= __("Unbalanced start tag short code found before:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME); + $l_str_SyntaxErrorWarning .= '

“'; + $l_str_SyntaxErrorWarning .= $l_str_ErrorSpotString; + $l_str_SyntaxErrorWarning .= '”

'; + + // prepend the warning box to the content: + $p_str_Content = $l_str_SyntaxErrorWarning . $p_str_Content; + + // checked, set flag to false to prevent duplicate warning: + self::$a_bool_SyntaxErrorFlag = false; + + return $p_str_Content; + } + } + + + // load referrer templates if footnotes text not hidden: + if (!$p_bool_HideFootnotesText) { + + // load footnote referrer template file: + if (self::$a_bool_AlternativeTooltipsEnabled) { + $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"); + } + + /** + * Call Boolean again for robustness when priority levels don’t match any longer. + * + * - Bugfix: Tooltips: fix display in Popup Maker popups by correcting a coding error. + * + * @since 2.5.4 + * @see self::add_filter('pum_popup_content', array($this, "the_content"), $l_int_TheContentPriority) + */ + self::$a_bool_TooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED)); + self::$a_bool_AlternativeTooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE)); + + // load tooltip inline script if jQuery tooltips are enabled: + if (self::$a_bool_TooltipsEnabled && ! self::$a_bool_AlternativeTooltipsEnabled) { + $l_obj_TemplateTooltip = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "tooltip"); + } + + } else { + $l_obj_Template = null; + $l_obj_TemplateTooltip = null; + } + + // search footnotes short codes in the content + do { + // get first occurrence of the footnote start tag short code: + $i_int_LenContent = strlen($p_str_Content); + if ($l_int_PosStart > $i_int_LenContent) $l_int_PosStart = $i_int_LenContent; + $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 the footnote end tag short code: + $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 + $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)); + + // get tooltip text if present: + self::$a_str_TooltipShortcode = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER); + self::$a_int_TooltipShortcodeLength = strlen( self::$a_str_TooltipShortcode ); + $l_int_TooltipTextLength = strpos( $l_str_FootnoteText, self::$a_str_TooltipShortcode ); + $l_bool_HasTooltipText = $l_int_TooltipTextLength === false ? false : true; + if ( $l_bool_HasTooltipText ) { + $l_str_TooltipText = substr( $l_str_FootnoteText, 0, $l_int_TooltipTextLength ); + } else { + $l_str_TooltipText = ''; + } + + /** + * URL line wrapping for Unicode non conformant browsers + * + * @since 2.1.1 (CSS) + * @since 2.1.4 (PHP) + * + * Despite Unicode recommends to line-wrap URLs at slashes, and Firefox follows + * the Unicode standard, Chrome does not, making long URLs hang out of tooltips + * or extend reference containers, so that the end is hidden outside the window + * and may eventually be viewed after we scroll horizontally or zoom out. It is + * up to the web page to make URLs breaking anywhere by wrapping them in a span + * that is assigned appropriate CSS properties and values. + * @see css/public.css + * + * - Bugfix: Tooltips: fix line breaking for hyperlinked URLs in Unicode-non-compliant user agents, thanks to @andreasra bug report. + * + * @since 2.1.1 + * + * @reporter @andreasra + * @link https://wordpress.org/support/topic/footnotes-appearing-in-header/page/3/#post-13657398 + * + * + * - Bugfix: Reference container: fix width in mobile view by URL wrapping for Unicode-non-conformant browsers, thanks to @karolszakiel bug report. + * + * @since 2.1.3 + * @date 2020-11-23 + * + * @reporter @karolszakiel + * @link https://wordpress.org/support/topic/footnotes-on-mobile-phones/ + * + * + * - Bugfix: Reference container, tooltips: fix line wrapping of URLs (hyperlinked or not) based on pattern, not link element. + * + * @since 2.1.4 + * @date 2020-11-25T0837+0100 + * @link https://wordpress.org/support/topic/footnotes-on-mobile-phones/#post-13710682 + * + * + * - Bugfix: Reference container, tooltips: URL wrap: exclude image source too, thanks to @bjrnet21 bug report. + * + * @since 2.1.5 + * + * @reporter @bjrnet21 + * @link https://wordpress.org/support/topic/2-1-4-breaks-on-my-site-images-dont-show/ + * + * + * - Bugfix: Reference container, tooltips: URL wrap: fix regex, thanks to @a223123131 bug report. + * + * @since 2.1.6 + * @date 2020-12-09T1921+0100 + * + * @reporter @a223123131 + * @link https://wordpress.org/support/topic/broken-layout-starting-version-2-1-4/ + * + * Even ARIA labels may take a URL as value, so use \w=[\'"] as a catch-all 2020-12-10T1005+0100 + * + * - Bugfix: Dashboard: URL wrap: add option to properly enable/disable URL wrap. + * + * @since 2.1.6 + * @date 2020-12-09T1606+0100 + * + * + * - Bugfix: Reference container, tooltips: URL wrap: make the quotation mark optional wrt query parameters, thanks to @spiralofhope2 bug report. + * + * @since 2.2.6 + * @date 2020-12-23T0409+0100 + * + * @reporter @spiralofhope2 + * @link https://wordpress.org/support/topic/two-links-now-breaks-footnotes-with-blogtext/ + * + * + * - Bugfix: Reference container, tooltips: URL wrap: remove a bug introduced in the regex, thanks to @rjl20 @spaceling @lukashuggenberg @klusik @friedrichnorth @bernardzit bug reports. + * + * @since 2.2.7 + * @date 2020-12-23T1046+0100 + * + * @reporter @rjl20 + * @link https://wordpress.org/support/topic/two-links-now-breaks-footnotes-with-blogtext/#post-13825479 + * + * @reporter @spaceling + * @link https://wordpress.org/support/topic/two-links-now-breaks-footnotes-with-blogtext/#post-13825532 + * + * @reporter @lukashuggenberg + * @link https://wordpress.org/support/topic/2-2-6-breaks-all-footnotes/ + * + * @reporter @klusik + * @link https://wordpress.org/support/topic/2-2-6-breaks-all-footnotes/#post-13825885 + * + * @reporter @friedrichnorth + * @link https://wordpress.org/support/topic/footnotes-dont-show-after-update-to-2-2-6/ + * + * @reporter @bernardzit + * @link https://wordpress.org/support/topic/footnotes-dont-show-after-update-to-2-2-6/#post-13826029 + * + * + * @since 2.2.8 Bugfix: Reference container, tooltips: URL wrap: correctly make the quotation mark optional wrt query parameters, thanks to @spiralofhope2 bug report. + * @date 2020-12-23T1107+0100 + * + * Correct is duplicating the negative lookbehind w/o quotes: '(?get( MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_URL_WRAP_ENABLED ) ) ) { + + $l_str_FootnoteText = preg_replace( + '#(?$1', + $l_str_FootnoteText + ); + } + + // Text to be displayed instead of the footnote + $l_str_FootnoteReplaceText = ""; + + // whether hard links are enabled: + if (self::$a_bool_HardLinksEnable) { + + // get the configurable parts: + self::$a_str_ReferrerLinkSlug = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERRER_FRAGMENT_ID_SLUG); + self::$a_str_FootnoteLinkSlug = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG); + self::$a_str_LinkIdsSeparator = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_HARD_LINK_IDS_SEPARATOR); + + // streamline ID concatenation: + self::$a_str_PostContainerIdCompound = self::$a_str_LinkIdsSeparator; + self::$a_str_PostContainerIdCompound .= self::$a_int_PostId; + self::$a_str_PostContainerIdCompound .= self::$a_str_LinkIdsSeparator; + self::$a_str_PostContainerIdCompound .= self::$a_int_ReferenceContainerId; + self::$a_str_PostContainerIdCompound .= self::$a_str_LinkIdsSeparator; + + } + + // display the footnote referrers and the tooltips: + if (!$p_bool_HideFootnotesText) { + $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 a truncated footnote text if option enabled: + $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)); + + // define excerpt text as footnote text by default: + $l_str_ExcerptText = $l_str_FootnoteText; + + /** + * Tooltip truncation + * + * - Adding: Tooltips: Read-on button: Label: configurable instead of localizable, thanks to @rovanov example provision. + * + * @since 2.1.0 + * @date 2020-11-08T2146+0100 + * + * @reporter @rovanov + * @link https://wordpress.org/support/topic/offset-x-axis-and-offset-y-axis-does-not-working/ + * + * If the tooltip truncation option is enabled, it’s done based on character count, + * and a trailing incomplete word is cropped. + * This is equivalent to the WordPress default excerpt generation, i.e. without a + * custom excerpt and without a delimiter. But WordPress does word count, usually 55. + */ + if (self::$a_bool_TooltipsEnabled && $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, ' ')); + $l_str_ExcerptText .= ' … <'; + $l_str_ExcerptText .= self::$a_bool_HardLinksEnable ? 'a' : 'span'; + $l_str_ExcerptText .= ' class="footnote_tooltip_continue" '; + $l_str_ExcerptText .= 'onclick="footnote_moveToAnchor_' . self::$a_int_PostId; + $l_str_ExcerptText .= '_' . self::$a_int_ReferenceContainerId; + $l_str_ExcerptText .= '(\'footnote_plugin_reference_' . self::$a_int_PostId; + $l_str_ExcerptText .= '_' . self::$a_int_ReferenceContainerId; + $l_str_ExcerptText .= "_$l_int_Index');\""; + + // if enabled, add the hard link fragment ID: + if (self::$a_bool_HardLinksEnable) { + + $l_str_ExcerptText .= ' href="#'; + $l_str_ExcerptText .= self::$a_str_FootnoteLinkSlug; + $l_str_ExcerptText .= self::$a_str_PostContainerIdCompound; + $l_str_ExcerptText .= $l_int_Index; + $l_str_ExcerptText .= '"'; + } + + $l_str_ExcerptText .= '>'; + + /** + * Configurable read-on button label + * + * - Adding: Tooltips: Read-on button: Label: configurable instead of localizable, thanks to @rovanov example provision. + * + * @since 2.1.0 + * @date 2020-11-08T2146+0100 + * + * @reporter @rovanov + * @link https://wordpress.org/support/topic/offset-x-axis-and-offset-y-axis-does-not-working/ + */ + $l_str_ExcerptText .= MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL); + + $l_str_ExcerptText .= self::$a_bool_HardLinksEnable ? '' : ''; + } + } + + /** + * Referrers element superscript or baseline + * + * Referrers: new setting for vertical align: superscript (default) or baseline (optional), thanks to @cwbayer bug report + * @since 2.1.1 + * + * @reporter @cwbayer + * @link https://wordpress.org/support/topic/footnote-number-in-text-superscript-disrupts-leading/ + * + * 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_SupSpan = 'sup'; + + } else { + + $l_str_SupSpan = 'span'; + } + + // whether hard links are enabled: + if (self::$a_bool_HardLinksEnable) { + + self::$a_str_LinkSpan = 'a'; + self::$a_str_LinkCloseTag = ''; + // self::$a_str_LinkOpenTag will be defined as needed + + // compose hyperlink address (leading space is in template): + $l_str_FootnoteLinkArgument = 'href="#'; + $l_str_FootnoteLinkArgument .= self::$a_str_FootnoteLinkSlug; + $l_str_FootnoteLinkArgument .= self::$a_str_PostContainerIdCompound; + $l_str_FootnoteLinkArgument .= $l_int_Index; + $l_str_FootnoteLinkArgument .= '" class="footnote_hard_link"'; + + /** + * Compose fragment ID anchor with offset, for use in reference container. + * Empty span, child of empty span, to avoid tall dotted rectangles in browser. + */ + $l_str_ReferrerAnchorElement = ''; + + } else { + + /** + * Initialize hard link variables when hard links are disabled. + * + * - Bugfix: Process: initialize hard link address variables to empty string to fix 'undefined variable' bug, thanks to @a223123131 bug report. + * + * @since 2.4.0 + * @date 2021-01-04T1622+0100 + * + * @reporter @a223123131 + * @link https://wordpress.org/support/topic/wp_debug-php-notice/ + * + * If no hyperlink nor offset anchor is needed, initialize as empty. + */ + $l_str_FootnoteLinkArgument = ''; + $l_str_ReferrerAnchorElement = ''; + + // The link element is set independently as it may be needed for styling: + if ( MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_LINK_ELEMENT_ENABLED)) ) { + + self::$a_str_LinkSpan = 'a'; + self::$a_str_LinkOpenTag = ''; + self::$a_str_LinkCloseTag = ''; + + } + } + + // determine tooltip content: + if ( self::$a_bool_TooltipsEnabled ) { + $l_str_TooltipContent = $l_bool_HasTooltipText ? $l_str_TooltipText : $l_str_ExcerptText; + } else { + $l_str_TooltipContent = ''; + } + + // fill in 'templates/public/footnote.html': + $l_obj_Template->replace( + array( + "link-span" => self::$a_str_LinkSpan, + "post_id" => self::$a_int_PostId, + "container_id" => self::$a_int_ReferenceContainerId, + "note_id" => $l_int_Index, + "hard-link" => $l_str_FootnoteLinkArgument, + "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), + "anchor-element" => $l_str_ReferrerAnchorElement, + "text" => $l_str_TooltipContent, + ) + ); + $l_str_FootnoteReplaceText = $l_obj_Template->getContent(); + + // reset the template + $l_obj_Template->reload(); + + // if standard tooltips are enabled but alternative are not: + if (self::$a_bool_TooltipsEnabled && ! self::$a_bool_AlternativeTooltipsEnabled) { + + $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)); + $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)); + + // fill in 'templates/public/tooltip.html': + $l_obj_TemplateTooltip->replace( + array( + "post_id" => self::$a_int_PostId, + "container_id" => self::$a_int_ReferenceContainerId, + "note_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, + ) + ); + $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 + self::$a_arr_Footnotes[] = $l_str_FootnoteText; + // increase footnote index + $l_int_FootnoteIndex++; + } + + /** + * Fixes a footnotes numbering bug (happening under de facto rare circumstances). + * + * - Bugfix: Fixed occasional bug where footnote ordering could be out of sequence + * + * @since 1.6.4 + * @date 2016-06-29T0054+0000 + * @committer @dartiss + * @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class/task.php?rev=1445718 @dartiss’ class/task.php + * @link https://plugins.trac.wordpress.org/log/footnotes/trunk/class/task.php?rev=1445718 @dartiss re-added class/task.php + * @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class?rev=1445711 class/ w/o task.php + * @link https://plugins.trac.wordpress.org/changeset/1445711/footnotes/trunk/class @dartiss deleted class/task.php + * @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class/task.php?rev=1026210 @aricura’s latest class/task.php + * + * + * - Bugfix: Process: fix numbering bug impacting footnote #2 with footnote #1 close to start, thanks to @rumperuu bug report, thanks to @lolzim code contribution. + * + * @since 2.5.5 + * + * @contributor @lolzim + * @link https://wordpress.org/support/topic/footnotes-numbered-incorrectly/#post-14062032 + * + * @reporter @rumperuu + * @link https://wordpress.org/support/topic/footnotes-numbered-incorrectly/ + * + * This assignment was overridden by another one, causing the algorithm to jump back + * near the post start to a position calculated as the sum of the length of the last + * footnote and the length of the last footnote replace text. + * A bug disturbing the order of the footnotes depending on the text before the first + * footnote, the length of the first footnote and the length of the templates for the + * footnote and the tooltip. Moreover, it was causing non-trivial process garbage. + */ + // add offset to the new starting position + $l_int_PosStart += $l_int_Length + strlen($l_str_EndingTag); + + } while (true); + + // return content + return $p_str_Content; + } + + /** + * Generates the reference container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + * + * @since 2.0.0 Update: remove backlink symbol along with column 2 of the reference container + * @since 2.0.3 Bugfix: prepend an arrow on user request + * @since 2.0.6 Bugfix: Reference container: fix line breaking behavior in footnote number clusters. + * @since 2.0.4 Bugfix: restore the arrow select and backlink symbol input settings + * @since 2.1.1 Bugfix: Referrers, reference container: Combining identical footnotes: fix dead links and ensure referrer-backlink bijectivity, thanks to @happyches bug report. + * @since 2.1.1 Bugfix: Reference container: Backlink symbol: make optional, not suggest configuring it to invisible, thanks to @spaceling feedback. + */ + public function ReferenceContainer() { + + // no footnotes have been replaced on this page: + if (empty(self::$a_arr_Footnotes)) { + return ""; + } + + + /** + * Footnote index backlink symbol + * + * - Bugfix: Reference container: Backlink symbol: make optional, not suggest configuring it to invisible, thanks to @spaceling feedback. + * + * @since 2.1.1 + * + * @reporter @spaceling + * @link https://wordpress.org/support/topic/change-the-position-5/page/2/#post-13671138 + * + * If the backlink symbol 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 = ''; + $l_str_FootnoteArrow .= $l_str_Arrow . ''; + + } else { + + // If the backlink symbol isn’t enabled, set it to empty: + $l_str_Arrow = ''; + $l_str_FootnoteArrow = ''; + + } + + + /** + * Backlink separator + * + * - Bugfix: Reference container: make separating and terminating punctuation optional and configurable, thanks to @docteurfitness issue report and code contribution. + * + * @since 2.1.4 + * @date 2020-11-28T1048+0100 + * + * @contributor @docteurfitness + * @link https://wordpress.org/support/topic/update-2-1-3/#post-13704194 + * + * @reporter @docteurfitness + * @link https://wordpress.org/support/topic/update-2-1-3/ + * + * Initially a comma was appended in this algorithm for enumerations. + * The comma in enumerations is not generally preferred. + */ + if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_SEPARATOR_ENABLED))) { + + // check if it is input-configured: + $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 = ''; + } + + /** + * 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. + * @since 2.1.4 the terminator is optional, has options, and is configurable: + */ + if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_TERMINATOR_ENABLED))) { + + // check if it is input-configured: + $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 { + + $l_str_Terminator = ''; + } + + + /** + * Line breaks + * + * - Bugfix: Reference container: Backlinks: fix stacked enumerations by adding optional line breaks. + * + * @since 2.1.4 + * @date 2020-11-28T1049+0100 + * + * 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)) ? '
' : ' '; + + /** + * For maintenance and support, table rows in the reference container should be + * 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): + */ + $l_str_Body = "\r\n\r\n"; + + + /** + * Reference container table row template load + * + * - Bugfix: Reference container: option to restore pre-2.0.0 layout with the backlink symbol in an extra column. + * + * @since 2.1.1 + * @date 2020-11-16T2024+0100 + */ + + // when combining identical footnotes 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))) { + // the combining template allows for backlink clusters and supports cell clicking for single notes: + $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 available 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, and combining and 3-columns are off: + 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"); + + } + } + } + + /** + * Switch backlink symbol and footnote number + * + * - Bugfix: Reference container: option to append symbol (prepended by default), thanks to @spaceling code contribution. + * + * @since 2.1.1 + * @date 2020-11-16T2024+0100 + * + * @contributor @spaceling + * @link https://wordpress.org/support/topic/change-the-position-5/#post-13615994 + * + * + * - Bugfix: Reference container: Backlink symbol: support for appending when combining identicals is on. + * + * @since 2.1.4 + * @date 2020-11-26T1633+0100 + */ + $l_bool_SymbolSwitch = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH)); + + // loop through all footnotes found in the page + for ($l_int_Index = 0; $l_int_Index < count(self::$a_arr_Footnotes); $l_int_Index++) { + + // get footnote text + $l_str_FootnoteText = self::$a_arr_Footnotes[$l_int_Index]; + + // if footnote is empty, go to the next one; + // With combine identicals turned on, identicals will be deleted and are skipped: + if (empty($l_str_FootnoteText)) { + continue; + } + + // 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_FootnoteId = MCI_Footnotes_Convert::Index(($l_int_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)); + + /** + * Case of only one backlink per table row + * + * If enabled, and for the case the footnote is single, compose hard link: + */ + // define anyway: + $l_str_HardLinkAddress = ''; + + if (self::$a_bool_HardLinksEnable) { + + /** + * Use-Backbutton-Hint tooltip, optional and configurable. + * + * - Update: Reference container: Hard backlinks (optional): optional configurable tooltip hinting to use the backbutton instead, thanks to @theroninjedi47 bug report. + * + * @since 2.5.4 + * + * @reporter @theroninjedi47 + * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ + * + * When hard links are enabled, clicks on the backlinks are logged in the browsing history. + * This tooltip hints to use the backbutton instead, so the history gets streamlined again. + * @link https://wordpress.org/support/topic/making-it-amp-compatible/#post-13837359 + */ + if ( MCI_Footnotes_Convert::toBool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE ) ) ) { + $l_str_UseBackbuttonHint = ' title="'; + $l_str_UseBackbuttonHint .= MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT); + $l_str_UseBackbuttonHint .= '"'; + } else { + $l_str_UseBackbuttonHint = ''; + } + + /** + * Compose fragment ID anchor with offset, for use in reference container. + * Empty span, child of empty span, to avoid tall dotted rectangles in browser. + */ + $l_str_FootnoteAnchorElement = ''; + + // compose optional hard link address: + $l_str_HardLinkAddress = ' href="#'; + $l_str_HardLinkAddress .= self::$a_str_ReferrerLinkSlug; + $l_str_HardLinkAddress .= self::$a_str_PostContainerIdCompound; + $l_str_HardLinkAddress .= $l_str_FootnoteId . '"'; + $l_str_HardLinkAddress .= $l_str_UseBackbuttonHint; + + // compose optional opening link tag with optional hard link, mandatory for instance: + self::$a_str_LinkOpenTag = 'get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) { + + // ID, optional hard link address, and class: + $l_str_FootnoteReference = '<' . self::$a_str_LinkSpan; + $l_str_FootnoteReference .= ' id="footnote_plugin_reference_'; + $l_str_FootnoteReference .= self::$a_int_PostId; + $l_str_FootnoteReference .= '_' . self::$a_int_ReferenceContainerId; + $l_str_FootnoteReference .= "_$l_str_FootnoteId\""; + if (self::$a_bool_HardLinksEnable) { + $l_str_FootnoteReference .= ' href="#'; + $l_str_FootnoteReference .= self::$a_str_ReferrerLinkSlug; + $l_str_FootnoteReference .= self::$a_str_PostContainerIdCompound; + $l_str_FootnoteReference .= $l_str_FootnoteId . '"'; + $l_str_FootnoteReference .= $l_str_UseBackbuttonHint; + } + $l_str_FootnoteReference .= ' class="footnote_backlink"'; + + // the click event goes in the table cell if footnote remains single: + $l_str_BacklinkEvent = ' onclick="footnote_moveToAnchor_'; + $l_str_BacklinkEvent .= self::$a_int_PostId; + $l_str_BacklinkEvent .= '_' . self::$a_int_ReferenceContainerId; + $l_str_BacklinkEvent .= "('footnote_plugin_tooltip_"; + $l_str_BacklinkEvent .= self::$a_int_PostId; + $l_str_BacklinkEvent .= '_' . self::$a_int_ReferenceContainerId; + $l_str_BacklinkEvent .= "_$l_str_FootnoteId');\""; + + + // the dedicated template enumerating backlinks uses another variable: + $l_str_FootnoteBacklinks = $l_str_FootnoteReference; + + // append the click event right to the backlink item for enumerations; + // else it goes in the table cell: + $l_str_FootnoteBacklinks .= $l_str_BacklinkEvent . '>'; + $l_str_FootnoteReference .= '>'; + + // append the optional offset anchor for hard links: + if (self::$a_bool_HardLinksEnable) { + $l_str_FootnoteReference .= $l_str_FootnoteAnchorElement; + $l_str_FootnoteBacklinks .= $l_str_FootnoteAnchorElement; + } + + // continue both single note and notes cluster, depending on switch option status: + if ($l_bool_SymbolSwitch) { + + $l_str_FootnoteReference .= "$l_str_FootnoteId$l_str_FootnoteArrow"; + $l_str_FootnoteBacklinks .= "$l_str_FootnoteId$l_str_FootnoteArrow"; + + } else { + + $l_str_FootnoteReference .= "$l_str_FootnoteArrow$l_str_FootnoteId"; + $l_str_FootnoteBacklinks .= "$l_str_FootnoteArrow$l_str_FootnoteId"; + + } + + // If that is the only footnote with this text, we’re almost done. + + // check if it isn't the last footnote in the array: + if ($l_int_FirstFootnoteIndex < count(self::$a_arr_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] = ""; + + // set the flag to true for the combined status: + $l_bool_FlagCombined = true; + + // 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)); + + // resume composing the backlinks enumeration: + $l_str_FootnoteBacklinks .= "$l_str_Separator'; + $l_str_FootnoteBacklinks .= $l_str_LineBreak; + $l_str_FootnoteBacklinks .= '<' . self::$a_str_LinkSpan; + $l_str_FootnoteBacklinks .= ' id="footnote_plugin_reference_'; + $l_str_FootnoteBacklinks .= self::$a_int_PostId; + $l_str_FootnoteBacklinks .= '_' . self::$a_int_ReferenceContainerId; + $l_str_FootnoteBacklinks .= "_$l_str_FootnoteId\""; + + // insert the optional hard link address: + if (self::$a_bool_HardLinksEnable) { + $l_str_FootnoteBacklinks .= ' href="#'; + $l_str_FootnoteBacklinks .= self::$a_str_ReferrerLinkSlug; + $l_str_FootnoteBacklinks .= self::$a_str_PostContainerIdCompound; + $l_str_FootnoteBacklinks .= $l_str_FootnoteId . '"'; + $l_str_FootnoteBacklinks .= $l_str_UseBackbuttonHint; + } + + $l_str_FootnoteBacklinks .= ' class="footnote_backlink"'; + $l_str_FootnoteBacklinks .= ' onclick="footnote_moveToAnchor_'; + $l_str_FootnoteBacklinks .= self::$a_int_PostId; + $l_str_FootnoteBacklinks .= '_' . self::$a_int_ReferenceContainerId; + $l_str_FootnoteBacklinks .= "('footnote_plugin_tooltip_"; + $l_str_FootnoteBacklinks .= self::$a_int_PostId; + $l_str_FootnoteBacklinks .= '_' . self::$a_int_ReferenceContainerId; + $l_str_FootnoteBacklinks .= "_$l_str_FootnoteId');\">"; + + // append the offset anchor for optional hard links: + if (self::$a_bool_HardLinksEnable) { + $l_str_FootnoteBacklinks .= ''; + } + + $l_str_FootnoteBacklinks .= $l_bool_SymbolSwitch ? '' : $l_str_FootnoteArrow; + $l_str_FootnoteBacklinks .= $l_str_FootnoteId; + $l_str_FootnoteBacklinks .= $l_bool_SymbolSwitch ? $l_str_FootnoteArrow : ''; + + } + } + } + + // append terminator and end tag: + $l_str_FootnoteReference .= $l_str_Terminator . ''; + $l_str_FootnoteBacklinks .= $l_str_Terminator . ''; + + } + + // line wrapping of URLs already fixed, see above + + // get reference container item text if tooltip text goes separate: + $l_int_TooltipTextLength = strpos( $l_str_FootnoteText, self::$a_str_TooltipShortcode ); + $l_bool_HasTooltipText = $l_int_TooltipTextLength === false ? false : true; + if ( $l_bool_HasTooltipText ) { + $l_str_NotTooltipText = substr( $l_str_FootnoteText, ( $l_int_TooltipTextLength + self::$a_int_TooltipShortcodeLength ) ); + self::$a_bool_MirrorTooltipText = MCI_Footnotes_Convert::toBool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE ) ); + if ( self::$a_bool_MirrorTooltipText ) { + $l_str_TooltipText = substr( $l_str_FootnoteText, 0, $l_int_TooltipTextLength ); + $l_str_ReferenceTextIntroducer = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR); + $l_str_ReferenceText = $l_str_TooltipText . $l_str_ReferenceTextIntroducer . $l_str_NotTooltipText; + } else { + $l_str_ReferenceText = $l_str_NotTooltipText; + } + } else { + $l_str_ReferenceText = $l_str_FootnoteText; + } + + // replace all placeholders in table row template: + $l_obj_Template->replace( + array( + + // placeholder used in all templates: + "text" => $l_str_ReferenceText, + + // used in standard layout W/O COMBINED FOOTNOTES: + "post_id" => self::$a_int_PostId, + "container_id" => self::$a_int_ReferenceContainerId, + "note_id" => MCI_Footnotes_Convert::Index($l_int_FirstFootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)), + "link-start" => self::$a_str_LinkOpenTag, + "link-end" => self::$a_str_LinkCloseTag, + "link-span" => self::$a_str_LinkSpan, + "terminator" => $l_str_Terminator, + "anchor-element" => $l_str_FootnoteAnchorElement, + "hard-link" => $l_str_HardLinkAddress, + + // used in standard layout WITH COMBINED IDENTICALS TURNED ON: + "pointer" => $l_bool_FlagCombined ? '' : ' pointer', + "event" => $l_bool_FlagCombined ? '' : $l_str_BacklinkEvent, + "backlinks" => $l_bool_FlagCombined ? $l_str_FootnoteBacklinks : $l_str_FootnoteReference, + + // Legacy placeholders for use in legacy layout templates: + "arrow" => $l_str_FootnoteArrow, + "index" => $l_str_FootnoteId, + ) + ); + + $l_str_Body .= $l_obj_Template->getContent(); + + // extra line breaks for page source readability: + $l_str_Body .= "\r\n\r\n"; + + $l_obj_Template->reload(); + + } + + // call again for robustness when priority levels don’t match any longer: + self::$a_int_ScrollOffset = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET)); + + // streamline: + $l_bool_CollapseDefault = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)); + + /** + * Reference container label + * + * - Bugfix: Reference container: Label: set empty label to U+202F NNBSP for more robustness, thanks to @lukashuggenberg feedback. + * + * @since 2.4.0 + * @date 2021-01-04T0504+0100 + * + * @reporter @lukashuggenberg + * + * Themes may drop-cap a first letter of initial paragraphs, like this label. + * In case of empty label that would apply to the left half button character. + * Hence the point in setting an empty label to U+202F NARROW NO-BREAK SPACE. + */ + $l_str_ReferenceContainerLabel = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME); + + // 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" => self::$a_int_PostId, + "container_id" => self::$a_int_ReferenceContainerId, + "element" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT), + "name" => empty($l_str_ReferenceContainerLabel) ? ' ' : $l_str_ReferenceContainerLabel, + "button-style" => !$l_bool_CollapseDefault ? 'display: none;' : '', + "style" => $l_bool_CollapseDefault ? 'display: none;' : '', + "content" => $l_str_Body, + "scroll-offset" => (self::$a_int_ScrollOffset / 100), + "scroll-duration" => intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION)), + ) + ); + + // free all found footnotes if reference container will be displayed + self::$a_arr_Footnotes = array(); + + return $l_obj_TemplateContainer->getContent(); + } } diff --git a/class/template.php b/class/template.php index 4d2758c..d8c19b9 100644 --- a/class/template.php +++ b/class/template.php @@ -7,7 +7,7 @@ * @since 1.5.0 14.09.14 10:58 * * - * @lastmodified 2021-02-12T1113+0100 + * @lastmodified 2021-02-18T2024+0100 * * @since 2.0.3 prettify reference container template * @since 2.0.3 replace tab with a space @@ -38,224 +38,224 @@ */ class MCI_Footnotes_Template { - /** - * Directory name for dashboard templates. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - const C_STR_DASHBOARD = "dashboard"; + /** + * Directory name for dashboard templates. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_DASHBOARD = "dashboard"; - /** - * Directory name for public templates. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - const C_STR_PUBLIC = "public"; + /** + * Directory name for public templates. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_PUBLIC = "public"; - /** - * Contains the content of the template after initialize. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - private $a_str_OriginalContent = ""; + /** + * Contains the content of the template after initialize. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + private $a_str_OriginalContent = ""; - /** - * Contains the content of the template after initialize with replaced place holders. - * - * @author Stefan Herndler - * @since 1.5.0 - * @var string - */ - private $a_str_ReplacedContent = ""; + /** + * Contains the content of the template after initialize with replaced place holders. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + private $a_str_ReplacedContent = ""; - /** - * Plugin Directory - * - * @author Patrizia Lutz @misfist - * @since 2.4.0d3 - * - * @var string - */ - public $plugin_directory; + /** + * Plugin Directory + * + * @author Patrizia Lutz @misfist + * @since 2.4.0d3 + * + * @var string + */ + public $plugin_directory; - /** - * Class Constructor. Reads and loads the template file without replace any placeholder. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param string $p_str_FileType Template file type (take a look on the Class constants). - * @param string $p_str_FileName Template file name inside the Template directory without the file extension. - * @param string $p_str_Extension Optional Template file extension (default: html) - * - * - * @since 2.2.6 support for custom templates 2020-12-19T0606+0100 - * @link https://wordpress.org/support/topic/template-override-filter/ - * - * @since 2.4.0 look for custom template in the active theme first, thanks to @misfist - * @link https://wordpress.org/support/topic/template-override-filter/#post-13846598 - */ - public function __construct($p_str_FileType, $p_str_FileName, $p_str_Extension = "html") { - // no template file type and/or file name set - if (empty($p_str_FileType) || empty($p_str_FileName)) { - return; - } + /** + * Class Constructor. Reads and loads the template file without replace any placeholder. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_FileType Template file type (take a look on the Class constants). + * @param string $p_str_FileName Template file name inside the Template directory without the file extension. + * @param string $p_str_Extension Optional Template file extension (default: html) + * + * + * @since 2.2.6 support for custom templates 2020-12-19T0606+0100 + * @link https://wordpress.org/support/topic/template-override-filter/ + * + * @since 2.4.0 look for custom template in the active theme first, thanks to @misfist + * @link https://wordpress.org/support/topic/template-override-filter/#post-13846598 + */ + public function __construct($p_str_FileType, $p_str_FileName, $p_str_Extension = "html") { + // no template file type and/or file name set + if (empty($p_str_FileType) || empty($p_str_FileName)) { + return; + } - /** - * Define plugin root path - * - * @since 2.4.0d3 - * - * @author Patrizia Lutz @misfist - */ - $this->plugin_directory = plugin_dir_path( dirname( __FILE__ ) ); + /** + * Define plugin root path + * + * @since 2.4.0d3 + * + * @author Patrizia Lutz @misfist + */ + $this->plugin_directory = plugin_dir_path( dirname( __FILE__ ) ); - /** - * Modularize functions - * - * @since 2.4.0d3 - * - * @author Patrizia Lutz @misfist - */ - if( $template = $this->get_template( $p_str_FileType, $p_str_FileName, $p_str_Extension ) ) { - $this->process_template( $template ); - } else { - return; - } + /** + * Modularize functions + * + * @since 2.4.0d3 + * + * @author Patrizia Lutz @misfist + */ + if( $template = $this->get_template( $p_str_FileType, $p_str_FileName, $p_str_Extension ) ) { + $this->process_template( $template ); + } else { + return; + } - } + } - /** - * Replace all placeholders specified in array. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param array $p_arr_Placeholders Placeholders (key = placeholder, value = value). - * @return bool True on Success, False if Placeholders invalid. - */ - public function replace($p_arr_Placeholders) { - // no placeholders set - if (empty($p_arr_Placeholders)) { - return false; - } - // template content is empty - if (empty($this->a_str_ReplacedContent)) { - return false; - } - // iterate through each placeholder and replace it with its value - foreach($p_arr_Placeholders as $l_str_Placeholder => $l_str_Value) { - $this->a_str_ReplacedContent = str_replace("[[" . $l_str_Placeholder . "]]", $l_str_Value, $this->a_str_ReplacedContent); - } - // success - return true; - } + /** + * Replace all placeholders specified in array. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param array $p_arr_Placeholders Placeholders (key = placeholder, value = value). + * @return bool True on Success, False if Placeholders invalid. + */ + public function replace($p_arr_Placeholders) { + // no placeholders set + if (empty($p_arr_Placeholders)) { + return false; + } + // template content is empty + if (empty($this->a_str_ReplacedContent)) { + return false; + } + // iterate through each placeholder and replace it with its value + foreach($p_arr_Placeholders as $l_str_Placeholder => $l_str_Value) { + $this->a_str_ReplacedContent = str_replace("[[" . $l_str_Placeholder . "]]", $l_str_Value, $this->a_str_ReplacedContent); + } + // success + return true; + } - /** - * Reloads the original content of the template file. - * - * @author Stefan Herndler - * @since 1.5.0 - */ - public function reload() { - $this->a_str_ReplacedContent = $this->a_str_OriginalContent; - } + /** + * Reloads the original content of the template file. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function reload() { + $this->a_str_ReplacedContent = $this->a_str_OriginalContent; + } - /** - * Returns the content of the template file with replaced placeholders. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string Template content with replaced placeholders. - */ - public function getContent() { - return $this->a_str_ReplacedContent; - } + /** + * Returns the content of the template file with replaced placeholders. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string Template content with replaced placeholders. + */ + public function getContent() { + return $this->a_str_ReplacedContent; + } - /** - * Process template file - * - * @author Patrizia Lutz @misfist - * - * @since 2.4.0d3 - * - * @param string $template - * @return void - * - * - * @since 2.0.3 replace tab with a space - * @since 2.0.3 replace 2 spaces with 1 - * @since 2.0.4 collapse multiple spaces - * @since 2.2.6 delete a space before a closing pointy bracket - * @since 2.5.4 collapse HTML comments and PHP/JS docblocks (only) - */ - public function process_template( $template ) { - $this->a_str_OriginalContent = preg_replace( '##s', "", file_get_contents( $template ) ); - $this->a_str_OriginalContent = preg_replace( '#/\*\*.+?\*/#s', "", $this->a_str_OriginalContent ); - $this->a_str_OriginalContent = str_replace( "\n", "", $this->a_str_OriginalContent ); - $this->a_str_OriginalContent = str_replace( "\r", "", $this->a_str_OriginalContent ); - $this->a_str_OriginalContent = str_replace( "\t", " ", $this->a_str_OriginalContent ); - $this->a_str_OriginalContent = preg_replace( '# +#', " ", $this->a_str_OriginalContent ); - $this->a_str_OriginalContent = str_replace( " >", ">", $this->a_str_OriginalContent ); - $this->reload(); - } + /** + * Process template file + * + * @author Patrizia Lutz @misfist + * + * @since 2.4.0d3 + * + * @param string $template + * @return void + * + * + * @since 2.0.3 replace tab with a space + * @since 2.0.3 replace 2 spaces with 1 + * @since 2.0.4 collapse multiple spaces + * @since 2.2.6 delete a space before a closing pointy bracket + * @since 2.5.4 collapse HTML comments and PHP/JS docblocks (only) + */ + public function process_template( $template ) { + $this->a_str_OriginalContent = preg_replace( '##s', "", file_get_contents( $template ) ); + $this->a_str_OriginalContent = preg_replace( '#/\*\*.+?\*/#s', "", $this->a_str_OriginalContent ); + $this->a_str_OriginalContent = str_replace( "\n", "", $this->a_str_OriginalContent ); + $this->a_str_OriginalContent = str_replace( "\r", "", $this->a_str_OriginalContent ); + $this->a_str_OriginalContent = str_replace( "\t", " ", $this->a_str_OriginalContent ); + $this->a_str_OriginalContent = preg_replace( '# +#', " ", $this->a_str_OriginalContent ); + $this->a_str_OriginalContent = str_replace( " >", ">", $this->a_str_OriginalContent ); + $this->reload(); + } - /** - * Get the template - * - * @author Patrizia Lutz @misfist - * - * @since 2.4.0d3 - * - * @param string $p_str_FileType - * @param string $p_str_FileName - * @param string $p_str_Extension - * @return mixed false | template path - */ - public function get_template( $p_str_FileType, $p_str_FileName, $p_str_Extension = "html" ) { - $located = false; + /** + * Get the template + * + * @author Patrizia Lutz @misfist + * + * @since 2.4.0d3 + * + * @param string $p_str_FileType + * @param string $p_str_FileName + * @param string $p_str_Extension + * @return mixed false | template path + */ + public function get_template( $p_str_FileType, $p_str_FileName, $p_str_Extension = "html" ) { + $located = false; - /** - * The directory change be modified - * @usage to change location of templates to `template_parts/footnotes/': - * add_filter( 'mci_footnotes_template_directory', function( $directory ) { - * return 'template_parts/footnotes/; - * } ); - */ - $template_directory = apply_filters( 'mci_footnotes_template_directory', 'footnotes/templates/' ); - $custom_directory = apply_filters( 'mci_footnotes_custom_template_directory', 'footnotes-custom/' ); - $template_name = $p_str_FileType . '/' . $p_str_FileName . '.' . $p_str_Extension; + /** + * The directory change be modified + * @usage to change location of templates to `template_parts/footnotes/': + * add_filter( 'mci_footnotes_template_directory', function( $directory ) { + * return 'template_parts/footnotes/; + * } ); + */ + $template_directory = apply_filters( 'mci_footnotes_template_directory', 'footnotes/templates/' ); + $custom_directory = apply_filters( 'mci_footnotes_custom_template_directory', 'footnotes-custom/' ); + $template_name = $p_str_FileType . '/' . $p_str_FileName . '.' . $p_str_Extension; - /** - * Look in active (child) theme - */ - if ( file_exists( trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name ) ) { - $located = trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name; + /** + * Look in active (child) theme + */ + if ( file_exists( trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name ) ) { + $located = trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name; - /** - * Look in parent theme - */ - } elseif ( file_exists( trailingslashit( get_template_directory() ) . $template_directory . $template_name ) ) { - $located = trailingslashit( get_template_directory() ) . $template_directory . $template_name; + /** + * Look in parent theme + */ + } elseif ( file_exists( trailingslashit( get_template_directory() ) . $template_directory . $template_name ) ) { + $located = trailingslashit( get_template_directory() ) . $template_directory . $template_name; - /** - * Look in custom directory - */ - } elseif ( file_exists( trailingslashit( WP_PLUGIN_DIR ) . $custom_directory . 'templates/' . $template_name ) ) { - $located = trailingslashit( WP_PLUGIN_DIR ) . $custom_directory . 'templates/' . $template_name; + /** + * Look in custom directory + */ + } elseif ( file_exists( trailingslashit( WP_PLUGIN_DIR ) . $custom_directory . 'templates/' . $template_name ) ) { + $located = trailingslashit( WP_PLUGIN_DIR ) . $custom_directory . 'templates/' . $template_name; - /** - * Look in plugin - */ - } elseif ( file_exists( $this->plugin_directory . 'templates/' . $template_name ) ) { - $located = $this->plugin_directory . 'templates/' . $template_name; - } + /** + * Look in plugin + */ + } elseif ( file_exists( $this->plugin_directory . 'templates/' . $template_name ) ) { + $located = $this->plugin_directory . 'templates/' . $template_name; + } - return $located; - } + return $located; + } } // end of class diff --git a/class/widgets/reference-container.php b/class/widgets/reference-container.php index 0c7931f..693ef58 100644 --- a/class/widgets/reference-container.php +++ b/class/widgets/reference-container.php @@ -18,68 +18,68 @@ */ class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase { - /** - * Returns an unique ID as string used for the Widget Base ID. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - */ - protected function getID() { - return "footnotes_widget"; - } + /** + * Returns an unique ID as string used for the Widget Base ID. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + protected function getID() { + return "footnotes_widget"; + } - /** - * Returns the Public name of the Widget to be displayed in the Configuration page. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - */ - protected function getName() { - return MCI_Footnotes_Config::C_STR_PLUGIN_NAME; - } + /** + * Returns the Public name of the Widget to be displayed in the Configuration page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + protected function getName() { + return MCI_Footnotes_Config::C_STR_PLUGIN_NAME; + } - /** - * Returns the Description of the child widget. - * - * @author Stefan Herndler - * @since 1.5.0 - * @return string - * - * Edit: curly quotes 2.2.0 2020-12-12T2130+0100 - */ - protected function getDescription() { - return __('The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME); - } + /** + * Returns the Description of the child widget. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + * + * Edit: curly quotes 2.2.0 2020-12-12T2130+0100 + */ + protected function getDescription() { + return __('The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME); + } - /** - * Outputs the Settings of the Widget. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param mixed $instance - * @return void - * - * Edit: curly quotes 2.2.0 2020-12-12T2130+0100 - */ - public function form($instance) { - echo __('The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME); - } + /** + * Outputs the Settings of the Widget. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param mixed $instance + * @return void + * + * Edit: curly quotes 2.2.0 2020-12-12T2130+0100 + */ + public function form($instance) { + echo __('The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME); + } - /** - * Outputs the Content of the Widget. - * - * @author Stefan Herndler - * @since 1.5.0 - * @param mixed $args - * @param mixed $instance - */ - public function widget($args, $instance) { - global $g_obj_MCI_Footnotes; - // reference container positioning is set to "widget area" - if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "widget") { - echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer(); - } - } + /** + * Outputs the Content of the Widget. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param mixed $args + * @param mixed $instance + */ + public function widget($args, $instance) { + global $g_obj_MCI_Footnotes; + // reference container positioning is set to "widget area" + if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "widget") { + echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer(); + } + } } diff --git a/css/dev-common.css b/css/dev-common.css index 9e28211..159901f 100644 --- a/css/dev-common.css +++ b/css/dev-common.css @@ -7,7 +7,7 @@ * Since: 1.0 * * @version 2.5.5 - * @lastmodified 2021-02-16T0651+0100 + * @lastmodified 2021-02-18T2026+0100 * * Classes recommended for Custom CSS: * @see templates/dashboard/customize-css-new.html @@ -82,31 +82,31 @@ */ .footnotes_validation_error { - border: 4px solid red; - padding: 20px 40px; - margin: 20px 0; - background: #ff000055; - text-align: start; + border: 4px solid red; + padding: 20px 40px; + margin: 20px 0; + background: #ff000055; + text-align: start; } .footnotes_validation_error p:first-child { - font-size: 20px; - font-weight: bold; - text-align: center; + font-size: 20px; + font-weight: bold; + text-align: center; } .footnotes_validation_error p:nth-child(2) { - font-size: 16px; - font-style: italic; + font-size: 16px; + font-style: italic; } .footnotes_validation_error p:nth-child(3) { - font-size: 14px; - font-weight: bold; + font-size: 14px; + font-weight: bold; } .footnotes_validation_error p:last-child { - font-size: 12px; + font-size: 12px; } /** @@ -145,9 +145,9 @@ */ .footnote_url_wrap { - word-wrap: anywhere; - overflow-wrap: anywhere; - word-break: break-all; + word-wrap: anywhere; + overflow-wrap: anywhere; + word-break: break-all; } /** @@ -168,12 +168,12 @@ .footnote_item_base, .footnote_referrer_base { - position: absolute; + position: absolute; } .footnote_item_anchor, .footnote_referrer_anchor { - position: relative; + position: relative; } /** @@ -203,9 +203,9 @@ .main-content .footnote_referrer > a:hover, .main-content .footnote_plugin_tooltip_text, .main-content .footnote_plugin_tooltip_text:hover { - text-decoration: none !important; - border-bottom: none !important; - box-shadow: none !important; + text-decoration: none !important; + border-bottom: none !important; + box-shadow: none !important; } /** @@ -226,8 +226,8 @@ .footnote_plugin_tooltip_text { line-height: 0; - position: relative !important; - cursor: pointer; + position: relative !important; + cursor: pointer; } /** @@ -241,14 +241,14 @@ */ .footnote_tooltip { - display: none; - z-index: 2147483647 !important; - cursor: auto; - text-align: left; - padding: 12px; - line-height: 1.2; - font-weight: normal; - font-style: normal; + display: none; + z-index: 2147483647 !important; + cursor: auto; + text-align: left; + padding: 12px; + line-height: 1.2; + font-weight: normal; + font-style: normal; } /** @@ -258,15 +258,15 @@ */ .footnote_referrer.relative { - position: relative; + position: relative; } .footnote_tooltip.position { - display: unset; - position: absolute; - bottom: 24px; - left: -50px; - width: 400px; + display: unset; + position: absolute; + bottom: 24px; + left: -50px; + width: 400px; } /* @@ -274,14 +274,14 @@ fade-in parameters */ .footnote_tooltip.shown { - visibility: visible; - opacity: 1; - transition-property: visibility opacity; - transition-timing-function: linear; + visibility: visible; + opacity: 1; + transition-property: visibility opacity; + transition-timing-function: linear; /* property values of settings are inline CSS - transition-delay: 0ms; - transition-duration: 200ms; + transition-delay: 0ms; + transition-duration: 200ms; */ } @@ -290,14 +290,14 @@ fade-out parameters */ .footnote_tooltip.hidden { - visibility: hidden; - opacity: 0; - transition-property: visibility opacity; - transition-timing-function: linear; + visibility: hidden; + opacity: 0; + transition-property: visibility opacity; + transition-timing-function: linear; /* property values of settings are inline CSS - transition-delay: 400ms; - transition-duration: 200ms; + transition-delay: 400ms; + transition-duration: 200ms; */ } @@ -306,16 +306,16 @@ Read-on button */ .footnote_tooltip_continue { - font-style: italic; - color: green; - text-decoration: none !important; - cursor: pointer; - white-space: nowrap; + font-style: italic; + color: green; + text-decoration: none !important; + cursor: pointer; + white-space: nowrap; } .footnote_tooltip_continue:hover { - color: blue; - text-decoration: underline !important; + color: blue; + text-decoration: underline !important; } @@ -354,9 +354,9 @@ Classes: */ .footnotes_reference_container { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } /* @@ -364,29 +364,29 @@ label */ .footnote_container_prepare { - display: block !important; - padding-top: 24px !important; + display: block !important; + padding-top: 24px !important; } .footnote_container_prepare > p { - line-height: 1.3 !important; - margin-top: 1em !important; - margin-bottom: 0.25em !important; - padding: 0 !important; - font-weight: normal !important; - /* bottom border optional since 2.2.5 */ - display: block !important; - -webkit-margin-before: 0.83em !important; - -webkit-margin-after: 0.83em !important; - -webkit-margin-start: 0px !important; - -webkit-margin-end: 0px !important; - text-align: left !important; - vertical-align: middle; + line-height: 1.3 !important; + margin-top: 1em !important; + margin-bottom: 0.25em !important; + padding: 0 !important; + font-weight: normal !important; + /* bottom border optional since 2.2.5 */ + display: block !important; + -webkit-margin-before: 0.83em !important; + -webkit-margin-after: 0.83em !important; + -webkit-margin-start: 0px !important; + -webkit-margin-end: 0px !important; + text-align: left !important; + vertical-align: middle; } .footnote_container_prepare > p > span:first-child { - text-align: left !important; - font-size: 1.5em !important; + text-align: left !important; + font-size: 1.5em !important; } /* @@ -395,11 +395,11 @@ fully clickable, not sign only */ .footnote_reference_container_collapse_button { - cursor: pointer; - padding: 0 0.5em; - font-size: 1.3em !important; - vertical-align: 2px; - text-decoration: none !important; + cursor: pointer; + padding: 0 0.5em; + font-size: 1.3em !important; + vertical-align: 2px; + text-decoration: none !important; } h2 > .footnote_reference_container_collapse_button, @@ -407,12 +407,12 @@ h3 > .footnote_reference_container_collapse_button, h4 > .footnote_reference_container_collapse_button, h5 > .footnote_reference_container_collapse_button, h6 > .footnote_reference_container_collapse_button { - font-size: inherit !important; + font-size: inherit !important; } .footnote_container_prepare > p > span:last-child a, .footnote_reference_container_collapse_button a { - text-decoration: none !important; + text-decoration: none !important; } /* @@ -421,8 +421,8 @@ table .footnote-reference-container, .footnotes_table { - width: 100%; - border: none; + width: 100%; + border: none; } /* @@ -438,10 +438,10 @@ footnotes .footnote_plugin_index_combi, .footnote_plugin_symbol, .footnote_plugin_text { - border: none !important; - text-align: left !important; - vertical-align: top !important; - padding: 5px 6px 10px 0 !important; + border: none !important; + text-align: left !important; + vertical-align: top !important; + padding: 5px 6px 10px 0 !important; } .footnote_backlink, @@ -452,19 +452,19 @@ footnotes .main-content .footnote_backlink:link, .main-content .footnote_plugin_link, .main-content .footnote_plugin_link:link { - text-decoration: none !important; - border-bottom: none !important; + text-decoration: none !important; + border-bottom: none !important; } .footnote_backlink, .footnote_plugin_link { - white-space: nowrap; + white-space: nowrap; } .pointer, .footnote_index, .footnote_backlink { - cursor: pointer; + cursor: pointer; } /* @@ -479,12 +479,12 @@ when hovered in some themes, not in others: .footnote_backlink:hover, .footnote_plugin_link:hover, .footnote_plugin_text a:hover { - text-decoration: unset; - text-decoration: underline; /*deprioritized to ease customization*/ + text-decoration: unset; + text-decoration: underline; /*deprioritized to ease customization*/ } .footnote_plugin_text { - width: unset; /*unset width of text column to fix site issues*/ + width: unset; /*unset width of text column to fix site issues*/ } /* @@ -499,8 +499,8 @@ These are overridden if settings are enabled. .footnote_plugin_index, .footnote_plugin_index_combi { - max-width: 100px; - width: 2.5em; + max-width: 100px; + width: 2.5em; } /* @@ -509,10 +509,10 @@ Responsive @media only screen and (max-width: 768px) { - .footnote_plugin_index, - .footnote_plugin_index_combi { - max-width: 80px; - } + .footnote_plugin_index, + .footnote_plugin_index_combi { + max-width: 80px; + } } @@ -532,31 +532,31 @@ Link color set to inherit, so referrers/numbers are not grayed out. */ .footnotes_reference_container { - page-break-inside: avoid; + page-break-inside: avoid; } @media print { - .footnote_tooltip, - .footnote_reference_container_collapse_button, - .footnote_index_arrow { - display: none; - } + .footnote_tooltip, + .footnote_reference_container_collapse_button, + .footnote_index_arrow { + display: none; + } - .footnote_plugin_tooltip_text { - color: inherit; - } + .footnote_plugin_tooltip_text { + color: inherit; + } - .footnote_plugin_index a, - .footnote_plugin_index_combi a { - color: inherit; - text-decoration: none !important; - } + .footnote_plugin_index a, + .footnote_plugin_index_combi a { + color: inherit; + text-decoration: none !important; + } - /* Edit button in WP2020 (added as a service) */ - div.post-meta-edit-link-wrapper { - display: none; - } + /* Edit button in WP2020 (added as a service) */ + div.post-meta-edit-link-wrapper { + display: none; + } } /** @@ -577,14 +577,14 @@ Link color set to inherit, so referrers/numbers are not grayed out. .footnotes_logo, .footnotes_logo:hover { - text-decoration: none; - font-weight: normal; + text-decoration: none; + font-weight: normal; } .footnotes_logo_part1 { - color: #2bb975; + color: #2bb975; } .footnotes_logo_part2 { - color: #545f5a; + color: #545f5a; } diff --git a/css/dev-layout-entry-content.css b/css/dev-layout-entry-content.css index 7a79167..d33feb9 100644 --- a/css/dev-layout-entry-content.css +++ b/css/dev-layout-entry-content.css @@ -26,7 +26,7 @@ Rationale In Hello Elementor Theme, this applies to .site-header, and also to .site-main, which is a class of the
element, at the condition that the page is not built with Elementor: - body:not([class*="elementor-page-"]) + body:not([class*="elementor-page-"]) Therefore, in pages built with Elementor, proper layout is applied only to features managed by Elementor, not others. @@ -47,55 +47,55 @@ Sources: .entry-content, .entry .entry-content, main .entry .entry-content { - margin: 0 auto; + margin: 0 auto; } @media (max-width: 575px) { - .page-content, - .entry-content, - .entry .entry-content, - main .entry .entry-content { - padding: 0 10px; - } + .page-content, + .entry-content, + .entry .entry-content, + main .entry .entry-content { + padding: 0 10px; + } } @media (min-width: 576px) { - .page-content, - .entry-content, - .entry .entry-content, - main .entry .entry-content { - max-width: 500px; - } + .page-content, + .entry-content, + .entry .entry-content, + main .entry .entry-content { + max-width: 500px; + } } @media (min-width: 768px) { - .page-content, - .entry-content, - .entry .entry-content, - main .entry .entry-content { - max-width: 600px; - } + .page-content, + .entry-content, + .entry .entry-content, + main .entry .entry-content { + max-width: 600px; + } } @media (min-width: 992px) { - .page-content, - .entry-content, - .entry .entry-content, - main .entry .entry-content { - max-width: 800px; - } + .page-content, + .entry-content, + .entry .entry-content, + main .entry .entry-content { + max-width: 800px; + } } @media (min-width: 1200px) { - .page-content, - .entry-content, - .entry .entry-content, - main .entry .entry-content { - max-width: 960px; - } + .page-content, + .entry-content, + .entry .entry-content, + main .entry .entry-content { + max-width: 960px; + } } diff --git a/css/dev-layout-main-content.css b/css/dev-layout-main-content.css index a7eba27..6eb75f8 100644 --- a/css/dev-layout-main-content.css +++ b/css/dev-layout-main-content.css @@ -22,7 +22,7 @@ Rationale In Hello Elementor Theme, this applies to .site-header, and also to .site-main, which is a class of the
element, at the condition that the page is not built with Elementor: - body:not([class*="elementor-page-"]) + body:not([class*="elementor-page-"]) Therefore, in pages built with Elementor, proper layout is applied only to features managed by Elementor, not others. @@ -40,55 +40,55 @@ main, .main-content, .site-main, div.hentry { - margin: 0 auto; + margin: 0 auto; } @media (max-width: 575px) { - main, - .main-content, - .site-main, - div.hentry { - padding: 0 10px; - } + main, + .main-content, + .site-main, + div.hentry { + padding: 0 10px; + } } @media (min-width: 576px) { - main, - .main-content, - .site-main, - div.hentry { - max-width: 500px; - } + main, + .main-content, + .site-main, + div.hentry { + max-width: 500px; + } } @media (min-width: 768px) { - main, - .main-content, - .site-main, - div.hentry { - max-width: 600px; - } + main, + .main-content, + .site-main, + div.hentry { + max-width: 600px; + } } @media (min-width: 992px) { - main, - .main-content, - .site-main, - div.hentry { - max-width: 800px; - } + main, + .main-content, + .site-main, + div.hentry { + max-width: 800px; + } } @media (min-width: 1200px) { - main, - .main-content, - .site-main, - div.hentry { - max-width: 960px; - } + main, + .main-content, + .site-main, + div.hentry { + max-width: 960px; + } } diff --git a/css/dev-layout-reference-container.css b/css/dev-layout-reference-container.css index c655cd5..78021e1 100644 --- a/css/dev-layout-reference-container.css +++ b/css/dev-layout-reference-container.css @@ -21,7 +21,7 @@ Rationale In Hello Elementor Theme, this applies to .site-header, and also to .site-main, which is a class of the
element, at the condition that the page is not built with Elementor: - body:not([class*="elementor-page-"]) + body:not([class*="elementor-page-"]) Therefore, in pages built with Elementor, proper layout is applied only to features managed by Elementor, not others. @@ -38,50 +38,50 @@ older browsers not yet supporting CSS variables. .entry-content div.footnotes_reference_container, .entry-content > .footnotes_reference_container, main div.footnotes_reference_container { - margin: 0 auto; + margin: 0 auto; } @media (max-width: 575px) { - .entry-content div.footnotes_reference_container, - .entry-content > .footnotes_reference_container, - main div.footnotes_reference_container { - padding: 0 10px; - } + .entry-content div.footnotes_reference_container, + .entry-content > .footnotes_reference_container, + main div.footnotes_reference_container { + padding: 0 10px; + } } @media (min-width: 576px) { - .entry-content div.footnotes_reference_container, - .entry-content > .footnotes_reference_container, - main div.footnotes_reference_container { - max-width: 500px; - } + .entry-content div.footnotes_reference_container, + .entry-content > .footnotes_reference_container, + main div.footnotes_reference_container { + max-width: 500px; + } } @media (min-width: 768px) { - .entry-content div.footnotes_reference_container, - .entry-content > .footnotes_reference_container, - main div.footnotes_reference_container { - max-width: 600px; - } + .entry-content div.footnotes_reference_container, + .entry-content > .footnotes_reference_container, + main div.footnotes_reference_container { + max-width: 600px; + } } @media (min-width: 992px) { - .entry-content div.footnotes_reference_container, - .entry-content > .footnotes_reference_container, - main div.footnotes_reference_container { - max-width: 800px; - } + .entry-content div.footnotes_reference_container, + .entry-content > .footnotes_reference_container, + main div.footnotes_reference_container { + max-width: 800px; + } } @media (min-width: 1200px) { - .entry-content div.footnotes_reference_container, - .entry-content > .footnotes_reference_container, - main div.footnotes_reference_container { - max-width: 960px; - } + .entry-content div.footnotes_reference_container, + .entry-content > .footnotes_reference_container, + main div.footnotes_reference_container { + max-width: 960px; + } } diff --git a/css/dev-tooltips-alternative.css b/css/dev-tooltips-alternative.css index 129b752..e22944a 100644 --- a/css/dev-tooltips-alternative.css +++ b/css/dev-tooltips-alternative.css @@ -4,7 +4,7 @@ * * @since 2.5.5 * @version 2.5.5 - * @lastmodified 2021-02-16T0206+0100 + * @lastmodified 2021-02-18T2029+0100 * * System of unified minified style sheets tailored to the instance. * @@ -19,15 +19,15 @@ */ .footnote_referrer.relative { - position: relative; + position: relative; } .footnote_tooltip.position { - display: unset; - position: absolute; - bottom: 24px; - left: -50px; - width: 400px; + display: unset; + position: absolute; + bottom: 24px; + left: -50px; + width: 400px; } /* @@ -35,14 +35,14 @@ fade-in parameters */ .footnote_tooltip.shown { - visibility: visible; - opacity: 1; - transition-property: visibility opacity; - transition-timing-function: linear; + visibility: visible; + opacity: 1; + transition-property: visibility opacity; + transition-timing-function: linear; /* property values of settings are inline CSS - transition-delay: 0ms; - transition-duration: 200ms; + transition-delay: 0ms; + transition-duration: 200ms; */ } @@ -51,13 +51,13 @@ fade-out parameters */ .footnote_tooltip.hidden { - visibility: hidden; - opacity: 0; - transition-property: visibility opacity; - transition-timing-function: linear; + visibility: hidden; + opacity: 0; + transition-property: visibility opacity; + transition-timing-function: linear; /* property values of settings are inline CSS - transition-delay: 400ms; - transition-duration: 200ms; + transition-delay: 400ms; + transition-duration: 200ms; */ } diff --git a/css/dev-tooltips.css b/css/dev-tooltips.css index 732028e..99b5a53 100644 --- a/css/dev-tooltips.css +++ b/css/dev-tooltips.css @@ -11,7 +11,7 @@ * It doesn’t matter if the tooltips are jQuery based or alternative. * @since 2.5.5 * @version 2.5.5 - * @lastmodified 2021-02-16T0206+0100 + * @lastmodified 2021-02-18T2030+0100 * * System of unified minified style sheets tailored to the instance. * @@ -30,14 +30,14 @@ */ .footnote_tooltip { - display: none; - z-index: 2147483647 !important; - cursor: auto; - text-align: left; - padding: 12px; - line-height: 1.2; - font-weight: normal; - font-style: normal; + display: none; + z-index: 2147483647 !important; + cursor: auto; + text-align: left; + padding: 12px; + line-height: 1.2; + font-weight: normal; + font-style: normal; } /* @@ -45,14 +45,14 @@ Read-on button */ .footnote_tooltip_continue { - font-style: italic; - color: green; - text-decoration: none !important; - cursor: pointer; - white-space: nowrap; + font-style: italic; + color: green; + text-decoration: none !important; + cursor: pointer; + white-space: nowrap; } .footnote_tooltip_continue:hover { - color: blue; - text-decoration: underline !important; + color: blue; + text-decoration: underline !important; } diff --git a/css/settings.css b/css/settings.css index 732e2fd..c325065 100755 --- a/css/settings.css +++ b/css/settings.css @@ -7,7 +7,7 @@ * Since: 1.0 * * @version 2.5.5 - * @lastmodified 2021-02-16T0033+0100 + * @lastmodified 2021-02-18T2026+0100 */ /** @@ -22,25 +22,25 @@ */ .footnotes_logo_heading { - display: inline-block; - float: left; - position: absolute; - text-decoration: none; - font-weight: normal; + display: inline-block; + float: left; + position: absolute; + text-decoration: none; + font-weight: normal; } .footnotes_logo_part1_heading { - left: 20px; - color: #2bb975; + left: 20px; + color: #2bb975; } .footnotes_logo_part2_heading { - left: 51px; - color: #545f5a; + left: 51px; + color: #545f5a; } .footnotes_heart_heading { - color:#ff6d3b; - font-weight:bold; - position: absolute; - left: 96px; + color:#ff6d3b; + font-weight:bold; + position: absolute; + left: 96px; } /** @@ -48,8 +48,8 @@ */ .postbox-header { - position: relative; - padding: 0 20px; + position: relative; + padding: 0 20px; } /************************************************************ @@ -63,28 +63,28 @@ Limited to a number of IDs to not affect all dashboards #footnote_inputfield_readon_label, #footnote_inputfield_references_label, #footnote_inputfield_love { - padding-left: 8px !important; - padding-right: 8px !important; - width: 80% !important; + padding-left: 8px !important; + padding-right: 8px !important; + width: 80% !important; } #footnote_inputfield_reference_container_place { - width: 310px; + width: 310px; } #footnote_inputfield_counter_style, #footnotes_inputfield_page_layout_support { - width: 505px; + width: 505px; } #footnote_inputfield_placeholder_start, #footnote_inputfield_placeholder_end, #footnote_inputfield_custom_mouse_over_box_excerpt_length { - width: 180px; + width: 180px; } #footnote_inputfield_placeholder_start_user_defined, #footnote_inputfield_placeholder_end_user_defined { - width: 320px; + width: 320px; } #footnote_inputfield_combine_identical, @@ -103,13 +103,13 @@ Limited to a number of IDs to not affect all dashboards #footnotes_inputfield_mouse_over_box_fade_out_duration, #footnote_inputfield_custom_mouse_over_box_border_width, #footnote_inputfield_custom_mouse_over_box_border_radius { - width: 80px; + width: 80px; } #footnote_inputfield_custom_hyperlink_symbol, #footnotes_inputfield_backlinks_terminator_option, #footnotes_inputfield_backlinks_separator_option { - width: 230px; + width: 230px; } #footnotes_inputfield_reference_container_top_margin, @@ -117,13 +117,13 @@ Limited to a number of IDs to not affect all dashboards #footnotes_inputfield_backlinks_column_width_scalar, #footnotes_inputfield_backlinks_column_max_width_scalar, #footnotes_inputfield_mouse_over_box_font_size_scalar { - width: 85px; + width: 85px; } #footnotes_inputfield_backlinks_column_width_unit, #footnotes_inputfield_backlinks_column_max_width_unit, #footnotes_inputfield_mouse_over_box_font_size_unit { - width: 140px; + width: 140px; } /************************************************************ @@ -131,44 +131,44 @@ Headings and labels */ label { - display: inline-block; + display: inline-block; } .postbox > h3 { - height: 32px !important; - line-height: 32px !important; + height: 32px !important; + line-height: 32px !important; } .postbox > h3 > span { - padding: 0 10px; + padding: 0 10px; } .postbox > .inside > table { - border: none !important; + border: none !important; } .postbox > .inside >table > tbody > tr > td:first-child { - width: 15% !important; - font-weight: bold !important; + width: 15% !important; + font-weight: bold !important; } .footnote_placeholder_box_container { - text-align: center !important; + text-align: center !important; } span.footnote_highlight_placeholder { - font-weight: bold !important; - padding: 0 8px !important; + font-weight: bold !important; + padding: 0 8px !important; } .footnote_placeholder_box_example { - border: 2px solid #2bb975 !important; - border-radius: 4px !important; - padding: 16px 0 !important; - width: 50% !important; - display: block !important; - margin: 20px auto !important; - text-align: center !important; + border: 2px solid #2bb975 !important; + border-radius: 4px !important; + padding: 16px 0 !important; + width: 50% !important; + display: block !important; + margin: 20px auto !important; + text-align: center !important; } /************************************************************ @@ -180,22 +180,22 @@ IE doesn’t support nth child, but these are not critical */ .expert_lookup tr th:first-child, .expert_lookup tr td:first-child { - width: 170px !important; + width: 170px !important; } .expert_lookup tr th:nth-child(2), .expert_lookup tr td:nth-child(2) { - width: 65px !important; + width: 65px !important; } .expert_lookup tr th:nth-child(3), .expert_lookup tr td:nth-child(3) { - width: 200px !important; + width: 200px !important; } .expert_lookup tr td:nth-child(3) input { - width: 190px; + width: 190px; } .expert_lookup tr th:last-child, .expert_lookup tr td:last-child { - white-space: nowrap; + white-space: nowrap; } /* @@ -216,31 +216,31 @@ The textarea has monospace font, but no other features helping edit CSS, like tab support and syntactic colors. */ #customize_css_new tr td:first-child { - width: 38% !important; - font-weight: normal !important; + width: 38% !important; + font-weight: normal !important; } .customize_css_new tr td:first-child span:first-child { - font-weight: bold !important; + font-weight: bold !important; } .customize_css_new .list { - padding-top: 10px; + padding-top: 10px; } .customize_css_new .list p { - font-family: monospace; - padding: 0 10px; - text-indent: -10px; - margin: .5em 0; + font-family: monospace; + padding: 0 10px; + text-indent: -10px; + margin: .5em 0; } #footnote_inputfield_custom_css_new { - height: 500px; + height: 500px; } #footnote_inputfield_custom_css, #footnote_inputfield_custom_css_new { - width: 96%; - resize: both; - overflow: scroll; - font-family: monospace; + width: 96%; + resize: both; + overflow: scroll; + font-family: monospace; } /************************************************************ @@ -260,9 +260,9 @@ look weird. since 2.1.4 */ .footnotes_notice { - font-style: italic; - display: inline-block; - text-align: end; + font-style: italic; + display: inline-block; + text-align: end; } /************************************************************ @@ -274,9 +274,9 @@ Use case: more extensive information not fitting into a brief notice after the end of the settings box. */ .footnotes_description { - padding: 0 4%; + padding: 0 4%; } .footnotes_description p { - font-size: 1.06em; - font-style: italic; + font-size: 1.06em; + font-style: italic; } diff --git a/footnotes.php b/footnotes.php index 1cda7f1..c57d878 100755 --- a/footnotes.php +++ b/footnotes.php @@ -1,13 +1,13 @@ ").attr("id", j.maskId), a("body").append(e)); - var l = c(); - e.css({position: "absolute", top: 0, left: 0, width: l[0], height: l[1], display: "none", opacity: j.startOpacity, zIndex: j.zIndex}), j.color && e.css("backgroundColor", j.color); - if (d(j.onBeforeLoad) === !1)return this; - j.closeOnEsc && a(document).on("keydown.mask", function (b) { - b.keyCode === 27 && a.mask.close(b) - }), j.closeOnClick && e.on("click.mask", function (b) { - a.mask.close(b) - }), a(window).on("resize.mask", function () { - a.mask.fit() - }), k && k.length && (i = k.eq(0).css("zIndex"), a.each(k, function () { - var b = a(this); - /relative|absolute|fixed/i.test(b.css("position")) || b.css("position", "relative") - }), f = k.css({zIndex: Math.max(j.zIndex + 1, i === "auto" ? 0 : i)})), e.css({display: "block"}).fadeTo(j.loadSpeed, j.opacity, function () { - a.mask.fit(), d(j.onLoad), g = "full" - }), g = !0; - return this - }, close: function () { - if (g) { - if (d(h.onBeforeClose) === !1)return this; - e.fadeOut(h.closeSpeed, function () { - d(h.onClose), f && f.css({zIndex: i}), g = !1 - }), a(document).off("keydown.mask"), e.off("click.mask"), a(window).off("resize.mask") - } - return this - }, fit: function () { - if (g) { - var a = c(); - e.css({width: a[0], height: a[1]}) - } - }, getMask: function () { - return e - }, isLoaded: function (a) { - return a ? g === "full" : g - }, getConf: function () { - return h - }, getExposed: function () { - return f - }}, a.fn.mask = function (b) { - a.mask.load(b); - return this - }, a.fn.expose = function (b) { - a.mask.load(b, this); - return this - } + /*if (a.browser && a.browser.msie) { + var b = a(document).height(), c = a(window).height(); + return[window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, b - c < 20 ? c : b] + }*/ + return[a(document).width(), a(document).height()] + } + + function d(b) { + if (b)return b.call(a.mask) + } + + var e, f, g, h, i; + a.mask = {load: function (j, k) { + if (g)return this; + + /** + * EQUALS SIGN IN JAVASCRIPT + * + * - Bugfix: Libraries: jQuery Tools: replace discouraged double equals sign with recommended triple equals sign + * + * @since 2.5.4 + * @date 2021-01-27T1955+0100 + * @accountable @pewgeuges + * + * 23 instances (27 less 4 already triple), first below, next was already + * All instances checked whether '==' has the semantics of '===', though. + * @bib Douglas Crockford, JavaScript: The Good Parts + */ + + typeof j === "string" && (j = {color: j}), j = j || h, h = j = a.extend(a.extend({}, b.conf), j), e = a("#" + j.maskId), e.length || (e = a("
").attr("id", j.maskId), a("body").append(e)); + var l = c(); + e.css({position: "absolute", top: 0, left: 0, width: l[0], height: l[1], display: "none", opacity: j.startOpacity, zIndex: j.zIndex}), j.color && e.css("backgroundColor", j.color); + if (d(j.onBeforeLoad) === !1)return this; + j.closeOnEsc && a(document).on("keydown.mask", function (b) { + b.keyCode === 27 && a.mask.close(b) + }), j.closeOnClick && e.on("click.mask", function (b) { + a.mask.close(b) + }), a(window).on("resize.mask", function () { + a.mask.fit() + }), k && k.length && (i = k.eq(0).css("zIndex"), a.each(k, function () { + var b = a(this); + /relative|absolute|fixed/i.test(b.css("position")) || b.css("position", "relative") + }), f = k.css({zIndex: Math.max(j.zIndex + 1, i === "auto" ? 0 : i)})), e.css({display: "block"}).fadeTo(j.loadSpeed, j.opacity, function () { + a.mask.fit(), d(j.onLoad), g = "full" + }), g = !0; + return this + }, close: function () { + if (g) { + if (d(h.onBeforeClose) === !1)return this; + e.fadeOut(h.closeSpeed, function () { + d(h.onClose), f && f.css({zIndex: i}), g = !1 + }), a(document).off("keydown.mask"), e.off("click.mask"), a(window).off("resize.mask") + } + return this + }, fit: function () { + if (g) { + var a = c(); + e.css({width: a[0], height: a[1]}) + } + }, getMask: function () { + return e + }, isLoaded: function (a) { + return a ? g === "full" : g + }, getConf: function () { + return h + }, getExposed: function () { + return f + }}, a.fn.mask = function (b) { + a.mask.load(b); + return this + }, a.fn.expose = function (b) { + a.mask.load(b, this); + return this + } })(jQuery); (function () { - var a = document.all, b = "http://www.adobe.com/go/getflashplayer", c = typeof jQuery === "function", d = /(\d+)[^\d]+(\d+)[^\d]*(\d*)/, e = {width: "100%", height: "100%", id: "_" + ("" + Math.random()).slice(9), allowfullscreen: !0, allowscriptaccess: "always", quality: "high", version: [3, 0], onFail: null, expressInstall: null, w3c: !1, cachebusting: !1}; - window.attachEvent && window.attachEvent("onbeforeunload", function () { - __flash_unloadHandler = function () { - }, __flash_savedUnloadHandler = function () { - } - }); - function f(a, b) { - if (b)for (var c in b)b.hasOwnProperty(c) && (a[c] = b[c]); - return a - } + var a = document.all, b = "http://www.adobe.com/go/getflashplayer", c = typeof jQuery === "function", d = /(\d+)[^\d]+(\d+)[^\d]*(\d*)/, e = {width: "100%", height: "100%", id: "_" + ("" + Math.random()).slice(9), allowfullscreen: !0, allowscriptaccess: "always", quality: "high", version: [3, 0], onFail: null, expressInstall: null, w3c: !1, cachebusting: !1}; + window.attachEvent && window.attachEvent("onbeforeunload", function () { + __flash_unloadHandler = function () { + }, __flash_savedUnloadHandler = function () { + } + }); + function f(a, b) { + if (b)for (var c in b)b.hasOwnProperty(c) && (a[c] = b[c]); + return a + } - function g(a, b) { - var c = []; - for (var d in a)a.hasOwnProperty(d) && (c[d] = b(a[d])); - return c - } + function g(a, b) { + var c = []; + for (var d in a)a.hasOwnProperty(d) && (c[d] = b(a[d])); + return c + } - window.flashembed = function (a, b, c) { - typeof a === "string" && (a = document.getElementById(a.replace("#", ""))); - if (a) { - typeof b === "string" && (b = {src: b}); - return new j(a, f(f({}, e), b), c) - } - }; - var h = f(window.flashembed, {conf: e, getVersion: function () { - var a, b; - try { - b = navigator.plugins["Shockwave Flash"].description.slice(16) - } catch (c) { - try { - a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"), b = a && a.GetVariable("$version") - } catch (e) { - try { - a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"), b = a && a.GetVariable("$version") - } catch (f) { - } - } - } - b = d.exec(b); - return b ? [b[1], b[3]] : [0, 0] - }, asString: function (a) { - if (a === null || a === undefined)return null; - var b = typeof a; - b === "object" && a.push && (b = "array"); - switch (b) { - case"string": - a = a.replace(new RegExp("([\"\\\\])", "g"), "\\$1"), a = a.replace(/^\s?(\d+\.?\d*)%/, "$1pct"); - return"\"" + a + "\""; - case"array": - return"[" + g(a,function (a) { - return h.asString(a) - }).join(",") + "]"; - case"function": - return"\"function()\""; - case"object": - var c = []; - for (var d in a)a.hasOwnProperty(d) && c.push("\"" + d + "\":" + h.asString(a[d])); - return"{" + c.join(",") + "}" - } - return String(a).replace(/\s/g, " ").replace(/\'/g, "\"") - }, getHTML: function (b, c) { - b = f({}, b); - var d = ""; - b.width = b.height = b.id = b.w3c = b.src = null, b.onFail = b.version = b.expressInstall = null; - for (var e in b)b[e] && (d += ""); - var g = ""; - if (c) { - for (var i in c)if (c[i]) { - var j = c[i]; - g += i + "=" + encodeURIComponent(/function|object/.test(typeof j) ? h.asString(j) : j) + "&" - } - g = g.slice(0, -1), d += "" - } - d += ""; - return d - }, isSupported: function (a) { - return i[0] > a[0] || i[0] === a[0] && i[1] >= a[1] - }}), i = h.getVersion(); + window.flashembed = function (a, b, c) { + typeof a === "string" && (a = document.getElementById(a.replace("#", ""))); + if (a) { + typeof b === "string" && (b = {src: b}); + return new j(a, f(f({}, e), b), c) + } + }; + var h = f(window.flashembed, {conf: e, getVersion: function () { + var a, b; + try { + b = navigator.plugins["Shockwave Flash"].description.slice(16) + } catch (c) { + try { + a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"), b = a && a.GetVariable("$version") + } catch (e) { + try { + a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"), b = a && a.GetVariable("$version") + } catch (f) { + } + } + } + b = d.exec(b); + return b ? [b[1], b[3]] : [0, 0] + }, asString: function (a) { + if (a === null || a === undefined)return null; + var b = typeof a; + b === "object" && a.push && (b = "array"); + switch (b) { + case"string": + a = a.replace(new RegExp("([\"\\\\])", "g"), "\\$1"), a = a.replace(/^\s?(\d+\.?\d*)%/, "$1pct"); + return"\"" + a + "\""; + case"array": + return"[" + g(a,function (a) { + return h.asString(a) + }).join(",") + "]"; + case"function": + return"\"function()\""; + case"object": + var c = []; + for (var d in a)a.hasOwnProperty(d) && c.push("\"" + d + "\":" + h.asString(a[d])); + return"{" + c.join(",") + "}" + } + return String(a).replace(/\s/g, " ").replace(/\'/g, "\"") + }, getHTML: function (b, c) { + b = f({}, b); + var d = ""; + b.width = b.height = b.id = b.w3c = b.src = null, b.onFail = b.version = b.expressInstall = null; + for (var e in b)b[e] && (d += ""); + var g = ""; + if (c) { + for (var i in c)if (c[i]) { + var j = c[i]; + g += i + "=" + encodeURIComponent(/function|object/.test(typeof j) ? h.asString(j) : j) + "&" + } + g = g.slice(0, -1), d += "" + } + d += ""; + return d + }, isSupported: function (a) { + return i[0] > a[0] || i[0] === a[0] && i[1] >= a[1] + }}), i = h.getVersion(); - function j(c, d, e) { - if (h.isSupported(d.version))c.innerHTML = h.getHTML(d, e); else if (d.expressInstall && h.isSupported([6, 65]))c.innerHTML = h.getHTML(f(d, {src: d.expressInstall}), {MMredirectURL: location.href, MMplayerType: "PlugIn", MMdoctitle: document.title}); else { - c.innerHTML.replace(/\s/g, "") || (c.innerHTML = "

Flash version " + d.version + " or greater is required

" + (i[0] > 0 ? "Your version is " + i : "You have no flash plugin installed") + "

" + (c.tagName === "A" ? "

Click here to download latest version

" : "

Download latest version from here

"), c.tagName === "A" && (c.onclick = function () { - location.href = b - })); - if (d.onFail) { - var g = d.onFail.call(this); - typeof g === "string" && (c.innerHTML = g) - } - } - a && (window[d.id] = document.getElementById(d.id)), f(this, {getRoot: function () { - return c - }, getOptions: function () { - return d - }, getConf: function () { - return e - }, getApi: function () { - return c.firstChild - }}) - } + function j(c, d, e) { + if (h.isSupported(d.version))c.innerHTML = h.getHTML(d, e); else if (d.expressInstall && h.isSupported([6, 65]))c.innerHTML = h.getHTML(f(d, {src: d.expressInstall}), {MMredirectURL: location.href, MMplayerType: "PlugIn", MMdoctitle: document.title}); else { + c.innerHTML.replace(/\s/g, "") || (c.innerHTML = "

Flash version " + d.version + " or greater is required

" + (i[0] > 0 ? "Your version is " + i : "You have no flash plugin installed") + "

" + (c.tagName === "A" ? "

Click here to download latest version

" : "

Download latest version from here

"), c.tagName === "A" && (c.onclick = function () { + location.href = b + })); + if (d.onFail) { + var g = d.onFail.call(this); + typeof g === "string" && (c.innerHTML = g) + } + } + a && (window[d.id] = document.getElementById(d.id)), f(this, {getRoot: function () { + return c + }, getOptions: function () { + return d + }, getConf: function () { + return e + }, getApi: function () { + return c.firstChild + }}) + } - c && (jQuery.tools = jQuery.tools || {version: "v1.2.7"}, jQuery.tools.flashembed = {conf: e}, jQuery.fn.flashembed = function (a, b) { - return this.each(function () { - jQuery(this).data("flashembed", flashembed(this, a, b)) - }) - }) + c && (jQuery.tools = jQuery.tools || {version: "v1.2.7"}, jQuery.tools.flashembed = {conf: e}, jQuery.fn.flashembed = function (a, b) { + return this.each(function () { + jQuery(this).data("flashembed", flashembed(this, a, b)) + }) + }) })(); (function (a) { - var b, c, d, e; - a.tools = a.tools || {version: "v1.2.7"}, a.tools.history = {init: function (g) { + var b, c, d, e; + a.tools = a.tools || {version: "v1.2.7"}, a.tools.history = {init: function (g) { - /** - * REDACT (COMMENT OUT) DEPRECATED FUNCTION jQuery.browser() - * - * #2 This was only for very old Internet Explorer (older than IE8). - */ + /** + * REDACT (COMMENT OUT) DEPRECATED FUNCTION jQuery.browser() + * + * #2 This was only for very old Internet Explorer (older than IE8). + */ - e || (/*a.browser && a.browser.msie && a.browser.version < "8" ? c || (c = a("