Editor: Allow Query Block to show posts from multiple selected authors.

This changeset adds handler for multiple cases where author data can be passed to the Query Block:
- array: array of author ids
- string: comma separated author ids
- integer: single author id

Props adi3890, costdev, mayur8991, oglekler.
Fixes #58426.



Built from https://develop.svn.wordpress.org/trunk@56109


git-svn-id: http://core.svn.wordpress.org/trunk@55621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2023-06-29 13:30:33 +00:00
parent bf2569ae1d
commit ed23ac2a04
2 changed files with 9 additions and 4 deletions

View File

@ -1376,10 +1376,15 @@ function build_query_vars_from_query_block( $block, $page ) {
$query['orderby'] = $block->context['query']['orderBy'];
}
if (
isset( $block->context['query']['author'] ) &&
(int) $block->context['query']['author'] > 0
isset( $block->context['query']['author'] )
) {
$query['author'] = (int) $block->context['query']['author'];
if ( is_array( $block->context['query']['author'] ) ) {
$query['author__in'] = array_filter( array_map( 'intval', $block->context['query']['author'] ) );
} elseif ( is_string( $block->context['query']['author'] ) ) {
$query['author__in'] = array_filter( array_map( 'intval', explode( ',', $block->context['query']['author'] ) ) );
} elseif ( is_int( $block->context['query']['author'] ) && $block->context['query']['author'] > 0 ) {
$query['author'] = $block->context['query']['author'];
}
}
if ( ! empty( $block->context['query']['search'] ) ) {
$query['s'] = $block->context['query']['search'];

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-beta2-56108';
$wp_version = '6.3-beta2-56109';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.