[wp-trac] [WordPress Trac] #54958: Inconsistent behaviour for wp_add_inline_script between block-based and standard themes

WordPress Trac noreply at wordpress.org
Fri Jan 28 14:06:41 UTC 2022


#54958: Inconsistent behaviour for wp_add_inline_script between block-based and
standard themes
--------------------------+------------------------------
 Reporter:  Rustaurius    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by Rustaurius):

 Thanks for the reply.

 Is the suggestion then to enqueue plugin scripts on every page load in
 that case, or is there a way to check whether a shortcode is included in
 the HTML that is being loaded more generally? I know that you can check
 for a shortcode using has_shortcode:


 {{{
 if ( has_shortcode( $post->post_content, 'shortcode' ) ) {
    //enqueue
 }
 }}}


 But my understanding was that this would miss certain contexts (if the
 shortcode was used in a widget, archives, etc.), and loading on every page
 would slow page load times.

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


More information about the wp-trac mailing list