Created
January 8, 2014 03:30
-
-
Save chriskoelle/8311326 to your computer and use it in GitHub Desktop.
Wordpress Cleanup wp_nav_menu Classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cleanup some of the extra menu item classes added to wp_nav_menu | |
function nh_allowed_menu_item_classes($classes, $item) { | |
// Get custom classes added from within the menus admin page | |
$new_classes = (array) get_post_meta( $item->ID, '_menu_item_classes', true ); | |
// Consolidate the assorted "current..." classes | |
$current_classes = preg_grep('/current/', $classes); | |
if(!empty($current_classes)) $new_classes[] = 'current'; | |
return $new_classes; | |
} | |
add_filter('nav_menu_css_class', 'nh_allowed_menu_item_classes', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment