From 8c9fffb5cc1ec10f47352b4731acf981dfff5b0a Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Thu, 29 Jun 2023 13:28:49 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@56109 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index aebb4b4065..097c3b8841 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -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'];