mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
Users: The 'who' parameter should not interfere with 'meta_key' + 'meta_value' in WP_User_Query
.
Props adrianosilvaferreira. Fixes #36724. Built from https://develop.svn.wordpress.org/trunk@37360 git-svn-id: http://core.svn.wordpress.org/trunk@37326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3c70037d46
commit
2d37a0ee17
@ -255,13 +255,6 @@ class WP_User_Query {
|
|||||||
$blog_id = absint( $qv['blog_id'] );
|
$blog_id = absint( $qv['blog_id'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) {
|
|
||||||
$qv['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'user_level';
|
|
||||||
$qv['meta_value'] = 0;
|
|
||||||
$qv['meta_compare'] = '!=';
|
|
||||||
$qv['blog_id'] = $blog_id = 0; // Prevent extra meta query
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $qv['has_published_posts'] && $blog_id ) {
|
if ( $qv['has_published_posts'] && $blog_id ) {
|
||||||
if ( true === $qv['has_published_posts'] ) {
|
if ( true === $qv['has_published_posts'] ) {
|
||||||
$post_types = get_post_types( array( 'public' => true ) );
|
$post_types = get_post_types( array( 'public' => true ) );
|
||||||
@ -281,6 +274,29 @@ class WP_User_Query {
|
|||||||
$this->meta_query = new WP_Meta_Query();
|
$this->meta_query = new WP_Meta_Query();
|
||||||
$this->meta_query->parse_query_vars( $qv );
|
$this->meta_query->parse_query_vars( $qv );
|
||||||
|
|
||||||
|
if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) {
|
||||||
|
$who_query = array(
|
||||||
|
'key' => $wpdb->get_blog_prefix( $blog_id ) . 'user_level',
|
||||||
|
'value' => 0,
|
||||||
|
'compare' => '!=',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Prevent extra meta query.
|
||||||
|
$qv['blog_id'] = $blog_id = 0;
|
||||||
|
|
||||||
|
if ( empty( $this->meta_query->queries ) ) {
|
||||||
|
$this->meta_query->queries = array( $who_query );
|
||||||
|
} else {
|
||||||
|
// Append the cap query to the original queries and reparse the query.
|
||||||
|
$this->meta_query->queries = array(
|
||||||
|
'relation' => 'AND',
|
||||||
|
array( $this->meta_query->queries, $who_query ),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->meta_query->parse_query_vars( $this->meta_query->queries );
|
||||||
|
}
|
||||||
|
|
||||||
$roles = array();
|
$roles = array();
|
||||||
if ( isset( $qv['role'] ) ) {
|
if ( isset( $qv['role'] ) ) {
|
||||||
if ( is_array( $qv['role'] ) ) {
|
if ( is_array( $qv['role'] ) ) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.6-alpha-37359';
|
$wp_version = '4.6-alpha-37360';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user