From 665ddda49b05eb5350e1f1c567c12aa871c84fa4 Mon Sep 17 00:00:00 2001 From: pewgeuges <73141620+pewgeuges@users.noreply.github.com> Date: Sun, 6 Dec 2020 17:54:59 +0000 Subject: [PATCH] bugfix release 2.1.4 (added features fix issues and are not localized yet) git-svn-id: https://plugins.svn.wordpress.org/footnotes/tags/2.1.4@2432656 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- class/convert.php | 2 +- class/dashboard/layout.php | 52 ++- class/dashboard/subpage-main.php | 220 +++++++--- class/init.php | 43 +- class/settings.php | 171 ++++++-- class/task.php | 406 ++++++++++++++---- css/layout-main-content.css | 75 ++++ css/layout-page-content.css | 75 ++++ css/layout-reference-container.css | 75 ++++ css/public.css | 107 +++-- css/settings.css | 119 +++-- footnotes.php | 3 +- js/jquery.tools.js | 4 +- readme.txt | 29 +- templates/dashboard/customize-css.html | 52 +-- .../dashboard/customize-hyperlink-arrow.html | 12 - .../dashboard/customize-mouse-over-box.html | 142 +++--- .../dashboard/customize-superscript.html | 30 +- templates/dashboard/diagnostics.html | 74 ++-- templates/dashboard/expert-lookup.html | 85 ++-- templates/dashboard/settings-love.html | 24 +- templates/dashboard/settings-other.html | 29 +- .../settings-reference-container.html | 114 +++-- templates/dashboard/settings-styling.html | 110 ++--- templates/public/footnote-alternative.html | 6 +- templates/public/footnote.html | 6 +- .../reference-container-body-3column.html | 26 +- .../reference-container-body-combi.html | 2 +- .../reference-container-body-switch.html | 4 +- .../public/reference-container-body.html | 4 +- templates/public/reference-container.html | 4 +- templates/public/tooltip.html | 8 +- 32 files changed, 1511 insertions(+), 602 deletions(-) create mode 100644 css/layout-main-content.css create mode 100644 css/layout-page-content.css create mode 100644 css/layout-reference-container.css delete mode 100644 templates/dashboard/customize-hyperlink-arrow.html diff --git a/class/convert.php b/class/convert.php index 090189a..3f8232b 100644 --- a/class/convert.php +++ b/class/convert.php @@ -210,4 +210,4 @@ class MCI_Footnotes_Convert { } echo "
"; } -} \ No newline at end of file +} diff --git a/class/dashboard/layout.php b/class/dashboard/layout.php index ccc57eb..1862d6e 100644 --- a/class/dashboard/layout.php +++ b/class/dashboard/layout.php @@ -6,9 +6,15 @@ * @author Stefan Herndler * @since 1.5.0 12.09.14 10:56 * - * 2.1.2 added version # of settings.css for cache busting 2020-11-19T1456+0100 + * Edited: + * 2.1.2 add versioning of settings.css for cache busting 2020-11-19T1456+0100 + * 2.1.4 automate passing version number for cache busting 2020-11-30T0648+0100 + * 2.1.4 optional step argument and support for floating in numbox 2020-12-05T0540+0100 * - * ############ Please update line 210 after changes to settings.css ############### + * ########## fix punctuation-related localization issue in dashboard labels 2020-12-01T0211+0100 + * ########## this fix reverted for now; restore when updating strings and translations, line 400 + * + * Last modified: 2020-12-06T1654+0100 */ @@ -203,14 +209,8 @@ abstract class MCI_Footnotes_LayoutEngine { // register stylesheet // added version # after changes started to settings.css from 2.1.2 on: - wp_register_style( - 'mci-footnotes-admin-styles', - plugins_url('../../css/settings.css', __FILE__), - '', - '2.1.3' - ); - // UPDATE version # when making changes to settings.css, FOR CACHE BUSTING - + // automated update of version number for cache busting + wp_register_style( 'mci-footnotes-admin-styles', plugins_url('footnotes/css/settings.css'), array(), FOOTNOTES_VERSION ); // add stylesheet to the output wp_enqueue_style('mci-footnotes-admin-styles'); @@ -380,12 +380,25 @@ abstract class MCI_Footnotes_LayoutEngine { * @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 #################### 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-01T0156+0100 + // ########## this fix reverted for now; restore when updating strings and translations } /** @@ -488,15 +501,26 @@ abstract class MCI_Footnotes_LayoutEngine { * @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 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-05T2006+0100 */ - protected function addNumBox($p_str_SettingName, $p_in_Min, $p_int_Max) { + 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); - return sprintf('', + + if ($p_bool_Deci) { + $l_str_Value = number_format($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 aa2fcfd..1919a37 100644 --- a/class/dashboard/subpage-main.php +++ b/class/dashboard/subpage-main.php @@ -7,12 +7,12 @@ * @since 1.5.0 14.09.14 14:47 * * Edited for: - * 2.0.4 2020-11-01T0509+0100 - * 2.1.0 2020-11-08T2148+0100 - * 2.1.1 2020-11-16T2152+0100 - * 2.1.3 2020-11-24T0955+0100 + * 2.0.4 restore arrow settings 2020-11-01T0509+0100 + * 2.1.0 read-on button label 2020-11-08T2148+0100 + * 2.1.1 options for ref container and alternative tooltips 2020-11-16T2152+0100 + * 2.1.4 settings for ref container, tooltips and scrolling 2020-12-03T0950+0100 * - * Last modified: 2020-11-24T0955+0100 + * Last modified: 2020-12-06T1653+0100 */ /** @@ -89,12 +89,13 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { // Change string "%s styling" to "Footnotes styling" to fix layout in WPv5.5: $this->addMetaBox("settings", "styling", __("Footnotes styling", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Styling"), $this->addMetaBox("settings", "reference-container", __("References Container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "ReferenceContainer"), + $this->addMetaBox("settings", "other", __("Other", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Other"), // Leave intact since this is not localized: $this->addMetaBox("settings", "love", MCI_Footnotes_Config::C_STR_PLUGIN_HEADING_NAME . ' ' . MCI_Footnotes_Config::C_STR_LOVE_SYMBOL_HEADING, "Love"), - $this->addMetaBox("settings", "other", __("Other", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Other"), - // This is restored to meet user demand for arrow symbol semantics: - $this->addMetaBox("customize", "hyperlink-arrow", __("Hyperlink symbol in the Reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "HyperlinkArrow"), + // The HyperlinkArrow meta box ceased for 2.0.0 + // The HyperlinkArrow meta box was restored for 2.0.4 to meet user demand for arrow symbol semantics + // The HyperlinkArrow meta box ceased for 2.1.4 as its content is moved to Settings > Reference container > Display a backlink symbol $this->addMetaBox("customize", "superscript", __("Superscript layout", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Superscript"), $this->addMetaBox("customize", "mouse-over-box", __("Mouse-over box", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "MouseOverBox"), $this->addMetaBox("customize", "custom-css", __("Add custom CSS to the public page", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSS"), @@ -111,6 +112,9 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { * * @author Stefan Herndler * @since 1.5.0 + * + * Completed: + * @since 2.1.4: layout and typography options 2020-11-30T0548+0100 */ public function ReferenceContainer() { // options for the positioning of the reference container @@ -119,6 +123,36 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "post_end" => __("at the end of the post", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "widget" => __("in the widget area", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) ); + // basic responsive page layout options: + $l_arr_PageLayoutOptions = array( + "none" => __("Don’t fix the layout", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "reference-container" => __("to the reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "page-content" => __("to everything after the post title until the reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "main-content" => __("to everything from the post title to the reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ); + // options for the separating punctuation between backlinks: + // Unicode names are conventionally uppercase. + $l_arr_Separators = array( + "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 it is bidi-mirrored. + // 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), + "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), @@ -136,20 +170,55 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "label-collapse" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, __("Collapse references by default", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), "collapse" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, $l_arr_Enabled), - "label-symbol" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, __("Display a backlink symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "symbol" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, $l_arr_Enabled), + "label-position" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __("Where shall the reference container appear", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_Positions), + + "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-startpage" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE, __("Display on start page too", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), "startpage" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE, $l_arr_Enabled), - "label-3column" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, __("Three-column layout", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "3column" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, $l_arr_Enabled), + "label-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), + "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), "label-switch" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH, __("Symbol appended, not prepended", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), "switch" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH, $l_arr_Enabled), - "label-position" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __("Where shall the reference container appear", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_Positions) + "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-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), ) ); // display template with replaced placeholders @@ -166,7 +235,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { // define some space for the output $l_str_Space = "     "; // options for the combination of identical footnotes - $l_arr_CombineIdentical = array( + $l_arr_Enable = array( "yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) ); @@ -198,28 +267,35 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { // replace all placeholders $l_obj_Template->replace( array( - "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_CombineIdentical), - "label-short-code-start" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, __("Footnote tag starts with", 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, __("and ends with", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), "short-code-end" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, $l_arr_ShortCodeEnd), - - "label-short-code-start-user" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED, ""), - "short-code-start-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED), - - "label-short-code-end-user" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED, ""), "short-code-end-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED), - "label-counter-style" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, __("Counter style", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "counter-style" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, $l_arr_CounterStyle), - + // 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, + + "label-counter-style" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, __("Counter 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), + + "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", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + ) ); // display template with replaced placeholders @@ -276,8 +352,15 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { // replace all placeholders $l_obj_Template->replace( array( + "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), + "label-excerpt" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, __("Allow footnotes on Summarized Posts", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), "excerpt" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, $l_arr_Enabled), + "notice1-excerpt" => __("This should be disabled.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "notice2-excerpt" => __("In some themes, the Advanced Excerpt plugin is indispensable to display footnotes in excerpts.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "notice3-excerpt" => __("Footnotes cannot be disabled in excerpts. A workaround is to avoid footnotes in the first 55 words.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "label-expert-mode" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_EXPERT_MODE, __("Enable the Expert mode", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), "expert-mode" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_EXPERT_MODE, $l_arr_Enabled) ) @@ -340,11 +423,25 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "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 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, "customize-mouse-over-box"); // replace all placeholders $l_obj_Template->replace( array( + + // tooltip settings: + "label-enable" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __("Enable the mouse-over box", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), "enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $l_arr_Enabled), @@ -355,7 +452,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "activate-excerpt" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, $l_arr_Enabled), "label-excerpt-length" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, __("Maximum characters for the excerpt", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "excerpt-length" => $this->addTextBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH), + "excerpt-length" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, 3, 10000), "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), @@ -364,13 +461,43 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION, $l_arr_Position), "label-offset-x" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, __("Offset X (px)", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "offset-x" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, -50, 50), + "offset-x" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, -150, 150), "notice-offset-x" => __("Offset (X axis) in px (may be negative)", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "label-offset-y" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, __("Offset Y (px)", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "offset-y" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, -50, 50), + "offset-y" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, -150, 150), "notice-offset-y" => __("Offset (Y axis) in px (may be negative)", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "label-max-width" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, __("Max. width (px)", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "max-width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, 0, 1280), + "notice-max-width" => __("Set the max-width to 0px to disable this setting.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + // display durations: + + "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), + + // tooltip styling: + + "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, __("Color", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), "color" => $this->addColorSelection(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR), "notice-color" => __("Empty color will use the default color defined by your current theme.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), @@ -380,7 +507,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "notice-background" => __("Empty color will use the default background-color defined by your current theme.", 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 (px)", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "border-width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, 0, 4), + "border-width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, 0, 4, true), "notice-border-width" => __("Set the width to 0px to hide the border.", 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)), @@ -388,13 +515,9 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "notice-border-color" => __("Empty color will use the default border-color defined by your current theme.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "label-border-radius" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, __("Border radius (px)", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "border-radius" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, 0, 20), + "border-radius" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, 0, 500), "notice-border-radius" => __("Set the radius to 0px to avoid a radius.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "label-max-width" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, __("Max. width (px)", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "max-width" => $this->addNumBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, 0, 1280), - "notice-max-width" => __("Set the max-width to 0px to disable this setting.", 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), "notice-box-shadow-color" => __("Empty color will use the default box shadow defined by your current theme.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), @@ -416,24 +539,9 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { * 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 */ - 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, __("Hyperlink symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "symbol" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, MCI_Footnotes_Convert::getArrow()), - - "label-user-defined" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED, __("or enter a user defined symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), - "user-defined" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED), - "comment" => __("if set it overrides the hyperlink symbol above", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) - ) - ); - // display template with replaced placeholders - echo $l_obj_Template->getContent(); - } /** * Displays the custom css box. @@ -477,7 +585,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { * * Edited for: * 2.1.1 add priority level setting for the_content 2020-11-16T2152+0100 - * 2.2.0 add priority level settings for the other hooks 2020-11-19T1421+0100 + * 2.1.4 add priority level settings for the other hooks 2020-11-19T1421+0100 */ public function lookupHooks() { // load template file @@ -496,10 +604,8 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "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" => __("Default 9223372036854775807 is lowest priority, 0 is highest.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "description-3" => __("To restore default priority, set to -1, interpreted as 9223372036854775807, the constant PHP_INT_MAX.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "description-4" => __("For the reference container to sit above related posts, the priority level of the_content hook may need to be at most 1200.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "description-5" => __("For Footnotes to work when a glossary plugin is active, a higher priority of 1000 may be needed.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "description-6" => __("For the_content, another good pick with proven efficiency is priority level 10.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), - "description-7" => __("Usually only the_content should be enabled; widget_text may cause issues in accordions, the_title causes issues in browser tabs.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "description-4" => __("For the_content, this figure needs to be lower than 1200 to make sure that the reference container displays above features inserted by other plugins running at 1200 or a greater/lower level, later in the process.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "description-5" => __("The widget_text hook must be disabled, because a footnotes container is inserted at the bottom of each widget, but multiple containers in a page are not disambiguated.", 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), diff --git a/class/init.php b/class/init.php index 989ebc5..ebf567a 100644 --- a/class/init.php +++ b/class/init.php @@ -2,21 +2,19 @@ /** * Includes the main Class of the Plugin. * - * ****************************************************************************************************** - * IMPORTANT: In registerPublic() line 163: Please keep plugin version # up to date for cache busting. * - * Also in class/dashboard/layout:210 for settings.css * - * ****************************************************************************************************** - * * @filesource * @author Stefan Herndler * @since 1.5.0 12.09.14 10:56 * - * Edited for v1.6.5: Replaced deprecated function create_function() - * Edited for v2.0.0: Added jQueryUI from Cloudflare 2020-10-26T1907+0100 - * Edited for v2.0.3: Added style sheet versioning 2020-10-29T1413+0100 - * Edited for v2.0.4: Added jQuery UI from WordPress 2020-11-01T1902+0100 + * Edited: + * 1.6.5 replace deprecated function create_function() + * 2.0.0 add jQueryUI from Cloudflare 2020-10-26T1907+0100 + * 2.0.3 add versioning of public.css for cache busting 2020-10-29T1413+0100 + * 2.0.4 add jQuery UI from WordPress 2020-11-01T1902+0100 + * 2.1.4 automate passing version number for cache busting 2020-11-30T0646+0100 + * 2.1.4 optionally enqueue an extra style sheet 2020-12-04T2231+0100 * - * Continual update of version number for cache busting. + * Last modified: 2020-12-06T1655+0100 */ @@ -135,8 +133,10 @@ class MCI_Footnotes { wp_enqueue_script( 'jquery-ui-position' ); wp_enqueue_script( 'jquery-ui-tooltip' ); - // enqueue jQuery Tools: redacted jQuery.browser, completed minification; added versioning 2020-11-18T2150+0100 - wp_enqueue_script('mci-footnotes-js-jquery-tools', plugins_url('../js/jquery.tools.min.js', __FILE__), '', '2.1.1'); + // enqueue jQuery Tools: + // redacted jQuery.browser, completed minification; 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.7redacted'); // Alternatively, fetch jQuery UI from cdnjs.cloudflare.com: @@ -155,13 +155,16 @@ class MCI_Footnotes { //### STYLES - // IMPORTANT: up-to-date plugin version number NEEDED FOR CACHE BUSTING: - wp_enqueue_style( - 'mci-footnotes-css-public', - plugins_url('../css/public.css', __FILE__), - '', - '2.1.3' - ); - } + // up-to-date plugin version number needed for cache busting: + // not use '-css' in the handle, is appended automatically; + // constant FOOTNOTES_VERSION defined in footnotes.php, media all is default + wp_enqueue_style( 'mci-footnotes-public', plugins_url('footnotes/css/public.css'), array(), FOOTNOTES_VERSION, 'all' ); + // optional layout fix by lack of layout support: + // since 2.1.4 2020-12-05T1417+0100 + $l_str_LayoutOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT); + if ($l_str_LayoutOption != 'none') { + wp_enqueue_style( 'mci-footnotes-layout-' . $l_str_LayoutOption, plugins_url('footnotes/css/layout-' . $l_str_LayoutOption . '.css'), array(), FOOTNOTES_VERSION, 'all' ); + } + } } diff --git a/class/settings.php b/class/settings.php index 1a7f2ec..244b781 100644 --- a/class/settings.php +++ b/class/settings.php @@ -7,18 +7,19 @@ * @since 1.5.0 14.09.14 10:43 * * Edited for: - * 2.0.4 restore arrow settings 2020-11-02T2115+0100 - * 2.0.7 remove hook the_post 2020-11-06T1342+0100 - * 2.1.0 add read-on button label customization 2020-11-08T2149+0100 - * 2.1.1 fix tooltips on site by alternative 2020-11-11T1819+0100 - * 2.1.1 fix disabling backlink symbol 2020-11-16T2021+0100 - * 2.1.1 fix superscript by making it optional - * 2.1.1 fix start pages by option to hide ref container - * 2.1.1 fix ref container by option restoring 3-column layout - * 2.1.1 fix ref container by option to switch index/symbol 2020-11-16T2022+0100 - * 2.1.3 fix ref container positioning by priority level 2020-11-17T0205+0100 + * 2.0.4 restore arrow settings 2020-11-02T2115+0100 + * 2.0.7 remove hook the_post 2020-11-06T1342+0100 + * 2.1.0 add read-on button label customization 2020-11-08T2149+0100 + * 2.1.1 fix tooltips on site by alternative 2020-11-11T1819+0100 + * 2.1.1 fix disabling backlink symbol 2020-11-16T2021+0100 + * 2.1.1 fix superscript by making it optional + * 2.1.1 fix start pages by option to hide ref container + * 2.1.1 fix ref container by option restoring 3-column layout + * 2.1.1 fix ref container by option to switch index/symbol 2020-11-16T2022+0100 + * 2.1.3 fix ref container positioning by priority level 2020-11-17T0205+0100 + * 2.1.4 more settings container keys 2020-12-03T0955+0100 * - * Last modified: 2020-11-17T0311+0100 + * Last modified: 2020-12-06T1653+0100 */ @@ -175,7 +176,7 @@ class MCI_Footnotes_Settings { /** * Settings Container Key for alternative tooltip implementation * - * @since 2.2.0 + * @since 2.1.4 * @var string * * 2020-11-11T1817+0100 @@ -373,7 +374,7 @@ class MCI_Footnotes_Settings { const C_STR_FOOTNOTES_TOOLTIP_READON_LABEL = "footnote_inputfield_readon_label"; /** - * Settings Container Keys of options fixing default layout + * Settings Container Keys for options fixing default layout * * @since 2.1.1 * @var string @@ -381,18 +382,83 @@ class MCI_Footnotes_Settings { * 2020-11-16T0859+0100 */ const C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS = "footnotes_inputfield_referrer_superscript_tags"; - const C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = "footnotes_inputfield_reference_container_backlink_symbol_enable"; const C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE = "footnotes_inputfield_reference_container_start_page_enable"; const C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = "footnotes_inputfield_reference_container_3column_layout_enable"; const C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = "footnotes_inputfield_reference_container_backlink_symbol_switch"; + /** + * Settings Container Keys for hook priority levels + * + * @since 2.1.1 (the_content) + * @since 2.1.2 + * @var string + * + * 2020-11-16T0859+0100 + * 2020-11-20T0620+0100 + */ const C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_title_priority_level"; const C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_content_priority_level"; const C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_the_excerpt_priority_level"; const C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_widget_title_priority_level"; const C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL = "footnote_inputfield_expert_lookup_widget_text_priority_level"; + /** + * 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 string|bool|int + * + * 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: + 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"; /** @@ -424,28 +490,61 @@ class MCI_Footnotes_Settings { "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_STR_FOOTNOTES_COUNTER_STYLE => 'arabic_plain', + self::C_INT_FOOTNOTES_SCROLL_OFFSET => 20, + self::C_INT_FOOTNOTES_SCROLL_DURATION => 380, + self::C_STR_REFERENCE_CONTAINER_NAME => 'References', self::C_BOOL_REFERENCE_CONTAINER_COLLAPSE => 'no', self::C_STR_REFERENCE_CONTAINER_POSITION => 'post_end', self::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES => 'yes', + // whether to enqueue additional style sheet: + self::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT => 'none', + self::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE => 'yes', self::C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE => 'yes', self::C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE => 'no', self::C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH => 'no', - 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_STR_FOOTNOTES_COUNTER_STYLE => 'arabic_plain', - self::C_STR_FOOTNOTES_LOVE => '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 use link elements: + self::C_BOOL_LINK_ELEMENT_ENABLED => 'yes', + + // excerpt should be disabled: self::C_BOOL_FOOTNOTES_IN_EXCERPT => 'no', // since removal of the_post hook, expert mode is no danger zone // not for experts only; raising awareness about relative positioning // changed default to 'yes': - self::C_BOOL_FOOTNOTES_EXPERT_MODE => 'yes' + self::C_BOOL_FOOTNOTES_EXPERT_MODE => 'yes', + + self::C_STR_FOOTNOTES_LOVE => 'no', ), @@ -487,6 +586,20 @@ class MCI_Footnotes_Settings { // the current line of text (web coordinates origin is top left): self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y => -7, + // 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: @@ -510,6 +623,8 @@ class MCI_Footnotes_Settings { "footnotes_storage_expert" => array( + // checkboxes + // Titles should all be enabled by default to prevent users from // thinking at first that the feature is broken in post titles. // See @@ -517,7 +632,7 @@ class MCI_Footnotes_Settings { self::C_BOOL_EXPERT_LOOKUP_THE_TITLE => '', // This is the only useful one: - self::C_BOOL_EXPERT_LOOKUP_THE_CONTENT => 'yes', + self::C_BOOL_EXPERT_LOOKUP_THE_CONTENT => 'checked', // And the_excerpt is disabled by default following @nikelaos in // @@ -526,16 +641,18 @@ class MCI_Footnotes_Settings { self::C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE => '', - // disabled by default because of issues with footnotes in Elementor accordions: + // The widget_text hook must be disabled, because a footnotes container is inserted + // at the bottom of each widget, but multiple containers in a page are not disambiguated. + // E.g. enabling this causes issues with footnotes in Elementor accordions. self::C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT => '', // 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: + // shows "9223372036854780000" instead of 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 self::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL => PHP_INT_MAX, - self::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL => 10, + self::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL => 1000, self::C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL => PHP_INT_MAX, self::C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL => PHP_INT_MAX, self::C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL => PHP_INT_MAX, diff --git a/class/task.php b/class/task.php index 0807493..abc29a7 100644 --- a/class/task.php +++ b/class/task.php @@ -8,17 +8,25 @@ * * Edited for v2.0.0 and following. * - * 2.0.5: Autoload / infinite scroll support added thanks to code from + * 2.0.5 Autoload / infinite scroll support added thanks to code from * @docteurfitness * - * 2.0.9: DISABLED the_post HOOK 2020-11-08T1839+0100 - * 2.1.0: promoted the 'Continue reading' button from localization to customization 2020-11-08T2146+0100 - * 2.1.1: combining identical footnotes: fixed dead links 2020-11-14T2233+0100 - * 2.1.1: options fixing ref container layout and referrer vertical alignment 2020-11-16T2024+0100 - * 2.1.1: option fixing ref container relative position 2020-11-17T0254+0100 - * 2.1.2: options for the other hooks 2020-11-19T1849+0100 + * 2.0.9 DISABLED the_post HOOK 2020-11-08T1839+0100 + * 2.1.0 promoted the 'Continue reading' button from localization to customization 2020-11-08T2146+0100 + * 2.1.1 combining identical footnotes: fixed dead links 2020-11-14T2233+0100 + * 2.1.1 options fixing ref container layout and referrer vertical alignment 2020-11-16T2024+0100 + * 2.1.1 option fixing ref container relative position 2020-11-17T0254+0100 + * 2.1.2 options for the other hooks 2020-11-19T1849+0100 + * 2.1.4 fix line wrapping of URLs based on pattern, not link element 2020-11-25T0837+0100 + * 2.1.4 fix issues with link elements by making them optional 2020-11-26T1051+0100 + * 2.1.4 support appending arrow when combining identicals is on 2020-11-26T1633+0100 + * 2.1.4 disable or select backlink separator and terminator 2020-11-28T1048+0100 + * 2.1.4 optional line breaks to stack enumerated backlinks 2020-11-28T1049+0100 + * 2.1.4 ref container column width and tooltip font size settings 2020-12-03T0954+0100 + * 2.1.4 scroll offset and duration settings 2020-12-05T0538+0100 + * 2.1.4 tooltip display duration settings 2020-12-06T1320+0100 * - * Last modified: 2020-11-24T0957+0100 + * Last modified: 2020-12-06T1652+0100 */ // If called directly, abort: @@ -142,22 +150,86 @@ class MCI_Footnotes_Task { * @since 1.5.0 */ public function wp_head() { + + // tooltip: + $l_str_FontSizeEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED)); + $l_str_FontSizeScalar = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR); + $l_str_FontSizeUnit = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT); + $l_str_Color = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR); $l_str_Background = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND); + $l_int_BorderWidth = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH); $l_str_BorderColor = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR); $l_int_BorderRadius = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS); + $l_int_MaxWidth = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH); + $l_str_BoxShadowColor = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR); + + // ref container first column width: + $l_bool_ColumnWidthEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED)); + $l_int_ColumnWidthScalar = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR); + $l_str_ColumnWidthUnit = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_UNIT); + + $l_bool_ColumnMaxWidthEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED)); + $l_int_ColumnMaxWidthScalar = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR); + $l_str_ColumnMaxWidthUnit = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT); + + if (!empty($l_int_ColumnWidthScalar)) { + if ($l_str_ColumnWidthUnit == '%') { + if ($l_int_ColumnWidthScalar > 100) { + $l_int_ColumnWidthScalar = 100; + } + } + } else { + $l_int_ColumnWidthScalar = 0; + } + + if (!empty($l_int_ColumnMaxWidthScalar)) { + if ($l_str_ColumnMaxWidthUnit == '%') { + if ($l_int_ColumnMaxWidthScalar > 100) { + $l_int_ColumnMaxWidthScalar = 100; + } + } + } else { + $l_int_ColumnMaxWidthScalar = 0; + } + ?> -