Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#54044 closed defect (bug) (fixed)

Docs: Provide a more accurate description for functions `wp_localize_script`, `wp_set_script_translations`, `wp_script_add_data` and `wp_style_add_data`

Reported by: audrasjb's profile audrasjb Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: has-patch
Focuses: docs Cc:

Description

For each of wp_localize_script, wp_set_script_translations, wp_script_add_data and wp_style_add_data function, the DocBlock description specifies that it "Works only if the script|stylesheet has already been added".

It's not clear whether "added" refers to "registered", "enqueued" or even "printed". I think we should probably replace "added" with "registered" as it's more accurate.

Attachments (1)

54044.diff (1.8 KB) - added by audrasjb 3 years ago.
Docs: Provide a more accurate description for functions wp_localize_script, wp_set_script_translations, wp_script_add_data and wp_style_add_data

Download all attachments as: .zip

Change History (4)

@audrasjb
3 years ago

Docs: Provide a more accurate description for functions wp_localize_script, wp_set_script_translations, wp_script_add_data and wp_style_add_data

#1 @audrasjb
3 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 5.9

#3 @SergeyBiryukov
3 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 51726:

Docs: Provide a more accurate description for a few script and style functions.

This should make it clear that the functions only work if the script or style has already been registered.

This affects:

  • wp_localize_script()
  • wp_set_script_translations()
  • wp_script_add_data()
  • wp_style_add_data()

Follow-up to [7970], [18464], [25594], [31223], [36633], [44169], [44350].

Props audrasjb.
Fixes #54044.

Note: See TracTickets for help on using tickets.