Make WordPress Core


Ignore:
Timestamp:
09/30/2025 04:26:44 PM (10 months ago)
Author:
johnbillion
Message:

Menus: Prevent HTML in menu item titles from being rendered unexpectedly.

Props audrasjb, desrosj, johnbillion, jorbin, phillsav, vortfu, westonruter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-nav-menus.php

    r60715 r60815  
    192192                        } elseif ( 'post' !== $object_name && 0 === $page && $post_type->has_archive ) {
    193193                                // Add a post type archive link.
     194                                $title   = $post_type->labels->archives;
    194195                                $items[] = array(
    195                                         'id'         => $object_name . '-archive',
    196                                         'title'      => $post_type->labels->archives,
    197                                         'type'       => 'post_type_archive',
    198                                         'type_label' => __( 'Post Type Archive' ),
    199                                         'object'     => $object_name,
    200                                         'url'        => get_post_type_archive_link( $object_name ),
     196                                        'id'             => $object_name . '-archive',
     197                                        'title'          => $title,
     198                                        'original_title' => $title,
     199                                        'type'           => 'post_type_archive',
     200                                        'type_label'     => __( 'Post Type Archive' ),
     201                                        'object'         => $object_name,
     202                                        'url'            => get_post_type_archive_link( $object_name ),
    201203                                );
    202204                        }
     
    245247                                }
    246248
     249                                $title   = html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) );
    247250                                $items[] = array(
    248                                         'id'         => "post-{$post->ID}",
    249                                         'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
    250                                         'type'       => 'post_type',
    251                                         'type_label' => $post_type_label,
    252                                         'object'     => $post->post_type,
    253                                         'object_id'  => (int) $post->ID,
    254                                         'url'        => get_permalink( (int) $post->ID ),
     251                                        'id'             => "post-{$post->ID}",
     252                                        'title'          => $title,
     253                                        'original_title' => $title,
     254                                        'type'           => 'post_type',
     255                                        'type_label'     => $post_type_label,
     256                                        'object'         => $post->post_type,
     257                                        'object_id'      => (int) $post->ID,
     258                                        'url'            => get_permalink( (int) $post->ID ),
    255259                                );
    256260                        }
     
    277281
    278282                        foreach ( $terms as $term ) {
     283                                $title   = html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) );
    279284                                $items[] = array(
    280                                         'id'         => "term-{$term->term_id}",
    281                                         'title'      => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
    282                                         'type'       => 'taxonomy',
    283                                         'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
    284                                         'object'     => $term->taxonomy,
    285                                         'object_id'  => (int) $term->term_id,
    286                                         'url'        => get_term_link( (int) $term->term_id, $term->taxonomy ),
     285                                        'id'             => "term-{$term->term_id}",
     286                                        'title'          => $title,
     287                                        'original_title' => $title,
     288                                        'type'           => 'taxonomy',
     289                                        'type_label'     => get_taxonomy( $term->taxonomy )->labels->singular_name,
     290                                        'object'         => $term->taxonomy,
     291                                        'object_id'      => (int) $term->term_id,
     292                                        'url'            => get_term_link( (int) $term->term_id, $term->taxonomy ),
    287293                                );
    288294                        }
Note: See TracChangeset for help on using the changeset viewer.