From d156b988e2d26197ce8888726c556ef39f9979fb Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Thu, 21 Nov 2024 12:04:27 +0100 Subject: [PATCH] Skip filter if a post is provided --- lib/compat/wordpress-6.8/rest-api.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/compat/wordpress-6.8/rest-api.php b/lib/compat/wordpress-6.8/rest-api.php index 8f66c8daf6f162..04f42169896a85 100644 --- a/lib/compat/wordpress-6.8/rest-api.php +++ b/lib/compat/wordpress-6.8/rest-api.php @@ -24,6 +24,13 @@ function gutenberg_add_post_type_rendering_mode() { // When querying terms for a given taxonomy in the REST API, respect the default // query arguments set for that taxonomy upon registration. function gutenberg_respect_taxonomy_default_args_in_rest_api( $args ) { + // If a `post` argument is provided, the Terms controller will use + // `wp_get_object_terms`, which respects the default query arguments, + // so we don't need to do anything. + if ( ! empty( $args['post'] ) ) { + return $args; + } + $t = get_taxonomy( $args['taxonomy'] ); if ( isset( $t->args ) && is_array( $t->args ) ) { $args = array_merge( $args, $t->args );