From c19c30b00d828062b8934ffd2cebe905516bc913 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Tue, 20 Jun 2023 22:17:27 +0000 Subject: [PATCH] REST API: Indicate when a theme supports the Site editor in the Themes REST API response. This changeset adds a `is_block_theme` property to each theme in the `wp/v2/themes` API response, which uses `WP_Theme::is_block_theme` to determinate whether the theme is block theme or not. Props grantmkin, ironprogrammer, zunaid321, azaozz, spacedmonkey, audrasjb, costdev. Fixes #58123. Built from https://develop.svn.wordpress.org/trunk@55951 git-svn-id: http://core.svn.wordpress.org/trunk@55463 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../endpoints/class-wp-rest-themes-controller.php | 9 +++++++++ wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php index 71dbcb6193..075be9efe4 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php @@ -326,6 +326,10 @@ class WP_REST_Themes_Controller extends WP_REST_Controller { } } + if ( rest_is_field_included( 'is_block_theme', $fields ) ) { + $data['is_block_theme'] = $theme->is_block_theme(); + } + $data = $this->add_additional_fields_to_object( $data, $request ); // Wrap the data in a response object. @@ -494,6 +498,11 @@ class WP_REST_Themes_Controller extends WP_REST_Controller { ), ), ), + 'is_block_theme' => array( + 'description' => __( 'Whether the theme is a block-based theme.' ), + 'type' => 'boolean', + 'readonly' => true, + ), 'name' => array( 'description' => __( 'The name of the theme.' ), 'type' => 'object', diff --git a/wp-includes/version.php b/wp-includes/version.php index 6ffd42b459..72cff7172d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55950'; +$wp_version = '6.3-alpha-55951'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.