Make WordPress Core


Ignore:
Timestamp:
06/20/2015 07:49:43 PM (11 years ago)
Author:
ocean90
Message:

Customizer: Improve handling of posts with no title.

Use the #%d (no title) string as a fallback which is already used on the nav menus screen.
Add a translator comment to all occurrences of the #%d (no title) string.

see #32576.

File:
1 edited

Legend:

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

    r32891 r32892  
    110110                        ) );
    111111                        foreach ( $posts as $post ) {
     112                                $post_title = $post->post_title;
     113                                if ( '' === $post_title ) {
     114                                        /* translators: %d: ID of a post */
     115                                        $post_title = sprintf( __( '#%d (no title)' ), $post->ID );
     116                                }
    112117                                $items[] = array(
    113118                                        'id'         => "post-{$post->ID}",
    114                                         'title'      => html_entity_decode( get_the_title( $post ), ENT_QUOTES, get_bloginfo( 'charset' ) ),
     119                                        'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
    115120                                        'type'       => 'post_type',
    116121                                        'type_label' => get_post_type_object( $post->post_type )->labels->singular_name,
     
    217222                if ( $get_posts->post_count ) {
    218223                        foreach ( $get_posts->posts as $post ) {
     224                                $post_title = $post->post_title;
     225                                if ( '' === $post_title ) {
     226                                        /* translators: %d: ID of a post */
     227                                        $post_title = sprintf( __( '#%d (no title)' ), $post->ID );
     228                                }
    219229                                $results[] = array(
    220230                                        'id'         => 'post-' . $post->ID,
     
    223233                                        'object'     => $post->post_type,
    224234                                        'object_id'  => intval( $post->ID ),
    225                                         'title'      => html_entity_decode( get_the_title( $post ), ENT_QUOTES, get_bloginfo( 'charset' ) ),
     235                                        'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
    226236                                );
    227237                        }
     
    271281                        'itemTypes'            => $this->available_item_types(),
    272282                        'l10n'                 => array(
    273                                 'untitled'          => _x( '(no label)', 'Missing menu item navigation label.' ),
     283                                'untitled'          => _x( '(no label)', 'missing menu item navigation label' ),
    274284                                'custom_label'      => __( 'Custom Link' ),
    275285                                /* translators: %s: Current menu location */
Note: See TracChangeset for help on using the changeset viewer.