Refactor Roots_Sidebar
This commit is contained in:
@@ -16,9 +16,9 @@ add_theme_support('bootstrap-top-navbar'); // Enable Bootstrap's fixed navbar
|
|||||||
* See lib/sidebar.php for more details
|
* See lib/sidebar.php for more details
|
||||||
*/
|
*/
|
||||||
function roots_display_sidebar() {
|
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
|
* Any of these conditional tags that return true won't show the sidebar
|
||||||
*/
|
*/
|
||||||
array(
|
array(
|
||||||
@@ -34,7 +34,7 @@ function roots_display_sidebar() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $exclude->display;
|
return $sidebar_config->display;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #main CSS classes
|
// #main CSS classes
|
||||||
|
|||||||
@@ -13,22 +13,18 @@
|
|||||||
class Roots_Sidebar {
|
class Roots_Sidebar {
|
||||||
private $conditionals;
|
private $conditionals;
|
||||||
private $templates;
|
private $templates;
|
||||||
|
|
||||||
public $display = true;
|
public $display = true;
|
||||||
|
|
||||||
function __construct($conditionals = array(), $templates = array()) {
|
function __construct($conditionals = array(), $templates = array()) {
|
||||||
$this->conditionals = $conditionals;
|
$this->conditionals = $conditionals;
|
||||||
$this->templates = $templates;
|
$this->templates = $templates;
|
||||||
|
|
||||||
foreach($this->conditionals as $conditional_tag) {
|
$conditionals = array_map($this->check_conditional_tag, $this->conditionals);
|
||||||
if ($this->check_conditional_tag($conditional_tag)) {
|
$templates = array_map($this->check_page_template, $this->templates);
|
||||||
$this->display = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($this->templates as $page_template) {
|
if (in_array(true, $conditionals) || in_array(true, $templates)) {
|
||||||
if ($this->check_page_template($page_template)) {
|
$this->display = false;
|
||||||
$this->display = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user