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.
WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()
- apply_filters( nav_menu_attr_title )filter line 648
- apply_filters( nav_menu_description )filter line 651
- apply_filters( wp_setup_nav_menu_item )filter line 654
WP_Customize_Nav_Menu_Item_Setting::sanitize()
- apply_filters( title_save_pre )filter line 728
- apply_filters( excerpt_save_pre )filter line 731
- apply_filters( content_save_pre )filter line 734
- apply_filters( customize_sanitize_{$this->id} )filter line 749
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.
$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
- __construct()Constructor.
- flush_cached_value()Clear the cached value when this nav menu item is updated.
- value()Get the instance data for a given nav_menu_item setting.
- js_value()Prepares the value for editing on the client.
- get_original_title()Get original title.
- get_type_label()Get type label.
- populate_value()Ensure that the value is fully populated with the necessary properties.
- preview()Handle previewing the setting.
- filter_wp_get_nav_menu_items()Filters the wp_get_nav_menu_items() result to supply the previewed menu items.
- sort_wp_get_nav_menu_items()Re-apply the tail logic also applied on $items by wp_get_nav_menu_items().
- value_as_wp_post_nav_menu_item()Get the value emulated into a WP_Post and set up as a nav_menu_item.
- sanitize()Sanitize an input.
- update()Creates/updates the nav_menu_item post for this setting.
- amend_customize_save_response()Export data for the JS client.
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 intChangelog
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 7.0.4 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.