WP_Bootstrap_Navwalker extends Walker_Nav_Menu

WP_Bootstrap_Navwalker class.

Tags
author

Edward McIntyre <@twittem>

author

WP Bootstrap

author

William Patton <@pattonwebz>

version
4.3.0
link
https://github.com/wp-bootstrap
link
https://github.com/wp-bootstrap/tkt-template-builder
link
https://github.com/wp-bootstrap/tkt-template-builder
license:

http://www.gnu.org/licenses/gpl-3.0.txt GPL-3.0+

extends

Walker_Nav_Menu

Table of Contents

display_element()  : mixed
Traverse elements to create list from elements.
fallback()  : mixed
Menu Fallback ============= If this function is assigned to the wp_nav_menu's fallback_cb variable and a menu has not been assigned to the theme location in the WordPress menu manager the function with display nothing to a non-logged in user, and will add a link to the WordPress menu manager if logged in as an admin.
start_el()  : mixed
Starts the element output.
start_lvl()  : mixed
Starts the list before the elements are added.
get_linkmod_type()  : string
Return a string containing a linkmod type and update $atts array accordingly depending on the decided.
linkmod_element_close()  : string
Return the correct closing tag for the linkmod element.
linkmod_element_open()  : string
Returns the correct opening element and attributes for a linkmod.
separate_linkmods_and_icons_from_classes()  : array<string|int, mixed>
Find any custom linkmod or icon classes and store in their holder arrays then remove them from the main classes array.
update_atts_for_linkmod_type()  : array<string|int, mixed>
Update the attributes of a nav item depending on the limkmod classes.
wrap_for_screen_reader()  : string
Wraps the passed text in a screen reader only class.

Methods

display_element()

Traverse elements to create list from elements.

public display_element(object $element, array<string|int, mixed> &$children_elements, int $max_depth, int $depth, array<string|int, mixed> $args, string &$output) : mixed
Description

Display one element if the element doesn't have any children otherwise, display the element and its children. Will only traverse up to the max depth and no ignore elements under that depth. It is possible to set the max depth to include all depths, see walk() method.

This method should not be called directly, use the walk() method instead.

Parameters
$element
(object) Data object.
$children_elements
(array<string|int, mixed>) List of elements to continue traversing (passed by reference).
$max_depth
(int) Max depth to traverse.
$depth
(int) Depth of current element.
$args
(array<string|int, mixed>) An array of arguments.
$output
(string) Used to append additional content (passed by reference).
Tags
since

WP 2.5.0

see
Walker::start_lvl()
Return
(mixed)

fallback()

Menu Fallback ============= If this function is assigned to the wp_nav_menu's fallback_cb variable and a menu has not been assigned to the theme location in the WordPress menu manager the function with display nothing to a non-logged in user, and will add a link to the WordPress menu manager if logged in as an admin.

public static fallback(array<string|int, mixed> $args) : mixed
Parameters
$args
(array<string|int, mixed>) passed from the wp_nav_menu function.
Return
(mixed)

start_el()

Starts the element output.

public start_el(string &$output, WP_Post $item[, int $depth = 0 ][, stdClass $args = array() ][, int $id = 0 ]) : mixed
Parameters
$output
(string) Used to append additional content (passed by reference).
$item
(WP_Post) Menu item data object.
$depth
(int) Depth of menu item. Used for padding. Defaults to: 0
$args
(stdClass) An object of wp_nav_menu() arguments. Defaults to: array()
$id
(int) Current item ID. Defaults to: 0
Tags
since

WP 3.0.0

since

WP 4.4.0 The {@see nav_menu_item_args()} filter was added.

see
Walker_Nav_Menu::start_el()
Return
(mixed)

start_lvl()

Starts the list before the elements are added.

public start_lvl(string &$output[, int $depth = 0 ][, stdClass $args = array() ]) : mixed
Parameters
$output
(string) Used to append additional content (passed by reference).
$depth
(int) Depth of menu item. Used for padding. Defaults to: 0
$args
(stdClass) An object of wp_nav_menu() arguments. Defaults to: array()
Tags
since

WP 3.0.0

see
Walker_Nav_Menu::start_lvl()
Return
(mixed)

get_linkmod_type()

Return a string containing a linkmod type and update $atts array accordingly depending on the decided.

private get_linkmod_type([array<string|int, mixed> $linkmod_classes = array() ]) : string
Parameters
$linkmod_classes
(array<string|int, mixed>) array of any link modifier classes. Defaults to: array()
Tags
since
4.0.0
Return
(string) empty for default, a linkmod type string otherwise.

linkmod_element_close()

Return the correct closing tag for the linkmod element.

private linkmod_element_close(string $linkmod_type) : string
Parameters
$linkmod_type
(string) a string containing a special linkmod type.
Tags
since
4.0.0
Return
(string) a string with the closing tag for this linkmod type.

linkmod_element_open()

Returns the correct opening element and attributes for a linkmod.

private linkmod_element_open(string $linkmod_type[, string $attributes = '' ]) : string
Parameters
$linkmod_type
(string) a sting containing a linkmod type flag.
$attributes
(string) a string of attributes to add to the element. Defaults to: ''
Tags
since
4.0.0
Return
(string) a string with the openign tag for the element with attribibutes added.

separate_linkmods_and_icons_from_classes()

Find any custom linkmod or icon classes and store in their holder arrays then remove them from the main classes array.

private separate_linkmods_and_icons_from_classes(array<string|int, mixed> $classes, array<string|int, mixed> &$linkmod_classes, array<string|int, mixed> &$icon_classes, int $depth) : array<string|int, mixed>
Description

Supported linkmods: .disabled, .dropdown-header, .dropdown-divider, .sr-only Supported iconsets: Font Awesome 4/5, Glypicons

NOTE: This accepts the linkmod and icon arrays by reference.

Parameters
$classes
(array<string|int, mixed>) an array of classes currently assigned to the item.
$linkmod_classes
(array<string|int, mixed>) an array to hold linkmod classes.
$icon_classes
(array<string|int, mixed>) an array to hold icon classes.
$depth
(int) an integer holding current depth level.
Tags
since
4.0.0
Return
(array<string|int, mixed>) $classes a maybe modified array of classnames.

update_atts_for_linkmod_type()

Update the attributes of a nav item depending on the limkmod classes.

private update_atts_for_linkmod_type([array<string|int, mixed> $atts = array() ][, array<string|int, mixed> $linkmod_classes = array() ]) : array<string|int, mixed>
Parameters
$atts
(array<string|int, mixed>) array of atts for the current link in nav item. Defaults to: array()
$linkmod_classes
(array<string|int, mixed>) an array of classes that modify link or nav item behaviors or displays. Defaults to: array()
Tags
since
4.0.0
Return
(array<string|int, mixed>) maybe updated array of attributes for item.

wrap_for_screen_reader()

Wraps the passed text in a screen reader only class.

private wrap_for_screen_reader([string $text = '' ]) : string
Parameters
$text
(string) the string of text to be wrapped in a screen reader class. Defaults to: ''
Tags
since
4.0.0
Return
(string) the string wrapped in a span with the class.

        

Search results