Make WordPress Core

Changeset 6467


Ignore:
Timestamp:
12/22/2007 08:19:10 AM (19 years ago)
Author:
ryan
Message:

Throw pages into search queries. Let's see how they handle. see #5149

File:
1 edited

Legend:

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

    r6435 r6467  
    750750                $groupby = '';
    751751
    752                 if ( !isset($q['post_type']) )
    753                         $q['post_type'] = 'post';
     752                if ( !isset($q['post_type']) ) {
     753                        if ( $this->is_search )
     754                                $q['post_type'] = 'any';
     755                        else
     756                                $q['post_type'] = 'post';
     757                }
    754758                $post_type = $q['post_type'];
    755759                if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
     
    886890                        if ($q['sentence']) {
    887891                                $q['search_terms'] = array($q['s']);
    888                         }
    889                         else {
     892                        } else {
    890893                                preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q[s], $matches);
    891894                                $q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
     
    898901                                $searchand = ' AND ';
    899902                        }
    900                         $term = addslashes_gpc($q['s']);
     903                        $term = $wpdb->escape($q['s']);
    901904                        if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] )
    902905                                $search .= " OR (post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')";
     
    11461149                } elseif ($this->is_single) {
    11471150                        $where .= " AND post_type = 'post'";
     1151                } elseif ( 'any' == $post_type ) {
     1152                        $where .= '';
    11481153                } else {
    11491154                        $where .= " AND post_type = '$post_type'";
Note: See TracChangeset for help on using the changeset viewer.