Changeset 16515
- Timestamp:
- 11/20/2010 09:51:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r16513 r16515 1594 1594 } 1595 1595 1596 if ( !$this->is_singular() ) { 1597 foreach ( $tax_query as $query ) { 1598 if ( 'IN' == $query['operator'] ) { 1599 switch ( $query['taxonomy'] ) { 1600 case 'category': 1601 $this->is_category = true; 1602 break; 1603 case 'post_tag': 1604 $this->is_tag = true; 1605 break; 1606 default: 1607 $this->is_tax = true; 1608 } 1596 foreach ( $tax_query as $query ) { 1597 if ( 'IN' == $query['operator'] ) { 1598 switch ( $query['taxonomy'] ) { 1599 case 'category': 1600 $this->is_category = true; 1601 break; 1602 case 'post_tag': 1603 $this->is_tag = true; 1604 break; 1605 default: 1606 $this->is_tax = true; 1609 1607 } 1610 1608 } … … 1946 1944 1947 1945 // Taxonomies 1948 $this->tax_query = $this->parse_tax_query( $q ); 1949 if ( !empty( $this->tax_query ) ) { 1950 $clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) ); 1951 1952 $join .= $clauses['join']; 1953 $where .= $clauses['where']; 1954 1955 if ( $this->is_tax ) { 1956 if ( empty($post_type) ) { 1957 $post_type = 'any'; 1958 $post_status_join = true; 1959 } elseif ( in_array('attachment', (array) $post_type) ) { 1960 $post_status_join = true; 1946 if ( !$this->is_singular ) { 1947 $this->tax_query = $this->parse_tax_query( $q ); 1948 if ( !empty( $this->tax_query ) ) { 1949 $clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) ); 1950 1951 $join .= $clauses['join']; 1952 $where .= $clauses['where']; 1953 1954 if ( $this->is_tax ) { 1955 if ( empty($post_type) ) { 1956 $post_type = 'any'; 1957 $post_status_join = true; 1958 } elseif ( in_array('attachment', (array) $post_type) ) { 1959 $post_status_join = true; 1960 } 1961 1961 } 1962 } 1963 1964 // Back-compat1965 $tax_query_in = wp_list_filter( $this->tax_query, array( 'operator' => 'IN' ) );1966 if ( !empty( $tax_query_in) ) {1967 if ( !isset( $q['taxonomy'] )) {1968 foreach ( $tax_query_in as $a_tax_query) {1969 if ( !in_array( $a_tax_query['taxonomy'], array( 'category', 'post_tag' ) ) ) {1970 $q['taxonomy'] = $a_tax_query['taxonomy'];1971 if ( 'slug' == $a_tax_query['field'] )1972 $q['term'] = $a_tax_query['terms'][0];1973 else1974 $q['term_id'] = $a_tax_query['terms'][0]; 1975 1976 break;1962 1963 // Back-compat 1964 $tax_query_in = wp_list_filter( $this->tax_query, array( 'operator' => 'IN' ) ); 1965 if ( !empty( $tax_query_in ) ) { 1966 if ( !isset( $q['taxonomy'] ) ) { 1967 foreach ( $tax_query_in as $a_tax_query ) { 1968 if ( !in_array( $a_tax_query['taxonomy'], array( 'category', 'post_tag' ) ) ) { 1969 $q['taxonomy'] = $a_tax_query['taxonomy']; 1970 if ( 'slug' == $a_tax_query['field'] ) 1971 $q['term'] = $a_tax_query['terms'][0]; 1972 else 1973 $q['term_id'] = $a_tax_query['terms'][0]; 1974 1975 break; 1976 } 1977 1977 } 1978 1978 } 1979 } 1980 1981 $cat_query = wp_list_filter( $tax_query_in, array( 'taxonomy' => 'category' ) );1982 if ( !empty( $cat_query ) ) {1983 $cat_query = reset( $cat_query);1984 $cat = get_term_by( $cat_query['field'], $cat_query['terms'][0], 'category' );1985 if ( $cat ) {1986 $this->set( 'cat', $cat->term_id);1987 $this->set( 'category_name', $cat->slug );1979 1980 $cat_query = wp_list_filter( $tax_query_in, array( 'taxonomy' => 'category' ) ); 1981 if ( !empty( $cat_query ) ) { 1982 $cat_query = reset( $cat_query ); 1983 $cat = get_term_by( $cat_query['field'], $cat_query['terms'][0], 'category' ); 1984 if ( $cat ) { 1985 $this->set( 'cat', $cat->term_id ); 1986 $this->set( 'category_name', $cat->slug ); 1987 } 1988 1988 } 1989 1989 }
Note: See TracChangeset
for help on using the changeset viewer.