Force HTML5 script theme support when printing JSON script#952
Force HTML5 script theme support when printing JSON script#952westonruter merged 7 commits intofeature/speculationrulesfrom
Conversation
|
@westonruter Can you open a Trac ticket for this? I think we should prioritize this, and it would be great to link to that in a code comment here. If the fix in core is straightforward (which I would expect it to be), then we can maybe ship this in 6.5 already and thus limit or remove this workaround sooner than later. |
Yes, I started doing that right after opening this PR (ref: "(ticket and PR pending)").
Oops. I mean here: https://core.trac.wordpress.org/ticket/60320 |
joemcgill
left a comment
There was a problem hiding this comment.
Looks good to me. One question about the tests, but pre-approving for merge.
| if ( $html5_support ) { | ||
| add_theme_support( 'html5', array( 'script' ) ); | ||
| } else { | ||
| remove_theme_support( 'html5' ); |
There was a problem hiding this comment.
I don't remember if theme support get reset between tests. Any chance of this causing side effects for other tests?
Summary
When a theme doesn't declare theme support for HTML5 scripts, the JSON
scriptis currently output with some XHTML compatibility wrappers:This breaks the parsing of the JSON. The
/* <![CDATA[ */and/* ]]> */need to be omitted from JSON output.Relevant technical choices
This needs to be fixed in core (ticket and PR pending), but a quick workaround is to temporarily override the
$_wp_theme_featuresglobal with the theme support added.Update: See core ticket: https://core.trac.wordpress.org/ticket/60320
Checklist
[Focus]orInfrastructurelabel.[Type]label.no milestonelabel.