From de42031a9474a53617e6a7de9056f0b70f576bfb Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 5 Jul 2022 14:57:52 +0000 Subject: [PATCH] Themes: Register the `block-templates` theme feature. This ensures the feature is included in the `theme_supports` REST API data for the active theme. Follow-up to [48171]. Props grantmkin, TimothyBlynJacobs, addiestavlo. Fixes #55681. git-svn-id: https://develop.svn.wordpress.org/trunk@53659 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/theme.php | 8 ++++++++ tests/phpunit/tests/rest-api/rest-themes-controller.php | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index ee544e25dc..c3d5003f75 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -3804,6 +3804,7 @@ function _wp_keep_alive_customize_changeset_dependent_auto_drafts( $new_status, * See {@see 'setup_theme'}. * * @since 5.5.0 + * @since 6.1.0 The `block-templates` feature was added. */ function create_initial_theme_features() { register_theme_feature( @@ -3820,6 +3821,13 @@ function create_initial_theme_features() { 'show_in_rest' => true, ) ); + register_theme_feature( + 'block-templates', + array( + 'description' => __( 'Whether a theme uses block-based templates.' ), + 'show_in_rest' => true, + ) + ); register_theme_feature( 'custom-background', array( diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php index 6737a707bd..36818f8976 100644 --- a/tests/phpunit/tests/rest-api/rest-themes-controller.php +++ b/tests/phpunit/tests/rest-api/rest-themes-controller.php @@ -387,6 +387,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $theme_supports = $properties['theme_supports']['properties']; $this->assertArrayHasKey( 'align-wide', $theme_supports ); $this->assertArrayHasKey( 'automatic-feed-links', $theme_supports ); + $this->assertArrayHasKey( 'block-templates', $theme_supports ); $this->assertArrayHasKey( 'custom-header', $theme_supports ); $this->assertArrayHasKey( 'custom-background', $theme_supports ); $this->assertArrayHasKey( 'custom-logo', $theme_supports ); @@ -405,7 +406,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $this->assertArrayHasKey( 'responsive-embeds', $theme_supports ); $this->assertArrayHasKey( 'title-tag', $theme_supports ); $this->assertArrayHasKey( 'wp-block-styles', $theme_supports ); - $this->assertCount( 20, $theme_supports ); + $this->assertCount( 21, $theme_supports ); } /**