From 7f5eea8c69a3ec88a3ff66edd372a3a5fba7da88 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Tue, 2 Oct 2012 15:36:51 -0400 Subject: [PATCH] Refactor Roots_Sidebar --- lib/config.php | 6 +++--- lib/sidebar.php | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/config.php b/lib/config.php index 9ab33df..8e8640d 100644 --- a/lib/config.php +++ b/lib/config.php @@ -16,9 +16,9 @@ add_theme_support('bootstrap-top-navbar'); // Enable Bootstrap's fixed navbar * See lib/sidebar.php for more details */ function roots_display_sidebar() { - $exclude = new Roots_Sidebar( + $sidebar_config = new Roots_Sidebar( /** - * Conditionals tag checks (http://codex.wordpress.org/Conditional_Tags) + * Conditional tag checks (http://codex.wordpress.org/Conditional_Tags) * Any of these conditional tags that return true won't show the sidebar */ array( @@ -34,7 +34,7 @@ function roots_display_sidebar() { ) ); - return $exclude->display; + return $sidebar_config->display; } // #main CSS classes diff --git a/lib/sidebar.php b/lib/sidebar.php index 93d821c..e9841df 100644 --- a/lib/sidebar.php +++ b/lib/sidebar.php @@ -13,22 +13,18 @@ class Roots_Sidebar { private $conditionals; private $templates; + public $display = true; function __construct($conditionals = array(), $templates = array()) { $this->conditionals = $conditionals; $this->templates = $templates; - foreach($this->conditionals as $conditional_tag) { - if ($this->check_conditional_tag($conditional_tag)) { - $this->display = false; - } - } + $conditionals = array_map($this->check_conditional_tag, $this->conditionals); + $templates = array_map($this->check_page_template, $this->templates); - foreach($this->templates as $page_template) { - if ($this->check_page_template($page_template)) { - $this->display = false; - } + if (in_array(true, $conditionals) || in_array(true, $templates)) { + $this->display = false; } }