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

WordPress Trac noreply at wordpress.org
Mon Apr 1 05:06:57 UTC 2024


#60862: wp_localize_script() on login_enqueue_scripts hook change in behavior
----------------------------------------+---------------------
 Reporter:  salcode                     |       Owner:  (none)
     Type:  defect (bug)                |      Status:  new
 Priority:  normal                      |   Milestone:  6.5.1
Component:  Login and Registration      |     Version:  trunk
 Severity:  normal                      |  Resolution:
 Keywords:  needs-unit-tests has-patch  |     Focuses:
----------------------------------------+---------------------
Changes (by jorbin):

 * keywords:  has-patch => needs-unit-tests has-patch
 * milestone:  6.5 => 6.5.1


Comment:

 Thanks @swissspidy!

 While this might not have been something that was intended, it is a
 behavior change from 6.4 to 6.5 that I think is worth fixing, so I'm
 milestoning it for 6.5.1 but agree that it needs an automated test. Maybe
 An E2E to ensure this localization on `login_enqueue_scripts` works as
 expected.


 As a workaround, calling `wp_scripts();` ensures that the global is setup.

 {{{
 <?php

 add_action(
   'login_enqueue_scripts',
   function() {
     wp_scripts();

     wp_localize_script(
       'wp-util',
       'salcodeExample',
       [
         'answerToTheUltimateQuestionOfLifeTheUniverseAndEverything' => 42,
       ]
     );
   }
 );

 }}}

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


More information about the wp-trac mailing list