wppaste
WordPress

WP_Customize_Nav_Menus

Since
4.3.0
Source
wp-includes/class-wp-customize-nav-menus.php:19
Customize Nav Menus class.

Description

Implements menu management in the Customizer.

Compatibility

WordPress
since 4.3.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 3

Every hook that fires from inside WP_Customize_Nav_Menus, in the order it appears in the class, grouped by the method that fires it.

Properties · 3

$managerWP_Customize_Managerpublic
WP_Customize_Manager instance.
$original_nav_menu_locationsarrayprotected
Original nav menu locations before the theme was switched.
$preview_nav_menu_instance_argsarraypublic
Nav menu args used for each instance, keyed by the args HMAC.

Methods · 30

Source code

#[AllowDynamicProperties]final class WP_Customize_Nav_Menus { 	/**	 * WP_Customize_Manager instance.	 *	 * @since 4.3.0	 * @var WP_Customize_Manager	 */	public $manager; 	/**	 * Original nav menu locations before the theme was switched.	 *	 * @since 4.9.0	 * @var array	 */	protected $original_nav_menu_locations; 	/**	 * Constructor.	 *	 * @since 4.3.0	 *	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.	 */	public function __construct( $manager ) {		$this->manager                     = $manager;		$this->original_nav_menu_locations = get_nav_menu_locations(); 		// See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L469-L499		add_action( 'customize_register', array( $this, 'customize_register' ), 11 );		add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_dynamic_setting_args' ), 10, 2 );		add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_dynamic_setting_class' ), 10, 3 );		add_action( 'customize_save_nav_menus_created_posts', array( $this, 'save_nav_menus_created_posts' ) ); 		// Skip remaining hooks when the user can't manage nav menus anyway.		if ( ! current_user_can( 'edit_theme_options' ) ) {			return;		} 		add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) );		add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) );		add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) );		add_action( 'wp_ajax_customize-nav-menus-insert-auto-draft', array( $this, 'ajax_insert_auto_draft_post' ) );		add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );		add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_templates' ) );		add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) );		add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) );		add_action( 'customize_preview_init', array( $this, 'make_auto_draft_status_previewable' ) ); 		// Selective Refresh partials.		add_filter( 'customize_dynamic_partial_args', array( $this, 'customize_dynamic_partial_args' ), 10, 2 );	} 	/**	 * Adds a nonce for customizing menus.	 *	 * @since 4.5.0	 *	 * @param string[] $nonces Array of nonces.	 * @return string[] Modified array of nonces.	 */	public function filter_nonces( $nonces ) {		$nonces['customize-menus'] = wp_create_nonce( 'customize-menus' );		return $nonces;	} 	/**	 * Ajax handler for loading available menu items.	 *	 * @since 4.3.0	 */	public function ajax_load_available_items() {		check_ajax_referer( 'customize-menus', 'customize-menus-nonce' ); 		if ( ! current_user_can( 'edit_theme_options' ) ) {			wp_die( -1 );		}

Changelog

Introduced in 4.3.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/class-wp-customize-nav-menus.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.