Ticket #8466: 8466.2.diff
File 8466.2.diff, 4.4 KB (added by , 14 years ago) |
---|
-
wp-admin/includes/default-list-tables.php
24 24 * Holds the number of pending comments for each post 25 25 * 26 26 * @since 3.1.0 27 * @var bool27 * @var int 28 28 * @access protected 29 29 */ 30 30 var $comment_pending_count; … … 33 33 * Holds the number of posts for this user 34 34 * 35 35 * @since 3.1.0 36 * @var bool36 * @var int 37 37 * @access private 38 38 */ 39 39 var $user_posts_count; 40 40 41 /** 42 * Holds the number of posts which are sticky. 43 * 44 * @since 3.1.0 45 * @var int 46 * @access private 47 */ 48 var $sticky_posts_count = 0; 49 41 50 function WP_Posts_Table() { 42 51 global $post_type_object, $post_type, $current_screen, $wpdb; 43 52 … … 54 63 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { 55 64 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " 56 65 SELECT COUNT( 1 ) FROM $wpdb->posts 57 WHERE post_type = '%s'AND post_status NOT IN ( 'trash', 'auto-draft' )66 WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' ) 58 67 AND post_author = %d 59 68 ", $post_type, get_current_user_id() ) ); 60 69 61 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) )70 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) 62 71 $_GET['author'] = get_current_user_id(); 63 72 } 64 73 74 if ( $sticky_posts = get_option( 'sticky_posts' ) ) { 75 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); 76 $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 ) ); 77 } 78 65 79 parent::WP_List_Table( array( 66 80 'screen' => $current_screen, 67 81 'plural' => 'posts', … … 142 156 foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) 143 157 $total_posts -= $num_posts->$state; 144 158 145 $class = empty( $class) && empty($_REQUEST['post_status']) ? ' class="current"' : '';159 $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; 146 160 $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>'; 147 161 148 162 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { … … 161 175 162 176 $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>'; 163 177 } 164 178 179 if ( ! empty( $this->sticky_posts_count ) ) { 180 $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; 181 182 $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>' ); 183 184 // Sticky comes after Publish, or if not listed, after All. 185 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); 186 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); 187 } 188 165 189 return $status_links; 166 190 } 167 191 -
wp-admin/includes/post.php
853 853 $query['posts_per_archive_page'] = -1; 854 854 } 855 855 856 wp( $query ); 856 if ( ! empty( $q['show_sticky'] ) ) 857 $query['post__in'] = (array) get_option( 'sticky_posts' ); 857 858 859 query_posts( $query ); 860 858 861 return $avail_post_stati; 859 862 } 860 863 … … 920 923 if ( isset($q['detached']) ) 921 924 add_filter('posts_where', '_edit_attachments_query_helper'); 922 925 923 wp($q);926 query_posts( $q ); 924 927 925 928 if ( isset($q['detached']) ) 926 929 remove_filter('posts_where', '_edit_attachments_query_helper');