Refactor sidebar configuration

Instead of editing an if statement (which could get ugly quickly), just
edit configuration arrays of conditional tags and page template checks.
This commit is contained in:
Scott Walkinshaw
2012-09-20 14:36:25 -06:00
parent 33d78b7a0d
commit 588ea8afa3
6 changed files with 81 additions and 9 deletions

View File

@@ -9,18 +9,37 @@ add_theme_support('rewrite-urls'); // Enable URL rewrites
add_theme_support('h5bp-htaccess'); // Enable HTML5 Boilerplate's .htaccess
add_theme_support('bootstrap-top-navbar'); // Enable Bootstrap's fixed navbar
// Define which pages shouldn't have the sidebar
function roots_sidebar() {
if (is_404() || is_page_template('page-custom.php')) {
return false;
} else {
return true;
}
/**
* Define which pages shouldn't have the sidebar
*
* See lib/sidebar.php for more details
*/
function roots_display_sidebar() {
$exclude = new Roots_Sidebar(
/**
* Conditionals tag checks (http://codex.wordpress.org/Conditional_Tags)
* Any of these conditional tags that return true won't show the sidebar
*/
array(
'404',
'front_page'
),
/**
* Page template checks (via is_page_template())
* Any of these page templates that return true won't show the sidebar
*/
array(
'page-custom'
)
);
return $exclude->display;
}
// #main CSS classes
function roots_main_class() {
if (roots_sidebar()) {
if (roots_display_sidebar()) {
echo 'span8';
} else {
echo 'span12';