[wp-trac] [WordPress Trac] #60862: wp_localize_script() on login_enqueue_scripts hook change in behavior
WordPress Trac
noreply at wordpress.org
Wed May 1 15:40:18 UTC 2024
#60862: wp_localize_script() on login_enqueue_scripts hook change in behavior
------------------------------+-------------------------
Reporter: salcode | Owner: swissspidy
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.5.3
Component: Script Loader | Version: 6.5
Severity: normal | Resolution: fixed
Keywords: has-patch commit | Focuses:
------------------------------+-------------------------
Changes (by swissspidy):
* owner: (none) => swissspidy
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"58068" 58068]:
{{{
#!CommitTicketReference repository="" revision="58068"
Script Loader: Ensure `wp_localize_script()` works when called early.
Before, `wp_localize_script()` did not work when the `$wp_scripts` global
was not already set (for example because of a script registration
happening elsewhere) and even emitted a warning in that case. Due to side
effects such as block registration early in the load process, this usually
never happened. However, the absence of these side effects in 6.5 caused
the `wp_localize_script()` to no longer work in places such as the
`login_enqueue_scripts`.
By calling `wp_scripts()` in `wp_localize_script()`, the `$wp_scripts`
global is automatically set if needed, restoring previous behavior. Adds
both a PHP unit test and an e2e test to verify this use case. Hat tip:
jorbin.
Happy birthday, Aaron!
Props salcode, aslamdoctor, jorbin, swissspidy.
Fixes #60862.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60862#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list