update trunk/ in vue of urgent bugfix plus feature release 2.5.0

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2452163 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
pewgeuges 2021-01-07 21:21:29 +00:00
parent 53def2ec48
commit 354b5439f0
27 changed files with 222 additions and 115 deletions

View file

@ -6,7 +6,7 @@
* @author Stefan Herndler
* @since 1.5.0 14.09.14 14:47
*
* Last modified: 2021-01-02T2335+0100
* Last modified: 2021-01-07T2207+0100
*
* Edited:
* @since 2.0.4 restore arrow settings 2020-11-01T0509+0100
@ -39,6 +39,8 @@
* @see <https://wordpress.org/support/topic/making-it-amp-compatible/>
* @see <https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/>
* @since 2.4.0 footnote shortcode syntax validation 2021-01-01T0624+0100
* @since 2.5.0 Shortcode syntax validation: add more information around the setting, thanks to @andreasra
* @see <https://wordpress.org/support/topic/warning-unbalanced-footnote-start-tag-short-code-before/>
*/
/**
@ -98,12 +100,17 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
*/
protected function getSections() {
$l_arr_Tabs = array();
// sync tab name with mirror in task.php:
$l_arr_Tabs[] = $this->addSection("settings", __("General settings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 0, true);
// tab name used in public function CustomCSSMigration()
// sync tab name with mirror in public function CustomCSSMigration():
$l_arr_Tabs[] = $this->addSection("customize", __("Referrers and tooltips", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 1, true);
$l_arr_Tabs[] = $this->addSection("expert", __("Scope and priority", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 2, true);
$l_arr_Tabs[] = $this->addSection("customcss", __("Custom CSS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 3, true);
$l_arr_Tabs[] = $this->addSection("how-to", __("Quick start guide", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false);
return $l_arr_Tabs;
}
@ -132,6 +139,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
protected function getMetaBoxes() {
$l_arr_MetaBoxes = array();
// sync box name with mirror in task.php:
$l_arr_MetaBoxes[] = $this->addMetaBox("settings", "start-end", __("Footnote start and end short codes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "StartEnd");
$l_arr_MetaBoxes[] = $this->addMetaBox("settings", "numbering", __("Footnotes numbering", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Numbering");
$l_arr_MetaBoxes[] = $this->addMetaBox("settings", "scrolling", __("Scrolling behavior", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Scrolling");
@ -340,8 +348,10 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
* @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
* @see <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.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
* @see <https://wordpress.org/support/topic/warning-unbalanced-footnote-start-tag-short-code-before/>
*/
public function StartEnd() {
// footnotes start tag short code options:
@ -384,7 +394,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
$l_obj_Template->replace(
array(
"description" => __("WARNING: Short codes with closing pointy brackets are disabled in the new WordPress Block Editor that disrupts the traditional balanced escapement applied by WordPress Classic Editor.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"description-escapement" => __("WARNING: Short codes with closing pointy brackets are disabled in the new WordPress Block Editor that disrupts the traditional balanced escapement applied by WordPress Classic Editor.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"label-short-code-start" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, __("Footnote start tag short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"short-code-start" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, $l_arr_ShortCodeStart),
@ -395,15 +405,19 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
"short-code-end-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED),
// for script showing/hiding user defined text boxes:
"short-code-start-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START,
"short-code-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,
// option to enable syntax validation:
"description-parentheses" => __("WARNING: Although widespread industry standard, the double parentheses are problematic because they may occur in scripts embedded in the content and be mistaken as a short code.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
// option to enable syntax validation, label mirrored in task.php:
"label-syntax" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, __("Check for balanced shortcodes:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
"syntax" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, $l_arr_Enable),
"notice-syntax" => __("In the presence of a lone start tag shortcode, a warning displays below the post title.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"description-syntax" => __("If the start tag short code is (( or (((, it will not be reported as unbalanced if the following string contains braces hinting that it is a script.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
)
);
// display template with replaced placeholders
@ -550,6 +564,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
* Edited heading 2020-12-12T1453+0100
* @since 2.1.1 more settings and notices, thanks to @nikelaos
* @see <https://wordpress.org/support/topic/doesnt-work-any-more-11/#post-13687068>
* @see <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() {

View file

@ -6,7 +6,7 @@
* @author Stefan Herndler
* @since 1.5.0 14.09.14 10:43
*
* Last modified: 2021-01-02T2340+0100
* Last modified: 2021-01-07T2206+0100
*
* Edited:
* @since 2.0.4 restore arrow settings 2020-11-02T2115+0100

View file

@ -8,7 +8,7 @@
*
* Edited for v2.0.0 and following.
*
* Last modified: 2021-01-04T1623+0100
* Last modified: 2021-01-07T2219+0100
*
* @since 2.0.5 Autoload / infinite scroll support added thanks to code from @docteurfitness
* @see <https://wordpress.org/support/topic/auto-load-post-compatibility-update/>
@ -72,6 +72,12 @@
* @since 2.4.0 set empty reference container label to NNBSP to make it more robust, thanks to @lukashuggenberg 2021-01-04T0504+0100
* @since 2.4.0 optimize template load and process, thanks to @misfist 2021-01-04T1355+0100
* @since 2.4.0 initialize hard link address as empty to fix undefined variable bug, thanks to @a223123131 2021-01-04T1622+0100
* @since 2.5.0 Shortcode syntax validation: exclude certain cases involving scripts, thanks to @andreasra 2021-01-07T0824+0100
* @since 2.5.0 Shortcode syntax validation: complete message with hint about setting, thanks to @andreasra
* @since 2.5.0 Shortcode syntax validation: limit length of quoted string to 300 characters, thanks to @andreasra
* @see <https://wordpress.org/support/topic/warning-unbalanced-footnote-start-tag-short-code-before/>
* @since 2.5.0 Hooks: support the term_description hook, thanks to @vitaefit (feature) and @misfist (hook name)
* @see <https://wordpress.org/support/topic/footnote-doesntwork-on-category-page/>
*/
// If called directly, abort:
@ -247,9 +253,12 @@ class MCI_Footnotes_Task {
* @since 1.5.0
*
* Edited for:
* @since 2.0.5 through v2.0.7 changes to priority 2020-11-02T0330+0100..2020-11-06T1344+0100
* @since 2.1.1 add setting for the_content
* @since 2.1.2 add settings for 4 other hooks 2020-11-19T1248+0100
* @since 2.0.5 through v2.0.7 changes to priority 2020-11-02T0330+0100..2020-11-06T1344+0100
* @since 2.1.1 add setting for the_content
* @since 2.1.2 add settings for 4 other hooks 2020-11-19T1248+0100
*
* @since 2.5.0 support for the term_description hook, thanks to @vitaefit (feature) and @misfist (hook name)
* @see <https://wordpress.org/support/topic/footnote-doesntwork-on-category-page/>
*
* 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
@ -293,6 +302,7 @@ class MCI_Footnotes_Task {
// custom priority level for reference container relative positioning; default 98:
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_CONTENT))) {
add_filter('the_content', array($this, "the_content"), $p_int_TheContentPriority);
add_filter('term_description', array($this, "the_content"), $p_int_TheContentPriority);
}
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_EXPERT_LOOKUP_THE_EXCERPT))) {
@ -305,6 +315,11 @@ class MCI_Footnotes_Task {
add_filter('widget_text', array($this, "widget_text"), $p_int_WidgetTextPriority);
}
// HOOK FOR CATEGORY PAGES:
// 2021-01-05T1402+0100
// see <https://wordpress.org/support/topic/footnote-doesntwork-on-category-page/#post-13866617>
// add_filter('term_description', array($this, "the_content"), $p_int_TheContentPriority);
// REMOVED the_post HOOK 2020-11-08T1839+0100
//
@ -772,6 +787,10 @@ class MCI_Footnotes_Task {
* Edited since 2.0.0
*
* @since 2.4.0 footnote shortcode syntax validation
* @since 2.5.0 Shortcode syntax validation: exclude certain cases involving scripts, thanks to @andreasra 2021-01-07T0824+0100
* @since 2.5.0 Shortcode syntax validation: complete message with hint about setting, thanks to @andreasra
* @since 2.5.0 Shortcode syntax validation: limit length of quoted string to 300 characters, thanks to @andreasra
* @see <https://wordpress.org/support/topic/warning-unbalanced-footnote-start-tag-short-code-before/>
*/
public function search($p_str_Content, $p_bool_ConvertHtmlChars, $p_bool_HideFootnotesText) {
@ -780,7 +799,7 @@ class MCI_Footnotes_Task {
// contains the index for the next footnote on this page
$l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
// contains the starting position for the lookup of a footnote
$l_int_PosStart = 0;
@ -805,9 +824,24 @@ class MCI_Footnotes_Task {
// if footnotes short codes are unbalanced, and syntax validation is not disabled,
// return content with prepended warning:
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE))) {
// convert the shortcodes to regex syntax conformant:
$l_str_StartTagRegex = preg_replace( '#([\(\)\{\}\[\]\*\.\?\!])#', '\\\\$1', $l_str_StartingTag );
$l_str_EndTagRegex = preg_replace( '#([\(\)\{\}\[\]\*\.\?\!])#', '\\\\$1', $l_str_EndingTag );
$l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ').)*?)(' . $l_str_StartTagRegex . '|$)#s';
// apply different regex depending on whether start shortcode is double/triple opening parenthesis:
if ( $l_str_StartingTag == '((' || $l_str_StartingTag == '(((' ) {
// this prevents from catching a script containing e.g. a double opening parenthesis:
$l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ')[^\{\}])*?)(' . $l_str_StartTagRegex . '|$)#s';
} else {
// catch all only if the start shortcode is not double/triple opening parenthesis, i.e. is unlikely to occur in scripts:
$l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ').)*?)(' . $l_str_StartTagRegex . '|$)#s';
}
// check syntax and get error locations:
preg_match( $l_str_ValidationRegex, $p_str_Content, $p_arr_ErrorLocation );
if ( empty( $p_arr_ErrorLocation ) ) {
self::$l_bool_SyntaxErrorFlag = false;
@ -815,15 +849,33 @@ class MCI_Footnotes_Task {
// prevent generating and inserting the warning multiple times:
if ( self::$l_bool_SyntaxErrorFlag ) {
$l_str_ErrorSpotString = strip_tags($p_arr_ErrorLocation[1]);
// get plain text string for error location:
$l_str_ErrorSpotString = strip_tags( $p_arr_ErrorLocation[1] );
// limit string length to 300 characters:
if ( strlen( $l_str_ErrorSpotString ) > 300 ) {
$l_str_ErrorSpotString = substr( $l_str_ErrorSpotString, 0, 299 ) . '…';
}
// compose warning box:
$l_str_SyntaxErrorWarning = '<div class="footnotes_validation_error"><p>';
$l_str_SyntaxErrorWarning .= __("WARNING: unbalanced footnote start tag short code before:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
$l_str_SyntaxErrorWarning .= __("WARNING: unbalanced footnote start tag short code found.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
$l_str_SyntaxErrorWarning .= '</p><p>';
// syntax validation setting in the dashboard under the General settings tab:
$l_str_SyntaxErrorWarning .= sprintf( __("If this warning is irrelevant, please disable the syntax validation feature in the dashboard under %s &gt; %s &gt; %s.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("General settings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Footnote start and end short codes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), __("Check for balanced shortcodes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) );
$l_str_SyntaxErrorWarning .= '</p><p>';
$l_str_SyntaxErrorWarning .= __("Unbalanced start tag short code found before:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
$l_str_SyntaxErrorWarning .= '</p><p>“';
$l_str_SyntaxErrorWarning .= $l_str_ErrorSpotString;
$l_str_SyntaxErrorWarning .= '”</p></div>';
// prepend the warning box to the content:
$p_str_Content = $l_str_SyntaxErrorWarning . $p_str_Content;
// checked, set flag to false to prevent duplicate warning:
self::$l_bool_SyntaxErrorFlag = false;
return $p_str_Content;
@ -1276,10 +1328,10 @@ class MCI_Footnotes_Task {
// INDEX COLUMN WITH ONE BACKLINK PER TABLE ROW
// if enabled, and for the case the footnote is single, compose hard link:
// define variable as empty for the reference container if not enabled:
$l_str_HardLinkAddress = '';
if (self::$l_bool_HardLinksEnable) {
// define variable as empty for the reference container if not enabled:
$l_str_HardLinkAddress = '';
if (self::$l_bool_HardLinksEnable) {
// compose fragment ID anchor with offset, for use in reference container, an
// empty span child of empty span to avoid tall dotted rectangles in browser:

View file

@ -6,7 +6,7 @@
* @author Stefan Herndler
* @since 1.5.0 14.09.14 10:58
*
* Last modified: 2021-01-02T2352+0100
* Last modified: 2021-01-07T2209+0100
*
* Edited:
* @since 2.0.3 prettify reference container template
@ -18,6 +18,8 @@
* @see <https://wordpress.org/support/topic/template-override-filter/>
* @since 2.4.0 templates may be in active theme, thanks to @misfist
* @see <https://wordpress.org/support/topic/template-override-filter/#post-13846598>
* @since 2.5.0 Enable template location stack, contributed by @misfist
* @see <https://wordpress.org/support/topic/template-override-filter/#post-13864301>
*/
@ -68,7 +70,7 @@ class MCI_Footnotes_Template {
/**
* Plugin Directory
*
*
* @author Patrizia Lutz @misfist
* @since 2.4.0d3
*
@ -93,7 +95,7 @@ class MCI_Footnotes_Template {
* @see <https://wordpress.org/support/topic/template-override-filter/>
*
* @since 2.2.6 delete a space before a closing pointy bracket
*
*
* @since 2.4.0 look for custom template in the active theme first, thanks to @misfist
* @see <https://wordpress.org/support/topic/template-override-filter/#post-13846598>
*/
@ -105,18 +107,18 @@ class MCI_Footnotes_Template {
/**
* Define plugin root path
*
*
* @since 2.4.0d3
*
*
* @author Patrizia Lutz @misfist
*/
$this->plugin_directory = plugin_dir_path( dirname( __FILE__ ) );
/**
* Modularize functions
*
*
* @since 2.4.0d3
*
*
* @author Patrizia Lutz @misfist
*/
if( $template = $this->get_template( $p_str_FileType, $p_str_FileName, $p_str_Extension ) ) {
@ -173,11 +175,11 @@ class MCI_Footnotes_Template {
return $this->a_str_ReplacedContent;
}
/**
/**
* Process template file
*
*
* @author Patrizia Lutz @misfist
*
*
* @since 2.4.0d3
*
* @param string $template
@ -194,9 +196,9 @@ class MCI_Footnotes_Template {
/**
* Get the template
*
*
* @author Patrizia Lutz @misfist
*
*
* @since 2.4.0d3
*
* @param string $p_str_FileType
@ -221,17 +223,17 @@ class MCI_Footnotes_Template {
/**
* Look in active (child) theme
*/
if ( file_exists( trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name ) ) {
if ( file_exists( trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name ) ) {
$located = trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name;
/**
* Look in parent theme
*/
} elseif ( file_exists( trailingslashit( get_template_directory() ) . $template_directory . $template_name ) ) {
$located = trailingslashit( get_template_directory() ) . $template_directory . $template_name;
/**
* Look custom directory
* Look in custom directory
*/
} elseif ( file_exists( trailingslashit( WP_PLUGIN_DIR ) . $custom_directory . 'templates/' . $template_name ) ) {
$located = trailingslashit( WP_PLUGIN_DIR ) . $custom_directory . 'templates/' . $template_name;