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.
Built from https://develop.svn.wordpress.org/trunk@32892


git-svn-id: http://core.svn.wordpress.org/trunk@32863 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-06-20 19:50:26 +00:00
parent baeadbb6fb
commit f127478bde
4 changed files with 20 additions and 5 deletions

View File

@ -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)' ),

View File

@ -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 );

View File

@ -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 );
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32891';
$wp_version = '4.3-alpha-32892';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.