From 309917ae6730cb159094c7a3edc73358c220a168 Mon Sep 17 00:00:00 2001 From: Eric Wafford Date: Tue, 7 Oct 2014 11:41:04 -0500 Subject: [PATCH 1/2] Add roots_body_class function that checks for page slug in body_class classes and adds it as needed --- lib/utils.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/utils.php b/lib/utils.php index 118c2f3..8f6b56d 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -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'); From 43507e4dd3818dd5dd21875fb2105cffe00e20de Mon Sep 17 00:00:00 2001 From: Eric Wafford Date: Sun, 19 Oct 2014 12:20:56 -0500 Subject: [PATCH 2/2] Fix Spaces --- lib/utils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/utils.php b/lib/utils.php index 8f6b56d..93e5116 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -21,9 +21,9 @@ add_filter('get_search_form', 'roots_get_search_form'); 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()); - } + if (!in_array(basename(get_permalink()), $classes)) { + $classes[] = basename(get_permalink()); + } } return $classes; }