Skip to content

Filters

rogerlos edited this page Jun 16, 2017 · 20 revisions

The following filters are accessible via add_filter(). Included are sample closures, with comments

Within Flexwalker Class

Configuration and HTML construction outside of the actual WordPress Menu.

Menu Arguments: Append Numeric?

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

Menu Arguments: Values

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

Javascript Localization

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

Clone this wiki locally