Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default theme supports #2029

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wp-includes/default-filters.php
Expand Up @@ -514,6 +514,7 @@
*/
// Theme.
add_action( 'setup_theme', 'create_initial_theme_features', 0 );
add_action( 'setup_theme', '_add_default_theme_supports', 1 );
add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
add_action( 'wp_head', '_custom_logo_header_styles' );
add_action( 'plugins_loaded', '_wp_customize_include' );
Expand Down
18 changes: 18 additions & 0 deletions src/wp-includes/theme.php
Expand Up @@ -4093,3 +4093,21 @@ function create_initial_theme_features() {
function wp_is_block_theme() {
return wp_get_theme()->is_block_theme();
}

/**
* Adds default theme supports for block themes when the 'setup_theme' action
* fires.
*
* @since 5.9.0
* @access private
*/
function _add_default_theme_supports() {
if ( wp_is_block_theme() ) {
add_theme_support( 'post-thumbnails' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'editor-styles' );
add_theme_support( 'html5', array( 'style', 'script' ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to extend the HTML5 support for other elements too. At least for components which are used by blocks like comment-form/comment-list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think @youknowriad? I'm just copying over what's already in the plugin 😀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also just copied what the themers suggested from 2022 theme. that said IMO, everything should be supported. Can we do * or something like that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that said IMO, everything should be supported. Can we do * or something like that?

No, add_theme_support( 'html5', ... ) intentionally requires an array of specific types to check, see this comment for context, and some more history in the description of https://core.trac.wordpress.org/ticket/51657.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the reasoning there though?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should we do in the short term for 5.9?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can land this as is or by adding as much elements as available to at least be on the same page as the Gutenberg plugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #2029 (comment), we only have to add the two for the comments blocks.

Suggested change
add_theme_support( 'html5', array( 'style', 'script' ) );
add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'style', 'script' ) );

search-form, gallery, caption, and navigation-widgets (not 100% sure) seem to be irrelevant for block themes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, declaring the support of navigation-widgets currently doesn't change anything to the markup of the navigation widgets (page/category list, etc).

It's supposed to add a <nav> container to the widget. This should probably be reported upstream since it's a regression from Classic themes. I'll open an issue on Gutenberg for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ocean90 can you add those 2 https://github.com/WordPress/wordpress-develop/pull/2029/files#r766453524 upstream in Gutenberg please? Will go ahead with the suggestion here. But needs to be synched with Gutenberg too.

add_theme_support( 'automatic-feed-links' );
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
}
}