mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-04 18:01:42 +01:00
Add context to get_meta_sql(). See #15018
git-svn-id: http://svn.automattic.com/wordpress/trunk@16286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cab19ed4aa
commit
8885e4f78e
@ -369,9 +369,10 @@ function update_meta_cache($meta_type, $object_ids) {
|
|||||||
* @param string $meta_type
|
* @param string $meta_type
|
||||||
* @param string $primary_table
|
* @param string $primary_table
|
||||||
* @param string $primary_id_column
|
* @param string $primary_id_column
|
||||||
|
* @param object $context (optional) The main query object
|
||||||
* @return array( 'join' => $join_sql, 'where' => $where_sql )
|
* @return array( 'join' => $join_sql, 'where' => $where_sql )
|
||||||
*/
|
*/
|
||||||
function get_meta_sql( $meta_query, $meta_type, $primary_table, $primary_id_column ) {
|
function get_meta_sql( $meta_query, $meta_type, $primary_table, $primary_id_column, $context = null ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
if ( ! $meta_table = _get_meta_table( $meta_type ) )
|
if ( ! $meta_table = _get_meta_table( $meta_type ) )
|
||||||
@ -440,7 +441,7 @@ function get_meta_sql( $meta_query, $meta_type, $primary_table, $primary_id_colu
|
|||||||
unset( $meta_compare_string );
|
unset( $meta_compare_string );
|
||||||
}
|
}
|
||||||
|
|
||||||
return apply_filters( 'get_meta_sql', compact( 'join', 'where' ), $meta_query, $meta_type, $primary_table, $primary_id_column );
|
return apply_filters_ref_array( 'get_meta_sql', array( compact( 'join', 'where' ), $meta_query, $meta_type, $primary_table, $primary_id_column, &$context ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2147,7 +2147,7 @@ class WP_Query extends WP_Object_Query {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty( $q['meta_query'] ) ) {
|
if ( !empty( $q['meta_query'] ) ) {
|
||||||
$clauses = get_meta_sql( $q['meta_query'], 'post', $wpdb->posts, 'ID' );
|
$clauses = call_user_func_array( 'get_meta_sql', array( $q['meta_query'], 'post', $wpdb->posts, 'ID', &$this) );
|
||||||
$join .= $clauses['join'];
|
$join .= $clauses['join'];
|
||||||
$where .= $clauses['where'];
|
$where .= $clauses['where'];
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,7 @@ class WP_User_Query extends WP_Object_Query {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty( $qv['meta_query'] ) ) {
|
if ( !empty( $qv['meta_query'] ) ) {
|
||||||
$clauses = get_meta_sql( $qv['meta_query'], 'user', $wpdb->users, 'ID' );
|
$clauses = call_user_func_array( 'get_meta_sql', array( $qv['meta_query'], 'user', $wpdb->users, 'ID', &$this ) );
|
||||||
$this->query_from .= $clauses['join'];
|
$this->query_from .= $clauses['join'];
|
||||||
$this->query_where .= $clauses['where'];
|
$this->query_where .= $clauses['where'];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user