From ba7d3a52b16bec0baed2c1f36b88da1cf0b472cc Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 4 Jan 2022 18:38:52 +0000 Subject: [PATCH] Themes: Make block themes support HTML5 by default. For block themes, [52369] added HTML5 support for `'comment-list'`, `'comment-form'`, `'style'`, and `'script'`. However, when sites upgrade to 5.9 with non-block content such as a gallery and caption, the markup was not HTML5. This commit adds full HTML5 theme feature support for block themes. Non-block content such as a `[gallery]` and `[caption]` shortcodes will natively be in HMTL5 markup without block themes needing to specifically add `add_theme_support( 'html5, .. )` to the theme. Follow-up to [24417], [27302], [34261], [52369], [52383], [52386]. Props @joyously, costdev, hellofromTonya, audrasjb, Mamaduka, ocean90. Fixes #54731. See #54597. git-svn-id: https://develop.svn.wordpress.org/trunk@52439 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/theme.php | 7 ++++++- tests/phpunit/tests/theme.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index ed33051c08..7a2b357d0a 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -4181,7 +4181,12 @@ function _add_default_theme_supports() { add_theme_support( 'post-thumbnails' ); add_theme_support( 'responsive-embeds' ); add_theme_support( 'editor-styles' ); - add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'style', 'script' ) ); + /* + * Makes block themes support HTML5 by default for the comment block and search form + * (which use default template functions) and `[caption]` and `[gallery]` shortcodes. + * Other blocks contain their own HTML5 markup. + */ + add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'search-form', 'gallery', 'caption', 'style', 'script' ) ); add_theme_support( 'automatic-feed-links' ); add_filter( 'should_load_separate_core_block_assets', '__return_true' ); diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index 23e2efad73..e16dd4c900 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -706,6 +706,8 @@ class Tests_Theme extends WP_UnitTestCase { * Tests that block themes support a feature by default. * * @ticket 54597 + * @ticket 54731 + * * @dataProvider data_block_theme_has_default_support * * @covers ::_add_default_theme_supports @@ -763,6 +765,36 @@ class Tests_Theme extends WP_UnitTestCase { 'feature' => 'editor-styles', ), ), + 'html5: comment-list' => array( + 'support' => array( + 'feature' => 'html5', + 'sub_feature' => 'comment-list', + ), + ), + 'html5: comment-form' => array( + 'support' => array( + 'feature' => 'html5', + 'sub_feature' => 'comment-form', + ), + ), + 'html5: search-form' => array( + 'support' => array( + 'feature' => 'html5', + 'sub_feature' => 'search-form', + ), + ), + 'html5: gallery' => array( + 'support' => array( + 'feature' => 'html5', + 'sub_feature' => 'gallery', + ), + ), + 'html5: caption' => array( + 'support' => array( + 'feature' => 'html5', + 'sub_feature' => 'caption', + ), + ), 'html5: style' => array( 'support' => array( 'feature' => 'html5',