WordPress.org

Make WordPress Core

Changeset 15765


Ignore:
Timestamp:
10/09/2010 10:19:15 AM (9 years ago)
Author:
scribu
Message:

Get rid of redundant ->tax_query. See #12891

Location:
trunk/wp-includes
Files:
3 edited

Legend:

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

    r15707 r15765  
    147147
    148148            $term_count = 0;
    149             foreach ( $wp_query->tax_query as $tax_query )
     149            foreach ( $wp_query->get('tax_query') as $tax_query )
    150150                $term_count += count( $tax_query['terms'] );
    151151
  • trunk/wp-includes/classes.php

    r15756 r15765  
    565565
    566566    /*
    567      * List of taxonomy queries
    568      *
    569      * A query is an associative array:
    570      * - 'taxonomy' string|array The taxonomy being queried
    571      * - 'terms' string|array The list of terms
    572      * - 'field' string (optional) Which term field is being used.
    573      *      Possible values: 'term_id', 'slug' or 'name'
    574      *      Default: 'slug'
    575      * - 'operator' string (optional)
    576      *      Possible values: 'IN' and 'NOT IN'.
    577      *      Default: 'IN'
    578      * - 'include_children' bool (optional) Whether to include child terms.
    579      *      Default: true
    580      *
    581      * @since 3.1.0
    582      * @access public
    583      * @var array
    584      */
    585     var $tax_query = array();
    586 
    587     /*
    588567     * Populates the $meta_query property
    589568     *
     
    695674     * @since 3.1.0
    696675     *
    697      * @uses $this->tax_query
     676     * @param array $tax_query List of taxonomy queries. A single taxonomy query is an associative array:
     677     * - 'taxonomy' string|array The taxonomy being queried
     678     * - 'terms' string|array The list of terms
     679     * - 'field' string (optional) Which term field is being used.
     680     *      Possible values: 'term_id', 'slug' or 'name'
     681     *      Default: 'slug'
     682     * - 'operator' string (optional)
     683     *      Possible values: 'IN' and 'NOT IN'.
     684     *      Default: 'IN'
     685     * - 'include_children' bool (optional) Whether to include child terms.
     686     *      Default: true
    698687     *
    699688     * @param string $object_id_column
    700689     * @return string
    701690     */
    702     function get_tax_sql( $object_id_column ) {
     691    function get_tax_sql( $tax_query, $object_id_column ) {
    703692        global $wpdb;
    704693
    705694        $sql = array();
    706         foreach ( $this->tax_query as $query ) {
     695        foreach ( $tax_query as $query ) {
    707696            if ( !isset( $query['include_children'] ) )
    708697                $query['include_children'] = true;
  • trunk/wp-includes/query.php

    r15752 r15765  
    10821082        unset($this->query);
    10831083        $this->query_vars = array();
    1084         $this->tax_query = array();
    10851084        $this->meta_query = array();
    10861085        unset($this->queried_object);
     
    14001399    }
    14011400
    1402     function parse_tax_query( $q ) {
     1401    /*
     1402     * Populates the 'tax_query' property
     1403     *
     1404     * @access protected
     1405     * @since 3.1.0
     1406     *
     1407     * @param array &$q The query variables
     1408     */
     1409    function parse_tax_query( &$q ) {
    14031410        if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) {
    14041411            $tax_query = $q['tax_query'];
     
    15031510        }
    15041511
    1505         $this->tax_query = $tax_query;
    1506 
    1507         foreach ( $this->tax_query as $query ) {
     1512        $q['tax_query'] = $tax_query;
     1513
     1514        foreach ( $q['tax_query'] as $query ) {
    15081515            if ( 'IN' == $query['operator'] ) {
    15091516                switch ( $query['taxonomy'] ) {
     
    18461853
    18471854        // Taxonomies
    1848         if ( !empty( $this->tax_query ) ) {
     1855        if ( !empty( $q['tax_query'] ) ) {
    18491856            if ( empty($post_type) ) {
    18501857                $post_type = 'any';
     
    18541861            }
    18551862
    1856             $where .= $this->get_tax_sql( "$wpdb->posts.ID" );
     1863            $where .= $this->get_tax_sql( $q['tax_query'], "$wpdb->posts.ID" );
    18571864
    18581865            // Back-compat
    18591866            if ( !empty( $ids ) ) {
    1860                 $cat_query = wp_list_filter( $this->tax_query, array( 'taxonomy' => 'category' ) );
     1867                $cat_query = wp_list_filter( $q['tax_query'], array( 'taxonomy' => 'category' ) );
    18611868                if ( !empty( $cat_query ) ) {
    18621869                    $cat_query = reset( $cat_query );
     
    25152522        $this->queried_object_id = 0;
    25162523
    2517         if ( $this->tax_query ) {
    2518             $query = reset( $this->tax_query );
    2519             if ( 'term_id' == $query['field']  )
     2524        $tax_query = $this->get('tax_query');
     2525
     2526        if ( !empty( $tax_query ) ) {
     2527            $query = reset( $tax_query );
     2528            if ( 'term_id' == $query['field'] )
    25202529                $term = get_term( reset( $query['terms'] ), $query['taxonomy'] );
    25212530            else
Note: See TracChangeset for help on using the changeset viewer.