From b00931176662fad590cf9482c05ed87e217158a6 Mon Sep 17 00:00:00 2001 From: pewgeuges <73141620+pewgeuges@users.noreply.github.com> Date: Fri, 12 Feb 2021 10:18:31 +0000 Subject: [PATCH] prepare urgent bugfix release 2.5.4 - this: 2.5.4d6 git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2473635 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- class/dashboard/subpage-main.php | 60 +++++++- class/settings.php | 91 ++++++++++++- class/task.php | 128 +++++++++++------- class/template.php | 6 +- css/public.css | 25 +++- footnotes.php | 6 +- note-for-developers.txt | 91 +++++++------ readme.txt | 17 ++- .../dashboard/mouse-over-box-position.html | 4 - templates/dashboard/settings-scrolling.html | 8 ++ 10 files changed, 317 insertions(+), 119 deletions(-) diff --git a/class/dashboard/subpage-main.php b/class/dashboard/subpage-main.php index c7b46a2..675860b 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-11T0821+0100 + * @lastmodified 2021-02-12T1035+0100 * * @since 2.0.4 restore arrow settings 2020-11-01T0509+0100 * @since 2.1.0 read-on button label 2020-11-08T2148+0100 @@ -150,10 +150,11 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { $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"); @@ -501,6 +502,15 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "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 @@ -709,6 +719,20 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { "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), @@ -780,6 +804,38 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine { 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( + + "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), + + + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + public function MouseOverBoxAppearance() { // options for Yes/No select box: $l_arr_Enabled = array( diff --git a/class/settings.php b/class/settings.php index 42911f6..2cc0b8e 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-11T1130+0100 + * @lastmodified 2021-02-12T0928+0100 * * @since 2.0.4 restore arrow settings 2020-11-02T2115+0100 * @since 2.0.7 remove hook the_post 2020-11-06T1342+0100 @@ -105,7 +105,7 @@ class MCI_Footnotes_Settings { * * @author Stefan Herndler * @since 1.5.0 - * @var bool + * @var str */ const C_BOOL_COMBINE_IDENTICAL_FOOTNOTES = "footnote_inputfield_combine_identical"; @@ -496,7 +496,6 @@ class MCI_Footnotes_Settings { * - 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"; @@ -612,7 +611,7 @@ class MCI_Footnotes_Settings { * Unicode-compliant browsers break URLs at slashes. * * @since 2.1.6 - * @var bool + * @var str * * 2020-12-09T1554+0100..2020-12-13T1313+0100 */ @@ -652,7 +651,7 @@ class MCI_Footnotes_Settings { * @link https://wordpress.org/support/topic/borders-25/ * * @since 2.2.10 - * @var bool + * @var str * * 2020-12-25T2311+0100 */ @@ -679,12 +678,81 @@ class MCI_Footnotes_Settings { * Settings container key for shortcode syntax validation * * @since 2.4.0 - * @var bool + * @var str * * 2021-01-01T0616+0100 */ const C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE = "footnotes_inputfield_shortcode_syntax_validation_enable"; + /** + * Settings container key to enable a backlink tooltip + * + * - + * + * @since 2.5.4 + * + * @reporter + * @link + * + * @var str + */ + const C_BOOL_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE = "footnotes_inputfield_backlink_tooltip_enable"; + + /** + * Settings container key to configure the backlink tooltip + * + * - + * + * @since 2.5.4 + * + * @reporter + * @link + * + * @var str + */ + const C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT = "footnotes_inputfield_backlink_tooltip_text"; + + /** + * Settings container key to configure the tooltip excerpt delimiter + * + * - + * + * @since 2.5.4 + * + * @reporter + * @link + * + * @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 + * + * @reporter + * @link + * + * @var str + */ + 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 + * + * @reporter + * @link + * + * @var str + */ + const C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR = "footnotes_inputfield_tooltip_excerpt_mirror_separator"; /** @@ -752,6 +820,11 @@ class MCI_Footnotes_Settings { 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', @@ -847,6 +920,12 @@ class MCI_Footnotes_Settings { // 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 => ' — ', + + // 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: diff --git a/class/task.php b/class/task.php index 2947f65..f240ee5 100644 --- a/class/task.php +++ b/class/task.php @@ -7,9 +7,10 @@ * @since 1.5.0 * * - * @lastmodified 2021-02-11T0817+0100 + * @lastmodified 2021-02-12T1100+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. * @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: Infinite scroll: debug autoload by adding post ID, thanks to @docteurfitness code contribution. @@ -74,6 +75,7 @@ * @since 2.5.2 Update: Tooltips: ability to display dedicated content before `[[/tooltip]]`, thanks to @jbj2199 issue report. * @since 2.5.3 Bugfix: Reference container, tooltips: URL wrap: exclude URL pattern as folder name in Wayback Machine URL, thanks to @rumperuu bug report. * @since 2.5.4 Bugfix: Reference container, tooltips: URL wrap: account for leading space in value, thanks to @karolszakiel example provision. + * @since 2.5.4 Update: Reference container: Hard backlinks (optional): optional configurable tooltip hinting to use the backbutton instead, thanks to @@theroninjedi47 bug report. * @since 2.5.4 Bugfix: Tooltips: fix display in Popup Maker popups by correcting a coding error. */ @@ -173,16 +175,28 @@ class MCI_Footnotes_Task { * @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 false; depend on settings + * @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. * @@ -197,12 +211,6 @@ class MCI_Footnotes_Task { * * The official AMP plugin strips off JavaScript, breaking Footnotes’ * animated scrolling. - * - * - * @since 2.0.4 remove hard links on user request - * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ - * - * @since 2.0.0 add hard links */ public static $a_bool_HardLinksEnable = false; public static $a_str_ReferrerLinkSlug = 'r'; @@ -239,9 +247,7 @@ class MCI_Footnotes_Task { /** * Optional link element for footnote referrers and backlinks * - * @since 2.0.0 add link elements with hard links - * @since 2.0.4 remove hard links on user request - * @link https://wordpress.org/support/topic/hyperlinked-footnotes-creating-excessive-back-history/ + * @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. @@ -261,29 +267,29 @@ class MCI_Footnotes_Task { * * @since 2.3.0 * @datetime 2020-12-30T2313+0100 - * @see self::$a_bool_HardLinksEnable * - * # Styling + * @contributor @martinneumannat + * @link https://wordpress.org/support/topic/making-it-amp-compatible/ * - * Link color is preferred for referrers and backlinks. - * Setting a global link color is a common feature in WordPress themes. - * CSS does not support identifiers for link colors (color: link | hover | active | visited) - * These are only supported as pseudo-classes of the link element. - * Hence the link element must be present for styling purposes. - * But styling these elements with the link color is not universally preferred. - * If not, the very presence of the link elements may need to be avoided. - * - * # Functionality + * @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 also raise further concerns, so that their useless proliferation needs - * to be mitigated. By contrast, due to an insufficiency in the CSS standard, real link - * elements are required to get the link color, as oppose - * this variable keeps its default value if hard links are disabled + * 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 = ''; @@ -1284,7 +1290,7 @@ class MCI_Footnotes_Task { $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 = '[[/tooltip]]'; // grab from DB + 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; @@ -1563,9 +1569,11 @@ class MCI_Footnotes_Task { $l_str_FootnoteLinkArgument .= $l_int_Index; $l_str_FootnoteLinkArgument .= '" class="footnote_hard_link"'; - // compose offset anchor, an empty span child of empty span - // to prevent browsers from drawing tall dotted rectangles: - $l_str_ReferrerAnchorElement = '