Changeset 60831 for branches/5.5/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
- Timestamp:
- 09/30/2025 05:04:24 PM (2 months ago)
- Location:
- branches/5.5
- 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/5.5
- Property svn:mergeinfo changed
/trunk merged: 60814-60816
- Property svn:mergeinfo changed
-
branches/5.5/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
r47428 r60831 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, … … 212 211 */ 213 212 public function value() { 213 $type_label = null; 214 214 if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) { 215 215 $undefined = new stdClass(); // Symbol. … … 220 220 } else { 221 221 $value = $post_value; 222 }223 if ( ! empty( $value ) && empty( $value['original_title'] ) ) {224 $value['original_title'] = $this->get_original_title( (object) $value );225 222 } 226 223 } elseif ( isset( $this->value ) ) { … … 235 232 $is_title_empty = empty( $post->post_title ); 236 233 $value = (array) wp_setup_nav_menu_item( $post ); 234 if ( isset( $value['type_label'] ) ) { 235 $type_label = $value['type_label']; 236 } 237 237 if ( $is_title_empty ) { 238 238 $value['title'] = ''; … … 251 251 } 252 252 253 if ( ! empty( $value ) && empty( $value['type_label'] ) ) { 254 $value['type_label'] = $this->get_type_label( (object) $value ); 253 // These properties are read-only and are part of the setting for use in the Customizer UI. 254 if ( is_array( $value ) ) { 255 $value_obj = (object) $value; 256 $value['type_label'] = isset( $type_label ) ? $type_label : $this->get_type_label( $value_obj ); 257 $value['original_title'] = $this->get_original_title( $value_obj ); 255 258 } 256 259 … … 259 262 260 263 /** 264 * Prepares the value for editing on the client. 265 * 266 * @since 6.8.3 267 * 268 * @return array|false Value prepared for the client. 269 */ 270 public function js_value() { 271 $value = parent::js_value(); 272 if ( is_array( $value ) && isset( $value['original_title'] ) ) { 273 // Decode entities for the sake of displaying the original title as a placeholder. 274 $value['original_title'] = html_entity_decode( $value['original_title'], ENT_QUOTES, get_bloginfo( 'charset' ) ); 275 } 276 return $value; 277 } 278 279 /** 261 280 * Get original title. 262 281 * … … 264 283 * 265 284 * @param object $item Nav menu item. 266 * @return string The original title .285 * @return string The original title, without entity decoding. 267 286 */ 268 287 protected function get_original_title( $item ) { … … 290 309 } 291 310 } 292 $original_title = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) );293 311 return $original_title; 294 312 } … … 346 364 $this->value['status'] = $this->value['post_status']; 347 365 unset( $this->value['post_status'] ); 348 }349 350 if ( ! isset( $this->value['original_title'] ) ) {351 $this->value['original_title'] = $this->get_original_title( (object) $this->value );352 366 } 353 367 … … 596 610 unset( $item->position ); 597 611 598 if ( empty( $item->original_title ) ) {599 $item->original_title = $this->get_original_title( $item );600 }601 612 if ( empty( $item->title ) && ! empty( $item->original_title ) ) { 602 $item->title = $item->original_title; 613 $item->title = $item->original_title; // This is NOT entity-decoded. It comes from self::get_original_title(). 603 614 } 604 615 if ( $item->title ) { … … 650 661 * @since 4.3.0 651 662 * 652 * @param array $menu_item_value Thevalue to sanitize.663 * @param array|false $value The menu item value to sanitize. 653 664 * @return array|false|null|WP_Error Null or WP_Error if an input isn't valid. False if it is marked for deletion. 654 665 * Otherwise the sanitized value. … … 704 715 } 705 716 706 $menu_item_value['original_title'] = sanitize_text_field( $menu_item_value['original_title'] );707 708 717 // Apply the same filters as when calling wp_insert_post(). 709 718
Note: See TracChangeset
for help on using the changeset viewer.