WP_Customize_Nav_Menu_Item_Setting::value
Get the instance data for a given nav_menu_item setting.
Method of the class: WP_Customize_Nav_Menu_Item_Setting{}
No Hooks.
Returns
Array|false. Instance data array, or false if the item is marked for deletion.
Usage
$WP_Customize_Nav_Menu_Item_Setting = new WP_Customize_Nav_Menu_Item_Setting(); $WP_Customize_Nav_Menu_Item_Setting->value();
Notes
Changelog
| Since 4.3.0 | Introduced. |
WP_Customize_Nav_Menu_Item_Setting::value() WP Customize Nav Menu Item Setting::value code WP 7.0
public function value() {
$type_label = null;
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;
}
} elseif ( isset( $this->value ) ) {
$value = $this->value;
} else {
$value = false;
// Note that an ID of less than one indicates a nav_menu not yet inserted.
if ( $this->post_id > 0 ) {
$post = get_post( $this->post_id );
if ( $post && self::POST_TYPE === $post->post_type ) {
$is_title_empty = empty( $post->post_title );
$value = (array) wp_setup_nav_menu_item( $post );
if ( isset( $value['type_label'] ) ) {
$type_label = $value['type_label'];
}
if ( $is_title_empty ) {
$value['title'] = '';
}
}
}
if ( ! is_array( $value ) ) {
$value = $this->default;
}
// Cache the value for future calls to avoid having to re-call wp_setup_nav_menu_item().
$this->value = $value;
$this->populate_value();
$value = $this->value;
}
// These properties are read-only and are part of the setting for use in the Customizer UI.
if ( is_array( $value ) ) {
$value_obj = (object) $value;
$value['type_label'] = $type_label ?? $this->get_type_label( $value_obj );
$value['original_title'] = $this->get_original_title( $value_obj );
}
return $value;
}