Make WordPress Core

Changeset 23372


Ignore:
Timestamp:
02/02/2013 01:54:06 AM (12 years ago)
Author:
nacin
Message:

Clean up rendering of the title column in the posts list table. Simplify branching. Use get_userdata() rather than get_user_by( 'id' ). Change string to '%s is currently editing'. see #23312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-posts-list-table.php

    r23371 r23372  
    473473        $post_type_object = get_post_type_object( $post->post_type );
    474474        $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
    475         $lock_holder_id = wp_check_post_lock( $post->ID );
    476         $lock_holder = '';
    477475
    478476        $alternate = 'alternate' == $alternate ? '' : 'alternate';
    479477        $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
    480    
    481         if ( $lock_holder_id ) {
     478
     479        $lock_holder = wp_check_post_lock( $post->ID );
     480        if ( $lock_holder ) {
    482481            $classes .= ' wp-locked';
    483             $lock_holder_data = get_user_by( 'id', $lock_holder_id );
    484 
    485             if ( $lock_holder_data )
    486                 $lock_holder = esc_html( sprintf( __('Currently edited by %s'), $lock_holder_data->data->display_name ) );
     482            $lock_holder = get_userdata( $lock_holder );
    487483        }
    488484    ?>
     
    521517
    522518            case 'title':
     519                $attributes = 'class="post-title page-title column-title"' . $style;
    523520                if ( $this->hierarchical_display ) {
    524                     $attributes = 'class="post-title page-title column-title"' . $style;
    525 
    526521                    if ( 0 == $level && (int) $post->post_parent > 0 ) {
    527522                        //sent level 0 by accident, by default, or because we don't know the actual level
     
    540535                        }
    541536                    }
    542 
    543                     $pad = str_repeat( '— ', $level );
    544 
    545                     ?>
    546                     <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); echo isset( $parent_name ) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''; ?></strong>
    547                     <?php
    548 
    549                     if ( $can_edit_post && $post->post_status != 'trash' ) {
    550                         ?>
    551                         <span class="lock-holder"><?php echo $lock_holder; ?></span>
    552                         <?php
    553                     }
     537                }
     538
     539                $pad = str_repeat( '&#8212; ', $level );
     540                echo "<td $attributes><strong>";
     541                if ( $can_edit_post && $post->post_status != 'trash' ) {
     542                    echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . $pad . $title . '</a>';
    554543                } else {
    555                     $attributes = 'class="post-title page-title column-title"' . $style;
    556 
    557                     $pad = str_repeat( '&#8212; ', $level );
    558 
    559                     ?>
    560                     <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong>
    561                     <?php
    562 
    563                     if ( $can_edit_post && $post->post_status != 'trash' ) {
    564                         ?>
    565                         <span class="lock-holder"><?php echo $lock_holder; ?></span>
    566                         <?php
    567                     }
    568 
    569                     if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
     544                    echo $pad . $title;
     545                }
     546                _post_states( $post );
     547
     548                if ( isset( $parent_name ) )
     549                    echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
     550
     551                echo "</strong>\n";
     552
     553                if ( $lock_holder && $can_edit_post && $post->post_status != 'trash' ) {
     554                    printf( '<span class="lock-holder">%s</span>',
     555                        esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name )  ) );
     556                }
     557
     558                if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
    570559                        the_excerpt();
    571                 }
    572560
    573561                $actions = array();
Note: See TracChangeset for help on using the changeset viewer.