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

git-svn-id: http://svn.automattic.com/wordpress/trunk@15624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-09-17 16:08:35 +00:00
parent d66d93ccab
commit 367e4916ee
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;