It’s a known issue right now for the block editor, and it will be fixed in the future release.
https://github.com/WordPress/gutenberg/issues/38299
There’s a workaround. If you are not using the block editor, you can add this code to your theme’s functions.php
add_action('after_setup_theme', function () {
remove_action('wp_enqueue_scripts', 'wp_enqueue_global_styles');
remove_action('wp_footer', 'wp_enqueue_global_styles', 1);
}, 10, 0);
However, if you use the block editor, the workaround above can break some of your page’s styling. If that happens, I suggest using this code instead (in your theme’s functions.php).
add_action('wp_footer',function() {
global $wp_filter;
if(empty($wp_filter['wp_footer'][10])) return;
foreach($wp_filter['wp_footer'][10] as $hook) {
if(!is_object($hook['function']) || get_class($hook['function']) !== 'Closure') continue;
$static=(new ReflectionFunction($hook['function']))->getStaticVariables();
if(empty($static['svg'])) continue;
if(!str_starts_with($static['svg'],'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 0 0" ')) continue;
remove_action('wp_footer',$hook['function'],10);
}
},9);
Thread Starter
Colir
(@colir)
Thank you.
I’ll try this next week.
That workaround works! Removes both default inline css and the filters from the footer.
Not sure why all that garbage is included by default anyway, should be added by a theme imho.