Changeset 15605 for trunk/wp-admin/includes/default-list-tables.php
- Timestamp:
- 09/09/2010 10:22:36 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/default-list-tables.php
r15604 r15605 30 30 var $comment_pending_count; 31 31 32 /** 33 * Holds the number of posts for this user 34 * 35 * @since 3.1.0 36 * @var bool 37 * @access private 38 */ 39 var $user_posts_count; 40 32 41 function WP_Posts_Table() { 33 global $post_type_object, $post_type, $current_screen ;42 global $post_type_object, $post_type, $current_screen, $wpdb; 34 43 35 44 if ( !isset( $_REQUEST['post_type'] ) ) … … 43 52 $post_type_object = get_post_type_object( $post_type ); 44 53 54 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { 55 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " 56 SELECT COUNT( 1 ) FROM $wpdb->posts 57 WHERE post_type = '%s' AND post_status NOT IN ( 'trash', 'auto-draft' ) 58 AND post_author = %d 59 ", $post_type, get_current_user_id() ) ); 60 61 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) ) 62 $_GET['author'] = get_current_user_id(); 63 } 64 45 65 parent::WP_List_Table( array( 46 66 'screen' => $current_screen, … … 99 119 function get_views() { 100 120 global $post_type, $post_type_object, $locked_post_status, $avail_post_stati; 101 121 102 122 if ( !empty($locked_post_status) ) 103 123 return array(); … … 108 128 $allposts = ''; 109 129 110 $user_posts = false; 111 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { 112 $user_posts = true; 113 114 $user_posts_count = $wpdb->get_var( $wpdb->prepare( " 115 SELECT COUNT( 1 ) FROM $wpdb->posts 116 WHERE post_type = '%s' AND post_status NOT IN ( 'trash', 'auto-draft' ) 117 AND post_author = %d 118 ", $post_type, get_current_user_id() ) ); 119 120 if ( $user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) ) 121 $_REQUEST['author'] = get_current_user_id(); 122 } 123 124 if ( $user_posts ) { 125 if ( isset( $_REQUEST['author'] ) && ( $_REQUEST['author'] == $current_user->ID ) ) 130 $current_user_id = get_current_user_id(); 131 132 if ( $this->user_posts_count ) { 133 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) 126 134 $class = ' class="current"'; 127 $status_links[' author'] = "<li><a href='edit.php?post_type=$post_type&author=$current_user->ID'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>';135 $status_links['mine'] = "<li><a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>'; 128 136 $allposts = '&all_posts=1'; 129 137 }
Note: See TracChangeset
for help on using the changeset viewer.