Opened 7 years ago
Last modified 3 years ago
#40276 new enhancement
enhancement: add a $type parameter to wp_add_inline_script()
Reported by: | paulschreiber | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.7.3 |
Component: | Script Loader | Keywords: | |
Focuses: | Cc: |
Description
It would be helpful to add a $type parameter to wp_add_inline_script().
Currently, it can only output scripts of type text/javascript. If you want something of another type, you need to either use the script_loader_tag filter (which gets run for every script), or manually add the script using a wp_head action.
This will require changing several functions:
- wp_add_inline_script()
- WP_Scripts::add_inline_script()
- WP_Scripts::do_item()
- WP_Dependencies::add_data()
- _WP_Dependency::add_data()
Along with the data structure (array) used by add_data.
Change History (4)
Note: See
TracTickets for help on using
tickets.
I originally wrote this up because of MathJax, which wants a block like this:
An even more widespread example is the ld+json structured data Google uses everywhere: