[wp-trac] [WordPress Trac] #60862: wp_localize_script() on login_enqueue_scripts hook change in behavior

WordPress Trac noreply at wordpress.org
Thu May 2 15:04:21 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 fixed-major dev-    |     Focuses:
  reviewed                                       |
-------------------------------------------------+-------------------------
Changes (by jorbin):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"58078" 58078]:
 {{{
 #!CommitTicketReference repository="" revision="58078"
 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.

 Thanks for the birthday wishes, Pascal!

 Reviewed by Jorbin.
 Merges [58068] to the 6.5 branch.

 Props salcode, aslamdoctor, jorbin, swissspidy.
 Fixes #60862.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60862#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list