Make WordPress Core


Ignore:
Timestamp:
08/11/2008 10:52:43 PM (17 years ago)
Author:
ryan
Message:

crazyhorse: merge with log:trunk@8334:8619 , merge arrows unresolved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/crazyhorse/wp-includes/query.php

    r8242 r8620  
    122122function is_tax( $slug = '' ) {
    123123    global $wp_query;
    124    
     124
    125125    if ( !$wp_query->is_tax )
    126126        return false;
     
    215215    $page = (array) $page;
    216216
    217     if ( in_array( $page_obj->ID, $page ) )
     217    if ( in_array( $page_obj->ID, $page ) )
    218218        return true;
    219219    elseif ( in_array( $page_obj->post_title, $page ) )
     
    473473            , 'category_name'
    474474            , 'tag'
     475            , 'cat'
    475476            , 'tag_id'
    476477            , 'author_name'
     
    774775
    775776        if ( !empty($qv['post_status']) )
    776             $qv['post_status'] = sanitize_user($qv['post_status'], true);
     777            $qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
    777778
    778779        if ( $this->is_posts_page && !$qv['withcomments'] )
     
    831832        $groupby = '';
    832833        $post_status_join = false;
     834
     835        if ( !isset($q['caller_get_posts']) )
     836            $q['caller_get_posts'] = false;
    833837
    834838        if ( !isset($q['post_type']) ) {
     
    988992            $n = ($q['exact']) ? '' : '%';
    989993            $searchand = '';
    990             foreach((array)$q['search_terms'] as $term) {
     994            foreach( (array) $q['search_terms'] as $term) {
    991995                $term = addslashes_gpc($term);
    992996                $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))";
     
    10131017            $q['cat'] = '';
    10141018            $req_cats = array();
    1015             foreach ( $cat_array as $cat ) {
     1019            foreach ( (array) $cat_array as $cat ) {
    10161020                $cat = intval($cat);
    10171021                $req_cats[] = $cat;
     
    11241128            $include_tags = "'" . implode("', '", $q['tag_slug__in']) . "'";
    11251129            $whichcat .= " AND $wpdb->terms.slug IN ($include_tags) ";
    1126             $reqtag = is_term( $q['tag_slug__in'][0], 'post_tag' );
     1130            $reqtag = get_term_by( 'slug', $q['tag_slug__in'][0], 'post_tag' );
    11271131            if ( !empty($reqtag) )
    1128                 $q['tag_id'] = $reqtag['term_id'];
     1132                $q['tag_id'] = $reqtag->term_id;
    11291133        }
    11301134
     
    13551359        if ( ! empty($q['meta_key']) || ! empty($q['meta_value']) )
    13561360            $join .= " LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
    1357         if ( ! empty($q['meta_key']) ) 
     1361        if ( ! empty($q['meta_key']) )
    13581362            $where .= $wpdb->prepare("AND $wpdb->postmeta.meta_key = %s ", $q['meta_key']);
    13591363        if ( ! empty($q['meta_value']) )
     
    14951499                    }
    14961500                }
     1501            }
     1502        }
     1503
     1504        // Put sticky posts at the top of the posts array
     1505        $sticky_posts = get_option('sticky_posts');
     1506        if ( $this->is_home && $page <= 1 && !empty($sticky_posts) && !$q['caller_get_posts'] ) {
     1507            $num_posts = count($this->posts);
     1508            $sticky_offset = 0;
     1509            // Loop over posts and relocate stickies to the front.
     1510            for ( $i = 0; $i < $num_posts; $i++ ) {
     1511                if ( in_array($this->posts[$i]->ID, $sticky_posts) ) {
     1512                    $sticky_post = $this->posts[$i];
     1513                    // Remove sticky from current position
     1514                    array_splice($this->posts, $i, 1);
     1515                    // Move to front, after other stickies
     1516                    array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
     1517                    // Increment the sticky offset.  The next sticky will be placed at this offset.
     1518                    $sticky_offset++;
     1519                    // Remove post from sticky posts array
     1520                    $offset = array_search($sticky_post->ID, $sticky_posts);
     1521                    array_splice($sticky_posts, $offset, 1);
     1522                }
     1523            }
     1524
     1525            // Fetch sticky posts that weren't in the query results
     1526            $stickies__in = implode(',', array_map( 'absint', $sticky_posts ));
     1527            $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in)" );
     1528            // TODO Make sure post is published or viewable by the current user
     1529            foreach ( $stickies as $sticky_post ) {
     1530                if ( 'publish' != $sticky_post->post_status )
     1531                    continue;
     1532                array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
     1533                $sticky_offset++;
    14971534            }
    14981535        }
Note: See TracChangeset for help on using the changeset viewer.