wppaste
WordPress

WP_Customize_Nav_Menu_Item_Setting

Since
4.3.0
Source
wp-includes/customize/class-wp-customize-nav-menu-item-setting.php:20
Customize Setting to represent a nav_menu.

Description

Subclass of WP_Customize_Setting to represent a nav_menu taxonomy term, and the IDs for the nav_menu_items associated with the nav menu.

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 · 8

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

Properties · 10

$typestringpublic
Setting type.
$defaultarraypublic
Default setting value.
$transportstringpublic
Default transport.
$post_idintpublic
The post ID represented by this setting instance. This is the db_id.
$valuearray|nullprotected
Storage of pre-setup menu item to prevent wasted calls to wp_setup_nav_menu_item().
$previous_post_idintpublic
Previous (placeholder) post ID used before creating a new menu item.
$original_nav_menu_term_idintpublic
When previewing or updating a menu item, this stores the previous nav_menu_term_id which ensures that we can apply the proper filters.
$is_updatedboolprotected
Whether or not update() was called.
$update_statusstringpublic
Status for calling the update method, used in customize_save_response filter.
$update_errorWP_Errorpublic
Any error object returned by wp_update_nav_menu_item() when setting is updated.

Methods · 14

Source code

class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { 	const ID_PATTERN = '/^nav_menu_item\[(?P<id>-?\d+)\]$/'; 	const POST_TYPE = 'nav_menu_item'; 	const TYPE = 'nav_menu_item'; 	/**	 * Setting type.	 *	 * @since 4.3.0	 * @var string	 */	public $type = self::TYPE; 	/**	 * Default setting value.	 *	 * @since 4.3.0	 * @var array	 *	 * @see wp_setup_nav_menu_item()	 */	public $default = array(		// The $menu_item_data for wp_update_nav_menu_item().		'object_id'        => 0,		'object'           => '', // Taxonomy name.		'menu_item_parent' => 0, // A.K.A. menu-item-parent-id; note that post_parent is different, and not included.		'position'         => 0, // A.K.A. menu_order.		'type'             => 'custom', // Note that type_label is not included here.		'title'            => '',		'url'              => '',		'target'           => '',		'attr_title'       => '',		'description'      => '',		'classes'          => '',		'xfn'              => '',		'status'           => 'publish',		'nav_menu_term_id' => 0, // This will be supplied as the $menu_id arg for wp_update_nav_menu_item().		'_invalid'         => false,	); 	/**	 * Default transport.	 *	 * @since 4.3.0	 * @since 4.5.0 Default changed to 'refresh'	 * @var string	 */	public $transport = 'refresh'; 	/**	 * The post ID represented by this setting instance. This is the db_id.	 *	 * A negative value represents a placeholder ID for a new menu not yet saved.	 *	 * @since 4.3.0	 * @var int	 */	public $post_id; 	/**	 * Storage of pre-setup menu item to prevent wasted calls to wp_setup_nav_menu_item().	 *	 * @since 4.3.0	 * @var array|null	 */	protected $value; 	/**	 * Previous (placeholder) post ID used before creating a new menu item.	 *	 * This value will be exported to JS via the customize_save_response filter	 * so that JavaScript can update the settings to refer to the newly-assigned	 * post ID. This value is always negative to indicate it does not refer to	 * a real post.	 *	 * @since 4.3.0	 * @var int

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.1.0 tag, from src/wp-includes/customize/class-wp-customize-nav-menu-item-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.