wppaste
WordPress

apply_filters( 'nav_menu_css_class', string[] $classes, WP_Post $menu_item, stdClass $args, int $depth )

Since
3.0.0, 4.1.0
Filters the CSS classes applied to a menu item's list item element.

Compatibility

WordPress
since 4.1.0
  • 6.7.10
  • 6.8.11
  • 6.9.10
  • 7.0.7
  • 7.1.3

Present in every tracked release (6.7.10 to 7.1.3).

Parameters

$classesstring[]
Array of the CSS classes that are applied to the menu item's <li> element.
$menu_itemWP_Post
The current menu item object.
$argsstdClass
An object of wp_nav_menu() arguments.
$depthint
Depth of menu item. Used for padding.

Where this hook fires · 1

  • wp-includes/class-walker-nav-menu.php:194Walker_Nav_Menu::start_el()

Source code

		 *		 * @param string[] $classes   Array of the CSS classes that are applied to the menu item's `<li>` element.		 * @param WP_Post  $menu_item The current menu item object.		 * @param stdClass $args      An object of wp_nav_menu() arguments.		 * @param int      $depth     Depth of menu item. Used for padding.		 */		$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) ); 		/**		 * Filters the ID attribute applied to a menu item's list item element.		 *		 * @since 3.0.1		 * @since 4.1.0 The `$depth` parameter was added.

Changelog

Introduced in 3.0.0. Unchanged from 6.7.10 through 7.1.3.

  1. 6.7.10
  2. 6.8.11
  3. 6.9.10
  4. 7.0.7
  5. 7.1.3

Signature, return type and hooks compared across 5 parsed releases.

4.1.0
The $depth parameter was added.from the docblock
3.0.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.3 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.