From 4fd22dd9f2ba2e18cc1386661cc2357d60af39ca Mon Sep 17 00:00:00 2001 From: alexmerz Date: Thu, 30 Mar 2023 11:23:58 +0200 Subject: [PATCH 1/4] Add filter when building WP_Query arguments Allow to customize the arguments for WP_Query created by build_articles_query using the new filter 'newspack_blocks_build_articles_query'. --- includes/class-newspack-blocks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-newspack-blocks.php b/includes/class-newspack-blocks.php index ef7f72d56..0c0c26933 100644 --- a/includes/class-newspack-blocks.php +++ b/includes/class-newspack-blocks.php @@ -713,7 +713,7 @@ function ( $acc, $block ) use ( $block_name ) { } } - return $args; + return apply_filters( 'newspack_blocks_build_articles_query', $args, $attributes, $block_name ); } /** From 0b6860a4f7b951ed5f0c17e45e4edd1dfd1c39d0 Mon Sep 17 00:00:00 2001 From: alexmerz Date: Sat, 1 Apr 2023 16:05:46 +0200 Subject: [PATCH 2/4] Add inline documentation to filter --- includes/class-newspack-blocks.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/class-newspack-blocks.php b/includes/class-newspack-blocks.php index 0c0c26933..13809d15d 100644 --- a/includes/class-newspack-blocks.php +++ b/includes/class-newspack-blocks.php @@ -713,6 +713,18 @@ function ( $acc, $block ) use ( $block_name ) { } } + /** + * Customize the WP_Query arguments to fetch post articles before the actual query is executed. + * + * The filter is called after the build_articles_query() function is called by a newspack block to + * build the WP_Query arguments based on the given attributes and block requesting the query. + * + * @since 1.66.0 + * + * @param array $args WP_Query arguments as created by build_articles_query() + * @param array $attributes The attributes initial passed to build_articles_query() + * @param string $block_name The name of the requesting block to create the query args for + */ return apply_filters( 'newspack_blocks_build_articles_query', $args, $attributes, $block_name ); } From 59af216224b9183409b28b457ba8a7f873480c17 Mon Sep 17 00:00:00 2001 From: Adam Boro Date: Fri, 5 Jan 2024 15:31:13 +0100 Subject: [PATCH 3/4] Update class-newspack-blocks.php --- includes/class-newspack-blocks.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/class-newspack-blocks.php b/includes/class-newspack-blocks.php index 13809d15d..31cb3bfb0 100644 --- a/includes/class-newspack-blocks.php +++ b/includes/class-newspack-blocks.php @@ -719,8 +719,6 @@ function ( $acc, $block ) use ( $block_name ) { * The filter is called after the build_articles_query() function is called by a newspack block to * build the WP_Query arguments based on the given attributes and block requesting the query. * - * @since 1.66.0 - * * @param array $args WP_Query arguments as created by build_articles_query() * @param array $attributes The attributes initial passed to build_articles_query() * @param string $block_name The name of the requesting block to create the query args for From 1c0437306820dbbb6ab9a3c15b894a87d5cdc4a4 Mon Sep 17 00:00:00 2001 From: Adam Boro Date: Fri, 5 Jan 2024 15:32:49 +0100 Subject: [PATCH 4/4] Update class-newspack-blocks.php --- includes/class-newspack-blocks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-newspack-blocks.php b/includes/class-newspack-blocks.php index 31cb3bfb0..5c5082b38 100644 --- a/includes/class-newspack-blocks.php +++ b/includes/class-newspack-blocks.php @@ -716,7 +716,7 @@ function ( $acc, $block ) use ( $block_name ) { /** * Customize the WP_Query arguments to fetch post articles before the actual query is executed. * - * The filter is called after the build_articles_query() function is called by a newspack block to + * The filter is called after the build_articles_query() function is called by a Newspack block to * build the WP_Query arguments based on the given attributes and block requesting the query. * * @param array $args WP_Query arguments as created by build_articles_query()