WP_Customize_Nav_Menus::filter_wp_nav_menu_args( array $args )
Keep track of the arguments that are being passed to wp_nav_menu().
Description
See also
Parameters
- $args
-
(Required) An array containing wp_nav_menu() arguments.
Return
(array) Arguments.
Source
File: wp-includes/class-wp-customize-nav-menus.php
public function filter_wp_nav_menu_args( $args ) {
/*
* The following conditions determine whether or not this instance of
* wp_nav_menu() can use selective refreshed. A wp_nav_menu() can be
* selective refreshed if...
*/
$can_partial_refresh = (
// ...if wp_nav_menu() is directly echoing out the menu (and thus isn't manipulating the string after generated),
! empty( $args['echo'] )
&&
// ...and if the fallback_cb can be serialized to JSON, since it will be included in the placement context data,
( empty( $args['fallback_cb'] ) || is_string( $args['fallback_cb'] ) )
&&
// ...and if the walker can also be serialized to JSON, since it will be included in the placement context data as well,
( empty( $args['walker'] ) || is_string( $args['walker'] ) )
// ...and if it has a theme location assigned or an assigned menu to display,
&& (
! empty( $args['theme_location'] )
||
( ! empty( $args['menu'] ) && ( is_numeric( $args['menu'] ) || is_object( $args['menu'] ) ) )
)
&&
// ...and if the nav menu would be rendered with a wrapper container element (upon which to attach data-* attributes).
(
! empty( $args['container'] )
||
( isset( $args['items_wrap'] ) && '<' === substr( $args['items_wrap'], 0, 1 ) )
)
);
$args['can_partial_refresh'] = $can_partial_refresh;
$exported_args = $args;
// Empty out args which may not be JSON-serializable.
if ( ! $can_partial_refresh ) {
$exported_args['fallback_cb'] = '';
$exported_args['walker'] = '';
}
/*
* Replace object menu arg with a term_id menu arg, as this exports better
* to JS and is easier to compare hashes.
*/
if ( ! empty( $exported_args['menu'] ) && is_object( $exported_args['menu'] ) ) {
$exported_args['menu'] = $exported_args['menu']->term_id;
}
ksort( $exported_args );
$exported_args['args_hmac'] = $this->hash_nav_menu_args( $exported_args );
$args['customize_preview_nav_menus_args'] = $exported_args;
$this->preview_nav_menu_instance_args[ $exported_args['args_hmac'] ] = $exported_args;
return $args;
}
Changelog
Version | Description |
---|---|
WP-4.3.0 | Introduced. |