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: https://develop.svn.wordpress.org/trunk@23372 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
712fcec00b
commit
6caa05bc81
|
@ -472,18 +472,14 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||||
$title = _draft_or_post_title();
|
$title = _draft_or_post_title();
|
||||||
$post_type_object = get_post_type_object( $post->post_type );
|
$post_type_object = get_post_type_object( $post->post_type );
|
||||||
$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
|
$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';
|
$alternate = 'alternate' == $alternate ? '' : 'alternate';
|
||||||
$classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
|
$classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
|
||||||
|
|
||||||
if ( $lock_holder_id ) {
|
$lock_holder = wp_check_post_lock( $post->ID );
|
||||||
|
if ( $lock_holder ) {
|
||||||
$classes .= ' wp-locked';
|
$classes .= ' wp-locked';
|
||||||
$lock_holder_data = get_user_by( 'id', $lock_holder_id );
|
$lock_holder = get_userdata( $lock_holder );
|
||||||
|
|
||||||
if ( $lock_holder_data )
|
|
||||||
$lock_holder = esc_html( sprintf( __('Currently edited by %s'), $lock_holder_data->data->display_name ) );
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>" valign="top">
|
<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;
|
break;
|
||||||
|
|
||||||
case 'title':
|
case 'title':
|
||||||
if ( $this->hierarchical_display ) {
|
|
||||||
$attributes = 'class="post-title page-title column-title"' . $style;
|
$attributes = 'class="post-title page-title column-title"' . $style;
|
||||||
|
if ( $this->hierarchical_display ) {
|
||||||
if ( 0 == $level && (int) $post->post_parent > 0 ) {
|
if ( 0 == $level && (int) $post->post_parent > 0 ) {
|
||||||
//sent level 0 by accident, by default, or because we don't know the actual level
|
//sent level 0 by accident, by default, or because we don't know the actual level
|
||||||
$find_main_page = (int) $post->post_parent;
|
$find_main_page = (int) $post->post_parent;
|
||||||
|
@ -539,36 +534,29 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||||
$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
|
$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$pad = str_repeat( '— ', $level );
|
$pad = str_repeat( '— ', $level );
|
||||||
|
echo "<td $attributes><strong>";
|
||||||
?>
|
|
||||||
<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 “%s”' ), $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' ) {
|
if ( $can_edit_post && $post->post_status != 'trash' ) {
|
||||||
?>
|
echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
|
||||||
<span class="lock-holder"><?php echo $lock_holder; ?></span>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$attributes = 'class="post-title page-title column-title"' . $style;
|
echo $pad . $title;
|
||||||
|
}
|
||||||
|
_post_states( $post );
|
||||||
|
|
||||||
$pad = str_repeat( '— ', $level );
|
if ( isset( $parent_name ) )
|
||||||
|
echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
|
||||||
|
|
||||||
?>
|
echo "</strong>\n";
|
||||||
<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 “%s”' ), $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' ) {
|
if ( $lock_holder && $can_edit_post && $post->post_status != 'trash' ) {
|
||||||
?>
|
printf( '<span class="lock-holder">%s</span>',
|
||||||
<span class="lock-holder"><?php echo $lock_holder; ?></span>
|
esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ) );
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
|
if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
|
||||||
the_excerpt();
|
the_excerpt();
|
||||||
}
|
|
||||||
|
|
||||||
$actions = array();
|
$actions = array();
|
||||||
if ( $can_edit_post && 'trash' != $post->post_status ) {
|
if ( $can_edit_post && 'trash' != $post->post_status ) {
|
||||||
|
|
Loading…
Reference in New Issue