Merge pull request #1165 from Tidal-Wave/enhancement/roots-body-class

Add roots_body_class function to check for page slug in body_class and add it as needed.
This commit is contained in:
Ben Word
2014-10-19 11:47:12 -06:00

View File

@@ -14,3 +14,17 @@ function roots_get_search_form($form) {
return $form;
}
add_filter('get_search_form', 'roots_get_search_form');
/**
* Add page slug to body_class() classes if it doesn't exist
*/
function roots_body_class($classes) {
// Add post/page slug
if (is_single() || is_page() && !is_front_page()) {
if (!in_array(basename(get_permalink()), $classes)) {
$classes[] = basename(get_permalink());
}
}
return $classes;
}
add_filter('body_class', 'roots_body_class');