From 70a3aa877d944ceacaa5d2dd1a7b264bd50a34ff Mon Sep 17 00:00:00 2001 From: westi Date: Tue, 30 Sep 2008 21:32:13 +0000 Subject: [PATCH] Introduce _draft_or_post_title() instead of lots of duplicated (no title) code. Fixes #7801. git-svn-id: http://svn.automattic.com/wordpress/trunk@9041 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-attachment-rows.php | 9 ++------- wp-admin/includes/template.php | 29 +++++++++++++++++++---------- wp-admin/upload.php | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/wp-admin/edit-attachment-rows.php b/wp-admin/edit-attachment-rows.php index 93ebd3bba8..e952bc920e 100644 --- a/wp-admin/edit-attachment-rows.php +++ b/wp-admin/edit-attachment-rows.php @@ -30,9 +30,7 @@ while (have_posts()) : the_post(); $class = 'alternate' == $class ? '' : 'alternate'; global $current_user; $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); -$att_title = get_the_title(); -if ( empty($att_title) ) - $att_title = __('(no title)'); +$att_title = _draft_or_post_title(); ?> post_status ); ?>' valign="top"> @@ -140,12 +138,9 @@ foreach ($posts_columns as $column_name => $column_display_name ) { break; case 'parent': - $title = __('(no title)'); // override below if ( $post->post_parent > 0 ) { if ( get_post($post->post_parent) ) { - $parent_title = get_the_title($post->post_parent); - if ( !empty($parent_title) ) - $title = $parent_title; + $title =_draft_or_post_title($post->post_parent); } ?> >, diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index f04f1e580d..a6b4335170 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -893,9 +893,7 @@ function get_inline_data($post) { if ( ! current_user_can('edit_' . $post->post_type, $post->ID) ) return; - $title = apply_filters( 'the_title', $post->post_title ); - if ( empty($title) ) - $title = __('(no title)'); + $title = _draft_or_post_title($post->ID); echo ' \n"; } - +/** + * Get the post title. + * + * The post title is fetched and if it is blank then a default string is returned. + * + * @since 2.7.0 + * @param int $id The post id. If not supplied the global $post is used.. + * + */ +function _draft_or_post_title($post_id = 0) +{ + $title = get_the_title($post_id); + if ( empty($title) ) + $title = __('(no title)'); + return $title; +} ?> diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 07019c9ee9..e6e94dbd7e 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -320,7 +320,7 @@ if ( $page_links ) if ( $orphans ) { foreach ( $orphans as $post ) { $class = 'alternate' == $class ? '' : 'alternate'; - $att_title = empty($post->post_title) ? __('(no title)') : wp_specialchars( apply_filters('the_title', $post->post_title) ); + $att_title = wp_specialchars( _draft_or_post_title($post->ID) ); ?>