I have read this but I see that $wp_styles->registered
contains only external stylesheets.
I am also trying to understand WP works. I am writing a theme from scratch. I believe that the unwanted inline styles are not caused by plugins (I have only 2 installed: Duplicator and Prevent Browser Caching, both updated).
The inline style that I do not want is this (taken from Chrome DevTools):
<style type="text/css" media="screen">
html { margin-top: 32px !important; }
* html body { margin-top: 32px !important; }
@media screen and ( max-width: 782px ) {
html { margin-top: 46px !important; }
* html body { margin-top: 46px !important; }
}
</style>
The theme contains just 3 files. index.php
and style.css
are just static files currently. Here is my functions.php
(nothing original):
<?php
/**
* Theme Functions
*/
function theme_name_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
/**
* Remove the inline styles of the theme.
*/
add_action( 'wp_enqueue_scripts', function() {
global $wp_styles;
foreach ($wp_styles->registered as $val) {
echo "CSS: " . $val->handle . " at " . $val->src . " \n";
}
// $styles = wp_styles();
// $styles->add_data( 'twentytwenty-style', 'after', array() );
}, 20 );
Thank you!