Skip to content

Commit

Permalink
Merge pull request #340 from publishpress/feature/#335-Sidebar_warnin…
Browse files Browse the repository at this point in the history
…g_for_theme_without_sidebar.php_on_custom_template

feature/#335-Sidebar_warning_for_theme_without_sidebar.php_on_custom_template
  • Loading branch information
olatechpro committed Dec 8, 2021
2 parents ce1f0c4 + cd30255 commit 654aa33
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
33 changes: 33 additions & 0 deletions inc/utility-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,37 @@ function pp_series_upgrade_function()

}
}

if (!function_exists('pp_series_locate_template')) {
/**
* Check if template exist in theme/child theme
*
* We wouldn't use wordpress locate_template()
* as it support theme compact which load
* default template for files like sidebar.php
* even if it doesn't exist in theme
*
* @param array $template
* @return void
*/
function pp_series_locate_template($template_names)
{
$located = false;
foreach ( (array) $template_names as $template_name ) {
if ( ! $template_name ) {
continue;
}
if ( file_exists( STYLESHEETPATH . '/' . $template_name ) ) {
$located = STYLESHEETPATH . '/' . $template_name;
break;
} elseif ( file_exists( TEMPLATEPATH . '/' . $template_name ) ) {
$located = TEMPLATEPATH . '/' . $template_name;
break;
}
}

return $located;

}
}
?>
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ v2.7.1- [===unreleased===]
* Added: Allow users to customize buttons #311
* Added: "Click to view" for "Series Table of Contents URL" #320
* Added: Add series group template to PRO version group addon #202
* Fixed: Sidebar warning for theme without sidebar.php on custom template #335

v2.7.0- 2021-11-17
* Fixed: Clarify what HTML is allowed in templates #273
Expand Down
6 changes: 5 additions & 1 deletion seriestoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@
</div><!-- #content -->
</section><!-- #primary -->

<?php get_sidebar(); ?>
<?php
if(pp_series_locate_template( array( 'sidebar.php' ) )){
get_sidebar();
}
?>
<?php get_footer(); ?>

0 comments on commit 654aa33

Please sign in to comment.