[wp-trac] [WordPress Trac] #58075: Twenty Twenty-Three: wp_enqueue_scripts action not firing at the right time (was: `wp_enqueue_scripts` action not firing at the right time)

WordPress Trac noreply at wordpress.org
Tue Apr 4 17:14:32 UTC 2023


#58075: Twenty Twenty-Three: 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          |  Resolution:
 Keywords:  needs-patch    |     Focuses:
---------------------------+------------------------------
Description changed by sabernhardt:

Old description:

> 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

New description:

 How to reproduce:

 Use this piece of code somewhere in the (child) 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#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list