development 2.3.1d1 for forum

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2448961 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
pewgeuges 2021-01-01 21:24:43 +00:00
parent 919e76bdef
commit 3096e8f3b4
6 changed files with 69 additions and 33 deletions

View file

@ -38,7 +38,7 @@
* @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: 2021-01-01T0639+0100
* Last modified: 2021-01-01T1241+0100
*/
/**
@ -400,7 +400,7 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
// 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),
"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),
)
);
// display template with replaced placeholders

View file

@ -66,7 +66,7 @@
* @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: 2021-01-01T0642+0100
* Last modified: 2021-01-01T1239+0100
*/
// If called directly, abort:
@ -212,8 +212,7 @@ class MCI_Footnotes_Task {
* @since 2.3.1
* @var bool
*/
public static $l_bool_SyntaxErrorFlag = false;
public static $l_bool_SyntaxErrorShow = true;
public static $l_bool_SyntaxErrorFlag = true;
@ -748,6 +747,8 @@ class MCI_Footnotes_Task {
* @return string
*
* Edited since 2.0.0
*
* @since 2.3.1 footnote shortcode syntax validation
*/
public function search($p_str_Content, $p_bool_ConvertHtmlChars, $p_bool_HideFootnotesText) {
@ -786,21 +787,21 @@ class MCI_Footnotes_Task {
$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;
self::$l_bool_SyntaxErrorFlag = false;
}
// prevent generating and inserting the warning multiple times:
if ( self::$l_bool_SyntaxErrorShow ) {
if ( self::$l_bool_SyntaxErrorFlag ) {
$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 .= __("WARNING: unbalanced footnote start tag short code before:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
$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;
self::$l_bool_SyntaxErrorFlag = false;
return $p_str_Content;
}

View file

@ -9,11 +9,13 @@
* Edited:
* @since 2.0.3 further minify template content
* @since 2.0.4 regex to delete multiple spaces
*
* @since 2.3.0 support for custom templates in fixed location, while failing to add filter thanks to @misfist 2020-12-19T0606+0100
* @see <https://wordpress.org/support/topic/template-override-filter/#post-13811141>
*
* Last modified: 2020-12-20T0200+0100
*
* @since 2.2.6 support for custom templates in fixed location, while failing to add filter thanks to @misfist 2020-12-19T0606+0100
* @see <https://wordpress.org/support/topic/template-override-filter/>
* @since 2.3.1 templates may be in active theme, thanks to @misfist
* @see <https://wordpress.org/support/topic/template-override-filter/#post-13846598>
*
* Last modified: 2021-01-01T2214+0100
*/
@ -74,11 +76,14 @@ class MCI_Footnotes_Template {
* Edited:
* @since 2.0.3 further minify template content
* @since 2.0.4 regex to delete multiple spaces
*
* @since 2.2.6 support for custom templates 2020-12-19T0606+0100
* @see <https://wordpress.org/support/topic/template-override-filter/>
*
* @since 2.2.6 regex to delete a space before a closing pointy bracket
*
* @since 2.3.0 support for custom templates 2020-12-19T0606+0100
* @see <https://wordpress.org/support/topic/template-override-filter/#post-13811141>
*
* @since 2.3.0 regex to delete space before >
* @since 2.3.1 look for custom template in the active theme
* @see <https://wordpress.stackexchange.com/questions/220942/how-to-get-the-active-themes-slug>
*/
public function __construct($p_str_FileType, $p_str_FileName, $p_str_Extension = "html") {
// no template file type and/or file name set
@ -86,17 +91,28 @@ class MCI_Footnotes_Template {
return;
}
// First look for a custom template:
// First look for a custom template in a 'footnotes-custom' sibling folder:
$l_str_TemplateFile = dirname(__FILE__) . "/../../footnotes-custom/templates/" . $p_str_FileType . "/" . $p_str_FileName . "." . $p_str_Extension;
// else load template from the active theme:
if (!file_exists($l_str_TemplateFile)) {
$l_str_TemplateFile = dirname(__FILE__) . "/../../../themes/";
// get active theme dir name (parent theme unlikely to contain custom templates):
// see <https://wordpress.stackexchange.com/questions/220942/how-to-get-the-active-themes-slug>
$l_str_TemplateFile .= get_stylesheet();
$l_str_TemplateFile .= "/templates/footnotes/" . $p_str_FileName . "." . $p_str_Extension;
// else load internal template:
// get absolute path to the specified template file
$l_str_TemplateFile = dirname(__FILE__) . "/../templates/" . $p_str_FileType . "/" . $p_str_FileName . "." . $p_str_Extension;
// Template file does not exist
if (!file_exists($l_str_TemplateFile)) {
return;
// get absolute path to the specified template file
$l_str_TemplateFile = dirname(__FILE__) . "/../templates/" . $p_str_FileType . "/" . $p_str_FileName . "." . $p_str_Extension;
// do nothing if template file does not exist:
if (!file_exists($l_str_TemplateFile)) {
return;
}
}
}

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

View file

@ -81,6 +81,7 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest**
== Changelog ==
= 2.3.1 =
- Bugfix: Customization: support for custom templates in active theme, thanks to @misfist
- Bugfix: Shortcodes: syntax validation for balanced footnote start and end tag short codes
= 2.3.0 =

View file

@ -1,23 +1,41 @@
note-for-developers.txt
2020-12-19T0609+0100
Last modified: 2020-12-19T0706+0100
Last modified: 2021-01-01T2212+0100
Footnotes plugin for WordPress, v2.3.0 and later
Footnotes plugin for WordPress, v2.2.6 and later
Support for custom templates
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Since v2.3.0, Footnotes can process custom templates.
Since v2.2.6, Footnotes supports custom templates.
To use custom templates, please make a sibling of the "footnotes" folder called "footnotes-custom" containing just the content of templates/public/ with the same structure.
Custom templates may be loaded from a sibling folder 'footnotes-custom'
or since v2.3.1 from a folder 'templates/footnotes/' in the active theme.
Existing homonymous templates on the path wp-content/plugins/footnotes-custom/templates/public/ are loaded instead of their counterparts in wp-content/plugins/footnotes/templates/public/.
See footnotes/class/template.php:67..116
The new location does not need to contain all templates.
E.g. for custom tooltips, you need only one or both of these:
A. Active theme
‾‾‾‾‾‾‾‾‾‾‾‾
Please create a folder 'templates/footnotes/' in your child theme and
store all your public custom templates for Footnotes directly therein.
Existing homonymous templates are loaded instead of their counterparts in
wp-content/plugins/footnotes/templates/public/.
B. Sibling folder
‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Please make a sibling of the "footnotes" folder called 'footnotes-custom' and
the same internal structure and file names as 'footnotes/templates/public/'.
Example for custom tooltips:
footnotes-custom
└── templates
└── public
├── footnote.html
└── tooltip.html
The timing parameters in the inline jQuery script 'tooltip.html' are already
configurable in the dashboard > Referrers and tooltips > Tooltip timing.