WP_Customize_Nav_Menu_Setting::value() WordPress Method

The WP_Customize_Nav_Menu_Setting::value() method is used to retrieve the value of a navigation menu setting. This setting is stored as an array and contains information about the navigation menu, such as the name, description, and location.

WP_Customize_Nav_Menu_Setting::value() #

Get the instance data for a given widget setting.


Description

Top ↑

See also


Top ↑

Return

(array) Instance data.


Top ↑

Source

File: wp-includes/customize/class-wp-customize-nav-menu-setting.php

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


Top ↑

Changelog

Changelog
VersionDescription
4.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.