diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php index 78c9d1ca2b..455c83a68d 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php @@ -227,6 +227,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { * Retrieves terms associated with a taxonomy. * * @since 4.7.0 + * @since 6.8.0 Respect default query arguments set for the taxonomy upon registration. * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. @@ -295,6 +296,22 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { } } + /* + * When a taxonomy is registered with an 'args' array, + * those params override the `$args` passed to this function. + * + * We only need to do this if no `post` argument is provided. + * Otherwise, terms will be fetched using `wp_get_object_terms()`, + * which respects the default query arguments set for the taxonomy. + */ + if ( + empty( $prepared_args['post'] ) && + isset( $taxonomy_obj->args ) && + is_array( $taxonomy_obj->args ) + ) { + $prepared_args = array_merge( $prepared_args, $taxonomy_obj->args ); + } + /** * Filters get_terms() arguments when querying terms via the REST API. * diff --git a/wp-includes/version.php b/wp-includes/version.php index c12c644cb1..feebff78b9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59457'; +$wp_version = '6.8-alpha-59458'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.