[wp-trac] [WordPress Trac] #35963: Only remove item from WP_Dependencies::to_do if it was successfully processed
WordPress Trac
noreply at wordpress.org
Fri Feb 26 12:37:34 UTC 2016
#35963: Only remove item from WP_Dependencies::to_do if it was successfully
processed
---------------------------+-----------------------------
Reporter: pcfreak30 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: trunk
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
If WP_Dependencies::do_item returns false, the item is removed from being
processed again. Due to this, if an item gets switched to the footer, it
is never actually outputted. A common scenario is depending on jquery
which depends on jquery-core and jquery-migrate. jquery is processed
right, but jquery-core and jquery-migrate are moved to the bottom but
still removed from the list.
The following example demonstrates:
{{{#!php
<?php
add_action('wp_print_scripts', function () {
if (!is_admin()) {
$jquery = wp_scripts()->registered['jquery'];
wp_dequeue_script('jquery');
wp_deregister_script('jquery');
wp_register_script('jquery', $jquery->src, $jquery->deps,
$jquery->ver, true);
}
}, 0);
}}}
Attached is a very simple patch to resolve this
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35963>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list