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.

git-svn-id: http://core.svn.wordpress.org/trunk@23372 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-02-02 01:54:06 +00:00
parent 0674bbfa8a
commit 91e3f2b866
1 changed files with 27 additions and 39 deletions

View File

@ -472,18 +472,14 @@ class WP_Posts_List_Table extends WP_List_Table {
$title = _draft_or_post_title();
$post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
$lock_holder_id = wp_check_post_lock( $post->ID );
$lock_holder = '';
$alternate = 'alternate' == $alternate ? '' : 'alternate';
$classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
if ( $lock_holder_id ) {
$classes .= ' wp-locked';
$lock_holder_data = get_user_by( 'id', $lock_holder_id );
if ( $lock_holder_data )
$lock_holder = esc_html( sprintf( __('Currently edited by %s'), $lock_holder_data->data->display_name ) );
$lock_holder = wp_check_post_lock( $post->ID );
if ( $lock_holder ) {
$classes .= ' wp-locked';
$lock_holder = get_userdata( $lock_holder );
}
?>
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>" valign="top">
@ -520,9 +516,8 @@ class WP_Posts_List_Table extends WP_List_Table {
break;
case 'title':
$attributes = 'class="post-title page-title column-title"' . $style;
if ( $this->hierarchical_display ) {
$attributes = 'class="post-title page-title column-title"' . $style;
if ( 0 == $level && (int) $post->post_parent > 0 ) {
//sent level 0 by accident, by default, or because we don't know the actual level
$find_main_page = (int) $post->post_parent;
@ -539,37 +534,30 @@ class WP_Posts_List_Table extends WP_List_Table {
$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
}
}
$pad = str_repeat( '&#8212; ', $level );
?>
<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>
<?php
if ( $can_edit_post && $post->post_status != 'trash' ) {
?>
<span class="lock-holder"><?php echo $lock_holder; ?></span>
<?php
}
} else {
$attributes = 'class="post-title page-title column-title"' . $style;
$pad = str_repeat( '&#8212; ', $level );
?>
<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>
<?php
if ( $can_edit_post && $post->post_status != 'trash' ) {
?>
<span class="lock-holder"><?php echo $lock_holder; ?></span>
<?php
}
if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
the_excerpt();
}
$pad = str_repeat( '&#8212; ', $level );
echo "<td $attributes><strong>";
if ( $can_edit_post && $post->post_status != 'trash' ) {
echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . $pad . $title . '</a>';
} else {
echo $pad . $title;
}
_post_states( $post );
if ( isset( $parent_name ) )
echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
echo "</strong>\n";
if ( $lock_holder && $can_edit_post && $post->post_status != 'trash' ) {
printf( '<span class="lock-holder">%s</span>',
esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ) );
}
if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
the_excerpt();
$actions = array();
if ( $can_edit_post && 'trash' != $post->post_status ) {
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';