WP_Customize_Nav_Menu_Setting::value(): array
- Since
- 4.3.0
- Source
wp-includes/customize/class-wp-customize-nav-menu-setting.php:158
Get the instance data for a given widget setting.
Return
array- Instance data.
Uses · 6
- get_current_blog_id()Retrieves the current site ID.
- wp_get_nav_menu_object()Returns a navigation menu object.
- wp_array_slice_assoc()Extracts a slice of an array, given a list of keys.
- get_option()Retrieves an option value based on an option name.
- stdClass::__construct()
- WP_Customize_Nav_Menu_Setting::post_value()
Used by · 5
- WP_Customize_Nav_Menu_Setting::amend_customize_save_response()Export data for the JS client.
- WP_Customize_Nav_Menu_Setting::filter_nav_menu_options()Filters the nav_menu_options option to include this menu's auto_add preference.
- WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menu_object()Filters the wp_get_nav_menu_object() result to supply the previewed menu object.
- WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menus()Filters the wp_get_nav_menus() result to ensure the inserted menu object is included, and the deleted one is removed.
- WP_Customize_Nav_Menu_Setting::preview()Handle previewing the setting.
Source
public function value() { if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) { $undefined = new stdClass(); // Symbol. $post_value = $this->post_value( $undefined ); if ( $undefined === $post_value ) { $value = $this->_original_value; } else { $value = $post_value; } } else { $value = false; // Note that a term_id of less than one indicates a nav_menu not yet inserted. if ( $this->term_id > 0 ) { $term = wp_get_nav_menu_object( $this->term_id ); if ( $term ) { $value = wp_array_slice_assoc( (array) $term, array_keys( $this->default ) ); $nav_menu_options = (array) get_option( 'nav_menu_options', array() ); $value['auto_add'] = false; if ( isset( $nav_menu_options['auto_add'] ) && is_array( $nav_menu_options['auto_add'] ) ) { $value['auto_add'] = in_array( $term->term_id, $nav_menu_options['auto_add'], true ); } } } if ( ! is_array( $value ) ) { $value = $this->default; } } return $value; }History
Introduced in 4.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/customize/class-wp-customize-nav-menu-setting.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.