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
This commit is contained in:
audrasjb 2023-06-20 22:17:27 +00:00
parent ae515caebf
commit c19c30b00d
2 changed files with 10 additions and 1 deletions

View File

@ -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 ); $data = $this->add_additional_fields_to_object( $data, $request );
// Wrap the data in a response object. // 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( 'name' => array(
'description' => __( 'The name of the theme.' ), 'description' => __( 'The name of the theme.' ),
'type' => 'object', 'type' => 'object',

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.