diff --git a/class/dashboard/layout.php b/class/dashboard/layout.php index 668453a..840410a 100644 --- a/class/dashboard/layout.php +++ b/class/dashboard/layout.php @@ -211,7 +211,7 @@ abstract class MCI_Footnotes_Layout_Engine { * 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 ) { + if ( C_BOOL_CSS_PRODUCTION_MODE ) { wp_register_style( 'mci-footnotes-admin', @@ -232,7 +232,7 @@ abstract class MCI_Footnotes_Layout_Engine { array(), filemtime( plugin_dir_path( - dirname( __FILE__ ) + dirname( __FILE__, 2 ) ) . 'css/settings.css' ) ); diff --git a/class/dashboard/subpage-main.php b/class/dashboard/subpage-main.php index bfddc98..ba26c16 100644 --- a/class/dashboard/subpage-main.php +++ b/class/dashboard/subpage-main.php @@ -121,7 +121,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { * * @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: + * 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 * @@ -130,16 +130,18 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { protected function get_meta_boxes() { $l_arr_meta_boxes = array(); - // Sync box name with mirror in task.php. + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'amp-compat', __( 'AMP compatibility', 'footnotes' ), 'amp_compat' ); $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'start-end', __( 'Footnote start and end short codes', 'footnotes' ), 'start_end' ); - $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'numbering', __( 'Footnotes numbering', 'footnotes' ), 'Numbering' ); - $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'scrolling', __( 'Scrolling behavior', 'footnotes' ), 'Scrolling' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'numbering', __( 'Footnotes numbering', 'footnotes' ), 'numbering' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'scrolling', __( 'Scrolling behavior', 'footnotes' ), 'scrolling' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'hard-links', __( 'URL fragment ID configuration', 'footnotes' ), 'hard_links' ); $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'reference-container', __( 'Reference container', 'footnotes' ), 'reference_container' ); $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'excerpts', __( 'Footnotes in excerpts', 'footnotes' ), 'excerpts' ); - $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'love', MCI_Footnotes_Config::C_STR_PLUGIN_HEADING_NAME . ' ' . MCI_Footnotes_Config::C_STR_LOVE_SYMBOL_HEADING, 'Love' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'love', MCI_Footnotes_Config::C_STR_PLUGIN_HEADING_NAME . ' ' . MCI_Footnotes_Config::C_STR_LOVE_SYMBOL_HEADING, 'love' ); $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'hyperlink-arrow', __( 'Backlink symbol', 'footnotes' ), 'hyperlink_arrow' ); - $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'superscript', __( 'Referrer typesetting and formatting', 'footnotes' ), 'superscript' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'superscript', __( 'Referrers', 'footnotes' ), 'superscript' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'label-solution', __( 'Referrers in labels', 'footnotes' ), 'label_solution' ); $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box', __( 'Tooltips', 'footnotes' ), 'mouseover_box' ); $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-position', __( 'Tooltip position', 'footnotes' ), 'mouseover_box_position' ); $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-dimensions', __( 'Tooltip dimensions', 'footnotes' ), 'mouseover_box_dimensions' ); @@ -164,6 +166,34 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { return $l_arr_meta_boxes; } + /** + * Displays the AMP compatibility mode option. + * + * @since 2.5.11 (draft) + * @since 2.6.0 (release) + */ + public function amp_compat() { + + // Load template file. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'settings-amp' ); + // Replace all placeholders. + $l_obj_template->replace( + array( + // Translators: '%s' is the link text 'AMP-WP' linked to the plugin’s front page on WordPress.org. + 'description-1-amp' => sprintf( __( 'The official %s plugin is required when this option is enabled.', 'footnotes' ), 'AMP-WP' ), + 'label-amp' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_AMP_COMPATIBILITY_ENABLE, __( 'Enable AMP compatibility mode:', 'footnotes' ) ), + 'amp' => $this->add_checkbox( MCI_Footnotes_Settings::C_STR_FOOTNOTES_AMP_COMPATIBILITY_ENABLE ), + 'notice-amp' => __( 'This option enables hard links with configurable scroll offset in % viewport height.', 'footnotes' ), + // Translators: '%s' is the logogram of the 'Footnotes' plugin. + 'description-2-amp' => sprintf( __( '%s is becoming AMP compatible when this box is checked. Styled tooltips are displayed with fade-in/fade-out effect if enabled, and the reference container expands also on clicking a referrer if it’s collapsed by default.', 'footnotes' ), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . '' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + /** * Displays all settings for the reference container. * @@ -207,7 +237,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { ); // 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. + // 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', 'footnotes' ), @@ -242,7 +272,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-name' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME, __( 'Heading:', 'footnotes' ) ), 'name' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME ), - 'label-element' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, __( 'Heading’s HTML element:', 'footnotes' ) ), + 'label-element' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, __( 'Heading’s HTML element:', 'footnotes' ) ), 'element' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, $l_arr_label_element ), 'label-border' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER, __( 'Border under the heading:', 'footnotes' ) ), @@ -253,7 +283,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-script' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE, __( 'Script mode:', 'footnotes' ) ), 'script' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE, $l_arr_script_mode ), - 'notice-script' => __( 'The plain JavaScript mode does not support scroll animation and will enable hard links with scroll offset.', 'footnotes' ), + 'notice-script' => __( 'The plain JavaScript mode will enable hard links with configurable scroll offset.', 'footnotes' ), 'label-position' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __( 'Default position:', 'footnotes' ) ), 'position' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_positions ), @@ -277,11 +307,11 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-page-layout' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT, __( 'Apply basic responsive page layout:', 'footnotes' ) ), 'page-layout' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT, $l_arr_page_layout_options ), - 'notice-page-layout' => __( 'Most themes don’t need this fix.', 'footnotes' ), + 'notice-page-layout' => __( 'Most themes don’t need this fix.', 'footnotes' ), 'label-url-wrap' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTE_URL_WRAP_ENABLED, __( 'Allow URLs to line-wrap anywhere:', 'footnotes' ) ), 'url-wrap' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTE_URL_WRAP_ENABLED, $l_arr_enabled ), - 'notice-url-wrap' => __( 'Unicode-conformant browsers don’t need this fix.', 'footnotes' ), + 'notice-url-wrap' => __( 'Unicode-conformant browsers don’t need this fix.', 'footnotes' ), 'label-symbol' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, __( 'Display a backlink symbol:', 'footnotes' ) ), 'symbol-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, $l_arr_enabled ), @@ -313,13 +343,13 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'width-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_ENABLED, $l_arr_enabled ), 'width-scalar' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR, 0, 500, true ), 'width-unit' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_UNIT, $l_arr_width_units ), - 'notice-width' => __( 'Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.', 'footnotes' ), + 'notice-width' => __( 'Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.', 'footnotes' ), 'label-max-width' => $this->add_label( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, __( 'Set backlinks column maximum width:', 'footnotes' ) ), 'max-width-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, $l_arr_enabled ), 'max-width-scalar' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR, 0, 500, true ), 'max-width-unit' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT, $l_arr_width_units ), - 'notice-max-width' => __( 'Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.', 'footnotes' ), + 'notice-max-width' => __( 'Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.', 'footnotes' ), 'label-line-break' => $this->add_label( MCI_Footnotes_Settings::C_STR_BACKLINKS_LINE_BREAKS_ENABLED, __( 'Stack backlinks when enumerating:', 'footnotes' ) ), 'line-break' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_LINE_BREAKS_ENABLED, $l_arr_enabled ), @@ -327,7 +357,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-link' => $this->add_label( MCI_Footnotes_Settings::C_STR_LINK_ELEMENT_ENABLED, __( 'Use the link element for referrers and backlinks:', 'footnotes' ) ), 'link' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_LINK_ELEMENT_ENABLED, $l_arr_enabled ), - 'notice-link' => __( 'The link element is needed to apply the theme’s link color.', 'footnotes' ), + 'notice-link' => __( 'The link element is needed to apply the theme’s link color.', 'footnotes' ), '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.', 'footnotes' ), ) ); @@ -393,8 +423,8 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { // 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.', 'footnotes' ), + // Translators: The 2 placeholders are the <ref></ref> and <fn></fn> shortcodes. + 'description-escapement' => sprintf( __( 'The problems with shortcodes with pointy brackets have been solved. We apologize for the longlasting bugs making the %1$s and %2$s shortcodes close to unusable.', 'footnotes' ), '<ref></ref>', '<fn></fn>' ), 'label-short-code-start' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, __( 'Footnote start tag short code:', 'footnotes' ) ), 'short-code-start' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, $l_arr_shortcode_start ), @@ -417,7 +447,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'syntax' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_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.', 'footnotes' ), - '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.', 'footnotes' ), + '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.', 'footnotes' ), ) ); // Display template with replaced placeholders. @@ -441,12 +471,12 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { ); // Options for the numbering style of the footnotes. $l_arr_counter_style = array( - 'arabic_plain' => __( 'plain Arabic numbers', 'footnotes' ) . $l_str_space . '1, 2, 3, 4, 5, …', - 'arabic_leading' => __( 'zero-padded Arabic numbers', 'footnotes' ) . $l_str_space . '01, 02, 03, 04, 05, …', - 'latin_low' => __( 'lowercase Latin letters', 'footnotes' ) . $l_str_space . 'a, b, c, d, e, …', - 'latin_high' => __( 'uppercase Latin letters', 'footnotes' ) . $l_str_space . 'A, B, C, D, E, …', - 'romanic' => __( 'uppercase Roman numerals', 'footnotes' ) . $l_str_space . 'I, II, III, IV, V, …', - 'roman_low' => __( 'lowercase Roman numerals', 'footnotes' ) . $l_str_space . 'i, ii, iii, iv, v, …', + 'arabic_plain' => __( 'plain Arabic numbers', 'footnotes' ) . $l_str_space . '1, 2, 3, 4, 5, …', + 'arabic_leading' => __( 'zero-padded Arabic numbers', 'footnotes' ) . $l_str_space . '01, 02, 03, 04, 05, …', + 'latin_low' => __( 'lowercase Latin letters', 'footnotes' ) . $l_str_space . 'a, b, c, d, e, …', + 'latin_high' => __( 'uppercase Latin letters', 'footnotes' ) . $l_str_space . 'A, B, C, D, E, …', + 'romanic' => __( 'uppercase Roman numerals', 'footnotes' ) . $l_str_space . 'I, II, III, IV, V, …', + 'roman_low' => __( 'lowercase Roman numerals', 'footnotes' ) . $l_str_space . 'i, ii, iii, iv, v, …', ); // Load template file. @@ -478,7 +508,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { */ public function scrolling() { - // Options for enabling hard links for AMP compat. + // Options for enabling scroll duration asymmetricity. $l_arr_enable = array( 'yes' => __( 'Yes', 'footnotes' ), 'no' => __( 'No', 'footnotes' ), @@ -490,18 +520,66 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { $l_obj_template->replace( array( + 'label-scroll-css' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_CSS_SMOOTH_SCROLLING, __( 'CSS-based smooth scrolling:', 'footnotes' ) ), + 'scroll-css' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_CSS_SMOOTH_SCROLLING, $l_arr_enable ), + 'notice-scroll-css' => __( 'May slightly disturb jQuery scrolling and is therefore disabled by default. Works in recent browsers.', 'footnotes' ), + 'label-scroll-offset' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET, __( 'Scroll offset:', 'footnotes' ) ), 'scroll-offset' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET, 0, 100 ), - 'notice-scroll-offset' => __( 'per cent from the upper edge of the window', 'footnotes' ), + 'notice-scroll-offset' => __( 'per cent viewport height from the upper edge', 'footnotes' ), 'label-scroll-duration' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION, __( 'Scroll duration:', 'footnotes' ) ), 'scroll-duration' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION, 0, 20000 ), - 'notice-scroll-duration' => __( 'milliseconds; instantly if hard links are enabled and JavaScript is disabled', 'footnotes' ), + 'notice-scroll-duration' => __( 'milliseconds. If asymmetric scroll durations are enabled, this is the scroll-up duration.', 'footnotes' ), + + // Enable scroll duration asymmetricity. + 'label-scroll-asymmetricity' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, __( 'Enable asymmetric scroll durations:', 'footnotes' ) ), + 'scroll-asymmetricity' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, $l_arr_enable ), + 'notice-scroll-asymmetricity' => __( 'With this option enabled, scrolling up may take longer than down, or conversely.', 'footnotes' ), + + 'label-scroll-down-duration' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DOWN_DURATION, __( 'Scroll-down duration:', 'footnotes' ) ), + 'scroll-down-duration' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DOWN_DURATION, 0, 20000 ), + 'notice-scroll-down-duration' => __( 'milliseconds', 'footnotes' ), + + 'label-scroll-down-delay' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DOWN_DELAY, __( 'Scroll-down delay:', 'footnotes' ) ), + 'scroll-down-delay' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DOWN_DELAY, 0, 20000 ), + 'notice-scroll-down-delay' => __( 'milliseconds. Useful to see the effect on input elements when referrers without hard links are clicked in form labels.', 'footnotes' ), + + 'label-scroll-up-delay' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_UP_DELAY, __( 'Scroll-up delay:', 'footnotes' ) ), + 'scroll-up-delay' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_UP_DELAY, 0, 20000 ), + 'notice-scroll-up-delay' => __( 'milliseconds. Less useful than the scroll-down delay.', 'footnotes' ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all options for the fragment identifier configuration. + * + * @since 2.2.0 in scrolling(). + * @since 2.5.12 separate metabox. + */ + public function hard_links() { + + // Options for enabling hard links for AMP compat. + $l_arr_enable = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // Load template file. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'settings-hard-links' ); + // Replace all placeholders. + $l_obj_template->replace( + array( - // Enable hard links for AMP compat. 'label-hard-links' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_HARD_LINKS_ENABLE, __( 'Enable hard links:', 'footnotes' ) ), 'hard-links' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_HARD_LINKS_ENABLE, $l_arr_enable ), - 'notice-hard-links' => __( 'Hard links are indispensable for AMP compatibility and allow to link to footnotes.', 'footnotes' ), + 'notice-hard-links' => __( 'Hard links disable jQuery delays but have the same scroll offset, and allow to share footnotes (accessed if the list is not collapsed by default).', 'footnotes' ), 'label-footnote' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG, __( 'Fragment identifier slug for footnotes:', 'footnotes' ) ), 'footnote' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG ), @@ -522,7 +600,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-backlink-tooltip-text' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT, __( 'Backlink tooltip text:', 'footnotes' ) ), 'backlink-tooltip-text' => $this->add_text_box( 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.', 'footnotes' ), + 'notice-backlink-tooltip-text' => __( 'Default text is the keyboard shortcut; may be a localized descriptive hint.', 'footnotes' ), ) ); @@ -552,15 +630,15 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'text-5' => sprintf( '%s %s', MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ), // Translators: 2: heart symbol 1: footnotes logogram. 'text-1' => sprintf( __( 'I %2$s %1$s', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL ), - // Translators: %s: Plugin logo. + // Translators: %s: Footnotes plugin logo. 'text-6' => sprintf( __( 'This website uses %s.', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ), - // Translators: %s: Plugin logo. + // Translators: %s: Footnotes plugin logo. 'text-7' => sprintf( __( 'This website uses the %s plugin.', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ), - // Translators: %s: Plugin logo. + // Translators: %s: Footnotes plugin logo. 'text-2' => sprintf( __( 'This website uses the awesome %s plugin.', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ), 'random' => __( 'randomly determined display of either mention', 'footnotes' ), // Translators: 1: Plugin logo.2: heart symbol. - 'no' => sprintf( __( 'no display of any “%1$s %2$s” mention in the footer', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL ), + 'no' => sprintf( __( 'no display of any “%1$s %2$s” mention in the footer', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL ), ); // Load template file. @@ -568,10 +646,11 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { // Replace all placeholders. $l_obj_template->replace( array( - // Translators: %s: Plugin logo. - 'label-love' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, sprintf( __( 'Tell the world you’re using %s:', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ) ), + // Translators: %s: Footnotes plugin logo. + 'label-love' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, sprintf( __( 'Tell the world you’re using %s:', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ) ), 'love' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, $l_arr_love ), - // Translators: %s: Plugin logo. + + // Translators: %s: Footnotes plugin logo. 'label-no-love' => $this->add_text( sprintf( __( 'Shortcode to inhibit the display of the %s mention on specific pages:', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ) ), 'no-love' => $this->add_text( MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG ), ) @@ -607,9 +686,10 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { array( 'label-excerpts' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_IN_EXCERPT, __( 'Display footnotes in excerpts:', 'footnotes' ) ), 'excerpts' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_IN_EXCERPT, $l_arr_enabled ), - 'notice-excerpts' => __( 'The recommended value is No.', 'footnotes' ), - // Translators: %s: link to the Advanced Excerpt Plugin. - '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.', 'footnotes' ), 'Advanced Excerpt' ), + 'notice-excerpts' => __( 'For this setting to be effective, the hook the_excerpt must be enabled under Scope and priority.', 'footnotes' ), + // Translators: %s: link text 'Advanced Excerpt' linked to the plugin’s WordPress.org front page. + // Translators: %s: Footnotes plugin logo. + 'description-excerpts' => sprintf( __( 'Both to display footnotes and to not display footnotes in excerpts, the %s plugin generates excerpts on the basis of the posts to ensure that footnotes are handled and don’t impact the excerpt length.', 'footnotes' ), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . '' ), ) ); // Display template with replaced placeholders. @@ -647,6 +727,10 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-superscript' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, __( 'Display footnote referrers in superscript:', 'footnotes' ) ), 'superscript' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, $l_arr_enabled ), + 'label-normalize' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, __( 'Normalize vertical alignment and font size:', 'footnotes' ) ), + 'normalize' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, $l_arr_normalize_superscript ), + 'notice-normalize' => __( 'Most themes don’t need this fix.', 'footnotes' ), + 'label-before' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE, __( 'At the start of the footnote referrers:', 'footnotes' ) ), 'before' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE ), @@ -654,11 +738,36 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'after' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER ), 'label-link' => $this->add_label( MCI_Footnotes_Settings::C_STR_LINK_ELEMENT_ENABLED, __( 'Use the link element for referrers and backlinks:', 'footnotes' ) ), - '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.', 'footnotes' ), + '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.', 'footnotes' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } - 'label-normalize' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, __( 'Normalize vertical alignment and font size:', 'footnotes' ) ), - 'normalize' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, $l_arr_normalize_superscript ), - 'notice-normalize' => __( 'Most themes don’t need this fix.', 'footnotes' ), + /** + * Displays the setting for the input label issue solution. + * + * @since 2.5.12 + */ + public function label_solution() { + // Options for the input label issue solution. + $l_arr_issue_solutions = array( + 'none' => __( '0. No problem or solved otherwise', 'footnotes' ), + 'move' => __( 'A. Footnotes are moved out and appended after the label’s end (recommended)', 'footnotes' ), + 'disconnect' => __( 'B. Labels with footnotes are disconnected from input element (discouraged)', 'footnotes' ), + ); + // Load template file. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'configure-label-solution' ); + // Replace all placeholders. + $l_obj_template->replace( + array( + 'description-1-selection' => __( 'Clicking a footnote referrer in an input element label toggles the input except when hard links are enabled. In jQuery mode, the recommended solution is to move footnotes and append them after the label (option A).', 'footnotes' ), + 'label-selection' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LABEL_ISSUE_SOLUTION, __( 'Solve input label issue:', 'footnotes' ) ), + 'selection' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LABEL_ISSUE_SOLUTION, $l_arr_issue_solutions ), + 'description-2-selection' => __( 'Option B is discouraged because disconnecting a label from its input element may compromise accessibility. This option is a last resort in case footnotes must absolutely stay inside the label. (Using jQuery ‘event.stopPropagation’ failed.)', 'footnotes' ), ) ); // Display template with replaced placeholders. @@ -696,8 +805,8 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-alternative' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, __( 'Display alternative tooltips:', 'footnotes' ) ), 'alternative' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, $l_arr_enabled ), 'notice-alternative' => __( 'Intended to work around a configuration-related tooltip outage.', 'footnotes' ), - // Translators: %s: Plugin logo. - '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.', 'footnotes' ), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . '' ), + // Translators: %s: Footnotes plugin logo. + '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.', 'footnotes' ), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . '' ), ) ); @@ -851,7 +960,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { // The feature trims back until the last full word. 'notice-max-length' => __( 'No weird cuts.', 'footnotes' ), - 'label-readon' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL, __( '‘Read on’ button label:', 'footnotes' ) ), + 'label-readon' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL, __( '‘Read on’ button label:', 'footnotes' ) ), 'readon' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL ), ) @@ -941,12 +1050,12 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-color' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR, __( 'Text color:', 'footnotes' ) ), 'color' => $this->add_color_selection( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR ), // Translators: %s: Clear or leave empty. - 'notice-color' => sprintf( __( 'To use the current theme’s default text color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), + 'notice-color' => sprintf( __( 'To use the current theme’s default text color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), 'label-background' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND, __( 'Background color:', 'footnotes' ) ), 'background' => $this->add_color_selection( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND ), // Translators: %s: Clear or leave empty. - 'notice-background' => sprintf( __( 'To use the current theme’s default background color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), + 'notice-background' => sprintf( __( 'To use the current theme’s default background color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), 'label-border-width' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, __( 'Border width:', 'footnotes' ) ), 'border-width' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, 0, 4, true ), @@ -955,7 +1064,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-border-color' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR, __( 'Border color:', 'footnotes' ) ), 'border-color' => $this->add_color_selection( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR ), // Translators: %s: Clear or leave empty. - 'notice-border-color' => sprintf( __( 'To use the current theme’s default border color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), + 'notice-border-color' => sprintf( __( 'To use the current theme’s default border color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), 'label-border-radius' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, __( 'Rounded corner radius:', 'footnotes' ) ), 'border-radius' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, 0, 500 ), @@ -964,7 +1073,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { 'label-box-shadow-color' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR, __( 'Box shadow color:', 'footnotes' ) ), 'box-shadow-color' => $this->add_color_selection( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR ), // Translators: %s: Clear or leave empty. - 'notice-box-shadow-color' => sprintf( __( 'To use the current theme’s default box shadow color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), + 'notice-box-shadow-color' => sprintf( __( 'To use the current theme’s default box shadow color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), ) ); @@ -979,11 +1088,22 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { * * @since 1.5.0 * - * Edited heading for v2.0.4 + * - Update: **symbol for backlinks** removed; hyperlink moved to the reference number. * - * The former 'hyperlink arrow', incompatible with combined identical footnotes, - * became 'prepended arrow' in v2.0.3 after a user complaint about missing backlinking semantics - * of the footnote number. + * @since 2.0.0 + * The former 'hyperlink arrow' is incompatible with combined identical footnotes. + * + * - Update: Reference container: clarify backlink semantics by prepended transitional up arrow, thanks to @mmallett issue report. + * + * @since 2.0.3 + * + * - Update: Restore arrow settings to customize or disable the now prepended arrow symbol, thanks to @mmallett issue report. + * + * @since 2.0.4 + * @date 2020-11-02T2115+0100 + * + * @reporter @mmallett + * @link https://wordpress.org/support/topic/mouse-over-broken/#post-13593037 * * @since 2.1.4 moved to Settings > Reference container > Display a backlink symbol * @since 2.2.1 and 2.2.4 back here @@ -1034,7 +1154,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { // phpcs:disable Squiz.PHP.CommentedOutCode.Found // CSS classes are listed in the template. - // Localized notices are dropped to ease translators’ task. + // Localized notices are dropped to ease translators’ task. // "label-class-1" => ".footnote_plugin_tooltip_text",. // "class-1" => $this->add_text(__("superscript, Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),. @@ -1222,17 +1342,17 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { array( 'label-start' => __( 'Start your footnote with the following short code:', 'footnotes' ), 'start' => $l_arr_footnote_starting_tag['value'], - 'label-end' => __( '…and end your footnote with this short code:', 'footnotes' ), + 'label-end' => __( '…and end your footnote with this short code:', 'footnotes' ), 'end' => $l_arr_footnote_ending_tag['value'], 'example-code' => $l_str_example, 'example-string' => '
' . __( 'will be displayed as:', 'footnotes' ), 'example' => $g_obj_mci_footnotes->a_obj_task->exec( $l_str_example, true ), // Translators: 1: ; 2: . - 'information' => sprintf( __( 'For further information please check out our %1$ssupport forum%2$s on WordPress.org.', 'footnotes' ), '', '' ), + 'information' => sprintf( __( 'For further information please check out our %1$ssupport forum%2$s on WordPress.org.', 'footnotes' ), '', '' ), ) ); // Call wp_head function to get the Styling of the mouse-over box. - $g_obj_mci_footnotes->a_obj_task->wp_head(); + $g_obj_mci_footnotes->a_obj_task->footnotes_output_head(); // Display template with replaced placeholders. // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped echo $l_obj_template->get_content(); @@ -1259,3 +1379,4 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { // phpcs:enable } } + diff --git a/class/hooks.php b/class/hooks.php index f5c90d1..8e44a82 100644 --- a/class/hooks.php +++ b/class/hooks.php @@ -76,7 +76,7 @@ class MCI_Footnotes_Hooks { */ public static function plugin_links( $p_arr_links, $p_str_plugin_file_name ) { // Append link to the WordPress Plugin page. - $p_arr_links[] = sprintf( '%s', __( 'Support', 'footnotes' ) ); + $p_arr_links[] = sprintf( '%s', __( 'Support', 'footnotes' ) ); // Append link to the settings page. $p_arr_links[] = sprintf( '%s', admin_url( 'admin.php?page=mfmmf-footnotes' ), __( 'Settings', 'footnotes' ) ); // Append link to the PayPal donate function. diff --git a/class/init.php b/class/init.php index b90fd66..af20d85 100644 --- a/class/init.php +++ b/class/init.php @@ -38,29 +38,83 @@ class MCI_Footnotes { public $a_obj_task = null; /** - * Idenfifies whether tooltips are enabled. Actual value depends on settings. + * Allows to determine whether tooltips are enabled. + * The actual value of these properties is configurable. + * + * - Bugfix: Templates: optimize template load and processing based on settings, thanks to @misfist code contribution. + * + * @since 2.4.0 + * @date 2021-01-04T1355+0100 * * @contributor 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 * - * @todo Refactor to have defines and assignments only in this class, - * then re-use these properties also in class/task.php (and elsewhere). - * Account for priority level issues. These properties must be assigned before - * the hooks—whose priority level may be configured to 0—are called in class/task.php. + * Template process and script / stylesheet load optimization. + * Streamline process depending on tooltip enabled status. + * Load tooltip inline script only if jQuery tooltips are enabled. */ public static $a_bool_tooltips_enabled = false; /** - * Idenfifies whether alternative tooltips are enabled. Actual value depends - * on settings. + * Allows to determine whether alternative tooltips are enabled. * + * - 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 + * + * @since 2.4.0 * @contributor Patrizia Lutz @misfist * @var bool - * - * @todo Refactor to have defines only here, and use assignments also in class/task.php. */ public static $a_bool_alternative_tooltips_enabled = false; + /** + * Allows to determine whether AMP compatibility mode is enabled. + * + * - Adding: Tooltips: make display work purely by style rules for AMP compatibility, thanks to @milindmore22 code contribution. + * - Bugfix: Tooltips: enable accessibility by keyboard navigation, thanks to @westonruter code contribution. + * - Adding: Reference container: get expanding and collapsing to work also in AMP compatibility mode, thanks to @westonruter code contribution. + * + * @since 2.5.11 (draft) + * @since 2.6.0 (release) + * + * @contributor @milindmore22 + * @link @link https://github.com/ampproject/amp-wp/issues/5913#issuecomment-785306933 + * + * @contributor @westonruter + * @link https://github.com/ampproject/amp-wp/issues/5913#issuecomment-785419655 + * @link https://github.com/markcheret/footnotes/issues/48#issuecomment-799580854 + * @link https://github.com/markcheret/footnotes/issues/48#issuecomment-799582394 + * + * @var bool + */ + public static $a_bool_amp_enabled = false; + + /** + * Allows to determine the script mode among jQuery or plain JS. + * + * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. + * + * @since 2.5.6 + * + * @reporter @hopper87it + * @link https://wordpress.org/support/topic/footnotes-wp-rocket/ + * + * @reporter @pkverma99 + * @link https://wordpress.org/support/topic/footnotes-wp-rocket/#post-14076188 + * + * @var str 'js' Plain JavaScript. + * 'jquery' Use jQuery libraries. + */ + public static $a_str_script_mode = 'js'; + /** * Executes the Plugin. * @@ -173,10 +227,11 @@ class MCI_Footnotes { * * The condition about tooltips was missing, only the not-alternative-tooltips part was present. */ - // Set conditions re-used for stylesheet enqueuing. + // Set conditions re-used for stylesheet enqueuing and in class/task.php. + self::$a_bool_amp_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_AMP_COMPATIBILITY_ENABLE ) ); self::$a_bool_tooltips_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ENABLED ) ); self::$a_bool_alternative_tooltips_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ) ); - $l_str_script_mode = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE ); + self::$a_str_script_mode = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE ); /** * Enqueues the jQuery library registered by WordPress. @@ -193,80 +248,83 @@ class MCI_Footnotes { * After adding the alternative reference container, jQuery has become optional, * but still enabled by default. */ - if ( 'jquery' === $l_str_script_mode || ( self::$a_bool_tooltips_enabled && ! self::$a_bool_alternative_tooltips_enabled ) ) { + if ( ! self::$a_bool_amp_enabled ) { - wp_enqueue_script( 'jquery' ); + if ( 'jquery' === self::$a_str_script_mode || ( self::$a_bool_tooltips_enabled && ! self::$a_bool_alternative_tooltips_enabled ) ) { - } + wp_enqueue_script( 'jquery' ); - if ( self::$a_bool_tooltips_enabled && ! self::$a_bool_alternative_tooltips_enabled ) { + } - /** - * Enqueues the jQuery Tools library shipped with the plugin. - * - * Redacted jQuery.browser, completed minification; - * see full header in js/jquery.tools.js. - * - * Add versioning. - * - * @since 2.1.2 - * @date 2020-11-18T2150+0100 - * - * No '-js' in the handle, is appended automatically. - * - * Deferring to the footer breaks jQuery tooltip display. - * @date 2021-02-23T1105+0100 - */ - wp_enqueue_script( - 'mci-footnotes-jquery-tools', - plugins_url( 'footnotes/js/jquery.tools.min.js' ), - array(), - '1.2.7.redacted.2', - false - ); + if ( self::$a_bool_tooltips_enabled && ! self::$a_bool_alternative_tooltips_enabled ) { - /** - * Enqueues some jQuery UI libraries registered by WordPress. - * - * - 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 - * - * @reporter @rajinderverma - * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/ - * - * @reporter @ericcorbett2 - * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13324142 - * - * @reporter @honlapdavid - * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13355421 - * - * @reporter @mmallett - * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13445437 - * - * Fetch jQuery UI from cdnjs.cloudflare.com. - * @since 2.0.0 - * @date 2020-10-26T1907+0100 - * @contributor @vonpiernik - * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13456762 - * - * jQueryUI re-enables the tooltip infobox disabled when WPv5.5 was released. * @since 2.1.2 - * - * - Update: Libraries: Load jQuery UI from WordPress, thanks to @check2020de issue report. - * - * @since 2.0.4 - * @date 2020-11-01T1902+0100 - * @reporter @check2020de - * @link https://wordpress.org/support/topic/gdpr-issue-with-jquery/ - * @link https://wordpress.stackexchange.com/questions/273986/correct-way-to-enqueue-jquery-ui - * - * 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 the jQuery Tools library shipped with the plugin. + * + * Redacted jQuery.browser, completed minification; + * see full header in js/jquery.tools.js. + * + * Add versioning. + * + * @since 2.1.2 + * @date 2020-11-18T2150+0100 + * + * No '-js' in the handle, is appended automatically. + * + * Deferring to the footer breaks jQuery tooltip display. + * @date 2021-02-23T1105+0100 + */ + wp_enqueue_script( + 'mci-footnotes-jquery-tools', + plugins_url( 'footnotes/js/jquery.tools.min.js' ), + array(), + '1.2.7.redacted.2', + false + ); + /** + * Enqueues some jQuery UI libraries registered by WordPress. + * + * - 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 + * + * @reporter @rajinderverma + * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/ + * + * @reporter @ericcorbett2 + * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13324142 + * + * @reporter @honlapdavid + * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13355421 + * + * @reporter @mmallett + * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13445437 + * + * Fetch jQuery UI from cdnjs.cloudflare.com. + * @since 2.0.0 + * @date 2020-10-26T1907+0100 + * @contributor @vonpiernik + * @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13456762 + * + * jQueryUI re-enables the tooltip infobox disabled when WPv5.5 was released. * @since 2.1.2 + * + * - Update: Libraries: Load jQuery UI from WordPress, thanks to @check2020de issue report. + * + * @since 2.0.4 + * @date 2020-11-01T1902+0100 + * @reporter @check2020de + * @link https://wordpress.org/support/topic/gdpr-issue-with-jquery/ + * @link https://wordpress.stackexchange.com/questions/273986/correct-way-to-enqueue-jquery-ui + * + * 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' ); + + } } /** @@ -281,7 +339,7 @@ class MCI_Footnotes { * 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 ) { + if ( C_BOOL_CSS_PRODUCTION_MODE ) { /** * Enqueues a minified united external stylesheet in production. @@ -305,21 +363,32 @@ class MCI_Footnotes { * @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_PACKAGE_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_tooltips_enabled ) { - if ( self::$a_bool_alternative_tooltips_enabled ) { - $l_str_tooltip_mode_short = 'al'; - $l_str_tooltip_mode_rest = 'ternative-tooltips'; + + if ( self::$a_bool_amp_enabled ) { + $l_str_tooltip_mode_short = 'ampt'; + $l_str_tooltip_mode_long = 'amp-tooltips'; + + } elseif ( self::$a_bool_alternative_tooltips_enabled ) { + $l_str_tooltip_mode_short = 'altt'; + $l_str_tooltip_mode_long = 'alternative-tooltips'; + } else { - $l_str_tooltip_mode_short = 'jq'; - $l_str_tooltip_mode_rest = 'uery-tooltips'; + $l_str_tooltip_mode_short = 'jqtt'; + $l_str_tooltip_mode_long = 'jquery-tooltips'; + } } else { - $l_str_tooltip_mode_short = 'no'; - $l_str_tooltip_mode_rest = '-tooltips'; + $l_str_tooltip_mode_short = 'nott'; + $l_str_tooltip_mode_long = 'no-tooltips'; } // Set basic responsive page layout mode for use in stylesheet name. @@ -342,9 +411,9 @@ class MCI_Footnotes { // Enqueue the tailored united minified stylesheet. wp_enqueue_style( - 'mci-footnotes-' . $l_str_tooltip_mode_short . $l_str_tooltip_mode_rest . '-pagelayout-' . $l_str_page_layout_option, + 'mci-footnotes-' . $l_str_tooltip_mode_long . '-pagelayout-' . $l_str_page_layout_option, plugins_url( - MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/footnotes-' . $l_str_tooltip_mode_short . 'ttbrpl' . $l_str_layout_mode . '.min.css' + MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/footnotes-' . $l_str_tooltip_mode_short . 'brpl' . $l_str_layout_mode . '.min.css' ), array(), filemtime( @@ -385,16 +454,32 @@ class MCI_Footnotes { ) . 'css/dev-tooltips.css' ) ); - wp_enqueue_style( - 'mci-footnotes-alternative', - plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips-alternative.css' ), - array(), - filemtime( - plugin_dir_path( - dirname( __FILE__ ) - ) . 'css/dev-tooltips-alternative.css' - ) - ); + + if ( self::$a_bool_amp_enabled ) { + wp_enqueue_style( + 'mci-footnotes-amp', + plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-amp-tooltips.css' ), + array(), + filemtime( + plugin_dir_path( + dirname( __FILE__ ) + ) . 'css/dev-amp-tooltips.css' + ) + ); + } + + if ( self::$a_bool_alternative_tooltips_enabled ) { + wp_enqueue_style( + 'mci-footnotes-alternative', + plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips-alternative.css' ), + array(), + filemtime( + plugin_dir_path( + dirname( __FILE__ ) + ) . 'css/dev-tooltips-alternative.css' + ) + ); + } $l_str_page_layout_option = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT ); if ( 'none' !== $l_str_page_layout_option ) { diff --git a/class/layout/abstract-engine.php b/class/layout/abstract-engine.php new file mode 100644 index 0000000..143ad96 --- /dev/null +++ b/class/layout/abstract-engine.php @@ -0,0 +1,587 @@ + MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_id, + 'title' => $p_str_title, + 'submit' => $p_bool_has_submit_button, + 'container' => $p_int_settings_container_index, + ); + } + + /** + * Returns an array describing a meta box. + * + * @since 1.5.0 + * @param string $p_str_section_id 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_callback_function_name Class method name for callback. + * @return array meta box description to be able to append a meta box to the output. + */ + protected function add_meta_box( $p_str_section_id, $p_str_id, $p_str_title, $p_str_callback_function_name ) { + return array( + 'parent' => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_section_id, + 'id' => $p_str_id, + 'title' => $p_str_title, + 'callback' => $p_str_callback_function_name, + ); + } + + /** + * Registers a sub page. + * + * @since 1.5.0 + */ + public function register_sub_page() { + global $submenu; + + if ( array_key_exists( plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG ), $submenu ) ) { + foreach ( $submenu[ plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG ) ] as $l_arr_sub_menu ) { + if ( plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug() ) === $l_arr_sub_menu[2] ) { + remove_submenu_page( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug() ); + } + } + } + + $this->a_str_sub_page_hook = add_submenu_page( + MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, + $this->get_sub_page_title(), + $this->get_sub_page_title(), + 'manage_options', + MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug(), + array( $this, 'display_content' ) + ); + } + + /** + * Registers all sections for a sub page. + * + * @since 1.5.0 + */ + public function register_sections() { + foreach ( $this->get_sections() 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'], + '', + array( $this, 'Description' ), + $l_arr_section['id'] + ); + $this->register_meta_boxes( $l_arr_section['id'] ); + } + } + + /** + * Registers all Meta boxes for a sub page. + * + * @since 1.5.0 + * @param string $p_str_parent_id Parent section unique id. + */ + private function register_meta_boxes( $p_str_parent_id ) { + // Iterate through each meta box. + foreach ( $this->get_meta_boxes() as $l_arr_meta_box ) { + if ( $p_str_parent_id !== $l_arr_meta_box['parent'] ) { + continue; + } + add_meta_box( + $p_str_parent_id . '-' . $l_arr_meta_box['id'], + $l_arr_meta_box['title'], + array( $this, $l_arr_meta_box['callback'] ), + $p_str_parent_id, + 'main' + ); + } + } + + /** + * Append javascript and css files for specific sub page. + * + * @since 1.5.0 + */ + private function append_scripts() { + wp_enqueue_script( 'postbox' ); + wp_enqueue_style( 'wp-color-picker' ); + 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 ( true === C_BOOL_CSS_PRODUCTION_MODE ) { + + wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.min.css' ), array(), C_STR_PACKAGE_VERSION ); + + } else { + + wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.css' ), array(), C_STR_PACKAGE_VERSION ); + + } + + wp_enqueue_style( 'mci-footnotes-admin' ); + } + + // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing + /** + * Displays the content of specific sub page. + * + * @since 1.5.0 + */ + public function display_content() { + $this->append_scripts(); + + // TODO: add nonce verification. + + // Get the current section. + reset( $this->a_arr_sections ); + $l_str_active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->a_arr_sections ); + $l_arr_active_section = $this->a_arr_sections[ $l_str_active_section_id ]; + + // Store settings. + $l_bool_settings_updated = false; + if ( array_key_exists( 'save-settings', $_POST ) ) { + if ( 'save' === $_POST['save-settings'] ) { + unset( $_POST['save-settings'] ); + unset( $_POST['submit'] ); + $l_bool_settings_updated = $this->save_settings(); + } + } + + // Display all sections and highlight the active section. + echo '
'; + echo '
'; + + if ( $l_bool_settings_updated ) { + echo sprintf( '
%s
', __( 'Settings saved', 'footnotes' ) ); + } + + // Form to submit the active section. + echo '
'; + echo ''; + // Outputs the settings field of the active section. + do_settings_sections( $l_arr_active_section['id'] ); + do_meta_boxes( $l_arr_active_section['id'], 'main', null ); + + // Add submit button to active section if defined. + if ( $l_arr_active_section['submit'] ) { + submit_button(); + } + echo '
'; + echo '
'; + + // Echo JavaScript for the expand/collapse function of the meta boxes. + echo ''; + } + // phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing + + // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing + /** + * Save all Plugin settings. + * + * @since 1.5.0 + * @return bool + */ + private function save_settings() { + $l_arr_new_settings = array(); + + // TODO: add nonce verification. + + // Get current section. + reset( $this->a_arr_sections ); + $l_str_active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->a_arr_sections ); + $l_arr_active_section = $this->a_arr_sections[ $l_str_active_section_id ]; + + foreach ( MCI_Footnotes_Settings::instance()->get_defaults( $l_arr_active_section['container'] ) as $l_str_key => $l_mixed_value ) { + if ( array_key_exists( $l_str_key, $_POST ) ) { + $l_arr_new_settings[ $l_str_key ] = wp_unslash( $_POST[ $l_str_key ] ); + } else { + // Setting is not defined in the POST array, define it to avoid the Default value. + $l_arr_new_settings[ $l_str_key ] = ''; + } + } + // Update settings. + return MCI_Footnotes_Settings::instance()->save_options( $l_arr_active_section['container'], $l_arr_new_settings ); + } + // phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing + + /** + * Output the Description of a section. May be overwritten in any section. + * + * @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]. + * + * @since 1.5.0 + * @param string $p_str_setting_key_name Settings Array key name. + * @return array Contains Settings ID, Settings Name and Settings Value. + * + * @since 2.5.11 Remove escapement function. + * When refactoring the codebase after 2.5.8, all and every output was escaped. + * After noticing that the plugin was broken, all escapement functions were removed. + * @link https://github.com/markcheret/footnotes/pull/50/commits/25c3f2f12eb5de1079e9215bf624ec4289b095a5 + * @link https://github.com/markcheret/footnotes/pull/50#issuecomment-787624123 + * In that process, this instance of esc_attr() was removed too, so the plugin was + * broken again. + * @link https://github.com/markcheret/footnotes/pull/50/commits/25c3f2f12eb5de1079e9215bf624ec4289b095a5#diff-a8ed6e859c32a18fc10bbbad3b4dd8ce7f43f2378d29471c7638e314ab30f1bdL349-L354 + * + * @since 2.5.15 To fix it, the data was escaped in add_select_box() instead. + * @since 2.6.1 Restore esc_attr() in load_setting(). + * @see add_select_box() + * This is the only instance of esc_|kses|sanitize in the pre-2.5.11 codebase. + * Removing this did not fix the quotation mark backslash escapement bug. + */ + protected function load_setting( $p_str_setting_key_name ) { + // Get current section. + reset( $this->a_arr_sections ); + $p_arr_return = array(); + $p_arr_return['id'] = sprintf( '%s', $p_str_setting_key_name ); + $p_arr_return['name'] = sprintf( '%s', $p_str_setting_key_name ); + $p_arr_return['value'] = esc_attr( MCI_Footnotes_Settings::instance()->get( $p_str_setting_key_name ) ); + return $p_arr_return; + } + + /** + * Returns a line break to start a new line. + * + * @since 1.5.0 + * @return string + */ + protected function add_newline() { + return '
'; + } + + /** + * Returns a line break to have a space between two lines. + * + * @since 1.5.0 + * @return string + */ + protected function add_line_space() { + return '

'; + } + + /** + * Returns a simple text inside html text. + * + * @since 1.5.0 + * @param string $p_str_text Message to be surrounded with simple html tag (span). + * @return string + */ + protected function add_text( $p_str_text ) { + return sprintf( '%s', $p_str_text ); + } + + /** + * Returns the html tag for an input/select label. + * + * @since 1.5.0 + * @param string $p_str_setting_name Name of the Settings key to connect the Label with the input/select field. + * @param string $p_str_caption Label caption. + * @return string + */ + protected function add_label( $p_str_setting_name, $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](https://softwareengineering.stackexchange.com/questions/234546/colons-in-internationalized-ui). + */ + return sprintf( '', $p_str_setting_name, $p_str_caption ); + } + + /** + * Returns the html tag for an input [type = text]. + * + * @since 1.5.0 + * @param string $p_str_setting_name Name of the Settings key to pre load the input field. + * @param int $p_str_max_length 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 add_text_box( $p_str_setting_name, $p_str_max_length = 999, $p_bool_readonly = false, $p_bool_hidden = false ) { + $l_str_style = ''; + // Collect data for given settings field. + $l_arr_data = $this->load_setting( $p_str_setting_name ); + if ( $p_bool_hidden ) { + $l_str_style .= 'display:none;'; + } + return sprintf( + '', + $l_arr_data['name'], + $l_arr_data['id'], + $p_str_max_length, + $l_str_style, + $l_arr_data['value'], + $p_bool_readonly ? 'readonly="readonly"' : '' + ); + } + + /** + * Returns the html tag for an input [type = checkbox]. + * + * @since 1.5.0 + * @param string $p_str_setting_name Name of the Settings key to pre load the input field. + * @return string + */ + protected function add_checkbox( $p_str_setting_name ) { + // Collect data for given settings field. + $l_arr_data = $this->load_setting( $p_str_setting_name ); + return sprintf( + '', + $l_arr_data['name'], + $l_arr_data['id'], + MCI_Footnotes_Convert::to_bool( $l_arr_data['value'] ) ? 'checked="checked"' : '' + ); + } + + /** + * Returns the html tag for a select box. + * + * @since 1.5.0 + * + * - Bugfix: Dashboard: Referrers and tooltips: Backlink symbol: debug select box by reverting identity check to equality check, thanks to @lolzim bug report. + * + * @reporter @lolzim + * + * @since 2.5.13 + * @param string $p_str_setting_name Name of the Settings key to pre select the current value. + * @param array $p_arr_options Possible options to be selected. + * @return string + * + * @since 2.5.15 Bugfix: Dashboard: General settings: Footnote start and end short codes: debug select box for shortcodes with pointy brackets. + * @since 2.6.1 Restore esc_attr() in load_setting(), remove htmlspecialchars() here. + */ + protected function add_select_box( $p_str_setting_name, $p_arr_options ) { + // Collect data for given settings field. + $l_arr_data = $this->load_setting( $p_str_setting_name ); + $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, + // Only check for equality, not identity, WRT backlink symbol arrows. + $l_str_value == $l_arr_data['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. + * + * @since 1.5.0 + * @param string $p_str_setting_name Name of the Settings key to pre fill the text area. + * @return string + */ + protected function add_textarea( $p_str_setting_name ) { + // Collect data for given settings field. + $l_arr_data = $this->load_setting( $p_str_setting_name ); + 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. + * + * @since 1.5.6 + * @param string $p_str_setting_name Name of the Settings key to pre load the input field. + * @return string + */ + protected function add_color_selection( $p_str_setting_name ) { + // Collect data for given settings field. + $l_arr_data = $this->load_setting( $p_str_setting_name ); + return sprintf( + '', + $l_arr_data['name'], + $l_arr_data['id'], + $l_arr_data['value'] + ); + } + + /** + * Returns the html tag for an input [type = num]. + * + * @since 1.5.0 + * @param string $p_str_setting_name 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 add_num_box( $p_str_setting_name, $p_in_min, $p_int_max, $p_bool_deci = false ) { + // Collect data for given settings field. + $l_arr_data = $this->load_setting( $p_str_setting_name ); + + 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 + ); + } + } + +} diff --git a/class/layout/diagnostics.php b/class/layout/diagnostics.php new file mode 100644 index 0000000..1a30015 --- /dev/null +++ b/class/layout/diagnostics.php @@ -0,0 +1,147 @@ +add_section( 'diagnostics', __( 'Diagnostics', 'footnotes' ), null, false ), + ); + } + + /** + * Returns an array of all registered meta boxes for each section of the sub page. + * + * @since 1.5.0 + * @return array + */ + protected function get_meta_boxes() { + return array( + $this->add_meta_box( 'diagnostics', 'diagnostics', __( 'Displays information about the web server, PHP and WordPress', 'footnotes' ), 'Diagnostics' ), + ); + } + + /** + * Displays a diagnostics about the web server, php and WordPress. + * + * @since 1.5.0 + */ + public function Diagnostics() { + global $wp_version; + $l_str_php_extensions = ''; + // Iterate through each PHP extension. + foreach ( get_loaded_extensions() as $l_int_index => $l_str_extension ) { + if ( $l_int_index > 0 ) { + $l_str_php_extensions .= ' | '; + } + $l_str_php_extensions .= $l_str_extension . ' ' . phpversion( $l_str_extension ); + } + + $l_obj_current_theme = wp_get_theme(); + + $l_str_wordpress_plugins = ''; + // Iterate through each installed WordPress Plugin. + foreach ( get_plugins() as $l_arr_plugin ) { + $l_str_wordpress_plugins .= ''; + $l_str_wordpress_plugins .= '' . $l_arr_plugin['Name'] . ''; + // phpcs:disable Generic.Strings.UnnecessaryStringConcat.Found + $l_str_wordpress_plugins .= '' . $l_arr_plugin['Version'] . ' [' . $l_arr_plugin['PluginURI'] . ']' . ''; + // phpcs:enable Generic.Strings.UnnecessaryStringConcat.Found + $l_str_wordpress_plugins .= ''; + } + // Load template file. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'diagnostics' ); + + if ( ! isset( $_SERVER['SERVER_NAME'] ) ) { + die; + } else { + $l_str_server_name = wp_unslash( $_SERVER['SERVER_NAME'] ); + } + if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) ) { + die; + } else { + $l_str_http_user_agent = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); + } + + // Replace all placeholders. + $l_obj_template->replace( + array( + 'label-server' => __( 'Server name', 'footnotes' ), + 'server' => $l_str_server_name, + + 'label-php' => __( 'PHP version', 'footnotes' ), + 'php' => phpversion(), + + 'label-user-agent' => __( 'User agent', 'footnotes' ), + 'user-agent' => $l_str_http_user_agent, + + 'label-max-execution-time' => __( 'Max execution time', 'footnotes' ), + 'max-execution-time' => ini_get( 'max_execution_time' ) . ' ' . __( 'seconds', 'footnotes' ), + + 'label-memory-limit' => __( 'Memory limit', 'footnotes' ), + 'memory-limit' => ini_get( 'memory_limit' ), + + 'label-php-extensions' => __( 'PHP extensions', 'footnotes' ), + 'php-extensions' => $l_str_php_extensions, + + 'label-wordpress' => __( 'WordPress version', 'footnotes' ), + 'wordpress' => $wp_version, + + 'label-theme' => __( 'Active Theme', 'footnotes' ), + 'theme' => $l_obj_current_theme->get( 'Name' ) . ' ' . $l_obj_current_theme->get( 'Version' ) . ', ' . $l_obj_current_theme->get( 'Author' ) . ' [' . $l_obj_current_theme->get( 'AuthorURI' ) . ']', + + 'plugins' => $l_str_wordpress_plugins, + ) + ); + // Display template with replaced placeholders. + echo $l_obj_template->get_content(); + } +} diff --git a/class/layout/init.php b/class/layout/init.php new file mode 100644 index 0000000..c3f505e --- /dev/null +++ b/class/layout/init.php @@ -0,0 +1,207 @@ +a_arr_sub_page_classes[ $l_obj_class->get_priority() ] = $l_obj_class; + } + } + ksort( $this->a_arr_sub_page_classes ); + + // Register hooks/actions. + add_action( 'admin_init', array( $this, 'initialize_settings' ) ); + add_action( 'admin_menu', array( $this, 'register_main_menu' ) ); + // Register AJAX callbacks for Plugin information. + add_action( 'wp_ajax_nopriv_footnotes_get_plugin_info', array( $this, 'get_plugin_meta_information' ) ); + add_action( 'wp_ajax_footnotes_get_plugin_info', array( $this, 'get_plugin_meta_information' ) ); + } + + /** + * Initializes all sub pages and registers the settings. + * + * @since 1.5.0 + */ + public function initialize_settings() { + MCI_Footnotes_Settings::instance()->register_settings(); + // Iterate though each sub class of the layout engine and register their sections. + foreach ( $this->a_arr_sub_page_classes as $l_obj_layout_engine_sub_class ) { + $l_obj_layout_engine_sub_class->register_sections(); + } + } + + /** + * Registers the new main menu for the WordPress dashboard. + * Registers all sub menu pages for the new main menu. + * + * @since 1.5.0 + * @see http://codex.wordpress.org/Function_Reference/add_menu_page + */ + public function register_main_menu() { + global $menu; + // Iterate through each main menu. + foreach ( $menu as $l_arr_main_menu ) { + // 3terate through each main menu attribute. + foreach ( $l_arr_main_menu as $l_str_attribute ) { + // Main menu already added, append sub pages and stop. + if ( self::C_STR_MAIN_MENU_SLUG === $l_str_attribute ) { + $this->register_sub_pages(); + 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, 'display_other_plugins' ), // Function. + plugins_url( 'footnotes/img/main-menu.png' ), // Icon URL. + null // Position. + ); + $this->register_sub_pages(); + } + + /** + * Registers all SubPages for this Plugin. + * + * @since 1.5.0 + */ + private function register_sub_pages() { + // 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. + foreach ( $this->a_arr_sub_page_classes as $l_obj_layout_engine_sub_class ) { + $l_obj_layout_engine_sub_class->register_sub_page(); + } + } + + /** + * Displays other Plugins from the developers. + * + * @since 1.5.0 + */ + public function display_other_plugins() { + printf( '

' ); + // Load template file. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'manfisher' ); + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped + + printf( 'visit Mark Cheret' ); + printf( '

' ); + + printf( '' ); + } + + // phpcs:disable WordPress.Security.NonceVerification.Missing + /** + * AJAX call. returns a JSON string containing meta information about a specific WordPress Plugin. + * + * @since 1.5.0 + */ + public function get_plugin_meta_information() { + // TODO: add nonce verification. + + // Get plugin internal name from POST data. + if ( isset( $_POST['plugin'] ) ) { + $l_str_plugin_name = wp_unslash( $_POST['plugin'] ); + } + + if ( empty( $l_str_plugin_name ) ) { + echo wp_json_encode( array( 'error' => 'Plugin name invalid.' ) ); + exit; + } + $l_str_url = 'https://api.wordpress.org/plugins/info/1.0/' . $l_str_plugin_name . '.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 wp_json_encode( array( 'error' => 'Error receiving Plugin Information from WordPress.' ) ); + exit; + } + if ( ! array_key_exists( 'body', $l_arr_response ) ) { + echo wp_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 wp_json_encode( array( 'error' => 'Error reading Plugin meta information.
URL: ' . $l_str_url . '
Response: ' . $l_str_response ) ); + exit; + } + + $l_int_num_ratings = 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 wp_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', 'footnotes' ) . ' ' . $l_int_num_ratings . ' ' . __( 'ratings', 'footnotes' ), + '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_num_ratings, + '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; + } + // phpcs:enable WordPress.Security.NonceVerification.Missing +} diff --git a/class/layout/settings.php b/class/layout/settings.php new file mode 100644 index 0000000..5fb3a89 --- /dev/null +++ b/class/layout/settings.php @@ -0,0 +1,1380 @@ +add_section( 'settings', __( 'General settings', 'footnotes' ), 0, true ); + + // Sync tab name with mirror in public function custom_css_migration(). + $l_arr_tabs[] = $this->add_section( 'customize', __( 'Referrers and tooltips', 'footnotes' ), 1, true ); + + $l_arr_tabs[] = $this->add_section( 'expert', __( 'Scope and priority', 'footnotes' ), 2, true ); + $l_arr_tabs[] = $this->add_section( 'customcss', __( 'Custom CSS', 'footnotes' ), 3, true ); + $l_arr_tabs[] = $this->add_section( 'how-to', __( 'Quick start guide', 'footnotes' ), null, false ); + + return $l_arr_tabs; + } + + /** + * Returns an array of all registered meta boxes for each section of the sub page. + * + * @since 1.5.0 + * @return array + * + * Edited for 2.0.0 and later. + * + * hyperlink_arrow 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 get_meta_boxes() { + $l_arr_meta_boxes = array(); + + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'amp-compat', __( 'AMP compatibility', 'footnotes' ), 'amp_compat' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'start-end', __( 'Footnote start and end short codes', 'footnotes' ), 'start_end' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'numbering', __( 'Footnotes numbering', 'footnotes' ), 'numbering' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'scrolling', __( 'Scrolling behavior', 'footnotes' ), 'scrolling' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'hard-links', __( 'URL fragment ID configuration', 'footnotes' ), 'hard_links' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'reference-container', __( 'Reference container', 'footnotes' ), 'reference_container' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'excerpts', __( 'Footnotes in excerpts', 'footnotes' ), 'excerpts' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'love', MCI_Footnotes_Config::C_STR_PLUGIN_HEADING_NAME . ' ' . MCI_Footnotes_Config::C_STR_LOVE_SYMBOL_HEADING, 'love' ); + + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'hyperlink-arrow', __( 'Backlink symbol', 'footnotes' ), 'hyperlink_arrow' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'superscript', __( 'Referrers', 'footnotes' ), 'superscript' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'label-solution', __( 'Referrers in labels', 'footnotes' ), 'label_solution' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box', __( 'Tooltips', 'footnotes' ), 'mouseover_box' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-position', __( 'Tooltip position', 'footnotes' ), 'mouseover_box_position' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-dimensions', __( 'Tooltip dimensions', 'footnotes' ), 'mouseover_box_dimensions' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-timing', __( 'Tooltip timing', 'footnotes' ), 'mouseover_box_timing' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-truncation', __( 'Tooltip truncation', 'footnotes' ), 'mouseover_box_truncation' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-text', __( 'Tooltip text', 'footnotes' ), 'mouseover_box_text' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-appearance', __( 'Tooltip appearance', 'footnotes' ), 'mouseover_box_appearance' ); + if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_CUSTOM_CSS_LEGACY_ENABLE ) ) ) { + $l_arr_meta_boxes[] = $this->add_meta_box( 'customize', 'custom-css', __( 'Your existing Custom CSS code', 'footnotes' ), 'custom_css' ); + } + + $l_arr_meta_boxes[] = $this->add_meta_box( 'expert', 'lookup', __( 'WordPress hooks with priority level', 'footnotes' ), 'lookup_hooks' ); + + if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_CUSTOM_CSS_LEGACY_ENABLE ) ) ) { + $l_arr_meta_boxes[] = $this->add_meta_box( 'customcss', 'custom-css-migration', __( 'Your existing Custom CSS code', 'footnotes' ), 'custom_css_migration' ); + } + $l_arr_meta_boxes[] = $this->add_meta_box( 'customcss', 'custom-css-new', __( 'Custom CSS', 'footnotes' ), 'custom_css_new' ); + + $l_arr_meta_boxes[] = $this->add_meta_box( 'how-to', 'help', __( 'Brief introduction in how to use the plugin', 'footnotes' ), 'help' ); + $l_arr_meta_boxes[] = $this->add_meta_box( 'how-to', 'donate', __( 'Help us to improve our Plugin', 'footnotes' ), 'donate' ); + + return $l_arr_meta_boxes; + } + + /** + * Displays the AMP compatibility mode option. + * + * @since 2.5.11 (draft) + * @since 2.6.0 (release) + */ + public function amp_compat() { + + // Load template file. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'settings-amp' ); + // Replace all placeholders. + $l_obj_template->replace( + array( + // Translators: '%s' is the link text 'AMP-WP' linked to the plugin’s front page on WordPress.org. + 'description-1-amp' => sprintf( __( 'The official %s plugin is required when this option is enabled.', 'footnotes' ), 'AMP-WP' ), + 'label-amp' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_AMP_COMPATIBILITY_ENABLE, __( 'Enable AMP compatibility mode:', 'footnotes' ) ), + 'amp' => $this->add_checkbox( MCI_Footnotes_Settings::C_STR_FOOTNOTES_AMP_COMPATIBILITY_ENABLE ), + 'notice-amp' => __( 'This option enables hard links with configurable scroll offset in % viewport height.', 'footnotes' ), + // Translators: '%s' is the logogram of the 'Footnotes' plugin. + 'description-2-amp' => sprintf( __( '%s is becoming AMP compatible when this box is checked. Styled tooltips are displayed with fade-in/fade-out effect if enabled, and the reference container expands also on clicking a referrer if it’s collapsed by default.', 'footnotes' ), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . '' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all settings for the reference container. + * + * @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 reference_container() { + + // Options for the label element. + $l_arr_label_element = array( + 'p' => __( 'paragraph', 'footnotes' ), + 'h2' => __( 'heading 2', 'footnotes' ), + 'h3' => __( 'heading 3', 'footnotes' ), + 'h4' => __( 'heading 4', 'footnotes' ), + 'h5' => __( 'heading 5', 'footnotes' ), + 'h6' => __( 'heading 6', 'footnotes' ), + ); + // Options for the positioning of the reference container. + $l_arr_positions = array( + 'post_end' => __( 'at the end of the post', 'footnotes' ), + 'widget' => __( 'in the widget area', 'footnotes' ), + 'footer' => __( 'in the footer', 'footnotes' ), + ); + // Basic responsive page layout options. + $l_arr_page_layout_options = array( + 'none' => __( 'No', 'footnotes' ), + 'reference-container' => __( 'to the reference container exclusively', 'footnotes' ), + 'entry-content' => __( 'to the div element starting below the post title', 'footnotes' ), + 'main-content' => __( 'to the main element including the post title', 'footnotes' ), + ); + // Options for the separating punctuation between backlinks. + $l_arr_separators = array( + // Unicode character names are conventionally uppercase. + 'comma' => __( 'COMMA', 'footnotes' ), + 'semicolon' => __( 'SEMICOLON', 'footnotes' ), + 'en_dash' => __( 'EN DASH', 'footnotes' ), + ); + // 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', 'footnotes' ), + // Unicode 1.0 name of RIGHT PARENTHESIS (represented as a left parenthesis in right-to-left scripts). + 'parenthesis' => __( 'CLOSING PARENTHESIS', 'footnotes' ), + 'colon' => __( 'COLON', 'footnotes' ), + ); + // Options for the first column width (per cent is a ratio, not a unit). + $l_arr_width_units = array( + '%' => __( 'per cent', 'footnotes' ), + 'px' => __( 'pixels', 'footnotes' ), + 'rem' => __( 'root em', 'footnotes' ), + 'em' => __( 'em', 'footnotes' ), + 'vw' => __( 'viewport width', 'footnotes' ), + ); + // Options for reference container script mode. + $l_arr_script_mode = array( + 'jquery' => __( 'jQuery', 'footnotes' ), + 'js' => __( 'plain JavaScript', 'footnotes' ), + ); + // Options for Yes/No select box. + $l_arr_enabled = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // 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->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME, __( 'Heading:', 'footnotes' ) ), + 'name' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME ), + + 'label-element' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, __( 'Heading’s HTML element:', 'footnotes' ) ), + 'element' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT, $l_arr_label_element ), + + 'label-border' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER, __( 'Border under the heading:', 'footnotes' ) ), + 'border' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER, $l_arr_enabled ), + + 'label-collapse' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_COLLAPSE, __( 'Collapse by default:', 'footnotes' ) ), + 'collapse' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_COLLAPSE, $l_arr_enabled ), + + 'label-script' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE, __( 'Script mode:', 'footnotes' ) ), + 'script' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE, $l_arr_script_mode ), + 'notice-script' => __( 'The plain JavaScript mode will enable hard links with configurable scroll offset.', 'footnotes' ), + + 'label-position' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __( 'Default position:', 'footnotes' ) ), + 'position' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_positions ), + // Translators: %s: at the end of the post. + 'notice-position' => sprintf( __( 'To use the position shortcode, please set the position to: %s', 'footnotes' ), '' . __( 'at the end of the post', 'footnotes' ) . '' ), + + 'label-shortcode' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE, __( 'Position shortcode:', 'footnotes' ) ), + 'shortcode' => $this->add_text_box( 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.', 'footnotes' ), + + 'label-startpage' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_START_PAGE_ENABLE, __( 'Display on start page too:', 'footnotes' ) ), + 'startpage' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_START_PAGE_ENABLE, $l_arr_enabled ), + + 'label-margin-top' => $this->add_label( MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_TOP_MARGIN, __( 'Top margin:', 'footnotes' ) ), + 'margin-top' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_TOP_MARGIN, -500, 500 ), + 'notice-margin-top' => __( 'pixels; may be negative', 'footnotes' ), + + 'label-margin-bottom' => $this->add_label( MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN, __( 'Bottom margin:', 'footnotes' ) ), + 'margin-bottom' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN, -500, 500 ), + 'notice-margin-bottom' => __( 'pixels; may be negative', 'footnotes' ), + + 'label-page-layout' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT, __( 'Apply basic responsive page layout:', 'footnotes' ) ), + 'page-layout' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT, $l_arr_page_layout_options ), + 'notice-page-layout' => __( 'Most themes don’t need this fix.', 'footnotes' ), + + 'label-url-wrap' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTE_URL_WRAP_ENABLED, __( 'Allow URLs to line-wrap anywhere:', 'footnotes' ) ), + 'url-wrap' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTE_URL_WRAP_ENABLED, $l_arr_enabled ), + 'notice-url-wrap' => __( 'Unicode-conformant browsers don’t need this fix.', 'footnotes' ), + + 'label-symbol' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, __( 'Display a backlink symbol:', 'footnotes' ) ), + 'symbol-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, $l_arr_enabled ), + 'notice-symbol' => __( 'Please choose or input the symbol at the top of the next dashboard tab.', 'footnotes' ), + + 'label-switch' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH, __( 'Symbol appended, not prepended:', 'footnotes' ) ), + 'switch' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH, $l_arr_enabled ), + + 'label-3column' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, __( 'Backlink symbol in an extra column:', 'footnotes' ) ), + '3column' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, $l_arr_enabled ), + 'notice-3column' => __( 'This legacy layout is available if identical footnotes are not combined.', 'footnotes' ), + + 'label-row-borders' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE, __( 'Borders around the table rows:', 'footnotes' ) ), + 'row-borders' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE, $l_arr_enabled ), + + 'label-separator' => $this->add_label( MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_ENABLED, __( 'Add a separator when enumerating backlinks:', 'footnotes' ) ), + 'separator-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_ENABLED, $l_arr_enabled ), + 'separator-options' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_OPTION, $l_arr_separators ), + 'separator-custom' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_SEPARATOR_CUSTOM ), + 'notice-separator' => __( 'Your input overrides the selection.', 'footnotes' ), + + 'label-terminator' => $this->add_label( MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_ENABLED, __( 'Add a terminal punctuation to backlinks:', 'footnotes' ) ), + 'terminator-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_ENABLED, $l_arr_enabled ), + 'terminator-options' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_OPTION, $l_arr_terminators ), + 'terminator-custom' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_TERMINATOR_CUSTOM ), + 'notice-terminator' => __( 'Your input overrides the selection.', 'footnotes' ), + + 'label-width' => $this->add_label( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_ENABLED, __( 'Set backlinks column width:', 'footnotes' ) ), + 'width-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_ENABLED, $l_arr_enabled ), + 'width-scalar' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR, 0, 500, true ), + 'width-unit' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_WIDTH_UNIT, $l_arr_width_units ), + 'notice-width' => __( 'Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.', 'footnotes' ), + + 'label-max-width' => $this->add_label( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, __( 'Set backlinks column maximum width:', 'footnotes' ) ), + 'max-width-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, $l_arr_enabled ), + 'max-width-scalar' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR, 0, 500, true ), + 'max-width-unit' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT, $l_arr_width_units ), + 'notice-max-width' => __( 'Absolute width in pixels doesn’t need to be accurate to the tenth, but relative width in rem or em may.', 'footnotes' ), + + 'label-line-break' => $this->add_label( MCI_Footnotes_Settings::C_STR_BACKLINKS_LINE_BREAKS_ENABLED, __( 'Stack backlinks when enumerating:', 'footnotes' ) ), + 'line-break' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_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.', 'footnotes' ), + + 'label-link' => $this->add_label( MCI_Footnotes_Settings::C_STR_LINK_ELEMENT_ENABLED, __( 'Use the link element for referrers and backlinks:', 'footnotes' ) ), + 'link' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_LINK_ELEMENT_ENABLED, $l_arr_enabled ), + 'notice-link' => __( 'The link element is needed to apply the theme’s link color.', 'footnotes' ), + '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.', 'footnotes' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all options for the footnotes start and end tag short codes. + * + * @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 start_end() { + // Footnotes start tag short code options. + $l_arr_shortcode_start = 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', 'footnotes' ), + ); + // Footnotes end tag short code options. + $l_arr_shortcode_end = 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', 'footnotes' ), + ); + // Options for the syntax validation. + $l_arr_enable = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // 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( + // Translators: The 2 placeholders are the <ref></ref> and <fn></fn> shortcodes. + 'description-escapement' => sprintf( __( 'The problems with shortcodes with pointy brackets have been solved. We apologize for the longlasting bugs making the %1$s and %2$s shortcodes close to unusable.', 'footnotes' ), '<ref></ref>', '<fn></fn>' ), + + 'label-short-code-start' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, __( 'Footnote start tag short code:', 'footnotes' ) ), + 'short-code-start' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, $l_arr_shortcode_start ), + 'short-code-start-user' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED ), + + 'label-short-code-end' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, __( 'Footnote end tag short code:', 'footnotes' ) ), + 'short-code-end' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, $l_arr_shortcode_end ), + 'short-code-end-user' => $this->add_text_box( 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.', 'footnotes' ), + + // Option to enable syntax validation, label mirrored in task.php. + 'label-syntax' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, __( 'Check for balanced shortcodes:', 'footnotes' ) ), + 'syntax' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_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.', 'footnotes' ), + + '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.', 'footnotes' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all options for the footnotes numbering. + * + * @since 2.2.0 + */ + 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', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + // Options for the numbering style of the footnotes. + $l_arr_counter_style = array( + 'arabic_plain' => __( 'plain Arabic numbers', 'footnotes' ) . $l_str_space . '1, 2, 3, 4, 5, …', + 'arabic_leading' => __( 'zero-padded Arabic numbers', 'footnotes' ) . $l_str_space . '01, 02, 03, 04, 05, …', + 'latin_low' => __( 'lowercase Latin letters', 'footnotes' ) . $l_str_space . 'a, b, c, d, e, …', + 'latin_high' => __( 'uppercase Latin letters', 'footnotes' ) . $l_str_space . 'A, B, C, D, E, …', + 'romanic' => __( 'uppercase Roman numerals', 'footnotes' ) . $l_str_space . 'I, II, III, IV, V, …', + 'roman_low' => __( 'lowercase Roman numerals', 'footnotes' ) . $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->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, __( 'Numbering style:', 'footnotes' ) ), + 'counter-style' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, $l_arr_counter_style ), + + // Algorithmically combine identicals. + 'label-identical' => $this->add_label( MCI_Footnotes_Settings::C_STR_COMBINE_IDENTICAL_FOOTNOTES, __( 'Combine identical footnotes:', 'footnotes' ) ), + 'identical' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_COMBINE_IDENTICAL_FOOTNOTES, $l_arr_enable ), + 'notice-identical' => __( 'This option may require copy-pasting footnotes in multiple instances.', 'footnotes' ), + // 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.', 'footnotes' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all options for the scrolling behavior. + * + * @since 2.2.0 + */ + public function scrolling() { + + // Options for enabling scroll duration asymmetricity. + $l_arr_enable = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // 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-css' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_CSS_SMOOTH_SCROLLING, __( 'CSS-based smooth scrolling:', 'footnotes' ) ), + 'scroll-css' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_CSS_SMOOTH_SCROLLING, $l_arr_enable ), + 'notice-scroll-css' => __( 'May slightly disturb jQuery scrolling and is therefore disabled by default. Works in recent browsers.', 'footnotes' ), + + 'label-scroll-offset' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET, __( 'Scroll offset:', 'footnotes' ) ), + 'scroll-offset' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET, 0, 100 ), + 'notice-scroll-offset' => __( 'per cent viewport height from the upper edge', 'footnotes' ), + + 'label-scroll-duration' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION, __( 'Scroll duration:', 'footnotes' ) ), + 'scroll-duration' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DURATION, 0, 20000 ), + 'notice-scroll-duration' => __( 'milliseconds. If asymmetric scroll durations are enabled, this is the scroll-up duration.', 'footnotes' ), + + // Enable scroll duration asymmetricity. + 'label-scroll-asymmetricity' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, __( 'Enable asymmetric scroll durations:', 'footnotes' ) ), + 'scroll-asymmetricity' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, $l_arr_enable ), + 'notice-scroll-asymmetricity' => __( 'With this option enabled, scrolling up may take longer than down, or conversely.', 'footnotes' ), + + 'label-scroll-down-duration' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DOWN_DURATION, __( 'Scroll-down duration:', 'footnotes' ) ), + 'scroll-down-duration' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DOWN_DURATION, 0, 20000 ), + 'notice-scroll-down-duration' => __( 'milliseconds', 'footnotes' ), + + 'label-scroll-down-delay' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DOWN_DELAY, __( 'Scroll-down delay:', 'footnotes' ) ), + 'scroll-down-delay' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_DOWN_DELAY, 0, 20000 ), + 'notice-scroll-down-delay' => __( 'milliseconds. Useful to see the effect on input elements when referrers without hard links are clicked in form labels.', 'footnotes' ), + + 'label-scroll-up-delay' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_UP_DELAY, __( 'Scroll-up delay:', 'footnotes' ) ), + 'scroll-up-delay' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_UP_DELAY, 0, 20000 ), + 'notice-scroll-up-delay' => __( 'milliseconds. Less useful than the scroll-down delay.', 'footnotes' ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all options for the fragment identifier configuration. + * + * @since 2.2.0 in scrolling(). + * @since 2.5.12 separate metabox. + */ + public function hard_links() { + + // Options for enabling hard links for AMP compat. + $l_arr_enable = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // Load template file. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'settings-hard-links' ); + // Replace all placeholders. + $l_obj_template->replace( + array( + + 'label-hard-links' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_HARD_LINKS_ENABLE, __( 'Enable hard links:', 'footnotes' ) ), + 'hard-links' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_HARD_LINKS_ENABLE, $l_arr_enable ), + 'notice-hard-links' => __( 'Hard links disable jQuery delays but have the same scroll offset, and allow to share footnotes (accessed if the list is not collapsed by default).', 'footnotes' ), + + 'label-footnote' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTE_FRAGMENT_ID_SLUG, __( 'Fragment identifier slug for footnotes:', 'footnotes' ) ), + 'footnote' => $this->add_text_box( 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.', 'footnotes' ), + + 'label-referrer' => $this->add_label( MCI_Footnotes_Settings::C_STR_REFERRER_FRAGMENT_ID_SLUG, __( 'Fragment identifier slug for footnote referrers:', 'footnotes' ) ), + 'referrer' => $this->add_text_box( 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.', 'footnotes' ), + + 'label-separator' => $this->add_label( MCI_Footnotes_Settings::C_STR_HARD_LINK_IDS_SEPARATOR, __( 'ID separator:', 'footnotes' ) ), + 'separator' => $this->add_text_box( 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.', 'footnotes' ), + + // Enable backlink tooltips. + 'label-backlink-tooltips' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, __( 'Enable backlink tooltips:', 'footnotes' ) ), + 'backlink-tooltips' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, $l_arr_enable ), + 'notice-backlink-tooltips' => __( 'Hard backlinks get ordinary tooltips hinting to use the backbutton instead.', 'footnotes' ), + + 'label-backlink-tooltip-text' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT, __( 'Backlink tooltip text:', 'footnotes' ) ), + 'backlink-tooltip-text' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT ), + 'notice-backlink-tooltip-text' => __( 'Default text is the keyboard shortcut; may be a localized descriptive hint.', 'footnotes' ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all settings for 'I love Footnotes'. + * + * @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 ), + // Translators: 2: heart symbol 1: footnotes logogram. + 'text-1' => sprintf( __( 'I %2$s %1$s', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL ), + // Translators: %s: Footnotes plugin logo. + 'text-6' => sprintf( __( 'This website uses %s.', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ), + // Translators: %s: Footnotes plugin logo. + 'text-7' => sprintf( __( 'This website uses the %s plugin.', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ), + // Translators: %s: Footnotes plugin logo. + 'text-2' => sprintf( __( 'This website uses the awesome %s plugin.', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ), + 'random' => __( 'randomly determined display of either mention', 'footnotes' ), + // Translators: 1: Plugin logo.2: heart symbol. + 'no' => sprintf( __( 'no display of any “%1$s %2$s” mention in the footer', 'footnotes' ), 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( + // Translators: %s: Footnotes plugin logo. + 'label-love' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, sprintf( __( 'Tell the world you’re using %s:', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ) ), + 'love' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, $l_arr_love ), + // Translators: %s: Footnotes plugin logo. + 'label-no-love' => $this->add_text( sprintf( __( 'Shortcode to inhibit the display of the %s mention on specific pages:', 'footnotes' ), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME ) ), + 'no-love' => $this->add_text( MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays the excerpt setting. + * + * @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', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // 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->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_IN_EXCERPT, __( 'Display footnotes in excerpts:', 'footnotes' ) ), + 'excerpts' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_IN_EXCERPT, $l_arr_enabled ), + 'notice-excerpts' => __( 'For this setting to be effective, the hook the_excerpt must be enabled under Scope and priority.', 'footnotes' ), + // Translators: %s: link text 'Advanced Excerpt' linked to the plugin’s WordPress.org front page. + // Translators: %s: Footnotes plugin logo. + 'description-excerpts' => sprintf( __( 'Both to display footnotes and to not display footnotes in excerpts, the %s plugin generates excerpts on the basis of the posts to ensure that footnotes are handled and don’t impact the excerpt length.', 'footnotes' ), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . '' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all settings for the footnote referrers. + * + * @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', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + // Options for superscript normalize scope. + $l_arr_normalize_superscript = array( + 'no' => __( 'No', 'footnotes' ), + 'referrers' => __( 'Footnote referrers', 'footnotes' ), + 'all' => __( 'All superscript elements', 'footnotes' ), + ); + // 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->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, __( 'Display footnote referrers in superscript:', 'footnotes' ) ), + 'superscript' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, $l_arr_enabled ), + + 'label-normalize' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, __( 'Normalize vertical alignment and font size:', 'footnotes' ) ), + 'normalize' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, $l_arr_normalize_superscript ), + 'notice-normalize' => __( 'Most themes don’t need this fix.', 'footnotes' ), + + 'label-before' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE, __( 'At the start of the footnote referrers:', 'footnotes' ) ), + 'before' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE ), + + 'label-after' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER, __( 'At the end of the footnote referrers:', 'footnotes' ) ), + 'after' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER ), + + 'label-link' => $this->add_label( MCI_Footnotes_Settings::C_STR_LINK_ELEMENT_ENABLED, __( 'Use the link element for referrers and backlinks:', 'footnotes' ) ), + '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.', 'footnotes' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays the setting for the input label issue solution. + * + * @since 2.5.12 + */ + public function label_solution() { + // Options for the input label issue solution. + $l_arr_issue_solutions = array( + 'none' => __( '0. No problem or solved otherwise', 'footnotes' ), + 'move' => __( 'A. Footnotes are moved out and appended after the label’s end (recommended)', 'footnotes' ), + 'disconnect' => __( 'B. Labels with footnotes are disconnected from input element (discouraged)', 'footnotes' ), + ); + // Load template file. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'configure-label-solution' ); + // Replace all placeholders. + $l_obj_template->replace( + array( + 'description-1-selection' => __( 'Clicking a footnote referrer in an input element label toggles the input except when hard links are enabled. In jQuery mode, the recommended solution is to move footnotes and append them after the label (option A).', 'footnotes' ), + 'label-selection' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LABEL_ISSUE_SOLUTION, __( 'Solve input label issue:', 'footnotes' ) ), + 'selection' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_LABEL_ISSUE_SOLUTION, $l_arr_issue_solutions ), + 'description-2-selection' => __( 'Option B is discouraged because disconnecting a label from its input element may compromise accessibility. This option is a last resort in case footnotes must absolutely stay inside the label. (Using jQuery ‘event.stopPropagation’ failed.)', 'footnotes' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays enabled status for the footnotes mouse-over box. + * + * @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 mouseover_box() { + // Options for Yes/No select box. + $l_arr_enabled = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // 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->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __( 'Display tooltips:', 'footnotes' ) ), + 'enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $l_arr_enabled ), + 'notice-enable' => __( 'Formatted text boxes allowing hyperlinks, displayed on mouse-over or tap and hold.', 'footnotes' ), + + 'label-alternative' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, __( 'Display alternative tooltips:', 'footnotes' ) ), + 'alternative' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, $l_arr_enabled ), + 'notice-alternative' => __( 'Intended to work around a configuration-related tooltip outage.', 'footnotes' ), + // Translators: %s: Footnotes plugin logo. + '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.', 'footnotes' ), '' . MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . '' ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays position settings for the footnotes mouse-over box. + * + * @since 2.2.0 + */ + public function mouseover_box_position() { + + // Options for the Mouse-over box position. + $l_arr_position = array( + 'top left' => __( 'top left', 'footnotes' ), + 'top center' => __( 'top center', 'footnotes' ), + 'top right' => __( 'top right', 'footnotes' ), + 'center right' => __( 'center right', 'footnotes' ), + 'bottom right' => __( 'bottom right', 'footnotes' ), + 'bottom center' => __( 'bottom center', 'footnotes' ), + 'bottom left' => __( 'bottom left', 'footnotes' ), + 'center left' => __( 'center left', 'footnotes' ), + ); + // Options for the alternative Mouse-over box position. + $l_arr_alternative_position = array( + 'top left' => __( 'top left', 'footnotes' ), + 'top right' => __( 'top right', 'footnotes' ), + 'bottom right' => __( 'bottom right', 'footnotes' ), + 'bottom left' => __( 'bottom left', 'footnotes' ), + ); + + // 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->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION, __( 'Position:', 'footnotes' ) ), + 'position' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION, $l_arr_position ), + 'position-alternative' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION, $l_arr_alternative_position ), + 'notice-position' => __( 'The second column of settings boxes is for the alternative tooltips.', 'footnotes' ), + + 'label-offset-x' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, __( 'Horizontal offset:', 'footnotes' ) ), + 'offset-x' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, -500, 500 ), + 'offset-x-alternative' => $this->add_num_box( 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', 'footnotes' ), + + 'label-offset-y' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, __( 'Vertical offset:', 'footnotes' ) ), + 'offset-y' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, -500, 500 ), + 'offset-y-alternative' => $this->add_num_box( 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', 'footnotes' ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays dimensions setting for the footnotes mouse-over box. + * + * @since 2.2.0 + */ + public function mouseover_box_dimensions() { + + // 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->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, __( 'Maximum width:', 'footnotes' ) ), + 'max-width' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, 0, 1280 ), + 'width' => $this->add_num_box( 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.', 'footnotes' ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays timing settings for the footnotes mouse-over box. + * + * @since 2.2.0 + */ + public function mouseover_box_timing() { + + // 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->add_label( MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY, __( 'Fade-in delay:', 'footnotes' ) ), + 'fade-in-delay' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY, 0, 20000 ), + 'notice-fade-in-delay' => __( 'milliseconds', 'footnotes' ), + + 'label-fade-in-duration' => $this->add_label( MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION, __( 'Fade-in duration:', 'footnotes' ) ), + 'fade-in-duration' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION, 0, 20000 ), + 'notice-fade-in-duration' => __( 'milliseconds', 'footnotes' ), + + 'label-fade-out-delay' => $this->add_label( MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY, __( 'Fade-out delay:', 'footnotes' ) ), + 'fade-out-delay' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY, 0, 20000 ), + 'notice-fade-out-delay' => __( 'milliseconds', 'footnotes' ), + + 'label-fade-out-duration' => $this->add_label( MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION, __( 'Fade-out duration:', 'footnotes' ) ), + 'fade-out-duration' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION, 0, 20000 ), + 'notice-fade-out-duration' => __( 'milliseconds', 'footnotes' ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays truncation settings for the footnotes mouse-over box. + * + * @since 2.2.0 + */ + public function mouseover_box_truncation() { + // Options for Yes/No select box. + $l_arr_enabled = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // 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->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, __( 'Truncate the note in the tooltip:', 'footnotes' ) ), + 'truncation' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, $l_arr_enabled ), + + 'label-max-length' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, __( 'Maximum number of characters in the tooltip:', 'footnotes' ) ), + 'max-length' => $this->add_num_box( 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.', 'footnotes' ), + + 'label-readon' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL, __( '‘Read on’ button label:', 'footnotes' ) ), + 'readon' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays dedicated tooltip text settings for the footnotes mouse-over box. + * + * @since 2.2.0 + */ + public function mouseover_box_text() { + // Options for Yes/No select box. + $l_arr_enabled = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // 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.', 'footnotes' ), + + 'label-delimiter' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER, __( 'Delimiter for dedicated tooltip text:', 'footnotes' ) ), + 'delimiter' => $this->add_text_box( 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.', 'footnotes' ), + + 'label-mirror' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, __( 'Mirror the tooltip in the reference container:', 'footnotes' ) ), + 'mirror' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_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.', 'footnotes' ), + + 'label-separator' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR, __( 'Separator between tooltip text and footnote text:', 'footnotes' ) ), + 'separator' => $this->add_text_box( 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.', 'footnotes' ), + + '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.', 'footnotes' ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays style settings for the footnotes mouse-over box. + * + * @since 2.2.0 + */ + public function mouseover_box_appearance() { + // Options for Yes/No select box. + $l_arr_enabled = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + // Options for the font size unit. + $l_arr_font_size_units = array( + 'em' => __( 'em', 'footnotes' ), + 'rem' => __( 'rem', 'footnotes' ), + 'px' => __( 'pixels', 'footnotes' ), + 'pt' => __( 'points', 'footnotes' ), + 'pc' => __( 'picas', 'footnotes' ), + 'mm' => __( 'millimeters', 'footnotes' ), + '%' => __( 'per cent', 'footnotes' ), + ); + + // 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->add_label( MCI_Footnotes_Settings::C_STR_MOUSE_OVER_BOX_FONT_SIZE_ENABLED, __( 'Set font size:', 'footnotes' ) ), + 'font-size-enable' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_MOUSE_OVER_BOX_FONT_SIZE_ENABLED, $l_arr_enabled ), + 'font-size-scalar' => $this->add_num_box( MCI_Footnotes_Settings::C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR, 0, 50, true ), + 'font-size-unit' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT, $l_arr_font_size_units ), + 'notice-font-size' => __( 'By default, the font size is set to equal the surrounding text.', 'footnotes' ), + + 'label-color' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR, __( 'Text color:', 'footnotes' ) ), + 'color' => $this->add_color_selection( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR ), + // Translators: %s: Clear or leave empty. + 'notice-color' => sprintf( __( 'To use the current theme’s default text color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), + + 'label-background' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND, __( 'Background color:', 'footnotes' ) ), + 'background' => $this->add_color_selection( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND ), + // Translators: %s: Clear or leave empty. + 'notice-background' => sprintf( __( 'To use the current theme’s default background color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), + + 'label-border-width' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, __( 'Border width:', 'footnotes' ) ), + 'border-width' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, 0, 4, true ), + 'notice-border-width' => __( 'pixels; 0 for borderless', 'footnotes' ), + + 'label-border-color' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR, __( 'Border color:', 'footnotes' ) ), + 'border-color' => $this->add_color_selection( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR ), + // Translators: %s: Clear or leave empty. + 'notice-border-color' => sprintf( __( 'To use the current theme’s default border color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), + + 'label-border-radius' => $this->add_label( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, __( 'Rounded corner radius:', 'footnotes' ) ), + 'border-radius' => $this->add_num_box( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, 0, 500 ), + 'notice-border-radius' => __( 'pixels; 0 for sharp corners', 'footnotes' ), + + 'label-box-shadow-color' => $this->add_label( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR, __( 'Box shadow color:', 'footnotes' ) ), + 'box-shadow-color' => $this->add_color_selection( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR ), + // Translators: %s: Clear or leave empty. + 'notice-box-shadow-color' => sprintf( __( 'To use the current theme’s default box shadow color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all settings for the backlink symbol. + * + * @since 1.5.0 + * + * - Update: **symbol for backlinks** removed; hyperlink moved to the reference number. + * + * @since 2.0.0 + * The former 'hyperlink arrow' is incompatible with combined identical footnotes. + * + * - Update: Reference container: clarify backlink semantics by prepended transitional up arrow, thanks to @mmallett issue report. + * + * @since 2.0.3 + * + * - Update: Restore arrow settings to customize or disable the now prepended arrow symbol, thanks to @mmallett issue report. + * + * @since 2.0.4 + * @date 2020-11-02T2115+0100 + * + * @reporter @mmallett + * @link https://wordpress.org/support/topic/mouse-over-broken/#post-13593037 + * + * @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 hyperlink_arrow() { + // 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->add_label( MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, __( 'Select or input the backlink symbol:', 'footnotes' ) ), + 'symbol-options' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, MCI_Footnotes_Convert::get_arrow() ), + 'symbol-custom' => $this->add_text_box( MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED ), + 'notice-symbol' => __( 'Your input overrides the selection.', 'footnotes' ), + '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.', 'footnotes' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays the Custom CSS box. + * + * @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 custom_css() { + // 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->add_label( MCI_Footnotes_Settings::C_STR_CUSTOM_CSS, __( 'Your existing Custom CSS code:', 'footnotes' ) ), + 'css' => $this->add_textarea( 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.', 'footnotes' ), + + // phpcs:disable Squiz.PHP.CommentedOutCode.Found + // 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->add_text(__("superscript, Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),. + + // "label-class-2" => ".footnote_tooltip",. + // "class-2" => $this->add_text(__("mouse-over box, tooltip for each superscript", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),. + + // "label-class-3" => ".footnote_plugin_index",. + // "class-3" => $this->add_text(__("1st column of the Reference Container, Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),. + + // "label-class-4" => ".footnote_plugin_text",. + // "class-4" => $this->add_text(__("2nd column of the Reference Container, Footnote text", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)). + // phpcs:enable + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays transitional legacy Custom CSS box. + * + * @since 2.2.2 + */ + public function custom_css_migration() { + + // Options for Yes/No select box. + $l_arr_enabled = array( + 'yes' => __( 'Yes', 'footnotes' ), + 'no' => __( 'No', 'footnotes' ), + ); + + // 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->add_label( MCI_Footnotes_Settings::C_STR_CUSTOM_CSS, __( 'Your existing Custom CSS code:', 'footnotes' ) ), + 'css' => $this->add_textarea( 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.', 'footnotes' ), + + 'label-show-legacy' => $this->add_label( MCI_Footnotes_Settings::C_STR_CUSTOM_CSS_LEGACY_ENABLE, 'Show legacy Custom CSS settings containers:' ), + 'show-legacy' => $this->add_select_box( MCI_Footnotes_Settings::C_STR_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.', 'footnotes' ), + // Translators: %s: Referres and tooltips. + '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.', 'footnotes' ), __( 'Referrers and tooltips', 'footnotes' ) ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays the new Custom CSS box. + * + * @since 2.2.2 + */ + public function custom_css_new() { + // 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->add_textarea( MCI_Footnotes_Settings::C_STR_CUSTOM_CSS_NEW ), + + 'headline' => $this->add_text( __( 'Recommended CSS classes:', 'footnotes' ) ), + + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays available Hooks to look for Footnote short codes. + * + * @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 lookup_hooks() { + // 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.', 'footnotes' ), + // Translators: 1: 99; 2: 1200. + '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.', 'footnotes' ), 99, 1200 ), + // Translators: 1: PHP_INT_MAX; 2: 0; 3: -1; 4: 'PHP_INT_MAX'. + '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.', 'footnotes' ), 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.', 'footnotes' ), + + 'head-hook' => __( 'WordPress hook function name', 'footnotes' ), + 'head-checkbox' => __( 'Activate', 'footnotes' ), + 'head-numbox' => __( 'Priority level', 'footnotes' ), + 'head-url' => __( 'WordPress documentation', 'footnotes' ), + + 'label-the-title' => $this->add_label( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_TITLE, 'the_title' ), + 'the-title' => $this->add_checkbox( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_TITLE ), + 'priority-the-title' => $this->add_num_box( 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->add_label( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_CONTENT, 'the_content' ), + 'the-content' => $this->add_checkbox( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_CONTENT ), + 'priority-the-content' => $this->add_num_box( 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->add_label( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_EXCERPT, 'the_excerpt' ), + 'the-excerpt' => $this->add_checkbox( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_EXCERPT ), + 'priority-the-excerpt' => $this->add_num_box( 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->add_label( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_WIDGET_TITLE, 'widget_title' ), + 'widget-title' => $this->add_checkbox( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_WIDGET_TITLE ), + 'priority-widget-title' => $this->add_num_box( 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->add_label( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_WIDGET_TEXT, 'widget_text' ), + 'widget-text' => $this->add_checkbox( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_WIDGET_TEXT ), + 'priority-widget-text' => $this->add_num_box( 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. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays a short introduction of the Plugin. + * + * @since 1.5.0 + */ + public function Help() { + global $g_obj_mci_footnotes; + // Load footnotes starting and end tag. + $l_arr_footnote_starting_tag = $this->load_setting( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START ); + $l_arr_footnote_ending_tag = $this->load_setting( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END ); + + if ( 'userdefined' === $l_arr_footnote_starting_tag['value'] || 'userdefined' === $l_arr_footnote_ending_tag['value'] ) { + // Load user defined starting and end tag. + $l_arr_footnote_starting_tag = $this->load_setting( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED ); + $l_arr_footnote_ending_tag = $this->load_setting( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED ); + } + $l_str_example = 'Hello' . $l_arr_footnote_starting_tag['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_ending_tag['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:', 'footnotes' ), + 'start' => $l_arr_footnote_starting_tag['value'], + 'label-end' => __( '…and end your footnote with this short code:', 'footnotes' ), + 'end' => $l_arr_footnote_ending_tag['value'], + 'example-code' => $l_str_example, + 'example-string' => '
' . __( 'will be displayed as:', 'footnotes' ), + 'example' => $g_obj_mci_footnotes->a_obj_task->exec( $l_str_example, true ), + // Translators: 1: ; 2: . + 'information' => sprintf( __( 'For further information please check out our %1$ssupport forum%2$s on WordPress.org.', 'footnotes' ), '', '' ), + ) + ); + // 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. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } + + /** + * Displays all Donate button to support the developers. + * + * @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', 'footnotes' ), + ) + ); + // Display template with replaced placeholders. + // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + echo $l_obj_template->get_content(); + // phpcs:enable + } +} diff --git a/class/settings.php b/class/settings.php index 7073a0e..d83907b 100644 --- a/class/settings.php +++ b/class/settings.php @@ -7,53 +7,11 @@ * @since 1.5.0 * @date 14.09.14 10:43 * - * @since 2.0.4 restore arrow settings 2020-11-02T2115+0100 - * @since 2.0.7 remove hook the_post 2020-11-06T1342+0100 - * @since 2.1.0 add read-on button label customization 2020-11-08T2149+0100 - * @since 2.1.1 fix tooltips on site by alternative 2020-11-11T1819+0100 - * @since 2.1.1 fix disabling backlink symbol 2020-11-16T2021+0100 - * @since 2.1.1 fix superscript by making it optional - * @since 2.1.1 fix start pages by option to hide ref container, thanks to @dragon013 - * @since 2.1.1 fix ref container by option restoring 3-column layout - * @since 2.1.1 fix ref container by option to switch index/symbol 2020-11-16T2022+0100 - * - * @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 - * - * @since 2.1.3 fix ref container positioning by priority level 2020-11-17T0205+0100 - * - * @since 2.1.4 more settings container keys 2020-12-03T0955+0100 - * - * @since 2.1.6 option to disable URL line wrapping 2020-12-09T1606+0100 - * - * @since 2.1.6 set default priority level of the_content to 98 to prevent plugin conflict, thanks to @marthalindeman 2020-12-10T0447+0100 - * - * @since 2.2.0 reference container custom position shortcode, thanks to @hamshe 2020-12-13T2056+0100 - * @link https://wordpress.org/support/topic/reference-container-in-elementor/ - * - * @since 2.2.2 Custom CSS settings container migration 2020-12-15T0709+0100 - * - * @since 2.2.4 move backlink symbol selection under previous tab 2020-12-16T1256+0100 - * - * @since 2.2.5 alternative tooltip position settings 2020-12-17T0907+0100 - * - * @since 2.2.5 options for reference container label element and bottom border, thanks to @markhillyer 2020-12-18T1455+0100 - * @link https://wordpress.org/support/topic/how-do-i-eliminate-the-horizontal-line-beneath-the-reference-container-heading/ - * - * @since 2.2.9 set default priority level of widget_text to 98 like for the_content (since 2.1.6), thanks to @marthalindeman 2020-12-25T1646+0100 - * - * @since 2.2.10 reference container row border option, thanks to @noobishh 2020-12-25T2316+0100 - * @link https://wordpress.org/support/topic/borders-25/ - * - * @since 2.3.0 reference container: settings for top (and bottom) margin, thanks to @hamshe - * @link https://wordpress.org/support/topic/reference-container-in-elementor/#post-13786635 - * - * @since 2.3.0 Bugfix: Dashboard: Custom CSS: swap migration Boolean, meaning 'show legacy' instead of 'migration complete', due to storage data structure constraints. - * @date 2020-12-27T1243+0100 - - * @since 2.3.0 referrers, reference container: settings for anchor slugs 2020-12-31T1429+0100 - * - * @since 2.4.0 footnote shortcode syntax validation 2021-01-01T0624+0100 + * The constants are ordered by ascending version so their docblocks can replace most of this list. + * @since 2.0.0 Update: **symbol for backlinks** removed; hyperlink moved to the reference number. + * @since 2.0.4 Update: Restore arrow settings to customize or disable the now prepended arrow symbol, thanks to @mmallett issue report. + * @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.1.3 Bugfix: Hooks: disable the_excerpt hook by default to fix issues, thanks to @nikelaos bug report. */ /** @@ -64,7 +22,7 @@ class MCI_Footnotes_Settings { /** - * Settings Container Key for the label of the reference container. + * Settings container key for the label of the reference container. * * @since 1.5.0 * @var str @@ -72,7 +30,7 @@ class MCI_Footnotes_Settings { const C_STR_REFERENCE_CONTAINER_NAME = 'footnote_inputfield_references_label'; /** - * Settings Container Key to collapse the reference container by default. + * Settings container key to collapse the reference container by default. * * @since 1.5.0 * @var str @@ -82,7 +40,7 @@ class MCI_Footnotes_Settings { const C_STR_REFERENCE_CONTAINER_COLLAPSE = 'footnote_inputfield_collapse_references'; /** - * Settings Container Key for the position of the reference container. + * Settings container key for the position of the reference container. * * @since 1.5.0 * @var str @@ -90,7 +48,7 @@ class MCI_Footnotes_Settings { const C_STR_REFERENCE_CONTAINER_POSITION = 'footnote_inputfield_reference_container_place'; /** - * Settings Container Key for combining identical footnotes. + * Settings container key for combining identical footnotes. * * @since 1.5.0 * @var str @@ -98,7 +56,7 @@ class MCI_Footnotes_Settings { const C_STR_COMBINE_IDENTICAL_FOOTNOTES = 'footnote_inputfield_combine_identical'; /** - * Settings Container Key for the short code of the footnote’s start. + * Settings container key for the short code of the footnote’s start. * * @since 1.5.0 * @var str @@ -106,7 +64,7 @@ class MCI_Footnotes_Settings { const C_STR_FOOTNOTES_SHORT_CODE_START = 'footnote_inputfield_placeholder_start'; /** - * Settings Container Key for the short code of the footnote’s end. + * Settings container key for the short code of the footnote’s end. * * @since 1.5.0 * @var str @@ -114,7 +72,7 @@ class MCI_Footnotes_Settings { const C_STR_FOOTNOTES_SHORT_CODE_END = 'footnote_inputfield_placeholder_end'; /** - * Settings Container Key for the user-defined short code of the footnotes start. + * Settings container key for the user-defined short code of the footnotes start. * * @since 1.5.0 * @var str @@ -122,7 +80,7 @@ class MCI_Footnotes_Settings { 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. + * Settings container key for the user-defined short code of the footnotes end. * * @since 1.5.0 * @var str @@ -130,7 +88,7 @@ class MCI_Footnotes_Settings { 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. + * Settings container key for the counter style of the footnotes. * * @since 1.5.0 * @var str @@ -138,37 +96,47 @@ class MCI_Footnotes_Settings { const C_STR_FOOTNOTES_COUNTER_STYLE = 'footnote_inputfield_counter_style'; /** - * Settings Container Key for the 'I love footnotes' text. + * Settings container key for the backlink symbol selection. + * + * @since 1.5.0 + * + * - Update: Restore arrow settings to customize or disable the now prepended arrow symbol, thanks to @mmallett issue report. + * + * @reporter @mmallett + * @link https://wordpress.org/support/topic/mouse-over-broken/#post-13593037 + * + * @since 2.0.4 + * @date 2020-11-02T2115+0100 + * @var str + */ + const C_STR_HYPERLINK_ARROW = 'footnote_inputfield_custom_hyperlink_symbol'; + + /** + * Settings container key for the user-defined backlink symbol. * * @since 1.5.0 * @var str */ - const C_STR_FOOTNOTES_LOVE = 'footnote_inputfield_love'; + const C_STR_HYPERLINK_ARROW_USER_DEFINED = 'footnote_inputfield_custom_hyperlink_symbol_user'; /** - * Settings Container Key to look for footnotes in post excerpts. + * Settings container key to look for footnotes in post excerpts. + * + * - Bugfix: Hooks: disable the_excerpt hook by default to fix issues, thanks to @nikelaos bug report. + * + * @reporter @nikelaos + * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13687068 * * @since 1.5.0 + * @since 2.6.2 Debug No option. + * @since 2.6.3 Enable by default after debugging both Yes and No options. + * @see C_STR_EXPERT_LOOKUP_THE_EXCERPT * @var str */ const C_STR_FOOTNOTES_IN_EXCERPT = 'footnote_inputfield_search_in_excerpt'; /** - * Settings Container Key for the Expert mode. - * - * @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_STR_FOOTNOTES_EXPERT_MODE = 'footnote_inputfield_enable_expert_mode'; - - /** - * Settings Container Key for the string before the footnote referrer. + * Settings container key for the string before the footnote referrer. * * @since 1.5.0 * @var str @@ -183,7 +151,7 @@ class MCI_Footnotes_Settings { const C_STR_FOOTNOTES_STYLING_BEFORE = 'footnote_inputfield_custom_styling_before'; /** - * Settings Container Key for the string after the footnote referrer. + * Settings container key for the string after the footnote referrer. * * @since 1.5.0 * @var str @@ -191,7 +159,25 @@ class MCI_Footnotes_Settings { const C_STR_FOOTNOTES_STYLING_AFTER = 'footnote_inputfield_custom_styling_after'; /** - * Settings Container Key to enable the mouse-over box. + * Settings container key for the Custom CSS. + * + * @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 'I love footnotes' text. + * + * @since 1.5.0 + * @var str + */ + const C_STR_FOOTNOTES_LOVE = 'footnote_inputfield_love'; + + /** + * Settings container key to enable the mouse-over box. * * @since 1.5.2 * @var str @@ -199,16 +185,258 @@ class MCI_Footnotes_Settings { const C_STR_FOOTNOTES_MOUSE_OVER_BOX_ENABLED = 'footnote_inputfield_custom_mouse_over_box_enabled'; /** - * Settings Container Key to enable the alternative tooltips. + * Settings container key to enable tooltip truncation. + * + * @since 1.5.4 + * @var str + * + * 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. + */ + const C_STR_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. + * + * @since 1.5.4 + * @var int + * + * @since 2.0.7 Increase default truncation length from 150 to 200 chars. + */ + const C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH = 'footnote_inputfield_custom_mouse_over_box_excerpt_length'; + + /** + * Settings container key to enable the 'the_title' hook. + * + * @since 1.5.5 + * @var str + * + * These are checkboxes; keyword 'checked' is converted to Boolean true, + * empty string to false (default). + * + * Hooks should all be enabled by default to prevent users from + * thinking at first that the feature is broken in post titles. + * @link https://wordpress.org/support/topic/more-feature-ideas/ + * + * Yet in titles, footnotes are still buggy, because WordPress + * uses the title string in menus and in the title element, but + * Footnotes doesn’t delete footnotes therein. + */ + const C_STR_EXPERT_LOOKUP_THE_TITLE = 'footnote_inputfield_expert_lookup_the_title'; + + /** + * Settings container key to enable the 'the_content' hook. + * + * @since 1.5.5 + * @var str + */ + const C_STR_EXPERT_LOOKUP_THE_CONTENT = 'footnote_inputfield_expert_lookup_the_content'; + + /** + * Settings container key to enable the 'the_excerpt' hook. + * + * @since 1.5.5 + * + * - Bugfix: Hooks: disable the_excerpt hook by default to fix issues, thanks to @nikelaos bug report. + * + * @reporter @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 + * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13687068 + * + * @since 2.1.3 + * @since 2.6.3 Enable by default after debugging the 'Footnotes in excerpts' setting. + * + * - Bugfix: Hooks: default-disable the_excerpt hook with respect to theme-specific excerpt handling, thanks to @mmallett bug reports. + * + * @reporter @mmallett + * @link https://wordpress.org/support/topic/broken-662/ + * @link https://wordpress.org/support/topic/update-crashed-my-website-3/#post-14260969 + * + * @since 2.6.5 + * @see C_STR_FOOTNOTES_IN_EXCERPT + * @var str + */ + const C_STR_EXPERT_LOOKUP_THE_EXCERPT = 'footnote_inputfield_expert_lookup_the_excerpt'; + + /** + * Settings container key to enable the 'widget_title' hook. + * + * @since 1.5.5 + * @var str + */ + const C_STR_EXPERT_LOOKUP_WIDGET_TITLE = 'footnote_inputfield_expert_lookup_widget_title'; + + /** + * Settings container key to enable the 'widget_text' hook. + * + * @since 1.5.5 + * @var str + * + * 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. + */ + const C_STR_EXPERT_LOOKUP_WIDGET_TEXT = 'footnote_inputfield_expert_lookup_widget_text'; + + /** + * Settings container key for the Expert mode. + * + * @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. + * @date 2020-11-06T1342+0100 + */ + const C_STR_FOOTNOTES_EXPERT_MODE = 'footnote_inputfield_enable_expert_mode'; + + /** + * Settings container key for the mouse-over box to define the color. + * + * @since 1.5.6 + * + * - Bugfix: Tooltips: Styling: Font color: set to black for maximum contrast with respect to white default background, thanks to 4msc bug report. + * + * @reporter @4msc + * @link https://wordpress.org/support/topic/tooltip-not-showing-on-dark-theme-with-white-text/ + * + * @since 2.6.1 + * @see C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND + * @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. + * + * @since 1.5.6 + * @since 1.2.5..1.5.5 #fff7a7 hard-coded. + * @since 1.5.6..2.0.6 #fff7a7 setting default. + * The mouse over box shouldn’t feature a colored background. + * By default, due to diverging user preferences. White is neutral. + * @since 2.0.7..2.5.10 #ffffff setting default. + * + * - Bugfix: Tooltips: Styling: Background color: empty default value to adopt theme background, thanks to 4msc bug report. + * + * @reporter @4msc + * @link https://wordpress.org/support/topic/tooltip-not-showing-on-dark-theme-with-white-text/ + * + * @since 2.5.11 + * Theme default background color is best. + * But theme default background color doesn’t seem to exist. + * @link https://wordpress.org/support/topic/problem-with-footnotes-in-excerpts-of-the-blog-page/#post-14241849 + * @since 2.6.1 default #ffffff again along with #000000 as font color. + * @see C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR + * @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. + * + * @since 1.5.6 + * @var int + */ + 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. + * + * @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. + * + * @since 1.5.6 + * @var int + * + * @since 2.0.7 The mouse over box corners mustn’t be rounded as that is outdated. + */ + 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. + * + * @since 1.5.6 + * @var int + * + * @since 2.0.7 Set default width 450. + * The width should be limited to start with, for the box to have shape. + */ + 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 position. + * + * @since 1.5.7 + * @var str + * + * 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. + */ + 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). + * + * @since 1.5.7 + * @var int + */ + 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). + * + * @since 1.5.7 + * @var int + * + * The vertical offset must be negative for the box not to cover + * The current line of text (web coordinates origin is top left). + */ + 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 box-shadow color. + * + * @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 label of the Read-on button in truncated tooltips. + * + * - Adding: Tooltips: Read-on button: Label: configurable instead of localizable, thanks to @rovanov example provision. + * + * @reporter @rovanov + * @link https://wordpress.org/support/topic/offset-x-axis-and-offset-y-axis-does-not-working/ + * + * @since 2.1.0 + * @date 2020-11-08T2106+0100 + * @var str + */ + const C_STR_FOOTNOTES_TOOLTIP_READON_LABEL = 'footnote_inputfield_readon_label'; + + /** + * 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 * + * @since 2.1.1 + * @date 2020-11-11T1817+0100 * @var str * * These alternative tooltips work around a website related jQuery UI @@ -219,251 +447,48 @@ class MCI_Footnotes_Settings { const C_STR_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE = 'footnote_inputfield_custom_mouse_over_box_alternative'; /** - * Settings Container Key to enable tooltip truncation. - * - * @since 1.5.4 - * @var str - */ - const C_STR_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. - * - * @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. - * - * @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). - * - * @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). - * - * @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. - * - * @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. - * - * @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. - * - * @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. - * - * @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. - * - * @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. - * - * @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. - * - * @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. - * - * @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. - * - * @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. - * - * @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 to_bool() converts empty to false. - */ - const C_STR_CUSTOM_CSS_LEGACY_ENABLE = 'footnote_inputfield_custom_css_legacy_enable'; - - /** - * Settings Container Key to enable the 'the_title' hook. - * - * @since 1.5.5 - * @var str - */ - const C_STR_EXPERT_LOOKUP_THE_TITLE = 'footnote_inputfield_expert_lookup_the_title'; - - /** - * Settings Container Key to enable the 'the_content' hook. - * - * @since 1.5.5 - * @var str - */ - const C_STR_EXPERT_LOOKUP_THE_CONTENT = 'footnote_inputfield_expert_lookup_the_content'; - - /** - * Settings Container Key to enable the 'the_excerpt' hook. - * - * @since 1.5.5 - * @var str - */ - const C_STR_EXPERT_LOOKUP_THE_EXCERPT = 'footnote_inputfield_expert_lookup_the_excerpt'; - - /** - * Settings Container Key to enable the 'widget_title' hook. - * - * @since 1.5.5 - * @var str - */ - const C_STR_EXPERT_LOOKUP_WIDGET_TITLE = 'footnote_inputfield_expert_lookup_widget_title'; - - /** - * Settings Container Key to enable the 'widget_text' hook. - * - * @since 1.5.5 - * @var str - */ - const C_STR_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. + * 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/ * + * @since 2.1.1 + * @date 2020-11-16T0859+0100 * @var str */ const C_STR_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS = 'footnotes_inputfield_referrer_superscript_tags'; /** - * Settings Container Key to enable the display of a backlink symbol. + * 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 * + * @since 2.1.1 + * @date 2020-11-16T2021+0100 * @var str */ const C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = 'footnotes_inputfield_reference_container_backlink_symbol_enable'; /** - * Settings Container Key to not display the reference container on the homepage. + * 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/ * + * @since 2.1.1 * @var str */ const C_STR_REFERENCE_CONTAINER_START_PAGE_ENABLE = 'footnotes_inputfield_reference_container_start_page_enable'; /** - * Settings Container Key to enable the legacy layout of the reference container. + * 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. * @@ -473,187 +498,549 @@ class MCI_Footnotes_Settings { const C_STR_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = 'footnotes_inputfield_reference_container_3column_layout_enable'; /** - * Settings Container Key to get the backlink symbol switch side. + * 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 * + * @since 2.1.1 + * @date 2020-11-16T2024+0100 * @var str */ const C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = 'footnotes_inputfield_reference_container_backlink_symbol_switch'; /** - * Settings Container Key for 'the_content' hook priority level. + * Settings container key for 'the_content' hook priority level. + * + * - Bugfix: Reference container: fix relative position through priority level, thanks to @june01 @imeson @spaceling bug reports, thanks to @spaceling code contribution. + * + * @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 + * + * @since 2.0.5 + * @date 2020-11-02T0330+0100 + * @link https://codex.wordpress.org/Plugin_API/#Hook_in_your_Filter + * + * - Bugfix: Dashboard: priority level setting for the_content hook, thanks to @imeson bug report. + * + * @reporter @imeson + * @link https://wordpress.org/support/topic/change-the-position-5/#post-13538345 * * @since 2.1.1 * @date 2020-11-16T0859+0100 * - * @var str + * - Bugfix: Priority levels: set the_content priority level to 98 to prevent plugin conflict, thanks to @marthalindeman bug report. + * + * @reporter @marthalindeman + * @link https://wordpress.org/support/topic/code-showing-up-in-references/ + * + * @since 2.1.6 + * @date 2020-12-10T0447+0100 + * + * 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. + * + * 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_the_content_priority =< 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 + * @var int */ const C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_the_content_priority_level'; /** - * Settings Container Key for '' hook priority level + * Settings container key for 'the_title' hook priority level. + * + * - Bugfix: Dashboard: priority level settings for all other hooks, thanks to @nikelaos bug report. + * + * @reporter @nikelaos + * @link https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13676705 * * @since 2.1.2 * @date 2020-11-20T0620+0100 - * - * @var str + * @var int */ - 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'; + const C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_the_title_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 + * Settings container key for 'widget_title' hook priority level. + * + * @since 2.1.2 + * @date 2020-11-20T0620+0100 + * @var int + */ + const C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_widget_title_priority_level'; + + /** + * Settings container key for 'widget_text' hook priority level. + * + * @since 2.1.2 + * @date 2020-11-20T0620+0100 + * @var int + */ + const C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_widget_text_priority_level'; + + /** + * Settings container key for 'the_excerpt' hook priority level. + * + * @since 2.1.2 + * @date 2020-11-20T0620+0100 + * @var int + */ + const C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_the_excerpt_priority_level'; + + /** + * Settings container key for the link element option. + * + * - Bugfix: Referrers and backlinks: Styling: make link elements optional to fix issues, thanks to @docteurfitness issue report and code contribution. + * + * @contributor @docteurfitness + * @link https://wordpress.org/support/topic/update-2-1-3/#post-13704194 * * @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 + * @var str */ - - // Link element option. const C_STR_LINK_ELEMENT_ENABLED = 'footnote_inputfield_link_element_enabled'; - // Backlink typography. - const C_STR_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'; + /** + * Settings container key to enable the presence of a backlink separator. + * + * - Bugfix: Reference container: make separating and terminating punctuation optional and configurable, thanks to @docteurfitness issue report and code contribution. + * + * @contributor @docteurfitness + * @link https://wordpress.org/support/topic/update-2-1-3/#post-13704194 + * + * @since 2.1.4 + * @var str + * + * Backlink separators and terminators are often not preferred. + * But a choice must be provided along with the ability to customize. + */ + const C_STR_BACKLINKS_SEPARATOR_ENABLED = 'footnotes_inputfield_backlinks_separator_enabled'; + + /** + * Settings container key for the backlink separator options. + * + * @since 2.1.4 + * @var str + */ + const C_STR_BACKLINKS_SEPARATOR_OPTION = 'footnotes_inputfield_backlinks_separator_option'; + + /** + * Settings container key for a custom backlink separator. + * + * @since 2.1.4 + * @var str + */ + const C_STR_BACKLINKS_SEPARATOR_CUSTOM = 'footnotes_inputfield_backlinks_separator_custom'; + + /** + * Settings container key to enable the presence of a backlink terminator. + * + * @since 2.1.4 + * @var str + */ const C_STR_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_STR_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'; + /** + * Settings container key for the backlink terminator options. + * + * @since 2.1.4 + * @var str + */ + const C_STR_BACKLINKS_TERMINATOR_OPTION = 'footnotes_inputfield_backlinks_terminator_option'; + + /** + * Settings container key for a custom backlink terminator. + * + * @since 2.1.4 + * @var str + */ + const C_STR_BACKLINKS_TERMINATOR_CUSTOM = 'footnotes_inputfield_backlinks_terminator_custom'; + + /** + * Settings container key to enable the backlinks column width. + * + * @since 2.1.4 + * @var str + */ + const C_STR_BACKLINKS_COLUMN_WIDTH_ENABLED = 'footnotes_inputfield_backlinks_column_width_enabled'; + + /** + * Settings container key for the backlinks column width scalar. + * + * @since 2.1.4 + * @var int + */ + const C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR = 'footnotes_inputfield_backlinks_column_width_scalar'; + + /** + * Settings container key for the backlinks column width unit. + * + * @since 2.1.4 + * @var str + */ + const C_STR_BACKLINKS_COLUMN_WIDTH_UNIT = 'footnotes_inputfield_backlinks_column_width_unit'; + + /** + * Settings container key to enable a max width for the backlinks column. + * + * @since 2.1.4 + * @var str + */ const C_STR_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_STR_BACKLINKS_LINE_BREAKS_ENABLED = 'footnotes_inputfield_backlinks_line_breaks_enabled'; - // Tooltip font size. - // Called mouse over box not tooltip for consistency. + /** + * Settings container key for the backlinks column max width scalar. + * + * @since 2.1.4 + * @var int + */ + const C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR = 'footnotes_inputfield_backlinks_column_max_width_scalar'; + + /** + * Settings container key for the backlinks column max width unit. + * + * @since 2.1.4 + * @var str + */ + const C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT = 'footnotes_inputfield_backlinks_column_max_width_unit'; + + /** + * Settings container key to enable line breaks between backlinks. + * + * @since 2.1.4 + * @var str + * Whether a
tag is inserted. + */ + const C_STR_BACKLINKS_LINE_BREAKS_ENABLED = 'footnotes_inputfield_backlinks_line_breaks_enabled'; + + /** + * Settings container key to enable setting the tooltip font size. + * + * @since 2.1.4 + * @date 2020-12-04T1023+0100. + * @var str + * + * 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, + * Called mouse over box not tooltip for consistency. + */ const C_STR_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. + /** + * Settings container key for the scalar value of the tooltip font size. + * + * @since 2.1.4 + * @var flo + */ + const C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR = 'footnotes_inputfield_mouse_over_box_font_size_scalar'; + + /** + * Settings container key for the unit of the tooltip font size. + * + * @since 2.1.4 + * @var str + */ + const C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT = 'footnotes_inputfield_mouse_over_box_font_size_unit'; + + /** + * Settings container key for basic responsive page layout support options. + * + * @since 2.1.4 + * @var str + * Whether to concatenate an additional stylesheet. + */ const C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT = 'footnotes_inputfield_page_layout_support'; /** - * Scroll offset and duration + * Settings container key for 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 + * @var int + */ + const C_INT_FOOTNOTES_SCROLL_OFFSET = 'footnotes_inputfield_scroll_offset'; + + /** + * Settings container key for scroll duration. + * * - Bugfix: Scroll duration: make configurable to conform to website content and style requirements. * * @since 2.1.4 * @date 2020-12-05T0538+0100 + * @var int */ - // 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'; + /** + * Settings container key for tooltip display fade-in delay. + * + * @since 2.1.4 + * @date 2020-12-05T0538+0100 + * @var int + */ + const C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY = 'footnotes_inputfield_mouse_over_box_fade_in_delay'; + + /** + * Settings container key for tooltip display fade-in duration. + * + * @since 2.1.4 + * @date 2020-12-05T0538+0100 + * @var int + */ + const C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION = 'footnotes_inputfield_mouse_over_box_fade_in_duration'; + + /** + * Settings container key for tooltip display fade-out delay. + * + * @since 2.1.4 + * @date 2020-12-05T0538+0100 + * @var int + */ + const C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY = 'footnotes_inputfield_mouse_over_box_fade_out_delay'; + + /** + * Settings container key for tooltip display fade-out duration. + * + * @since 2.1.4 + * @date 2020-12-05T0538+0100 + * @var int + */ const C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION = 'footnotes_inputfield_mouse_over_box_fade_out_duration'; /** - * Settings Container Key for URL wrap option + * 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 + * @date 2020-12-09T1606+0100 * @var str - * - * 2020-12-09T1554+0100..2020-12-13T1313+0100 */ const C_STR_FOOTNOTE_URL_WRAP_ENABLED = 'footnote_inputfield_url_wrap_enabled'; /** - * Settings Container Key for reference container position shortcode + * Settings container key for reference container position shortcode. + * + * - Adding: Reference container: support for custom position shortcode, thanks to @hamshe issue report. + * + * @reporter @hamshe + * @link https://wordpress.org/support/topic/reference-container-in-elementor/ * * @since 2.2.0 + * @date 2020-12-13T2056+0100 * @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 + * Settings container key for the Custom CSS migrated to a dedicated tab. * + * - Update: Dashboard: Custom CSS: unearth text area and migrate to dedicated tab as designed. + * + * @since 2.2.2 + * @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 + * + * - Bugfix: Dashboard: Custom CSS: swap migration Boolean, meaning 'show legacy' instead of 'migration complete', due to storage data structure constraints. + * + * @since 2.3.0 + * @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 to_bool() converts empty to false. + */ + const C_STR_CUSTOM_CSS_LEGACY_ENABLE = 'footnote_inputfield_custom_css_legacy_enable'; + + /** + * Settings container key for alternative tooltip position. + * + * @since 2.2.5 + * @date 2020-12-17T0746+0100 + * @var str + * + * Fixed width is for alternative tooltips, cannot reuse max-width nor offsets. + */ + const C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION = 'footnotes_inputfield_alternative_mouse_over_box_position'; + + /** + * Settings container key for alternative tooltip x offset. + * + * @since 2.2.5 + * @date 2020-12-17T0746+0100 + * @var int + */ + const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X = 'footnotes_inputfield_alternative_mouse_over_box_offset_x'; + + /** + * Settings container key for alternative tooltip y offset. + * + * @since 2.2.5 + * @date 2020-12-17T0746+0100 + * @var int + */ + const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y = 'footnotes_inputfield_alternative_mouse_over_box_offset_y'; + + /** + * Settings container key for alternative tooltip width. + * + * @since 2.2.5 + * @date 2020-12-17T0746+0100 + * @var int + */ + const C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH = 'footnotes_inputfield_alternative_mouse_over_box_width'; + + + /** + * Settings container key for the reference container label element. + * + * - Bugfix: Reference container: Label: option to select paragraph or heading element, thanks to @markhillyer issue report. + * + * @reporter @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 + * @date 2020-12-18T1509+0100 + * @var str */ - 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_STR_REFERENCE_CONTAINER_LABEL_ELEMENT = 'footnotes_inputfield_reference_container_label_element'; + /** + * Settings container key to enable the reference container label bottom border. + * + * - Bugfix: Reference container: Label: make bottom border an option, thanks to @markhillyer issue report. + * + * @reporter @markhillyer + * @link https://wordpress.org/support/topic/how-do-i-eliminate-the-horizontal-line-beneath-the-reference-container-heading/ + * + * @since 2.2.5 + * @date 2020-12-18T1509+0100 + * @var str + */ const C_STR_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER = 'footnotes_inputfield_reference_container_label_bottom_border'; /** - * Settings Container Key for table cell borders, thanks to @noobishh + * Settings container key to enable reference container table row borders. * + * - Bugfix: Reference container: add option for table borders to restore pre-2.0.0 design, thanks to @noobishh issue report. + * + * @reporter @noobishh * @link https://wordpress.org/support/topic/borders-25/ * * @since 2.2.10 + * @date 2020-12-25T2311+0100 * @var str - * - * 2020-12-25T2311+0100 */ const C_STR_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 + * Settings container key for reference container top margin. + * + * - Bugfix: Reference container: convert top padding to margin and make it a setting, thanks to @hamshe bug report. + * + * @reporter @hamshe + * @link https://wordpress.org/support/topic/reference-container-in-elementor/#post-13786635 * * @since 2.3.0 - * @var int|bool|str - * - * 2020-12-29T0914+0100 + * @date 2020-12-29T0914+0100 + * @var int */ - 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_STR_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'; + const C_INT_REFERENCE_CONTAINER_TOP_MARGIN = 'footnotes_inputfield_reference_container_top_margin'; /** - * Settings container key for shortcode syntax validation. + * Settings container key for reference container bottom margin. + * + * - Bugfix: Reference container: convert top padding to margin and make it a setting, thanks to @hamshe bug report. + * + * @reporter @hamshe + * @link https://wordpress.org/support/topic/reference-container-in-elementor/#post-13786635 + * + * @since 2.3.0 + * @date 2020-12-29T0914+0100 + * @var int + */ + const C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN = 'footnotes_inputfield_reference_container_bottom_margin'; + + /** + * Settings container key to enable hard links. + * + * - Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro issue report, thanks to @martinneumannat issue report and code contribution. + * + * @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/ + * + * @since 2.3.0 + * @date 2020-12-29T0914+0100 + * @var str + * + * When the alternative reference container is enabled, hard links are too. + */ + const C_STR_FOOTNOTES_HARD_LINKS_ENABLE = 'footnotes_inputfield_hard_links_enable'; + + /** + * Settings container key for the fragment ID slug in referrers. + * + * @since 2.3.0 + * @date 2020-12-29T0914+0100 + * @var str + */ + const C_STR_REFERRER_FRAGMENT_ID_SLUG = 'footnotes_inputfield_referrer_fragment_id_slug'; + + /** + * Settings container key for the fragment ID slug in footnotes. + * + * @since 2.3.0 + * @date 2020-12-29T0914+0100 + * @var str + */ + const C_STR_FOOTNOTE_FRAGMENT_ID_SLUG = 'footnotes_inputfield_footnote_fragment_id_slug'; + + /** + * Settings container key for the ID separator in fragment IDs. + * + * @since 2.3.0 + * @date 2020-12-29T0914+0100 + * @var str + */ + const C_STR_HARD_LINK_IDS_SEPARATOR = 'footnotes_inputfield_hard_link_ids_separator'; + + /** + * Settings container key to enable shortcode syntax validation. * * @since 2.4.0 * @date 2021-01-01T0616+0100 - * * @var str */ const C_STR_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE = 'footnotes_inputfield_shortcode_syntax_validation_enable'; @@ -663,17 +1050,16 @@ class MCI_Footnotes_Settings { * * - 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/ * + * @since 2.5.4 + * @var str + * * 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_STR_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE = 'footnotes_inputfield_backlink_tooltip_enable'; @@ -682,11 +1068,10 @@ class MCI_Footnotes_Settings { * * - 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/ * + * @since 2.5.4 * @var str */ const C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT = 'footnotes_inputfield_backlink_tooltip_text'; @@ -699,17 +1084,16 @@ class MCI_Footnotes_Settings { * 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/ * + * @since 2.5.4 + * @var str + * * 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'; @@ -740,11 +1124,10 @@ class MCI_Footnotes_Settings { * * -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/ * + * @since 2.5.4 * @var str */ const C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT = 'footnotes_inputfield_referrers_normal_superscript'; @@ -754,18 +1137,99 @@ class MCI_Footnotes_Settings { * * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. * - * @since 2.5.6 - * * @reporter @hopper87it * @link https://wordpress.org/support/topic/footnotes-wp-rocket/ * + * @since 2.5.6 * @var str */ const C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE = 'footnotes_inputfield_reference_container_script_mode'; + /** + * Settings container key to enable AMP compatibility mode. + * + * - Adding: Tooltips: make display work purely by style rules for AMP compatibility, thanks to @milindmore22 code contribution. + * - Bugfix: Tooltips: enable accessibility by keyboard navigation, thanks to @westonruter code contribution. + * - Adding: Reference container: get expanding and collapsing to work also in AMP compatibility mode, thanks to @westonruter code contribution. + * + * @contributor @milindmore22 + * @link @link https://github.com/ampproject/amp-wp/issues/5913#issuecomment-785306933 + * + * @contributor @westonruter + * @link https://github.com/ampproject/amp-wp/issues/5913#issuecomment-785419655 + * @link https://github.com/markcheret/footnotes/issues/48#issuecomment-799580854 + * @link https://github.com/markcheret/footnotes/issues/48#issuecomment-799582394 + * + * @since 2.5.11 (draft) + * @since 2.6.0 (release) + * @var str + */ + const C_STR_FOOTNOTES_AMP_COMPATIBILITY_ENABLE = 'footnotes_inputfield_amp_compatibility_enable'; /** - * SETTINGS STORAGE + * Settings container key for scroll duration asymmetricity. + * + * @since 2.5.11 + * @var str + */ + const C_STR_FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY = 'footnotes_inputfield_scroll_duration_asymmetricity'; + + /** + * Settings container key for scroll down duration. + * + * @since 2.5.11 + * @var int + */ + const C_INT_FOOTNOTES_SCROLL_DOWN_DURATION = 'footnotes_inputfield_scroll_down_duration'; + + /** + * Settings container key for scroll down delay. + * + * @since 2.5.11 + * @var int + */ + const C_INT_FOOTNOTES_SCROLL_DOWN_DELAY = 'footnotes_inputfield_scroll_down_delay'; + + /** + * Settings container key for scroll up delay. + * + * @since 2.5.11 + * @var int + */ + const C_INT_FOOTNOTES_SCROLL_UP_DELAY = 'footnotes_inputfield_scroll_up_delay'; + + /** + * Settings container key to set the solution of the input element label issue. + * + * @since 2.5.12 + * @var str + * If hard links are not enabled, clicking a referrer in an input element label + * toggles the state of the input element the label is connected to. + * Beside hard links, other solutions include moving footnotes off the label and + * append them, or disconnecting this label from the input element (discouraged). + * @link https://wordpress.org/support/topic/compatibility-issue-with-wpforms/#post-14212318 + */ + const C_STR_FOOTNOTES_LABEL_ISSUE_SOLUTION = 'footnotes_inputfield_label_issue_solution'; + + /** + * Settings container key to enable CSS smooth scrolling. + * + * - Update: Scrolling: CSS-based smooth scroll behavior (optional), thanks to @paulgpetty and @bogosavljev issue reports. + * + * @reporter @paulgpetty + * @link https://wordpress.org/support/topic/functionally-great/#post-13607795 + * + * @reporter @bogosavljev + * @link https://wordpress.org/support/topic/compatibility-issue-with-wpforms/#post-14214720 + * + * @since 2.5.12 + * Native smooth scrolling only works in recent browsers. + */ + const C_STR_FOOTNOTES_CSS_SMOOTH_SCROLLING = 'footnotes_inputfield_css_smooth_scrolling'; + + + /** + * SETTINGS STORAGE. */ /** @@ -800,229 +1264,183 @@ class MCI_Footnotes_Settings { * @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 + * Comments are moved to constant docblocks. */ private $a_arr_default = array( + // General settings. 'footnotes_storage' => array( + // AMP compatibility. + self::C_STR_FOOTNOTES_AMP_COMPATIBILITY_ENABLE => '', + + // Footnote start and end short codes. 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_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE => 'yes', + // Footnotes numbering. self::C_STR_FOOTNOTES_COUNTER_STYLE => 'arabic_plain', self::C_STR_COMBINE_IDENTICAL_FOOTNOTES => 'yes', + // Scrolling behavior. + self::C_STR_FOOTNOTES_CSS_SMOOTH_SCROLLING => 'no', + self::C_INT_FOOTNOTES_SCROLL_OFFSET => 20, + self::C_INT_FOOTNOTES_SCROLL_DURATION => 380, + self::C_STR_FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY => 'no', + self::C_INT_FOOTNOTES_SCROLL_DOWN_DURATION => 150, + self::C_INT_FOOTNOTES_SCROLL_DOWN_DELAY => 0, + self::C_INT_FOOTNOTES_SCROLL_UP_DELAY => 0, self::C_STR_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_STR_FOOTNOTES_BACKLINK_TOOLTIP_ENABLE => 'yes', self::C_STR_FOOTNOTES_BACKLINK_TOOLTIP_TEXT => 'Alt+ ←', - + // Reference container. self::C_STR_REFERENCE_CONTAINER_NAME => 'References', self::C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT => 'p', self::C_STR_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER => 'yes', self::C_STR_REFERENCE_CONTAINER_COLLAPSE => 'no', self::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE => 'jquery', - self::C_STR_REFERENCE_CONTAINER_POSITION => 'post_end', self::C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE => '[[references]]', self::C_STR_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_STR_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE => 'no', - - // Backlink symbol. - self::C_STR_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE => 'no', + self::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT => 'none', + self::C_STR_FOOTNOTE_URL_WRAP_ENABLED => 'yes', self::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE => 'yes', self::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH => 'no', + self::C_STR_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE => 'no', + self::C_STR_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE => 'no', - // Backlink separators and terminators are often not preferred.. - // But a choice must be provided along with the ability to customize. self::C_STR_BACKLINKS_SEPARATOR_ENABLED => 'yes', self::C_STR_BACKLINKS_SEPARATOR_OPTION => 'comma', self::C_STR_BACKLINKS_SEPARATOR_CUSTOM => '', + self::C_STR_BACKLINKS_TERMINATOR_ENABLED => 'no', self::C_STR_BACKLINKS_TERMINATOR_OPTION => 'full_stop', self::C_STR_BACKLINKS_TERMINATOR_CUSTOM => '', - // Set backlinks column width. self::C_STR_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_STR_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_STR_BACKLINKS_LINE_BREAKS_ENABLED => 'no', - - // Whether to enable URL line wrapping. - self::C_STR_FOOTNOTE_URL_WRAP_ENABLED => 'yes', - - // Whether to use link elements. self::C_STR_LINK_ELEMENT_ENABLED => 'yes', - // Excerpt should be disabled. - self::C_STR_FOOTNOTES_IN_EXCERPT => 'no', - - self::C_STR_FOOTNOTES_EXPERT_MODE => 'yes', + // Footnotes in excerpts. + self::C_STR_FOOTNOTES_IN_EXCERPT => 'yes', + // Footnotes love. self::C_STR_FOOTNOTES_LOVE => 'no', + // Deprecated. + self::C_STR_FOOTNOTES_EXPERT_MODE => 'yes', + ), + // Referrers and tooltips. 'footnotes_storage_custom' => array( + // Backlink symbol. self::C_STR_HYPERLINK_ARROW => '↑', self::C_STR_HYPERLINK_ARROW_USER_DEFINED => '', - self::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL => 'Continue reading', - + // Referrers. self::C_STR_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS => 'yes', - + self::C_STR_FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT => 'no', self::C_STR_FOOTNOTES_STYLING_BEFORE => '[', self::C_STR_FOOTNOTES_STYLING_AFTER => ']', - self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ENABLED => 'yes', + // Referrers in labels. + self::C_STR_FOOTNOTES_LABEL_ISSUE_SOLUTION => 'none', + // Tooltips. + self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ENABLED => 'yes', self::C_STR_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_STR_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, - - // 2.5.4 fast-tracked. - self::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER => '[[/tooltip]]', - self::C_STR_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. + // Tooltip position. 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, - - // 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_MOUSE_OVER_BOX_OFFSET_X => 0, self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X => -50, + self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y => -7, self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y => 24, + + // Tooltip dimensions. + self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH => 450, self::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH => 400, - // Tooltip display durations. - // Called mouse over box not tooltip for consistency. + // Tooltip timing. 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. + // Tooltip truncation. + self::C_STR_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED => 'yes', + self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH => 200, + self::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL => 'Continue reading', + + // Tooltip text. + self::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER => '[[/tooltip]]', + self::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE => 'no', + self::C_STR_FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR => ' — ', + + // Tooltip appearance. self::C_STR_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_COLOR => '#000000', 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. + // Your existing Custom CSS code. self::C_STR_CUSTOM_CSS => '', ), + // Scope and priority. '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.. + // WordPress hooks with priority level. self::C_STR_EXPERT_LOOKUP_THE_TITLE => '', - - self::C_STR_EXPERT_LOOKUP_THE_CONTENT => 'checked', - - // And the_excerpt is disabled by default following @nikelaos in. - // . - // . - self::C_STR_EXPERT_LOOKUP_THE_EXCERPT => '', - - self::C_STR_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_STR_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_STR_EXPERT_LOOKUP_THE_CONTENT => 'checked', self::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL => 98, + + self::C_STR_EXPERT_LOOKUP_THE_EXCERPT => '', self::C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL => PHP_INT_MAX, + + self::C_STR_EXPERT_LOOKUP_WIDGET_TITLE => '', self::C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL => PHP_INT_MAX, + + self::C_STR_EXPERT_LOOKUP_WIDGET_TEXT => '', self::C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL => 98, ), + // Custom CSS. 'footnotes_storage_custom_css' => array( + // Your existing Custom CSS code. self::C_STR_CUSTOM_CSS_LEGACY_ENABLE => 'yes', + + // Custom CSS. self::C_STR_CUSTOM_CSS_NEW => '', ), @@ -1099,14 +1517,18 @@ class MCI_Footnotes_Settings { } /** - * Loads all Settings from specified Settings Container. + * Loads all settings from specified settings container. * * @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 + * - Bugfix: Removed the 'trim' function to allow leading and trailing whitespace in settings text boxes, thanks to @compasscare bug report. + * + * @reporter @compasscare + * @link https://wordpress.org/support/topic/leading-space-in-footnotes-tag/ + * + * @since 1.5.2 + * @param int $p_int_index Settings container array key index. + * @return array Settings loaded from defaults if container is empty (first usage). */ private function load( $p_int_index ) { // Load all settings from container. @@ -1126,14 +1548,6 @@ class MCI_Footnotes_Settings { $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; } diff --git a/class/task.php b/class/task.php index e39a7e4..e61b155 100644 --- a/class/task.php +++ b/class/task.php @@ -12,7 +12,7 @@ * @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. + * @since 2.0.6 Bugfix: Infinite scroll: debug autoload by adding post ID, thanks to @docteurfitness issue report and code contribution. * @since 2.0.6 Bugfix: Priority level back to PHP_INT_MAX (ref container positioning not this plugin’s responsibility). * @since 2.0.6 Bugfix: Reference container: fix line breaking behavior in footnote number clusters. * @since 2.0.7 BUGFIX: Hooks: Default-disable 'the_post', thanks to @spaceling @markcheret @nyamachi @whichgodsaves @spiralofhope2 @mmallett @andreasra @widecast @ymorin007 @tashi1es bug reports. @@ -59,7 +59,7 @@ * @since 2.2.10 Bugfix: Reference container: add option for table borders to restore pre-2.0.0 design, thanks to @noobishh issue report. * @since 2.2.10 Bugfix: Reference container, tooltips: URL wrap: support also file transfer protocol URLs. * @since 2.3.0 Bugfix: Reference container: convert top padding to margin and make it a setting, thanks to @hamshe bug report. - * @since 2.3.0 Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro bug report, thanks to @martinneumannat code contribution. + * @since 2.3.0 Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro issue report, thanks to @martinneumannat issue report and code contribution. * @since 2.3.0 Bugfix: Dashboard: Custom CSS: swap migration Boolean, meaning 'show legacy' instead of 'migration complete', due to storage data structure constraints. * @since 2.4.0 Adding: Footnote delimiters: syntax validation for balanced footnote start and end tag short codes. * @since 2.4.0 Bugfix: Scroll offset: initialize to safer one third window height for more robustness, thanks to @lukashuggenberg bug report. @@ -80,6 +80,8 @@ * @since 2.5.5 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.6 Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. * @since 2.5.7 Bugfix: Process: fix footnote duplication by emptying the footnotes list every time the search algorithm is run on the content, thanks to @inoruhana bug report. + * @since 2.5.11 Bugfix: Forms: remove footnotes from input field values, thanks to @bogosavljev bug report. + * @since 2.5.14 Bugfix: Footnote delimiter short codes: fix numbering bug by cross-editor HTML escapement schema harmonization, thanks to @patrick_here @alifarahani8000 @gova bug reports. */ // If called directly, abort. @@ -88,15 +90,14 @@ if ( ! defined( 'ABSPATH' ) ) { } /** - * Searches and replaces the footnotes. - * Generates the reference container. + * Searches and replaces the footnotes and generates the reference container. * * @since 1.5.0 */ class MCI_Footnotes_Task { /** - * Contains all footnotes found on current public page. + * Contains all footnotes found in the searched content. * * @since 1.5.0 * @var array @@ -122,16 +123,16 @@ class MCI_Footnotes_Task { /** * Autoload a.k.a. infinite scroll, or archive view. * - * - Bugfix: Infinite scroll: debug autoload by adding post ID, thanks to @docteurfitness code contribution + * - Bugfix: Infinite scroll: debug autoload by adding post ID, thanks to @docteurfitness issue report and code contribution * - * @since 2.0.6 - * @var int + * @reporter @docteurfitness + * @link https://wordpress.org/support/topic/auto-load-post-compatibility-update/ * * @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/ + * @since 2.0.6 + * @var int * * 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. @@ -143,14 +144,13 @@ class MCI_Footnotes_Task { * * - 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 every time after a reference container is inserted + * @since 2.2.9 + * @date 2020-12-25T0338+0100 + * @var int Incremented every 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 @@ -159,53 +159,18 @@ class MCI_Footnotes_Task { public static $a_int_reference_container_id = 1; /** - * Whether tooltips are enabled. Actual value depends on settings. - * - * - Bugfix: Templates: optimize template load and processing based on settings, thanks to @misfist code contribution. - * - * @since 2.4.0 - * @date 2021-01-04T1355+0100 - * - * @contributor 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 - * - * Template process and script / stylesheet load optimization. - * Streamline process depending on tooltip enabled status. - * Load tooltip inline script only if jQuery tooltips are enabled. - */ - public static $a_bool_tooltips_enabled = false; - - /** - * Whether alternative tooltips are enabled. Actual value depends on settings. - * - * @since 2.4.0 - * - * @var bool - */ - public static $a_bool_alternative_tooltips_enabled = false; - - /** - * Hard links for AMP compatibility + * 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/ * + * @since 2.0.4 * - * - 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 + * - Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro issue report, thanks to @martinneumannat issue report and code contribution. * * @contributor @martinneumannat * @link https://wordpress.org/support/topic/making-it-amp-compatible/ @@ -213,19 +178,11 @@ class MCI_Footnotes_Task { * @reporter @psykonevro * @link https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/ * - * The official AMP plugin strips off JavaScript, breaking Footnotes’ - * animated scrolling. - * When the alternative reference container is enabled, hard links are too. - * - * Used both in search() and reference_container(), these need to be class variables. - */ - /** - * Whether hard links are enabled. - * * @since 2.3.0 * @var bool + * A property because used both in search() and reference_container(). */ - public static $a_bool_hard_links_enable = false; + public static $a_bool_hard_links_enabled = false; /** * The referrer slug. @@ -252,7 +209,7 @@ class MCI_Footnotes_Task { private static $a_str_link_ids_separator = '+'; /** - * Contains the concatenated link. + * Contains the concatenated fragment ID base. * * @since 2.3.0 * @var str @@ -267,16 +224,14 @@ class MCI_Footnotes_Task { * @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 * + * @since 2.4.0 + * @date 2021-01-03T2055+0100 + * @date 2021-01-04T0504+0100 * @var int * * Websites may use high fixed headers not contracting at scroll. @@ -292,20 +247,17 @@ class MCI_Footnotes_Task { * * - 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 + * @reporter @docteurfitness + * @link https://wordpress.org/support/topic/update-2-1-3/ * * @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/ + * @since 2.1.4 + * @date 2020-11-25T1306+0100 + * @date 2020-11-26T1051+0100 * - * - 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 + * - Adding: Referrers and backlinks: optional hard links for AMP compatibility, thanks to @psykonevro issue report, thanks to @martinneumannat issue report and code contribution. * * @contributor @martinneumannat * @link https://wordpress.org/support/topic/making-it-amp-compatible/ @@ -313,6 +265,9 @@ class MCI_Footnotes_Task { * @reporter @psykonevro * @link https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/ * + * @since 2.3.0 + * @date 2020-12-30T2313+0100 + * * 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. @@ -328,9 +283,8 @@ class MCI_Footnotes_Task { * 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_hard_links_enable - * - * Used both in search() and reference_container(), these need to be class variables. + * @see self::$a_bool_hard_links_enabled + * A property because used both in search() and reference_container(). */ /** @@ -362,12 +316,12 @@ class MCI_Footnotes_Task { * * - 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/ * + * @since 2.5.2 + * @date 2021-01-19T2223+0100 + * * 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. @@ -399,7 +353,43 @@ class MCI_Footnotes_Task { public static $a_bool_mirror_tooltip_text = false; /** - * Footnote delimiter syntax validation. + * Footnote delimiter start short code. + * + * @since 1.5.0 (constant, variable) + * @since 2.6.2 (property) + * @var str + */ + public static $a_str_start_tag = ''; + + /** + * Footnote delimiter end short code. + * + * @since 1.5.0 (constant, variable) + * @since 2.6.2 (property) + * @var str + */ + public static $a_str_end_tag = ''; + + /** + * Footnote delimiter start short code in regex format. + * + * @since 2.4.0 (variable) + * @since 2.6.2 (property) + * @var str + */ + public static $a_str_start_tag_regex = ''; + + /** + * Footnote delimiter end short code in regex format. + * + * @since 2.4.0 (variable) + * @since 2.6.2 (property) + * @var str + */ + public static $a_str_end_tag_regex = ''; + + /** + * Footnote delimiter syntax validation enabled. * * - Adding: Footnote delimiters: syntax validation for balanced footnote start and end tag short codes. * @@ -438,55 +428,6 @@ class MCI_Footnotes_Task { */ public function register_hooks() { - /** - * 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_the_content_priority =< 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_the_title_priority = intval( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL ) ); $l_int_the_content_priority = intval( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL ) ); @@ -502,61 +443,62 @@ class MCI_Footnotes_Task { $l_int_widget_text_priority = ( -1 === $l_int_widget_text_priority ) ? PHP_INT_MAX : $l_int_widget_text_priority; // Append custom css to the header. - add_filter( 'wp_head', array( $this, 'wp_head' ), PHP_INT_MAX ); + add_filter( 'wp_head', array( $this, 'footnotes_output_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 ); + add_filter( 'wp_footer', array( $this, 'footnotes_output_footer' ), PHP_INT_MAX ); if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_TITLE ) ) ) { - add_filter( 'the_title', array( $this, 'the_title' ), $l_int_the_title_priority ); + add_filter( 'the_title', array( $this, 'footnotes_in_title' ), $l_int_the_title_priority ); } // Configurable priority level for reference container relative positioning; default 98. if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_CONTENT ) ) ) { - add_filter( 'the_content', array( $this, 'the_content' ), $l_int_the_content_priority ); + add_filter( 'the_content', array( $this, 'footnotes_in_content' ), $l_int_the_content_priority ); /** * 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 + * @reporter @vitaefit + * @link https://wordpress.org/support/topic/footnote-doesntwork-on-category-page/ * * @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/ + * @since 2.5.0 + * @date 2021-01-05T1402+0100 * * 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_the_content_priority ); + add_filter( 'term_description', array( $this, 'footnotes_in_content' ), $l_int_the_content_priority ); /** * 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/ + * + * @since 2.5.1 + * @date 2021-01-18T2038+0100 */ - add_filter( 'pum_popup_content', array( $this, 'the_content' ), $l_int_the_content_priority ); + add_filter( 'pum_popup_content', array( $this, 'footnotes_in_content' ), $l_int_the_content_priority ); } if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_THE_EXCERPT ) ) ) { - add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), $l_int_the_excerpt_priority ); + add_filter( 'the_excerpt', array( $this, 'footnotes_in_excerpt' ), $l_int_the_excerpt_priority ); + add_filter( 'get_the_excerpt', array( $this, 'footnotes_in_excerpt' ), $l_int_the_excerpt_priority ); } if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_WIDGET_TITLE ) ) ) { - add_filter( 'widget_title', array( $this, 'widget_title' ), $l_int_widget_title_priority ); + add_filter( 'widget_title', array( $this, 'footnotes_in_widget_title' ), $l_int_widget_title_priority ); } if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_EXPERT_LOOKUP_WIDGET_TEXT ) ) ) { - add_filter( 'widget_text', array( $this, 'widget_text' ), $l_int_widget_text_priority ); + add_filter( 'widget_text', array( $this, 'footnotes_in_widget_text' ), $l_int_widget_text_priority ); } /** @@ -577,13 +519,6 @@ class MCI_Footnotes_Task { * * - 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 * @@ -617,6 +552,11 @@ class MCI_Footnotes_Task { * @reporter @tashi1es * @link https://wordpress.org/support/topic/footnotes-appear-in-random-places-on-academic-website/#post-13630495 * + * @since 2.0.7 + * @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 * * - UPDATE: Hooks: remove 'the_post', the plugin stops supporting this hook. * @@ -645,22 +585,40 @@ class MCI_Footnotes_Task { * @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() { + public function footnotes_output_head() { // Insert start tag without switching out of PHP. echo "\r\n