Changeset 60838 for branches/4.8/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
- Timestamp:
- 09/30/2025 05:06:32 PM (6 months ago)
- Location:
- branches/4.8
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.8
- Property svn:mergeinfo changed
/trunk merged: 60814-60816
- Property svn:mergeinfo changed
-
branches/4.8/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
r39393 r60838 59 59 'xfn' => '', 60 60 'status' => 'publish', 61 'original_title' => '',62 61 'nav_menu_term_id' => 0, // This will be supplied as the $menu_id arg for wp_update_nav_menu_item(). 63 62 '_invalid' => false, … … 225 224 */ 226 225 public function value() { 227 if ( $this->is_previewed && $this->_previewed_blog_id === get_current_blog_id() ) { 226 $type_label = null; 227 if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) { 228 228 $undefined = new stdClass(); // Symbol. 229 229 $post_value = $this->post_value( $undefined ); … … 233 233 } else { 234 234 $value = $post_value; 235 }236 if ( ! empty( $value ) && empty( $value['original_title'] ) ) {237 $value['original_title'] = $this->get_original_title( (object) $value );238 235 } 239 236 } elseif ( isset( $this->value ) ) { … … 248 245 $is_title_empty = empty( $post->post_title ); 249 246 $value = (array) wp_setup_nav_menu_item( $post ); 247 if ( isset( $value['type_label'] ) ) { 248 $type_label = $value['type_label']; 249 } 250 250 if ( $is_title_empty ) { 251 251 $value['title'] = ''; … … 264 264 } 265 265 266 if ( ! empty( $value ) && empty( $value['type_label'] ) ) { 267 $value['type_label'] = $this->get_type_label( (object) $value ); 268 } 269 266 // These properties are read-only and are part of the setting for use in the Customizer UI. 267 if ( is_array( $value ) ) { 268 $value_obj = (object) $value; 269 $value['type_label'] = isset( $type_label ) ? $type_label : $this->get_type_label( $value_obj ); 270 $value['original_title'] = $this->get_original_title( $value_obj ); 271 } 272 273 return $value; 274 } 275 276 /** 277 * Prepares the value for editing on the client. 278 * 279 * @since 6.8.3 280 * 281 * @return array|false Value prepared for the client. 282 */ 283 public function js_value() { 284 $value = parent::js_value(); 285 if ( is_array( $value ) && isset( $value['original_title'] ) ) { 286 // Decode entities for the sake of displaying the original title as a placeholder. 287 $value['original_title'] = html_entity_decode( $value['original_title'], ENT_QUOTES, get_bloginfo( 'charset' ) ); 288 } 270 289 return $value; 271 290 } … … 278 297 * 279 298 * @param object $item Nav menu item. 280 * @return string The original title .299 * @return string The original title, without entity decoding. 281 300 */ 282 301 protected function get_original_title( $item ) { … … 304 323 } 305 324 } 306 $original_title = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) );307 325 return $original_title; 308 326 } … … 362 380 $this->value['status'] = $this->value['post_status']; 363 381 unset( $this->value['post_status'] ); 364 }365 366 if ( ! isset( $this->value['original_title'] ) ) {367 $this->value['original_title'] = $this->get_original_title( (object) $this->value );368 382 } 369 383 … … 607 621 unset( $item->position ); 608 622 609 if ( empty( $item->original_title ) ) {610 $item->original_title = $this->get_original_title( $item );611 }612 623 if ( empty( $item->title ) && ! empty( $item->original_title ) ) { 613 $item->title = $item->original_title; 624 $item->title = $item->original_title; // This is NOT entity-decoded. It comes from self::get_original_title(). 614 625 } 615 626 if ( $item->title ) { … … 662 673 * @access public 663 674 * 664 * @param array $menu_item_value The value to sanitize.675 * @param array|false $menu_item_value The value to sanitize. 665 676 * @return array|false|null Null if an input isn't valid. False if it is marked for deletion. 666 677 * Otherwise the sanitized value. … … 716 727 } 717 728 718 $menu_item_value['original_title'] = sanitize_text_field( $menu_item_value['original_title'] );719 720 729 // Apply the same filters as when calling wp_insert_post(). 721 730 $menu_item_value['title'] = wp_unslash( apply_filters( 'title_save_pre', wp_slash( $menu_item_value['title'] ) ) );
Note: See TracChangeset
for help on using the changeset viewer.