Changeset 16003 for trunk/wp-admin/includes/list-table-posts.php
- Timestamp:
- 10/27/2010 08:27:45 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/list-table-posts.php
r15958 r16003 22 22 * 23 23 * @since 3.1.0 24 * @var bool24 * @var int 25 25 * @access protected 26 26 */ … … 31 31 * 32 32 * @since 3.1.0 33 * @var bool33 * @var int 34 34 * @access private 35 35 */ 36 36 var $user_posts_count; 37 38 /** 39 * Holds the number of posts which are sticky. 40 * 41 * @since 3.1.0 42 * @var int 43 * @access private 44 */ 45 var $sticky_posts_count = 0; 37 46 38 47 function WP_Posts_Table() { … … 52 61 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " 53 62 SELECT COUNT( 1 ) FROM $wpdb->posts 54 WHERE post_type = '%s'AND post_status NOT IN ( 'trash', 'auto-draft' )63 WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' ) 55 64 AND post_author = %d 56 65 ", $post_type, get_current_user_id() ) ); 57 66 58 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) )67 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) 59 68 $_GET['author'] = get_current_user_id(); 69 } 70 71 if ( $sticky_posts = get_option( 'sticky_posts' ) ) { 72 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); 73 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND ID IN ($sticky_posts)", $post_type ) ); 60 74 } 61 75 … … 140 154 $total_posts -= $num_posts->$state; 141 155 142 $class = empty( $class) && empty($_REQUEST['post_status']) ? ' class="current"' : '';156 $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; 143 157 $status_links['all'] = "<li><a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>'; 144 158 … … 158 172 159 173 $status_links[$status_name] = "<li><a href='edit.php?post_status=$status_name&post_type=$post_type'$class>" . sprintf( _n( $status->label_count[0], $status->label_count[1], $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>'; 174 } 175 176 if ( ! empty( $this->sticky_posts_count ) ) { 177 $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; 178 179 $sticky_link = array( 'sticky' => "<li><a href='edit.php?post_type=$post_type&show_sticky=1'$class>" . sprintf( _nx( 'Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts' ), number_format_i18n( $this->sticky_posts_count ) ) . '</a>' ); 180 181 // Sticky comes after Publish, or if not listed, after All. 182 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); 183 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); 160 184 } 161 185
Note: See TracChangeset
for help on using the changeset viewer.