Changeset 8620 for branches/crazyhorse/wp-includes/query.php
- Timestamp:
- 08/11/2008 10:52:43 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crazyhorse/wp-includes/query.php
r8242 r8620 122 122 function is_tax( $slug = '' ) { 123 123 global $wp_query; 124 124 125 125 if ( !$wp_query->is_tax ) 126 126 return false; … … 215 215 $page = (array) $page; 216 216 217 217 if ( in_array( $page_obj->ID, $page ) ) 218 218 return true; 219 219 elseif ( in_array( $page_obj->post_title, $page ) ) … … 473 473 , 'category_name' 474 474 , 'tag' 475 , 'cat' 475 476 , 'tag_id' 476 477 , 'author_name' … … 774 775 775 776 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']); 777 778 778 779 if ( $this->is_posts_page && !$qv['withcomments'] ) … … 831 832 $groupby = ''; 832 833 $post_status_join = false; 834 835 if ( !isset($q['caller_get_posts']) ) 836 $q['caller_get_posts'] = false; 833 837 834 838 if ( !isset($q['post_type']) ) { … … 988 992 $n = ($q['exact']) ? '' : '%'; 989 993 $searchand = ''; 990 foreach( (array)$q['search_terms'] as $term) {994 foreach( (array) $q['search_terms'] as $term) { 991 995 $term = addslashes_gpc($term); 992 996 $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))"; … … 1013 1017 $q['cat'] = ''; 1014 1018 $req_cats = array(); 1015 foreach ( $cat_array as $cat ) {1019 foreach ( (array) $cat_array as $cat ) { 1016 1020 $cat = intval($cat); 1017 1021 $req_cats[] = $cat; … … 1124 1128 $include_tags = "'" . implode("', '", $q['tag_slug__in']) . "'"; 1125 1129 $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' ); 1127 1131 if ( !empty($reqtag) ) 1128 $q['tag_id'] = $reqtag ['term_id'];1132 $q['tag_id'] = $reqtag->term_id; 1129 1133 } 1130 1134 … … 1355 1359 if ( ! empty($q['meta_key']) || ! empty($q['meta_value']) ) 1356 1360 $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']) ) 1358 1362 $where .= $wpdb->prepare("AND $wpdb->postmeta.meta_key = %s ", $q['meta_key']); 1359 1363 if ( ! empty($q['meta_value']) ) … … 1495 1499 } 1496 1500 } 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++; 1497 1534 } 1498 1535 }
Note: See TracChangeset
for help on using the changeset viewer.