[wp-trac] [WordPress Trac] #63007: Bundled themes: Stylesheets for block themes are missing path data for inlining
WordPress Trac
noreply at wordpress.org
Wed May 28 14:47:47 UTC 2025
#63007: Bundled themes: Stylesheets for block themes are missing path data for
inlining
-----------------------------------+-------------------------------
Reporter: westonruter | Owner: westonruter
Type: enhancement | Status: accepted
Priority: normal | Milestone: 6.9
Component: Bundled Theme | Version:
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion | Focuses: css, performance
-----------------------------------+-------------------------------
Comment (by poena):
Yes, styles from {{{theme.json > styles > css}}} are added inline, in the
tag {{{<style id='global-styles-inline-css'>}}}
It is not without its own problems:
- It requires WP 6.2. (Twenty Twenty-Two must work on 5.9)
- It uses the "Additional CSS field" in the Site Editor:
- Users can remove CSS from that field (this can be good or bad of course
depending on what your project requirements are).
- If the user has already saved content in this field, the data from the
database is used, and the styles from theme.json>styles>css are not
automatically merged with the global styles nor printed/enqueued.
The post type is wp_global_styles and the post content looks something
like this when the user has saved CSS changes:
{{{
{"styles":{"css":"*{border: 1px solid
green;}"},"isGlobalStylesUserThemeJSON":true,"version":3}
}}}
Which means we can detect if there is Custom CSS saved.
It is possible to use for example the
[https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_theme_data/
WP_Theme_JSON_Resolver Class] to get the value from the .json file and
then this can be used in many different ways.
For example added inline to a different file, to wp_head in a style tag,
saved to the post type mentioned above, etc.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63007#comment:36>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list