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

How to remove "wp-block-navigation-link-inline-css" or "wp-block-site-logo-inline-css" #61237

Open
tablufc88 opened this issue Apr 30, 2024 · 5 comments
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@tablufc88
Copy link

Is it possible to remove inline styles with ids such as "wp-block-navigation-link-inline-css", "wp-block-site-logo-inline-css", "wp-block-list-inline-css" or "wp-block-image-inline-css"?

This doesn't do it - https://fullsiteediting.com/lessons/how-to-remove-default-block-styles/#h-how-to-remove-the-inline-styles-on-the-front

I'm not using an fse theme & have removed 'block-templates' support.

But I have added support for 'block-template-parts' so that I can create template parts for header and footer.

@colorful-tones colorful-tones added [Type] Help Request Help with setup, implementation, or "How do I?" questions. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Apr 30, 2024
@colorful-tones
Copy link
Member

@tablufc88, are you looking to remove the CSS altogether for each block, or do you just not want it inlined?

@tablufc88
Copy link
Author

@colorful-tones ideally I'd like to filter the styles to remove a couple of conflicts but it would be useful to know why they are showing on my page when they are not in the queue if you know? Possibly could be enqueued differently since I opted in for block-template-parts support?

Got rid of these inline styles with wp_deregister_style for now.

add_action('wp_enqueue_scripts', function () {
  wp_deregister_style('wp-block-navigation-link');
  wp_deregister_style('wp-block-navigation');
  wp_deregister_style('wp-block-image');
  wp_deregister_style('wp-block-list');
  wp_deregister_style('wp-block-site-logo');
});

When dumping the queue:

add_action('wp_enqueue_scripts', function () {
    global $wp_styles;
    dd($wp_styles->queue);
});

I get the following. I expected them to be in here:

[
  0 => "admin-bar"
  1 => "wp-block-heading"
  2 => "wp-block-paragraph"
  3 => "wp-block-button"
  4 => "wp-block-buttons"
  5 => "wp-block-block"
  6 => "wp-block-column"
  7 => "wp-block-columns"
  8 => "wp-block-library"
  9 => "classic-theme-styles"
  10 => "woocommerce-layout"
  11 => "woocommerce-smallscreen"
  12 => "woocommerce-general"
  13 => "woocommerce-inline"
  14 => "duplicate-post"
]

Thanks for your help

@colorful-tones
Copy link
Member

Got rid of these inline styles with wp_deregister_style for now.

add_action('wp_enqueue_scripts', function () {
  wp_deregister_style('wp-block-navigation-link');
  wp_deregister_style('wp-block-navigation');
  wp_deregister_style('wp-block-image');
  wp_deregister_style('wp-block-list');
  wp_deregister_style('wp-block-site-logo');
});

Are you all set then? Are we good to close this out?

@tablufc88
Copy link
Author

Kind of but if they are not enqueued, why are the styled inlined in the first place?

@t-hamano
Copy link
Contributor

t-hamano commented May 1, 2024

why are the styled inlined in the first place?

I believe this is for performance improvement. You can check the post below for more details.

Block-styles loading enhancements in WordPress 5.8 – Make WordPress Core

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. [Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants