WordPress.org

Make WordPress Core

Changeset 9041


Ignore:
Timestamp:
09/30/2008 09:32:13 PM (13 years ago)
Author:
westi
Message:

Introduce _draft_or_post_title() instead of lots of duplicated (no title) code. Fixes #7801.

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-attachment-rows.php

    r9028 r9041  
    3131global $current_user;
    3232$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
    33 $att_title = get_the_title();
    34 if ( empty($att_title) )
    35     $att_title = __('(no title)');
     33$att_title = _draft_or_post_title();
    3634
    3735?>
     
    141139
    142140    case 'parent':
    143         $title = __('(no title)'); // override below
    144141        if ( $post->post_parent > 0 ) {
    145142            if ( get_post($post->post_parent) ) {
    146                 $parent_title = get_the_title($post->post_parent);
    147                 if ( !empty($parent_title) )
    148                     $title = $parent_title;
     143                $title =_draft_or_post_title($post->post_parent);
    149144            }
    150145            ?>
  • trunk/wp-admin/includes/template.php

    r9036 r9041  
    894894        return;
    895895   
    896     $title = apply_filters( 'the_title', $post->post_title );
    897     if ( empty($title) )
    898         $title = __('(no title)');
     896    $title = _draft_or_post_title($post->ID);
    899897
    900898    echo '
     
    966964    $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
    967965    $edit_link = get_edit_post_link( $post->ID );
    968     $title = get_the_title();
    969     if ( empty($title) )
    970         $title = __('(no title)');
     966    $title = _draft_or_post_title();
    971967?>
    972968    <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
     
    11841180    $posts_columns = wp_manage_pages_columns();
    11851181    $hidden = (array) get_user_option( 'manage-page-columns-hidden' );
    1186     $title = get_the_title();
    1187     if ( empty($title) )
    1188         $title = __('(no title)');
     1182    $title = _draft_or_post_title();
    11891183?>
    11901184<tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
     
    25012495    echo "</div></div>\n";
    25022496}
    2503 
     2497/**
     2498 * Get the post title.
     2499 *
     2500 * The post title is fetched and if it is blank then a default string is returned.
     2501 *
     2502 * @since 2.7.0
     2503 * @param int $id The post id. If not supplied the global $post is used..
     2504 *
     2505 */
     2506function _draft_or_post_title($post_id = 0)
     2507{
     2508    $title = get_the_title($post_id);
     2509    if ( empty($title) )
     2510        $title = __('(no title)');
     2511    return $title;
     2512}
    25042513?>
  • trunk/wp-admin/upload.php

    r9032 r9041  
    321321        foreach ( $orphans as $post ) {
    322322            $class = 'alternate' == $class ? '' : 'alternate';
    323             $att_title = empty($post->post_title) ? __('(no title)') : wp_specialchars( apply_filters('the_title', $post->post_title) );
     323            $att_title = wp_specialchars( _draft_or_post_title($post->ID) );
    324324?>
    325325    <tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top">
Note: See TracChangeset for help on using the changeset viewer.