Walker_Nav_Menu::start_lvl()publicWP 3.0.0

Starts the list before the elements are added.

Метод класса: Walker_Nav_Menu{}

Возвращает

null. Ничего (null).

Использование

$Walker_Nav_Menu = new Walker_Nav_Menu();
$Walker_Nav_Menu->start_lvl( $output, $depth, $args );
$output(строка) (обязательный) (передается по ссылке — &)
Used to append additional content (passed by reference).
$depth(int)
Depth of menu item. Used for padding.
$args(stdClass)
An object of wp_nav_menu() arguments.
По умолчанию: null

Заметки

Список изменений

С версии 3.0.0 Введена.

Код Walker_Nav_Menu::start_lvl() WP 6.5.2

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 `wp_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 ) );

	$atts          = array();
	$atts['class'] = ! empty( $class_names ) ? $class_names : '';

	/**
	 * Filters the HTML attributes applied to a menu list element.
	 *
	 * @since 6.3.0
	 *
	 * @param array $atts {
	 *     The HTML attributes applied to the `<ul>` element, empty strings are ignored.
	 *
	 *     @type string $class    HTML CSS class attribute.
	 * }
	 * @param stdClass $args      An object of `wp_nav_menu()` arguments.
	 * @param int      $depth     Depth of menu item. Used for padding.
	 */
	$atts       = apply_filters( 'nav_menu_submenu_attributes', $atts, $args, $depth );
	$attributes = $this->build_atts( $atts );

	$output .= "{$n}{$indent}<ul{$attributes}>{$n}";
}