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
This commit is contained in:
parent
724b22938e
commit
5f9ef8fed3
|
@ -109,9 +109,14 @@ final class WP_Customize_Nav_Menus {
|
||||||
'post_type' => $taxonomy_or_post_type,
|
'post_type' => $taxonomy_or_post_type,
|
||||||
) );
|
) );
|
||||||
foreach ( $posts as $post ) {
|
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(
|
$items[] = array(
|
||||||
'id' => "post-{$post->ID}",
|
'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' => 'post_type',
|
||||||
'type_label' => get_post_type_object( $post->post_type )->labels->singular_name,
|
'type_label' => get_post_type_object( $post->post_type )->labels->singular_name,
|
||||||
'object' => $post->post_type,
|
'object' => $post->post_type,
|
||||||
|
@ -216,13 +221,18 @@ final class WP_Customize_Nav_Menus {
|
||||||
// Check if any posts were found.
|
// Check if any posts were found.
|
||||||
if ( $get_posts->post_count ) {
|
if ( $get_posts->post_count ) {
|
||||||
foreach ( $get_posts->posts as $post ) {
|
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(
|
$results[] = array(
|
||||||
'id' => 'post-' . $post->ID,
|
'id' => 'post-' . $post->ID,
|
||||||
'type' => 'post_type',
|
'type' => 'post_type',
|
||||||
'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name,
|
'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name,
|
||||||
'object' => $post->post_type,
|
'object' => $post->post_type,
|
||||||
'object_id' => intval( $post->ID ),
|
'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(),
|
'allMenus' => wp_get_nav_menus(),
|
||||||
'itemTypes' => $this->available_item_types(),
|
'itemTypes' => $this->available_item_types(),
|
||||||
'l10n' => array(
|
'l10n' => array(
|
||||||
'untitled' => _x( '(no label)', 'Missing menu item navigation label.' ),
|
'untitled' => _x( '(no label)', 'missing menu item navigation label' ),
|
||||||
'custom_label' => __( 'Custom Link' ),
|
'custom_label' => __( 'Custom Link' ),
|
||||||
/* translators: %s: Current menu location */
|
/* translators: %s: Current menu location */
|
||||||
'menuLocation' => __( '(Currently set to: %s)' ),
|
'menuLocation' => __( '(Currently set to: %s)' ),
|
||||||
|
|
|
@ -702,6 +702,7 @@ function wp_setup_nav_menu_item( $menu_item ) {
|
||||||
$original_title = $original_object->post_title;
|
$original_title = $original_object->post_title;
|
||||||
|
|
||||||
if ( '' === $original_title ) {
|
if ( '' === $original_title ) {
|
||||||
|
/* translators: %d: ID of a post */
|
||||||
$original_title = sprintf( __( '#%d (no title)' ), $original_object->ID );
|
$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->object = $object->name;
|
||||||
$menu_item->type_label = $object->labels->singular_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->post_title = sprintf( __( '#%d (no title)' ), $menu_item->ID );
|
||||||
|
}
|
||||||
|
|
||||||
$menu_item->title = $menu_item->post_title;
|
$menu_item->title = $menu_item->post_title;
|
||||||
$menu_item->url = get_permalink( $menu_item->ID );
|
$menu_item->url = get_permalink( $menu_item->ID );
|
||||||
|
|
|
@ -1418,6 +1418,7 @@ class Walker_Page extends Walker {
|
||||||
$css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
|
$css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
|
||||||
|
|
||||||
if ( '' === $page->post_title ) {
|
if ( '' === $page->post_title ) {
|
||||||
|
/* translators: %d: ID of a post */
|
||||||
$page->post_title = sprintf( __( '#%d (no title)' ), $page->ID );
|
$page->post_title = sprintf( __( '#%d (no title)' ), $page->ID );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1508,6 +1509,7 @@ class Walker_PageDropdown extends Walker {
|
||||||
|
|
||||||
$title = $page->post_title;
|
$title = $page->post_title;
|
||||||
if ( '' === $title ) {
|
if ( '' === $title ) {
|
||||||
|
/* translators: %d: ID of a post */
|
||||||
$title = sprintf( __( '#%d (no title)' ), $page->ID );
|
$title = sprintf( __( '#%d (no title)' ), $page->ID );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue