diff --git a/class/dashboard/subpage-main.php b/class/dashboard/subpage-main.php index 24505c5..ea93d1b 100644 --- a/class/dashboard/subpage-main.php +++ b/class/dashboard/subpage-main.php @@ -526,7 +526,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { '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 viewport', '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 ), @@ -630,11 +630,11 @@ 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. @@ -646,10 +646,10 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_Layout_Engine { // Replace all placeholders. $l_obj_template->replace( array( - // Translators: %s: Plugin logo. + // 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 ), ) @@ -685,9 +685,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' ), + '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. - 'description-excerpts' => sprintf( __( 'In some themes, the %s plugin is indispensable to display footnotes in excerpts. Footnotes can be disabled in excerpts. To do so, please set this option to No.', 'footnotes' ), 'Advanced Excerpt' ), + // 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. @@ -803,7 +804,7 @@ 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. + // 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 . '' ), ) diff --git a/class/settings.php b/class/settings.php index cd28d99..c8defe0 100644 --- a/class/settings.php +++ b/class/settings.php @@ -128,6 +128,9 @@ class MCI_Footnotes_Settings { * @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'; @@ -244,6 +247,8 @@ class MCI_Footnotes_Settings { * @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. + * @see C_STR_FOOTNOTES_IN_EXCERPT * @var str */ const C_STR_EXPERT_LOOKUP_THE_EXCERPT = 'footnote_inputfield_expert_lookup_the_excerpt'; @@ -1326,7 +1331,7 @@ class MCI_Footnotes_Settings { self::C_STR_LINK_ELEMENT_ENABLED => 'yes', // Footnotes in excerpts. - self::C_STR_FOOTNOTES_IN_EXCERPT => 'no', + self::C_STR_FOOTNOTES_IN_EXCERPT => 'yes', // Footnotes love. self::C_STR_FOOTNOTES_LOVE => 'no', @@ -1411,7 +1416,7 @@ class MCI_Footnotes_Settings { 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_STR_EXPERT_LOOKUP_THE_EXCERPT => 'checked', self::C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL => PHP_INT_MAX, self::C_STR_EXPERT_LOOKUP_WIDGET_TITLE => '', diff --git a/class/task.php b/class/task.php index 7ae8f7e..792372f 100644 --- a/class/task.php +++ b/class/task.php @@ -1100,25 +1100,6 @@ class MCI_Footnotes_Task { */ public function footnotes_in_content( $p_str_content ) { - /** - * Empties the footnotes list every time Footnotes is run when the_content hook is called. - * - * - 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. - * - * @reporter @inoruhana - * @link https://wordpress.org/support/topic/footnote-duplicated-in-the-widget/ - * - * @since 2.5.7 - * Under certain circumstances, footnotes were duplicated, because the footnotes list was - * not emptied every time before the search algorithm was run. That happened eg when both - * the reference container resides in the widget area, and the YOAST SEO plugin is active - * and calls the hook the_content to generate the Open Graph description, while Footnotes - * is set to avoid missing out on the footnotes (in the content) by hooking in as soon as - * the_content is called, whereas at post end Footnotes seems to hook in the_content only - * the time it’s the blog engine processing the post for display and appending the refs. - */ - self::$a_arr_footnotes = array(); - // phpcs:disable WordPress.PHP.YodaConditions.NotYoda // Appends the reference container if set to "post_end". return $this->exec( $p_str_content, 'post_end' === MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION ) ); @@ -1126,12 +1107,14 @@ class MCI_Footnotes_Task { } /** - * Replaces existing excerpt with new from scratch if enabled, else does nothing. + * Replaces existing excerpt with a new one generated on the basis of the post. * * @since 1.5.0 * @param string $p_str_excerpt Excerpt content. * @return string $p_str_excerpt Excerpt as-is. - * The input is already the processed excerpt, no more foonotes to search. + * The input was already the processed excerpt, no more footnotes to search. + * @since 2.6.2 Debug No option. + * @since 2.6.3 Debug Yes option, the setting becomes fully effective. */ public function footnotes_in_excerpt( $p_str_excerpt ) { if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_IN_EXCERPT ) ) ) { @@ -1142,9 +1125,9 @@ class MCI_Footnotes_Task { } /** - * Generates excerpt from scratch. + * Generates excerpt on the basis of the post. * - * - Bugfix: Excerpts: debug the 'No' option by generating excerpts from scratch without footnotes, thanks to @nikelaos @markcheret @martinneumannat bug reports. + * - Bugfix: Excerpts: debug the 'No' option by generating excerpts on the basis of the post without footnotes, thanks to @nikelaos @markcheret @martinneumannat bug reports. * * @reporter @nikelaos * @link https://wordpress.org/support/topic/jquery-comes-up-in-feed-content/ @@ -1165,7 +1148,7 @@ class MCI_Footnotes_Task { */ public function generate_excerpt( $p_str_content ) { - // Discard existing excerpt and start from scratch. + // Discard existing excerpt and start on the basis of the post. $p_str_content = get_the_content( get_the_id() ); // Get delimiter shortcodes and unify them. @@ -1195,9 +1178,9 @@ class MCI_Footnotes_Task { } /** - * Generates excerpt with footnotes from scratch. + * Generates excerpt with footnotes on the basis of the post. * - * - Bugfix: Excerpts: debug the 'Yes' option by generating excerpts with footnotes from scratch, thanks to @nikelaos @martinneumannat bug reports. + * - Bugfix: Excerpts: debug the 'Yes' option by generating excerpts with footnotes on the basis of the posts, thanks to @nikelaos @martinneumannat bug reports. * * @reporter @nikelaos * @link https://wordpress.org/support/topic/jquery-comes-up-in-feed-content/ @@ -1216,7 +1199,7 @@ class MCI_Footnotes_Task { */ public function generate_excerpt_with_footnotes( $p_str_content ) { - // Discard existing excerpt and start from scratch. + // Discard existing excerpt and start on the basis of the post. $p_str_content = get_the_content( get_the_id() ); // Get delimiter shortcodes and unify them. @@ -1237,13 +1220,22 @@ class MCI_Footnotes_Task { $l_str_excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' ); // Safeguard the footnotes. - preg_match_all( '#' . self::$a_str_start_tag_regex . '.+?' . self::$a_str_end_tag_regex . '#', $p_str_content, $p_arr_saved_footnotes ); + preg_match_all( + '#' . self::$a_str_start_tag_regex . '.+?' . self::$a_str_end_tag_regex . '#', + $p_str_content, + $p_arr_saved_footnotes, + ); - // Prevent the footnotes from altering the excerpt. - $p_str_content = preg_replace( '#' . self::$a_str_start_tag_regex . '.+?' . self::$a_str_end_tag_regex . '#', '5ED84D6', $p_str_content ); + // Prevent the footnotes from altering the excerpt: previously hard-coded '5ED84D6'. + $l_int_placeholder = '@' . mt_rand( 100000000, 2147483647 ) . '@'; + $p_str_content = preg_replace( + '#' . self::$a_str_start_tag_regex . '.+?' . self::$a_str_end_tag_regex . '#', + $l_int_placeholder, + $p_str_content, + ); // Replace line breaking markup with a separator. - $l_str_separator = ' — '; + $l_str_separator = ' '; $p_str_content = preg_replace( '#
#', $l_str_separator, $p_str_content ); $p_str_content = preg_replace( '#
#', $l_str_separator, $p_str_content ); $p_str_content = preg_replace( '#<(p|li|div)[^>]*>#', $l_str_separator, $p_str_content ); @@ -1278,8 +1270,13 @@ class MCI_Footnotes_Task { // Readd footnotes in excerpt. $l_int_index = 0; - while ( 0 !== preg_match( '#5ED84D6#', $p_str_content ) ) { - $p_str_content = preg_replace( '#5ED84D6#', $p_arr_saved_footnotes[0][ $l_int_index ], $p_str_content, 1 ); + while ( 0 !== preg_match( '#' . $l_int_placeholder . '#', $p_str_content ) ) { + $p_str_content = preg_replace( + '#' . $l_int_placeholder . '#', + $p_arr_saved_footnotes[0][ $l_int_index ], + $p_str_content, + 1, + ); $l_int_index++; } @@ -1631,6 +1628,30 @@ class MCI_Footnotes_Task { // Post ID to make everything unique wrt infinite scroll and archive view. self::$a_int_post_id = get_the_id(); + /** + * Empties the footnotes list every time Footnotes is run when the_content hook is called. + * + * - 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. + * + * @reporter @inoruhana + * @link https://wordpress.org/support/topic/footnote-duplicated-in-the-widget/ + * + * @since 2.5.7 + * Under certain circumstances, footnotes were duplicated, because the footnotes list was + * not emptied every time before the search algorithm was run. That happened eg when both + * the reference container resides in the widget area, and the YOAST SEO plugin is active + * and calls the hook the_content to generate the Open Graph description, while Footnotes + * is set to avoid missing out on the footnotes (in the content) by hooking in as soon as + * the_content is called, whereas at post end Footnotes seems to hook in the_content only + * the time it’s the blog engine processing the post for display and appending the refs. + * + * @since 2.6.3 Move footnotes list reset from footnotes_in_content() to search(). + * Emptying the footnotes list only when the_content hook is called is ineffective + * when footnotes are processed in generate_excerpt_with_footnotes(). + * Footnotes duplication is prevented also when resetting the list here. + */ + self::$a_arr_footnotes = array(); + // Resets the footnote number. $l_int_footnote_index = 1; @@ -1641,7 +1662,7 @@ class MCI_Footnotes_Task { * Load footnote referrer template file. */ - // Set to null in case anyone is not needed. + // Set to null in case all templates are unnecessary. $l_obj_template = null; $l_obj_template_tooltip = null; diff --git a/footnotes.php b/footnotes.php index 49e9ad9..50b0d07 100755 --- a/footnotes.php +++ b/footnotes.php @@ -4,7 +4,7 @@ * Plugin URI: https://wordpress.org/plugins/footnotes/ * Description: time to bring footnotes to your website! footnotes are known from offline publishing and everybody takes them for granted when reading a magazine. * Author: Mark Cheret - * Package V.: 2.6.3d0 + * Package V.: 2.6.3 * Version: 2.6.3 * CAUTION: THIS V. FIELD IS PARSED FOR UPDATE CONFIGURATION. * Author URI: https://cheret.org/footnotes/ @@ -21,9 +21,9 @@ * @since 2.1.4 * @since 2.5.3 (Hungarian) * @var str - * @lastmodified 2021-03-29T2014+0200 + * @lastmodified 2021-03-30T1135+0200 */ -define( 'C_STR_PACKAGE_VERSION', '2.6.3d0' ); +define( 'C_STR_PACKAGE_VERSION', '2.6.3' ); /** * Enables toggling the stylesheet enqueuing mode from production (true) to development (false). * @see Full docblock below next. diff --git a/readme.txt b/readme.txt index 1a319e5..ab0f335 100755 --- a/readme.txt +++ b/readme.txt @@ -4,9 +4,9 @@ Tags: footnote, footnotes, bibliography, formatting, notes, Post, posts, referen Requires at least: 3.9 Tested up to: 5.7 Requires PHP: 5.6 -Package Version: 2.6.3d0 +Package Version: 2.6.3 Version: 2.6.3 -Stable Tag: 2.6.0 +Stable Tag: 2.6.3 CAUTION: THE S. T. FIELD IS PARSED FOR RELEASE CONFIGURATION. License: GPLv3 or later License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -19,7 +19,7 @@ Cheers for the review, folks! https://www.youtube.com/watch?v=HzHaMAAJwbI **footnotes** aims to be the all-in-one solution for displaying an automatically generated list of references on your Page or Post. The Plugin ships with a set of defaults while also empowering you to control how your footnotes are being displayed. -**footnotes** gives you the ability to display well-formatted footnotes on your WordPress Pages and Posts — those footnotes we know from offline publishing. +**footnotes** gives you the ability to display well-formatted footnotes on your WordPress Pages and Posts, as well as in post excerpts with fully functional tooltips if enabled. = Main Features = - Fully customizable **footnote** start and end shortcodes; @@ -37,7 +37,7 @@ These are a few examples of possible ways to delimit footnotes: 1. Your awesome text((with an awesome footnote)) 2. Your awesome text[ref]with an awesome footnote[/ref] 3. Your awesome text``with an awesome footnote`` -4. Your awesome text`custom-shortcode`with an awesome footnote`custom-shortcode` +4. Your awesome text`custom-start-shortcode`with an awesome footnote`custom-end-shortcode` = Where to get footnotes? = The current version is available on the [WordPress.org plugins platform, Footnotes](https://wordpress.org/plugins/footnotes/). @@ -82,7 +82,10 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest** = 2.6.3 = - Bugfix: Reference container: debug footnotes number text color in the table header cells required for accessibility, thanks to @spaceling bug report. -- Bugfix: Excerpts: debug the 'Yes' option by generating excerpts with footnotes from scratch, thanks to @nikelaos @martinneumannat bug reports. +- Bugfix: Excerpts: debug the 'Yes' option by generating excerpts with footnotes on the basis of the posts, thanks to @nikelaos @martinneumannat bug reports. +- Bugfix: Reference container: debug span elements in backlinks by removing 'event.stopPropagation()' from jQuery scroll down function, thanks to @lolzim bug report. +- Update: Excerpts: set the default value of the debugged 'Footnotes in excerpts' setting to Yes. +- Update: Excerpts: enable the hook 'the_excerpt' by default to make the debugged 'Footnotes in excerpts' setting effective. = 2.6.2 = - Bugfix: Excerpts: debug the 'No' option by generating excerpts from scratch without footnotes, thanks to @nikelaos @markcheret @martinneumannat bug reports. @@ -130,6 +133,7 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest** - Update: Documentation: Readme.txt: informative 'Version' field in sync with 'Version' in 'footnotes.php' for bugfix versions available ahead of the Stable Tag. - Update: Documentation: Readme.txt: informative 'Package Version' field in sync with the 'Package V.' field added in the 'footnotes.php' file header. - Update: Codebase: make PHP code comply to WordPress PHP Coding Standards requirements, thanks to @rumperuu code contribution and refactoring. +- Bugfix: Forms: try to prevent the adverse effect of clicking footnote referrers in labels of input elements by 'event.stopPropagation()' in jQuery scroll down function. - Bugfix: Forms: mitigate the adverse effect of clicking footnote referrers in labels of input elements by an optional, configurable scroll down delay. - Bugfix: Scroll durations: mitigate the downside of delayed scrolling down by optionally enabling asymmetric scroll durations (e.g. fast down, slower up). - Update: Scroll delays: add a setting to configure also a scroll up delay for completeness. diff --git a/templates/public/reference-container.html b/templates/public/reference-container.html index 16b4240..1ddf3df 100644 --- a/templates/public/reference-container.html +++ b/templates/public/reference-container.html @@ -86,9 +86,6 @@ } } function footnote_moveToReference_[[post_id]]_[[container_id]](p_str_TargetID) { - jQuery( 'span' ).click( function( event ) { - event.stopPropagation(); - }); footnote_expand_reference_container_[[post_id]]_[[container_id]](); var l_obj_Target = jQuery('#' + p_str_TargetID); if (l_obj_Target.length) {