Walker_Nav_Menu::start_lvl()
最后更新于:2021-11-26 06:40:20
Walker_Nav_Menu::start_lvl( string$output, int$depth, stdClass$args=null)Starts the list before the elements are added.
参数
- $output
-
(string) (Required) Used to append additional content (passed by reference).
- $depth
-
(int) (Required) Depth of menu item. Used for padding.
- $args
-
(stdClass) (Optional) An object of gc_nav_menu() arguments.
Default value: null
源文件
文件: gc-includes/class-walker-nav-menu.php
public function start_lvl( &$output, $depth = 0, $args = null ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "t";
$n = "n";
}
$indent = str_repeat( $t, $depth );
// Default class.
$classes = array( 'sub-menu' );
/**
* Filters the CSS class(es) applied to a menu list element.
*
* @since 4.8.0
*
* @param string[] $classes Array of the CSS classes that are applied to the menu `<ul>` element.
* @param stdClass $args An object of `gc_nav_menu()` arguments.
* @param int $depth Depth of menu item. Used for padding.
*/
$class_names = implode( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
$output .= "{$n}{$indent}<ul$class_names>{$n}";
}