[wp-trac] [WordPress Trac] #54529: Allow for `wp_register_script()` to be called after `wp_enqueue_script()`.
WordPress Trac
noreply at wordpress.org
Tue Dec 7 17:45:00 UTC 2021
#54529: Allow for `wp_register_script()` to be called after `wp_enqueue_script()`.
-------------------------------------------------+-------------------------
Reporter: dd32 | Owner: audrasjb
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.9
Component: Script Loader | Version: trunk
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests commit | Focuses:
needs-dev-note |
-------------------------------------------------+-------------------------
Changes (by audrasjb):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"52338" 52338]:
{{{
#!CommitTicketReference repository="" revision="52338"
Script Loader: Allow for `wp_register_script()` to be called after
`wp_enqueue_script()`.
When a plugin registers styles/scripts on `wp_enqueue_scripts` (as plugin
authors are encouraged to do), and conditionally enqueues their
script/style on `the_content` filter, things "just work". In block themes,
`the_content` is run prior to the header being processed, which results in
the above scenario failing.
This change makes a `wp_enqueue_script( 'example' ); wp_register_script(
'example' );` work, where as currently the enqueue silently fails (no
"doing it wrong" message) and the following register has no impact.
Scripts can therefore be enqueued and dequeued (by "handle") before they
are registered.
Fixes #54529.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54529#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list