Whitelist Menu Item Classes

<?php
/**
* Clean Nav Menu Classes
*
*/
function ea_clean_nav_menu_classes( $classes ) {
if( ! is_array( $classes ) )
return $classes;
$allowed_classes = array(
'home',
'menu-item',
'current-menu-item',
'current-menu-ancestor',
'menu-item-has-children',
);
return array_intersect( $classes, $allowed_classes );
}
add_filter( 'nav_menu_css_class', 'ea_clean_nav_menu_classes', 5 );
view raw functions.php hosted with ❤ by GitHub

performance