Skip to content

Commit

Permalink
Refactor Roots_Sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
swalkinshaw committed Oct 2, 2012
1 parent 85596e1 commit 7f5eea8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/config.php
Expand Up @@ -16,9 +16,9 @@
* 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(
Expand All @@ -34,7 +34,7 @@ function roots_display_sidebar() {
)
);

return $exclude->display;
return $sidebar_config->display;
}

// #main CSS classes
Expand Down
14 changes: 5 additions & 9 deletions lib/sidebar.php
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 7f5eea8

Please sign in to comment.