[wp-trac] [WordPress Trac] #58075: `wp_enqueue_scripts` action not firing at the right time

WordPress Trac noreply at wordpress.org
Tue Apr 4 05:01:44 UTC 2023


#58075: `wp_enqueue_scripts` action not firing at the right time
---------------------------+-----------------------------
 Reporter:  wprj           |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Bundled Theme  |    Version:  6.2
 Severity:  major          |   Keywords:  needs-patch
  Focuses:                 |
---------------------------+-----------------------------
 How to reproduce:

 Use this piece of code somewhere in the theme or a plugin

 {{{#!php
 <?php
 add_filter( 'the_content', function( $content ) {
         ob_start();
         var_dump( did_action( 'wp_enqueue_scripts' ) );
         $done = ob_get_clean();
         return $content . $done;
 } );
 }}}

 It will print 0 despite being in the middle of processing the post
 content.

 It cause problems for plugins that add inline JS (wp_add_inline_script) in
 the post content that are generated from plugin settings or a block
 attributes for instance.

 Does not happen with any other theme

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58075>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list