Clarity over cleverness
This commit is contained in:
@@ -22,15 +22,15 @@ function roots_display_sidebar() {
|
|||||||
* 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(
|
||||||
'404',
|
'is_404',
|
||||||
'front_page'
|
'is_front_page'
|
||||||
),
|
),
|
||||||
/**
|
/**
|
||||||
* Page template checks (via is_page_template())
|
* Page template checks (via is_page_template())
|
||||||
* Any of these page templates that return true won't show the sidebar
|
* Any of these page templates that return true won't show the sidebar
|
||||||
*/
|
*/
|
||||||
array(
|
array(
|
||||||
'page-custom'
|
'page-custom.php'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,13 @@
|
|||||||
*
|
*
|
||||||
* If any of the is_* conditional tags or is_page_template(template_file) checks return true, the sidebar will NOT be displayed.
|
* If any of the is_* conditional tags or is_page_template(template_file) checks return true, the sidebar will NOT be displayed.
|
||||||
*
|
*
|
||||||
* @param array list of conditional tags (http://codex.wordpress.org/Conditional_Tags) without the 'is_' prefix
|
* @param array list of conditional tags (http://codex.wordpress.org/Conditional_Tags)
|
||||||
* @param array list of templates without the '.php' extension. These will be checked via is_page_template()
|
* @param array list of page templates. These will be checked via is_page_template()
|
||||||
*
|
*
|
||||||
* @return boolean True will display the sidebar, False will not
|
* @return boolean True will display the sidebar, False will not
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Roots_Sidebar {
|
class Roots_Sidebar {
|
||||||
const EXTENSION = '.php';
|
|
||||||
private $conditionals;
|
private $conditionals;
|
||||||
private $templates;
|
private $templates;
|
||||||
public $display = true;
|
public $display = true;
|
||||||
@@ -34,12 +33,11 @@ class Roots_Sidebar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function check_conditional_tag($conditional_tag) {
|
private function check_conditional_tag($conditional_tag) {
|
||||||
$conditional_tag_function = "is_$conditional_tag";
|
return $conditional_tag();
|
||||||
return $conditional_tag_function();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function check_page_template($page_template) {
|
private function check_page_template($page_template) {
|
||||||
return is_page_template($page_template . self::EXTENSION);
|
return is_page_template($page_template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user