Make WordPress Core


Ignore:
Timestamp:
09/30/2025 05:00:33 PM (5 months ago)
Author:
desrosj
Message:

Grouped backports for the 6.6 branch.

  • REST API: Increase the specificity of capability checks for collections when the edit context is in use.
  • Menus: Prevent HTML in menu item titles from being rendered unexpectedly.

Merges [60814], [60815], [60816] to the 6.6 branch.

Props andraganescu, desrosj, ehti, hurayraiit, iandunn, joehoyle, johnbillion, jorbin, mnelson4, noisysocks, peterwilsoncc, phillsav, rmccue, timothyblynjacobs, vortfu, westonruter , whyisjake, zieladam.

Location:
branches/6.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.6

  • branches/6.6/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r56548 r60820  
    5757        'xfn'              => '',
    5858        'status'           => 'publish',
    59         'original_title'   => '',
    6059        'nav_menu_term_id' => 0, // This will be supplied as the $menu_id arg for wp_update_nav_menu_item().
    6160        '_invalid'         => false,
     
    211210     */
    212211    public function value() {
     212        $type_label = null;
    213213        if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) {
    214214            $undefined  = new stdClass(); // Symbol.
     
    219219            } else {
    220220                $value = $post_value;
    221             }
    222             if ( ! empty( $value ) && empty( $value['original_title'] ) ) {
    223                 $value['original_title'] = $this->get_original_title( (object) $value );
    224221            }
    225222        } elseif ( isset( $this->value ) ) {
     
    234231                    $is_title_empty = empty( $post->post_title );
    235232                    $value          = (array) wp_setup_nav_menu_item( $post );
     233                    if ( isset( $value['type_label'] ) ) {
     234                        $type_label = $value['type_label'];
     235                    }
    236236                    if ( $is_title_empty ) {
    237237                        $value['title'] = '';
     
    250250        }
    251251
    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 );
    254257        }
    255258
     
    258261
    259262    /**
     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    /**
    260279     * Get original title.
    261280     *
     
    263282     *
    264283     * @param object $item Nav menu item.
    265      * @return string The original title.
     284     * @return string The original title, without entity decoding.
    266285     */
    267286    protected function get_original_title( $item ) {
     
    289308            }
    290309        }
    291         $original_title = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) );
    292310        return $original_title;
    293311    }
     
    345363            $this->value['status'] = $this->value['post_status'];
    346364            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 );
    351365        }
    352366
     
    595609        unset( $item->position );
    596610
    597         if ( empty( $item->original_title ) ) {
    598             $item->original_title = $this->get_original_title( $item );
    599         }
    600611        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().
    602613        }
    603614        if ( $item->title ) {
     
    655666     * @since 5.9.0 Renamed `$menu_item_value` to `$value` for PHP 8 named parameter support.
    656667     *
    657      * @param array $value The menu item value to sanitize.
     668     * @param array|false $value The menu item value to sanitize.
    658669     * @return array|false|null|WP_Error Null or WP_Error if an input isn't valid. False if it is marked for deletion.
    659670     *                                   Otherwise the sanitized value.
     
    712723        }
    713724
    714         $menu_item_value['original_title'] = sanitize_text_field( $menu_item_value['original_title'] );
    715 
    716725        // Apply the same filters as when calling wp_insert_post().
    717726
Note: See TracChangeset for help on using the changeset viewer.