Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#41990 new defect (bug)

wp_add_inline_script() does not print if the handler has already processed

Reported by: satollo Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.5
Component: Script Loader Keywords: needs-patch
Focuses: Cc:


If the wp_add_inline_script() function (with 'after' position set) is called after the head scripts have already been printed and the handler specified on wp_add_inline_script() is part of the head printed scripts, the code is not added later in the footer.

Probably it should. Example a plugin which implements a shortcode needs to add some jquery inline statement only when the shortcode is executed (to add the js code only on relevant pages). It enqueues jquery to be added in the footer and a piece of inline script.

But another plugin or the theme enqueues jquery in the header (as many do): the above inline code is not printed but it actually does not need to be exactly after the jquery inclusion.


Change History (3)

#1 @swissspidy
4 years ago

  • Component changed from General to Script Loader

#2 @ocean90
3 years ago

#44709 was marked as a duplicate.

#3 @ocean90
3 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 4.8.1 to 4.5
Note: See TracTickets for help on using tickets.