Changeset 6021
- Timestamp:
- 09/03/2007 06:14:05 PM (17 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r6011 r6021 2 2 3 3 class WP { 4 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', ' tag_id', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');5 6 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and' );4 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots'); 5 6 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id'); 7 7 var $extra_query_vars = array(); 8 8 -
trunk/wp-includes/query.php
r6012 r6021 421 421 422 422 $array_keys = array('category__in', 'category__not_in', 'category__and', 423 'tag__in', 'tag__not_in', 'tag__and' );423 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and'); 424 424 425 425 foreach ( $array_keys as $key ) { … … 607 607 $qv['tag__and'] = array_map('intval', $qv['tag__and']); 608 608 $this->is_category = true; 609 } 610 611 if ( !is_array($qv['tag_slug__in']) || empty($qv['tag_slug__in']) ) { 612 $qv['tag_slug__in'] = array(); 613 } else { 614 $qv['tag_slug__in'] = array_map('sanitize_title', $qv['tag_slug__in']); 615 $this->is_tag = true; 616 } 617 618 if ( !is_array($qv['tag_slug__and']) || empty($qv['tag_slug__amd']) ) { 619 $qv['tag_slug__and'] = array(); 620 } else { 621 $qv['tag_slug__and'] = array_map('sanitize_title', $qv['tag_slug__and']); 622 $this->is_tag = true; 609 623 } 610 624 … … 985 999 // Tags 986 1000 if ( '' != $q['tag'] ) { 987 $reqtag = is_term( $q['tag'], 'post_tag' ); 988 if ( !empty($reqtag) ) 989 $reqtag = $reqtag['term_id']; 990 else 991 $reqtag = 0; 992 993 $q['tag_id'] = $reqtag; 994 $q['tag__in'][] = $reqtag; 995 } 996 997 if ( !empty($q['tag__in']) || !empty($q['tag__not_in']) || !empty($q['tag__and']) ) { 1001 if ( strpos($q['tag'], ',') !== false ) { 1002 $tags = preg_split('/[,\s]+/', $q['tag']); 1003 foreach ( (array) $tags as $tag ) { 1004 $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); 1005 $q['tag_slug__in'][] = $tag; 1006 } 1007 } else if ( preg_match('/[+\s]+/', $q['tag']) ) { 1008 $tags = preg_split('/[+\s]+/', $q['tag']); 1009 foreach ( (array) $tags as $tag ) { 1010 $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); 1011 $q['tag_slug__and'][] = $tag; 1012 } 1013 } else { 1014 $q['tag'] = sanitize_term_field('slug', $q['tag'], 0, 'post_tag', 'db'); 1015 $reqtag = is_term( $q['tag'], 'post_tag' ); 1016 if ( !empty($reqtag) ) 1017 $reqtag = $reqtag['term_id']; 1018 else 1019 $reqtag = 0; 1020 1021 $q['tag_id'] = $reqtag; 1022 $q['tag__in'][] = $reqtag; 1023 } 1024 } 1025 1026 if ( !empty($q['tag__in']) || !empty($q['tag__not_in']) || !empty($q['tag__and']) || 1027 !empty($q['tag_slug__in']) || !empty($q['tag_slug__and']) ) { 998 1028 $groupby = "{$wpdb->posts}.ID"; 999 1029 } … … 1006 1036 } 1007 1037 1038 if ( !empty($q['tag_slug__in']) ) { 1039 $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) LEFT JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) "; 1040 $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'post_tag' "; 1041 $include_tags = "'" . implode("', '", $q['tag_slug__in']) . "'"; 1042 $whichcat .= " AND $wpdb->terms.slug IN ($include_tags) "; 1043 } 1044 1008 1045 if ( !empty($q['tag__not_in']) ) { 1009 1046 $ids = get_objects_in_term($q['tag__not_in'], 'post_tag'); … … 1014 1051 } 1015 1052 1016 if ( !empty($q['tag_ _and']) ) {1053 if ( !empty($q['tag_slug__and']) ) { 1017 1054 $count = 0; 1018 foreach ( $q['tag_ _and'] as $tag_and ) {1019 $join .= " LEFT JOIN $wpdb->term_relationships AS tr$count ON ($wpdb->posts.ID = tr$count.object_id) LEFT JOIN $wpdb->term_taxonomy AS tt$count ON (tr$count.term_taxonomy_id = tt$count.term_taxonomy_id) ";1020 $whichcat .= " AND t t$count.term_id= '$tag_and' ";1055 foreach ( $q['tag_slug__and'] as $tag_and ) { 1056 $join .= " LEFT JOIN $wpdb->term_relationships AS tr$count ON ($wpdb->posts.ID = tr$count.object_id) LEFT JOIN $wpdb->term_taxonomy AS tt$count ON (tr$count.term_taxonomy_id = tt$count.term_taxonomy_id) LEFT JOIN $wpdb->terms AS term$count ON (tt$count.term_id = term$count.term_id) "; 1057 $whichcat .= " AND term$count.slug = '$tag_and' "; 1021 1058 $count++; 1022 1059 }
Note: See TracChangeset
for help on using the changeset viewer.