WP_Customize_Nav_Menu_Setting::preview() WordPress Method

The WP_Customize_Nav_Menu_Setting::preview() method is used to preview changes to a nav menu in the Customizer. This is done by calling the render_menu() method on the nav_menu_walker object associated with the nav menu. The changes can then be seen in the Customizer preview pane.

WP_Customize_Nav_Menu_Setting::preview() #

Handle previewing the setting.


Description

Top ↑

See also


Top ↑

Return

(bool) False if method short-circuited due to no-op.


Top ↑

Source

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

	public function preview() {
		if ( $this->is_previewed ) {
			return false;
		}

		$undefined      = new stdClass();
		$is_placeholder = ( $this->term_id < 0 );
		$is_dirty       = ( $undefined !== $this->post_value( $undefined ) );
		if ( ! $is_placeholder && ! $is_dirty ) {
			return false;
		}

		$this->is_previewed       = true;
		$this->_original_value    = $this->value();
		$this->_previewed_blog_id = get_current_blog_id();

		add_filter( 'wp_get_nav_menus', array( $this, 'filter_wp_get_nav_menus' ), 10, 2 );
		add_filter( 'wp_get_nav_menu_object', array( $this, 'filter_wp_get_nav_menu_object' ), 10, 2 );
		add_filter( 'default_option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) );
		add_filter( 'option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) );

		return true;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Added boolean return value
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.