[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
Mon Nov 8 02:55:50 UTC 2021
#51124: Can we get an additional parameter in wp_add_inline_script to set the
script type?
------------------------------------------------+--------------------------
Reporter: hcabrera | Owner: audrasjb
Type: feature request | Status: accepted
Priority: normal | Milestone: Future
| Release
Component: Script Loader | Version:
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests early | Focuses:
------------------------------------------------+--------------------------
Comment (by galbaras):
Seems very related to https://core.trac.wordpress.org/ticket/40276.
Personally, I need to add attributes like `data-cfasync='false'`, and I
can't find a way to do this with the current version of
`wp_add_inline_script()` (or `wp_localize_script()`, for that matter).
The following solutions will give developers absolute freedom:
1. Allow the script tag to be passed along with the code (see
https://core.trac.wordpress.org/ticket/43403)
2. Add a filter on the script tag
3. Add an array parameter (e.g. `[ 'data-cfasync' => 'false' ]`) and
expand it into arbitrary script tag attributes (not just `type`)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51124#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list