Make WordPress Core

Changeset 14217


Ignore:
Timestamp:
04/24/2010 06:04:05 AM (16 years ago)
Author:
dd32
Message:

Ignore sticky posts which the current user cannot read, Ignore sticky posts which have been explicitly excluded with 'postnot_in'. Fixes #11197

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r14160 r14217  
    24662466                        }
    24672467
     2468                        // If any posts have been excluded specifically, Ignore those that are sticky.
     2469                        if ( !empty($sticky_posts) && !empty($q['post__not_in']) )
     2470                                $sticky_posts = array_diff($sticky_posts, $q['post__not_in']);
     2471
    24682472                        // Fetch sticky posts that weren't in the query results
    24692473                        if ( !empty($sticky_posts) ) {
     
    24792483                                        $stickies_where = "AND $wpdb->posts.post_type IN ('" . $post_types . "')";
    24802484                                }
     2485
    24812486                                $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in) $stickies_where" );
    2482                                 /** @todo Make sure post is published or viewable by the current user */
    24832487                                foreach ( $stickies as $sticky_post ) {
    2484                                         if ( 'publish' != $sticky_post->post_status )
     2488                                        // Ignore sticky posts the current user cannot read or are not published.
     2489                                        if ( !current_user_can('read_post', $sticky_post->ID) || 'publish' != $sticky_post->post_status )
    24852490                                                continue;
    24862491                                        array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
Note: See TracChangeset for help on using the changeset viewer.