Blocks

Toggle_Menu_Walker extends Walker_Nav_Menu
in package

Custom Walker_Nav_Menu for accessible sub-menu toggles.

Tags
see
Walker_Nav_Menu

Table of Contents

Properties

$pending_submenu_ids  : array<string|int, mixed>
Stack to track pending submenu IDs for each depth.
$submenu_count  : int
Static counter to create unique submenu IDs.

Methods

end_el()  : mixed
Ends the element output, if needed.
end_lvl()  : mixed
Ends the list of after the elements are added.
start_el()  : mixed
Start the element output.
start_lvl()  : mixed
Start the list before the child elements are added.
get_submenu_open_markup()  : string
Returns the opening markup for a submenu <ul>.

Properties

$pending_submenu_ids

Stack to track pending submenu IDs for each depth.

protected array<string|int, mixed> $pending_submenu_ids = array()

This ensures correct assignment in nested menus.

Methods

end_el()

Ends the element output, if needed.

public end_el(string &$output, object $item[, int $depth = 0 ][, array<string|int, mixed> $args = array() ]) : mixed
Parameters
$output : string

Passed by reference. Used to append additional content.

$item : object

Page data object. Not used.

$depth : int = 0

Depth of page. Not Used.

$args : array<string|int, mixed> = array()

An array of arguments. @see wp_nav_menu().

end_lvl()

Ends the list of after the elements are added.

public end_lvl(string &$output[, int $depth = 0 ][, array<string|int, mixed> $args = array() ]) : mixed
Parameters
$output : string

Passed by reference. Used to append additional content.

$depth : int = 0

Depth of menu item. Used for padding.

$args : array<string|int, mixed> = array()

An array of arguments. @see wp_nav_menu().

start_el()

Start the element output.

public start_el(string &$output, object $item[, int $depth = 0 ][, stdClass|null $args = null ][, int $id = 0 ]) : mixed
Parameters
$output : string

Passed by reference. Used to append additional content.

$item : object

Menu item data object.

$depth : int = 0

Depth of menu item. Used for padding.

$args : stdClass|null = null

An array of arguments. @see wp_nav_menu().

$id : int = 0

Current item ID.

start_lvl()

Start the list before the child elements are added.

public start_lvl(string &$output[, int $depth = 0 ][, array<string|int, mixed> $args = array() ]) : mixed
Parameters
$output : string

Passed by reference. Used to append additional content.

$depth : int = 0

Depth of menu item. Used for padding.

$args : array<string|int, mixed> = array()

An array of arguments. @see wp_nav_menu().

get_submenu_open_markup()

Returns the opening markup for a submenu <ul>.

protected get_submenu_open_markup(string $submenu_id, int $depth, array<string|int, mixed> $args) : string

Child classes may override this to inject additional

  • s, etc.

  • Parameters
    $submenu_id : string

    The unique ID for the submenu

      .

    $depth : int

    Menu depth.

    $args : array<string|int, mixed>

    Menu arguments.

    Return values
    string

    The markup for the opening

      .

    
            
    On this page

    Search results