-
Notifications
You must be signed in to change notification settings - Fork 110
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
Force HTML5 script theme support when printing JSON script #952
Force HTML5 script theme support when printing JSON script #952
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember if theme support get reset between tests. Any chance of this causing side effects for other tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Good point. Fixed in a1037f8
Summary
When a theme doesn't declare theme support for HTML5 scripts, the JSON
script
is 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_features
global with the theme support added.Update: See core ticket: https://core.trac.wordpress.org/ticket/60320
Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.