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

FSE: Allow themes to opt in to wp-block-styles using theme.json #40097

Closed
wants to merge 2 commits into from

Conversation

scruffian
Copy link
Contributor

@scruffian scruffian commented Apr 6, 2022

What?

This allows themes to enable the wp-block-styles theme support using theme.json rather than calling add_theme_support in functions.php.

Why?

Themes shouldn't need to use PHP.

How?

I've had to overload a few things inside WP_Theme_JSON_Gutenberg. I think this stuff might need to be in a 6.1 directory unless this lands soon.

Testing Instructions

:where(.wp-block-group.has-background) {
   padding: 1.25em 2.375em;
}

cc @WordPress/block-themers

Fixes #37255

@scruffian scruffian self-assigned this Apr 6, 2022
@scruffian scruffian added the [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. label Apr 6, 2022
@scruffian scruffian marked this pull request as ready for review April 6, 2022 13:54
'text' => null,
),
'custom' => null,
'defaultBlockStyles' => null,
Copy link
Contributor Author

@scruffian scruffian Apr 6, 2022

Choose a reason for hiding this comment

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

This is the only change. Should I just add this to the array in the construct?

* One of 'default', 'theme', or 'custom'. Default 'theme'.
*/
public function __construct( $theme_json = array(), $origin = 'theme' ) {
parent::__construct( $theme_json, $origin );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why we don't do this more?

Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

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

This works well for me using Archeo, I can see the wp-block-styles styles.

Should we update the theme.json schema to include defaultBlockStyles at the same time?

@scruffian
Copy link
Contributor Author

Should we update the theme.json schema to include defaultBlockStyles at the same time?

Yes good idea. Updated!

@scruffian
Copy link
Contributor Author

We decided that 37255 is not the right approach, so this isn't needed.

@scruffian scruffian closed this Apr 8, 2022
@scruffian scruffian deleted the fix/37255 branch April 8, 2022 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider allowing themes to opt in to wp-block-styles via theme.json
2 participants