nav_menu_css_class

最后更新于:2021-11-27 08:47:16

apply_filters( ‘nav_menu_css_class’, string[] $classes, GC_Post $item, stdClass $args, int $depth )

Filters the CSS classes applied to a menu item’s list item element.

参数

$classes

(string[])
Array of the CSS classes that are applied to the menu item’s <li> element.

$item

(GC_Post)
The current menu item.

$args

(stdClass)
An object of gc_nav_menu() arguments.

$depth

(int)
Depth of menu item. Used for padding.

<?php 
/* GC 3.0+ */
function filter_handler( $classes , $item ) { ...... }

add_filter( 'nav_menu_css_class', 'filter_handler', 10, 2 ); 

/* GC 3.1+ */
function filter_handler( $classes , $item, $args ) { ...... }

add_filter( 'nav_menu_css_class', 'filter_handler', 10, 3 ); 

/* GC 4.1+ */
function filter_handler( $classes, $item, $args, $depth ) { ...... }

add_filter( 'nav_menu_css_class', 'filter_handler', 10, 4 ); 
?>

源文件

文件: gc-includes/class-walker-nav-menu.php

View on Trac