Allow plugins to manipulate the meta query args. See #14645

git-svn-id: https://develop.svn.wordpress.org/trunk@15624 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
scribu 2010-09-17 16:08:35 +00:00
parent d9039c38d7
commit 89382ae313
1 changed files with 14 additions and 3 deletions

View File

@ -670,6 +670,15 @@ class WP_Query {
*/
var $tax_query = array();
/**
* Metadata query
*
* @since 3.1.0
* @access public
* @var array
*/
var $meta_query = array();
/**
* Holds the data for a single object that is queried.
*
@ -1363,6 +1372,10 @@ class WP_Query {
$this->is_tax = true;
}
$meta_query = wp_array_slice_assoc( $qv, array( 'meta_key', 'meta_value', 'meta_compare' ) );
if ( !empty( $meta_query ) )
$this->meta_query[] = $meta_query;
if ( empty($qv['author']) || ($qv['author'] == '0') ) {
$this->is_author = false;
} else {
@ -2166,9 +2179,7 @@ class WP_Query {
$where .= ')';
}
// postmeta queries
$meta_query = wp_array_slice_assoc( $q, array( 'meta_key', 'meta_value', 'meta_compare' ) );
list( $meta_join, $meta_where ) = _wp_meta_sql( array( $meta_query ), $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' );
list( $meta_join, $meta_where ) = _wp_meta_sql( $this->meta_query, $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' );
$join .= $meta_join;
$where .= $meta_where;