-
Notifications
You must be signed in to change notification settings - Fork 0
Filters
The following filters are accessible via add_filter(). Included are sample closures, with comments
Configuration and HTML construction outside of the actual WordPress Menu.
When merging $args and $this->cfg, append (true) or overwrite (false) array values which have a numeric key?
add_filter( 'flexwalker_menu_numeric', function( $bool ) {
// always append
return TRUE;
}, 10, 1 );The merged array of arguments being used by Flexwalker.
add_filter( 'flexwalker_menu_args', function( $array ) {
// change walker container_id argument
$array['walker']['container_id'] = 'mynewid';
return $array;
}, 10, 1 );The template being used by Flexwalker. Note, this needs to be in the 'template' format, see JSON: templates. If it's empty, Flexwalker will return nothing.
add_filter( 'flexwalker_menu_template', function( $array ) {
// change depth
$array['depth'] = 1;
return $array;
}, 10, 1 );Flexwalker by default generates a random ID to assign to the menu.
add_filter( 'flexwalker_menu_id', function( $string ) {
// change to your own value.
return 'myniftyid';
}, 10, 1 );This is structure of the HTML returned, see JSON: templates for more information. There should be a special walker item in this array if you are actually calling a menu.
add_filter( 'flexwalker_navbar_tags', function( $tags_array, $template_id ) {
// Note that changes in this array should be done carefully, see JSON: templates
return $tags_array;
}, 10, 1 );Filter the array of data which is being made available to flexwalker.js. Note that arbitrarily changing the structure or keys will probably break things.
/*
* $array contains the contents of $this->cfg['display'] as modified by the
* passed arguments when flexwalker( $args ). $this->cfg['display'] is initially
* the contents of display.json
*/
add_filter( 'flexwalker_localize', function( $array ) {
// turn off resize hiding
$array['resizehide']['use'] = false;
return $array;
}, 10, 1 );