Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created July 17, 2018 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/3883589cce11d37f60534c4dfe307690 to your computer and use it in GitHub Desktop.
Save billerickson/3883589cce11d37f60534c4dfe307690 to your computer and use it in GitHub Desktop.
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment