Opened 10 months ago
Last modified 6 weeks ago
#59972 new defect (bug)
Clarify description of wp_script_add_data()
Reported by: | crstauf | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Script Loader | Keywords: | needs-patch |
Focuses: | docs | Cc: |
Description
The function description does not include strategy
as a possible value for $key
. Suggest to adjust to indicate function is a wrapper for WP_Scripts::add_data()
, and then add possible values conditional
and strategy
to WP_Scripts::add_data()
function description or parameter description.
This documentation does not make it very clear that this can’t be used for adding arbitrary values attributes to the script tag. It only supports ‘conditional’ or, more recently, a “strategy” value.
For adding an alternate
type
attribute, for example, you’ll still need to use older strategies like thescript_loader_tag
filter.
Reported by @mrwweb via User Contributed Notes.
Change History (2)
Note: See
TracTickets for help on using
tickets.
@crstauf I recommend updating the function name because
wp_script_add_data
might raise the question, "Which data?".The purpose of this function is to add attributes to the script if
wp_script_add_data
matches the 'browser version' when the 'conditional' value is passed as$key
or the strategy 'defer' or 'async' is used.