Changeset 60820 for branches/6.6/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
- Timestamp:
- 09/30/2025 05:00:33 PM (5 months ago)
- Location:
- branches/6.6
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/6.6
- Property svn:mergeinfo changed
/trunk merged: 60814-60816
- Property svn:mergeinfo changed
-
branches/6.6/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
r56548 r60820 57 57 'xfn' => '', 58 58 'status' => 'publish', 59 'original_title' => '',60 59 'nav_menu_term_id' => 0, // This will be supplied as the $menu_id arg for wp_update_nav_menu_item(). 61 60 '_invalid' => false, … … 211 210 */ 212 211 public function value() { 212 $type_label = null; 213 213 if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) { 214 214 $undefined = new stdClass(); // Symbol. … … 219 219 } else { 220 220 $value = $post_value; 221 }222 if ( ! empty( $value ) && empty( $value['original_title'] ) ) {223 $value['original_title'] = $this->get_original_title( (object) $value );224 221 } 225 222 } elseif ( isset( $this->value ) ) { … … 234 231 $is_title_empty = empty( $post->post_title ); 235 232 $value = (array) wp_setup_nav_menu_item( $post ); 233 if ( isset( $value['type_label'] ) ) { 234 $type_label = $value['type_label']; 235 } 236 236 if ( $is_title_empty ) { 237 237 $value['title'] = ''; … … 250 250 } 251 251 252 if ( ! empty( $value ) && empty( $value['type_label'] ) ) { 253 $value['type_label'] = $this->get_type_label( (object) $value ); 252 // These properties are read-only and are part of the setting for use in the Customizer UI. 253 if ( is_array( $value ) ) { 254 $value_obj = (object) $value; 255 $value['type_label'] = isset( $type_label ) ? $type_label : $this->get_type_label( $value_obj ); 256 $value['original_title'] = $this->get_original_title( $value_obj ); 254 257 } 255 258 … … 258 261 259 262 /** 263 * Prepares the value for editing on the client. 264 * 265 * @since 6.8.3 266 * 267 * @return array|false Value prepared for the client. 268 */ 269 public function js_value() { 270 $value = parent::js_value(); 271 if ( is_array( $value ) && isset( $value['original_title'] ) ) { 272 // Decode entities for the sake of displaying the original title as a placeholder. 273 $value['original_title'] = html_entity_decode( $value['original_title'], ENT_QUOTES, get_bloginfo( 'charset' ) ); 274 } 275 return $value; 276 } 277 278 /** 260 279 * Get original title. 261 280 * … … 263 282 * 264 283 * @param object $item Nav menu item. 265 * @return string The original title .284 * @return string The original title, without entity decoding. 266 285 */ 267 286 protected function get_original_title( $item ) { … … 289 308 } 290 309 } 291 $original_title = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) );292 310 return $original_title; 293 311 } … … 345 363 $this->value['status'] = $this->value['post_status']; 346 364 unset( $this->value['post_status'] ); 347 }348 349 if ( ! isset( $this->value['original_title'] ) ) {350 $this->value['original_title'] = $this->get_original_title( (object) $this->value );351 365 } 352 366 … … 595 609 unset( $item->position ); 596 610 597 if ( empty( $item->original_title ) ) {598 $item->original_title = $this->get_original_title( $item );599 }600 611 if ( empty( $item->title ) && ! empty( $item->original_title ) ) { 601 $item->title = $item->original_title; 612 $item->title = $item->original_title; // This is NOT entity-decoded. It comes from self::get_original_title(). 602 613 } 603 614 if ( $item->title ) { … … 655 666 * @since 5.9.0 Renamed `$menu_item_value` to `$value` for PHP 8 named parameter support. 656 667 * 657 * @param array $value The menu item value to sanitize.668 * @param array|false $value The menu item value to sanitize. 658 669 * @return array|false|null|WP_Error Null or WP_Error if an input isn't valid. False if it is marked for deletion. 659 670 * Otherwise the sanitized value. … … 712 723 } 713 724 714 $menu_item_value['original_title'] = sanitize_text_field( $menu_item_value['original_title'] );715 716 725 // Apply the same filters as when calling wp_insert_post(). 717 726
Note: See TracChangeset
for help on using the changeset viewer.