[wp-trac] [WordPress Trac] #51124: Can we get an additional parameter in wp_add_inline_script to set the script type?
WordPress Trac
noreply at wordpress.org
Fri Feb 26 17:03:26 UTC 2021
#51124: Can we get an additional parameter in wp_add_inline_script to set the
script type?
----------------------------------------+------------------------------
Reporter: hcabrera | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version:
Severity: normal | Resolution:
Keywords: good-first-bug needs-patch | Focuses:
----------------------------------------+------------------------------
Comment (by mikejdent):
I think using a parameter rather than filter makes more sense, as you
specify the type as you are writing the script. I have written a patch to
address this but just need to get the test suite built in npm so I can
check it is working.
My thinking is, pass a $type parameter into {{{ add_inline_script() }}}
and {{{ WP_Scripts::add_inline_script() }}} then if that parameter exists,
assign it to {{{ WP_Scripts::type_attr }}}
If it isn't set, then we revert to the default setting of
'text/javascript' unless we are using {{{ add_theme_support( 'html5', [
'script' ] ); }}}
@GeekPress html5 has been around a while now. I wonder if we should make
it default, and require developers to actively {{{ remove_theme_support(
'html5', [ 'script' ] ); }}} if needs be?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51124#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list