Make WordPress Core

Opened 7 months ago

#59972 new defect (bug)

Clarify description of wp_script_add_data()

Reported by: crstauf's profile crstauf Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: docs Cc:


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 the script_loader_tag filter.

See this StackExchange post for details.

Reported by @mrwweb via User Contributed Notes.

Change History (0)

Note: See TracTickets for help on using tickets.