From d036893b68bc645f40a6e622ef14e1290b8925c3 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Wed, 15 Aug 2012 14:53:17 -0400 Subject: [PATCH] Fix #493 - remove duplicate active class in menu --- inc/cleanup.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/inc/cleanup.php b/inc/cleanup.php index 5c4140d..db10623 100644 --- a/inc/cleanup.php +++ b/inc/cleanup.php @@ -411,16 +411,8 @@ add_filter('excerpt_more', 'roots_excerpt_more'); * Replace various active menu class names with "active" */ function roots_wp_nav_menu($text) { - $replace = array( - 'current-menu-item' => 'active', - 'current-menu-parent' => 'active', - 'current-menu-ancestor' => 'active', - 'current_page_item' => 'active', - 'current_page_parent' => 'active', - 'current_page_ancestor' => 'active', - ); - - $text = str_replace(array_keys($replace), $replace, $text); + $text = preg_replace('/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $text); + $text = preg_replace('/( active){2,}/', ' active', $text); return $text; }