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

Making Gutenberg stylesheet conditional #1121

Closed
RiaanKnoetze opened this issue May 2, 2019 · 1 comment · Fixed by #1122
Closed

Making Gutenberg stylesheet conditional #1121

RiaanKnoetze opened this issue May 2, 2019 · 1 comment · Fixed by #1122

Comments

@RiaanKnoetze
Copy link

I'm referring to the following lines of code:

wp_enqueue_style( 'storefront-gutenberg-blocks', get_template_directory_uri() . '/assets/css/base/gutenberg-blocks.css', '', $storefront_version );
wp_style_add_data( 'storefront-gutenberg-blocks', 'rtl', 'replace' );

In instances where Gutenberg is disabled, by using a plugin/child theme with a filter, shouldn't we remove the loading of Gutenberg styles in Storefront? If blocks aren't used, there's no need to add the feature bloat on sites.


If required, the filters that'll be set to disable Gutenberg, include:

// disable for posts
add_filter('use_block_editor_for_post', '__return_false', 10);

// disable for post types
add_filter('use_block_editor_for_post_type', '__return_false', 10);
@RiaanKnoetze RiaanKnoetze added the type: question The issue is a question about how code works. label May 2, 2019
@tiagonoronha
Copy link
Contributor

@RiaanKnoetze I've made a few changes in #1122 to ensure that CSS is only loaded via Gutenberg hooks.

However, this is will still load the stylesheets in the frontend since WordPress doesn't currently include a way to know if blocks are being used in a post (that's different from checking whether the block editor is enabled).

Should WordPress add a way, it will work.

@tiagonoronha tiagonoronha added Status: has-pr and removed type: question The issue is a question about how code works. labels May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants