From 1aabb0596b2c787755ed12c463a32b52dc74a30e Mon Sep 17 00:00:00 2001 From: QWp6t Date: Fri, 12 Jun 2015 13:57:35 -0700 Subject: [PATCH] Remove ConditonalTagCheck class --- functions.php | 1 - lib/conditional-tag-check.php | 43 ---------------------------------- lib/config.php | 44 ++++++++--------------------------- 3 files changed, 10 insertions(+), 78 deletions(-) delete mode 100644 lib/conditional-tag-check.php diff --git a/functions.php b/functions.php index bfb84adeda..73534fef86 100644 --- a/functions.php +++ b/functions.php @@ -13,7 +13,6 @@ 'lib/utils.php', // Utility functions 'lib/init.php', // Initial theme setup and constants 'lib/wrapper.php', // Theme wrapper class - 'lib/conditional-tag-check.php', // ConditionalTagCheck class 'lib/config.php', // Configuration 'lib/assets.php', // Scripts and stylesheets 'lib/titles.php', // Page titles diff --git a/lib/conditional-tag-check.php b/lib/conditional-tag-check.php deleted file mode 100644 index 61f53b6f16..0000000000 --- a/lib/conditional-tag-check.php +++ /dev/null @@ -1,43 +0,0 @@ -conditionals = $conditionals; - - $conditionals = array_map([$this, 'checkConditionalTag'], $this->conditionals); - - if (in_array(true, $conditionals)) { - $this->result = false; - } - } - - private function checkConditionalTag($conditional) { - if (is_array($conditional)) { - list($tag, $args) = $conditional; - } else { - $tag = $conditional; - $args = false; - } - - if (function_exists($tag)) { - return $args ? $tag($args) : $tag(); - } else { - return false; - } - } -} diff --git a/lib/config.php b/lib/config.php index 20c16bc8d0..c969d533c5 100644 --- a/lib/config.php +++ b/lib/config.php @@ -2,8 +2,6 @@ namespace Roots\Sage\Config; -use Roots\Sage\ConditionalTagCheck; - /** * Enable theme features */ @@ -28,38 +26,16 @@ } /** - * Define which pages shouldn't have the sidebar + * Determine which pages should NOT display the sidebar */ function display_sidebar() { - static $display; - - if (!isset($display)) { - $conditionalCheck = new ConditionalTagCheck( - /** - * Any of these conditional tags that return true won't show the sidebar. - * You can also specify your own custom function as long as it returns a boolean. - * - * To use a function that accepts arguments, use an array instead of just the function name as a string. - * - * Examples: - * - * 'is_single' - * 'is_archive' - * ['is_page', 'about-me'] - * ['is_tax', ['flavor', 'mild']] - * ['is_page_template', 'about.php'] - * ['is_post_type_archive', ['foo', 'bar', 'baz']] - * - */ - [ - 'is_404', - 'is_front_page', - ['is_page_template', 'template-custom.php'] - ] - ); - - $display = apply_filters('sage/display_sidebar', $conditionalCheck->result); - } - - return $display; + $display = !in_array(true, [ + // The sidebar will NOT be displayed if ANY of the following return true. + // @link https://codex.wordpress.org/Conditional_Tags + is_404(), + is_front_page(), + is_page_template('template-custom.php'), + ]); + + return apply_filters('sage/display_sidebar', $display); }