Blacklist Menu Item Classes

<?php
/**
* Clean Nav Menu Classes
*
*/
function ea_clean_nav_menu_classes( $classes ) {
if( ! is_array( $classes ) )
return $classes;
$remove_classes = array(
'menu-item-type-custom',
'menu-item-type-taxonomy',
'menu-item-object-custom',
'menu-item-object-category',
);
$classes = array_diff( $classes, $remove_classes );
foreach( $classes as $i => $class ) {
// Remove class with menu item id
$id = strtok( $class, 'menu-item-' );
if( 0 < intval( $id ) )
unset( $classes[ $i ] );
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'ea_clean_nav_menu_classes', 5 );
view raw functions.php hosted with ❤ by GitHub

performance