diff --git src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
index 46601a9e18..2f725de7b3 100644
|
|
|
class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { |
| 179 | 179 | // Ensure that an initially-supplied value is valid. |
| 180 | 180 | if ( isset( $this->value ) ) { |
| 181 | 181 | $this->populate_value(); |
| | 182 | add_action( 'admin_init', array( $this, 'reset_type_label' ) ); |
| | 183 | |
| 182 | 184 | foreach ( array_diff( array_keys( $this->default ), array_keys( $this->value ) ) as $missing ) { |
| 183 | 185 | throw new Exception( "Supplied nav_menu_item value missing property: $missing" ); |
| 184 | 186 | } |
| 185 | 187 | } |
| | 188 | } |
| | 189 | |
| | 190 | /** |
| | 191 | * Reset the item's 'type_label' using {@see get_post_states()}, which |
| | 192 | * is not typically available as the Customizer is being bootstrapped. |
| | 193 | * |
| | 194 | * @see wp_setup_nav_menu_item() |
| | 195 | */ |
| | 196 | public function reset_type_label() { |
| | 197 | if ( ! function_exists( 'get_post_states' ) ) { |
| | 198 | return; |
| | 199 | } |
| 186 | 200 | |
| | 201 | if ( |
| | 202 | empty( $this->value['object_id'] ) |
| | 203 | || empty( $this->value['type'] ) |
| | 204 | || 'post_type' !== $this->value['type'] |
| | 205 | ) { |
| | 206 | return; |
| | 207 | } |
| | 208 | |
| | 209 | $menu_post = get_post( $this->value['object_id'] ); |
| | 210 | |
| | 211 | if ( ! $menu_post ) { |
| | 212 | return; |
| | 213 | } |
| | 214 | |
| | 215 | $post_states = get_post_states( $menu_post ); |
| | 216 | |
| | 217 | if ( $post_states ) { |
| | 218 | $this->value['type_label'] = wp_strip_all_tags( implode( ', ', $post_states ) ); |
| | 219 | } |
| 187 | 220 | } |
| 188 | 221 | |
| 189 | 222 | /** |