WordPress.org

Make WordPress Core

Ticket #15250: context.15250.patch

File context.15250.patch, 1.4 KB (added by scribu, 8 years ago)

'get_tax_sql' filter with context

  • wp-includes/taxonomy.php

     
    572572 *              Default: true
    573573 *
    574574 * @param string $object_id_column
     575 * @param object $context (optional) The main query object
    575576 * @return string
    576577 */
    577 function get_tax_sql( $tax_query, $object_id_column ) {
     578function get_tax_sql( $tax_query, $object_id_column, $context = null ) {
    578579        global $wpdb;
    579580
    580581        $sql = array();
     
    603604        }
    604605
    605606        if ( !empty( $ids ) )
    606                 return " AND $object_id_column IN(" . implode( ', ', $ids ) . ")";
     607                $sql = " AND $object_id_column IN(" . implode( ', ', $ids ) . ")";
    607608        else
    608                 return ' AND 0 = 1';
     609                $sql = ' AND 0 = 1';
     610
     611        return apply_filters_ref_array( 'get_tax_sql', $sql, $tax_query, $object_id_column, &$context );
    609612}
    610613
    611 
    612614/**
    613615 * Get all Term data from database by Term ID.
    614616 *
  • wp-includes/query.php

     
    19401940                                $post_status_join = true;
    19411941                        }
    19421942
    1943                         $where .= get_tax_sql( $q['tax_query'], "$wpdb->posts.ID" );
     1943                        $where .= call_user_func_array( 'get_tax_sql', array( $q['tax_query'], "$wpdb->posts.ID", &$this ) );
    19441944
    19451945                        // Back-compat
    19461946                        $tax_query_in = wp_list_filter( $q['tax_query'], array( 'operator' => 'IN' ) );