From 6caa05bc81eb1715b062e1d168ff73301cca9dde Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sat, 2 Feb 2013 01:54:06 +0000 Subject: [PATCH] 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 --- .../includes/class-wp-posts-list-table.php | 66 ++++++++----------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index f0ba11c39a..0c0231bc86 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -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 ); } ?> @@ -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( '— ', $level ); - - ?> - >post_status != 'trash' ) { ?>labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''; ?> - post_status != 'trash' ) { - ?> - - - >post_status != 'trash' ) { ?> - post_status != 'trash' ) { - ?> - - ID ) ) - the_excerpt(); } + $pad = str_repeat( '— ', $level ); + echo ""; + if ( $can_edit_post && $post->post_status != 'trash' ) { + echo '' . $pad . $title . ''; + } else { + echo $pad . $title; + } + _post_states( $post ); + + if ( isset( $parent_name ) ) + echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); + + echo "\n"; + + if ( $lock_holder && $can_edit_post && $post->post_status != 'trash' ) { + printf( '%s', + 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'] = '' . __( 'Edit' ) . '';