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.




git-svn-id: https://develop.svn.wordpress.org/trunk@55951 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras
2023-06-20 22:15:57 +00:00
parent 9bc6b0a060
commit 1e8b61bd4d
2 changed files with 40 additions and 1 deletions
@@ -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',