From 5f9ef8fed344f4d5e45ef53197dd010371c4b7f0 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Sat, 20 Jun 2015 19:49:43 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@32892 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-customize-nav-menus.php | 16 +++++++++++++--- src/wp-includes/nav-menu.php | 5 ++++- src/wp-includes/post-template.php | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/class-wp-customize-nav-menus.php b/src/wp-includes/class-wp-customize-nav-menus.php index b15269d68b..0c4fb6f852 100644 --- a/src/wp-includes/class-wp-customize-nav-menus.php +++ b/src/wp-includes/class-wp-customize-nav-menus.php @@ -109,9 +109,14 @@ final class WP_Customize_Nav_Menus { 'post_type' => $taxonomy_or_post_type, ) ); foreach ( $posts as $post ) { + $post_title = $post->post_title; + if ( '' === $post_title ) { + /* translators: %d: ID of a post */ + $post_title = sprintf( __( '#%d (no title)' ), $post->ID ); + } $items[] = array( 'id' => "post-{$post->ID}", - 'title' => html_entity_decode( get_the_title( $post ), ENT_QUOTES, get_bloginfo( 'charset' ) ), + 'title' => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ), 'type' => 'post_type', 'type_label' => get_post_type_object( $post->post_type )->labels->singular_name, 'object' => $post->post_type, @@ -216,13 +221,18 @@ final class WP_Customize_Nav_Menus { // Check if any posts were found. if ( $get_posts->post_count ) { foreach ( $get_posts->posts as $post ) { + $post_title = $post->post_title; + if ( '' === $post_title ) { + /* translators: %d: ID of a post */ + $post_title = sprintf( __( '#%d (no title)' ), $post->ID ); + } $results[] = array( 'id' => 'post-' . $post->ID, 'type' => 'post_type', 'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name, 'object' => $post->post_type, 'object_id' => intval( $post->ID ), - 'title' => html_entity_decode( get_the_title( $post ), ENT_QUOTES, get_bloginfo( 'charset' ) ), + 'title' => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ), ); } } @@ -270,7 +280,7 @@ final class WP_Customize_Nav_Menus { 'allMenus' => wp_get_nav_menus(), 'itemTypes' => $this->available_item_types(), 'l10n' => array( - 'untitled' => _x( '(no label)', 'Missing menu item navigation label.' ), + 'untitled' => _x( '(no label)', 'missing menu item navigation label' ), 'custom_label' => __( 'Custom Link' ), /* translators: %s: Current menu location */ 'menuLocation' => __( '(Currently set to: %s)' ), diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index 578bf23e62..d255859190 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -702,6 +702,7 @@ function wp_setup_nav_menu_item( $menu_item ) { $original_title = $original_object->post_title; if ( '' === $original_title ) { + /* translators: %d: ID of a post */ $original_title = sprintf( __( '#%d (no title)' ), $original_object->ID ); } @@ -764,8 +765,10 @@ function wp_setup_nav_menu_item( $menu_item ) { $menu_item->object = $object->name; $menu_item->type_label = $object->labels->singular_name; - if ( '' === $menu_item->post_title ) + if ( '' === $menu_item->post_title ) { + /* translators: %d: ID of a post */ $menu_item->post_title = sprintf( __( '#%d (no title)' ), $menu_item->ID ); + } $menu_item->title = $menu_item->post_title; $menu_item->url = get_permalink( $menu_item->ID ); diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index f190ad0b9f..1b4901cc92 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -1418,6 +1418,7 @@ class Walker_Page extends Walker { $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); if ( '' === $page->post_title ) { + /* translators: %d: ID of a post */ $page->post_title = sprintf( __( '#%d (no title)' ), $page->ID ); } @@ -1508,6 +1509,7 @@ class Walker_PageDropdown extends Walker { $title = $page->post_title; if ( '' === $title ) { + /* translators: %d: ID of a post */ $title = sprintf( __( '#%d (no title)' ), $page->ID ); }