WP_Customize_Nav_Menu_Setting::filter_nav_menu_options_value()
Updates a nav_menu_options array.
Method of the class: WP_Customize_Nav_Menu_Setting{}
No Hooks.
Return
Array
. (Maybe) modified nav_menu_options array.
Usage
// protected - for code of main (parent) or child class $result = $this->filter_nav_menu_options_value( $nav_menu_options, $menu_id, $auto_add );
- $nav_menu_options(array) (required)
- Array as returned by get_option( 'nav_menu_options' ).
- $menu_id(int) (required)
- The term ID for the given menu.
- $auto_add(true|false) (required)
- Whether to auto-add or not.
Notes
- See: WP_Customize_Nav_Menu_Setting::filter_nav_menu_options()
- See: WP_Customize_Nav_Menu_Setting::update()
Changelog
Since 4.3.0 | Introduced. |
WP_Customize_Nav_Menu_Setting::filter_nav_menu_options_value() WP Customize Nav Menu Setting::filter nav menu options value code WP 6.6.2
protected function filter_nav_menu_options_value( $nav_menu_options, $menu_id, $auto_add ) { $nav_menu_options = (array) $nav_menu_options; if ( ! isset( $nav_menu_options['auto_add'] ) ) { $nav_menu_options['auto_add'] = array(); } $i = array_search( $menu_id, $nav_menu_options['auto_add'], true ); if ( $auto_add && false === $i ) { array_push( $nav_menu_options['auto_add'], $this->term_id ); } elseif ( ! $auto_add && false !== $i ) { array_splice( $nav_menu_options['auto_add'], $i, 1 ); } return $nav_menu_options; }