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

@ -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;
}
}
}