WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 11 months 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:
PR Number:

Description

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.

Stefano.

Change History (3)

#1 @swissspidy
2 years ago

  • Component changed from General to Script Loader

#2 @ocean90
11 months ago

#44709 was marked as a duplicate.

#3 @ocean90
11 months 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.