From 3096e8f3b4cee81d3ba05631b89c10b2f70be408 Mon Sep 17 00:00:00 2001
From: pewgeuges <73141620+pewgeuges@users.noreply.github.com>
Date: Fri, 1 Jan 2021 21:24:43 +0000
Subject: [PATCH] development 2.3.1d1 for forum
git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2448961 b8457f37-d9ea-0310-8a92-e5e31aec5664
---
class/dashboard/subpage-main.php | 4 +--
class/task.php | 15 +++++-----
class/template.php | 46 +++++++++++++++++++++----------
footnotes.php | 4 +--
readme.txt | 1 +
templates/note-for-developers.txt | 32 ++++++++++++++++-----
6 files changed, 69 insertions(+), 33 deletions(-)
diff --git a/class/dashboard/subpage-main.php b/class/dashboard/subpage-main.php
index de48be7..d35b00f 100644
--- a/class/dashboard/subpage-main.php
+++ b/class/dashboard/subpage-main.php
@@ -38,7 +38,7 @@
* @see
* @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
diff --git a/class/task.php b/class/task.php
index 9fb9d2c..9808c30 100644
--- a/class/task.php
+++ b/class/task.php
@@ -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 = '
';
$p_str_Content = $l_str_SyntaxErrorWarning . $p_str_Content;
- self::$l_bool_SyntaxErrorShow = false;
+ self::$l_bool_SyntaxErrorFlag = false;
return $p_str_Content;
}
diff --git a/class/template.php b/class/template.php
index 6debbc8..ce5786b 100644
--- a/class/template.php
+++ b/class/template.php
@@ -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
- *
- * 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
+ * @since 2.3.1 templates may be in active theme, thanks to @misfist
+ * @see
+ *
+ * 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
+ *
+ * @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
- *
- * @since 2.3.0 regex to delete space before >
+ * @since 2.3.1 look for custom template in the active theme
+ * @see
*/
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
+ $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;
+ }
}
}
diff --git a/footnotes.php b/footnotes.php
index 026b14e..9629b71 100755
--- a/footnotes.php
+++ b/footnotes.php
@@ -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)
diff --git a/readme.txt b/readme.txt
index 65180e6..95c1834 100755
--- a/readme.txt
+++ b/readme.txt
@@ -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 =
diff --git a/templates/note-for-developers.txt b/templates/note-for-developers.txt
index 74b7b93..dc54ea6 100644
--- a/templates/note-for-developers.txt
+++ b/templates/note-for-developers.txt
@@ -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.