development 2.3.1d0 for forum

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2448740 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
pewgeuges 2021-01-01 05:52:49 +00:00
parent 62f3b5c360
commit 919e76bdef
7 changed files with 207 additions and 92 deletions

View file

@ -36,8 +36,9 @@
* @since 2.3.0 add settings for hard links, thanks to @psykonevro and @martinneumannat 2020-12-29T1322+0100
* @see <https://wordpress.org/support/topic/making-it-amp-compatible/>
* @see <https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/>
* @since 2.3.1 footnote shortcode syntax validation 2021-01-01T0624+0100
*
* Last modified: 2020-12-31T0801+0100
* Last modified: 2021-01-01T0639+0100
*/
/**
@ -371,6 +372,11 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
// Custom (user-defined) start and end tags bracketing the footnote text inline:
"userdefined" => __('custom short code', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
);
// options for the syntax validation:
$l_arr_Enable = array(
"yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
);
// load template file
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-start-end");
@ -391,6 +397,10 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
"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:
"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 an unclosed opening tag shortcode, a warning displays below the post title.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
)
);
// display template with replaced placeholders

View file

@ -37,8 +37,9 @@
* @see <https://wordpress.org/support/topic/reference-container-in-elementor/#post-13786635>
* @since 2.3.0 swap Custom CSS migration Boolean from 'migration complete' to 'show legacy' 2020-12-27T1243+0100
* @since 2.3.0 referrers, reference container: settings for anchor slugs 2020-12-31T1429+0100
* @since 2.3.1 footnote shortcode syntax validation 2021-01-01T0624+0100
*
* Last modified: 2020-12-31T1429+0100
* Last modified: 2021-01-01T0624+0100
*/
@ -565,6 +566,18 @@ class MCI_Footnotes_Settings {
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";
/**
* Settings container key for shortcode syntax validation
*
* @since 2.3.1
* @var bool
*
* 2021-01-01T0616+0100
*/
const C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE = "footnotes_inputfield_shortcode_syntax_validation_enable";
/**
* SETTINGS STORAGE
*/
@ -618,6 +631,8 @@ class MCI_Footnotes_Settings {
self::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED => '',
self::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED => '',
self::C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE => 'yes',
self::C_STR_FOOTNOTES_COUNTER_STYLE => 'arabic_plain',
self::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES => 'yes',

View file

@ -64,8 +64,9 @@
* @see <https://wordpress.org/support/topic/making-it-amp-compatible/>
* @see <https://wordpress.org/support/topic/footnotes-is-not-amp-compatible/>
* @since 2.3.0 swap Custom CSS migration Boolean from 'migration complete' to 'show legacy' 2020-12-27T1243+0100
* @since 2.3.1 syntax validation for balanced footnote start and end tags 2021-01-01T0227+0100
*
* Last modified: 2020-12-31T1234+0100
* Last modified: 2021-01-01T0642+0100
*/
// If called directly, abort:
@ -196,6 +197,24 @@ class MCI_Footnotes_Task {
public static $l_str_LinkOpenTag = '';
public static $l_str_LinkCloseTag = '';
/**
* SYNTAX VALIDATION
*
* This part of the algorithm first checks for balanced footnote opening and closing tag
* short codes. The first encountered error triggers the display of a warning below the
* post title and cancellation of further parsing.
*
* Unbalanced short codes have caused significant trouble because they are hard to detect.
* Any compiler or other tool reports syntax errors in the first place. Footnotes exception
* is considered a design flaw, and the feature is released as a bug fix after overdue 2.3.0
* released in urgency to provide AMP compat before 2021.
*
* @since 2.3.1
* @var bool
*/
public static $l_bool_SyntaxErrorFlag = false;
public static $l_bool_SyntaxErrorShow = true;
/**
@ -753,11 +772,41 @@ class MCI_Footnotes_Task {
$l_str_StartingTag = htmlspecialchars($l_str_StartingTag);
$l_str_EndingTag = htmlspecialchars($l_str_EndingTag);
}
// if footnotes short code is empty, return the content without changes
if (empty($l_str_StartingTag) || empty($l_str_EndingTag)) {
return $p_str_Content;
}
// 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))) {
$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';
preg_match( $l_str_ValidationRegex, $p_str_Content, $p_arr_ErrorLocation );
if ( empty( $p_arr_ErrorLocation ) ) {
self::$l_bool_SyntaxErrorShow = false;
}
// prevent generating and inserting the warning multiple times:
if ( self::$l_bool_SyntaxErrorShow ) {
$l_str_ErrorSpotString = strip_tags($p_arr_ErrorLocation[1]);
$l_str_SyntaxErrorWarning = '<div class="footnotes_validation_error"><p>';
$l_str_SyntaxErrorWarning .= 'WARNING: unbalanced footnote start tag short code before:';
$l_str_SyntaxErrorWarning .= '</p><p>“';
$l_str_SyntaxErrorWarning .= $l_str_ErrorSpotString;
$l_str_SyntaxErrorWarning .= '”</p></div>';
$p_str_Content = $l_str_SyntaxErrorWarning . $p_str_Content;
self::$l_bool_SyntaxErrorShow = false;
return $p_str_Content;
}
}
// load referrer templates if footnotes text not hidden:
if (!$p_bool_HideFootnotesText) {
// load two template files:
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE))) {

View file

@ -5,7 +5,7 @@
* Created-Time: 16:21
* Since: 1.0
*
* Version: 2.3.0
* Version: 2.3.1
*
* Classes added to public.css may be added to the
* list documenting CSS classes for Custom CSS if
@ -20,8 +20,9 @@
* @since 2.1.6 set z-index to maximum 2147483647 to address display issues with overlay content, thanks to @russianicons
* @see <https://wordpress.org/support/topic/counter-styles-not-working/>
* @since 2.3.0 offset anchors for optional hard links
* @since 2.3.1 validation error warning box
*
* Last modified: 2020-12-31T1211+0100
* Last modified: 2021-01-01T0642+0100
*/
@ -51,6 +52,39 @@ css/settings.css
color: #545f5a;
}
/*****************************************************
Validation error warning displayed below post title
The presence of unbalanced footnote start short codes
significantly alters the post display and may cause an
issue with missing content or footnotes, while it may
be hard to detect in long posts and under deadline.
A validation check displays a warning box below the
post title, populated with the first instance of a
content snippet preceded by an unbalanced start tag
short code.
@since 2.3.1
*/
.footnotes_validation_error {
border: 4px solid red;
padding: 20px;
background: #ff000055;
}
.footnotes_validation_error p:first-child {
font-size: 20px;
font-weight: bold;
text-align: center;
}
.footnotes_validation_error p:last-child {
font-size: 12px;
text-align: start;
}
/*****************************************************
Long URLs in Unicode-non-compliant user agents

View file

@ -4,12 +4,12 @@
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
Version: 2.3.0
Version: 2.3.1d0
Author URI: http://cheret.de/plugins/footnotes-2/
Text Domain: footnotes
Domain Path: /languages
*/
define( 'FOOTNOTES_VERSION', '2.3.0' );
define( 'FOOTNOTES_VERSION', '2.3.1d0' );
/*
Copyright 2020 Mark Cheret (email: mark@cheret.de)

View file

@ -80,6 +80,9 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest**
== Changelog ==
= 2.3.1 =
- Bugfix: Shortcodes: syntax validation for balanced footnote start and end tag short codes
= 2.3.0 =
- Add: optional hard links in referrers and backlinks for AMP compatibility, thanks to @psykonevro and @martinneumannat
- Bugfix: Reference container: convert top padding to margin and make it a setting, thanks to @hamshe

View file

@ -1,4 +1,4 @@
<table id="settings_styling" class="widefat fixed">
<table id="settings_start_end" class="widefat fixed">
<tbody>
<tr>
<td>[[label-short-code-start]]</td>
@ -14,6 +14,10 @@
<span>[[short-code-end-user]]</span>
</td>
</tr>
<tr>
<td>[[label-syntax]]</td>
<td>[[syntax]] <span class="footnotes_notice">[[notice-syntax]]</span></td>
</tr>
</tbody>
</table>
<script type="text/javascript">