Blocks

Toggle_Menu_Walker_With_Parent_Links extends Toggle_Menu_Walker
in package

Extension of Toggle_Menu_Walker to add parent links to sub-menus.

Table of Contents

Properties

$parent_stack  : array<string|int, mixed>
Stack to track parent items by depth.
$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> and injects a parent-link <li>.

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 ][, array<string|int, mixed> $args = array() ][, 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 : array<string|int, mixed> = array()

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> and injects a parent-link <li>.

protected get_submenu_open_markup(string $submenu_id, int $depth, array<string|int, mixed> $args) : string
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

    with parent link.


        
On this page

Search results