function wp_deregister_script($handle) { global $wp_scripts; if (!is_a($wp_scripts, 'WP_Scripts')) { $wp_scripts = new WP_Scripts(); } $wp_scripts->remove($handle); }
/** * Remove a registered script. * * @since r16 * @see WP_Scripts::remove() For parameter information. */ function wp_deregister_script($handle) { global $wp_scripts; if (!is_a($wp_scripts, 'WP_Scripts')) { if (!did_action('init')) { _doing_it_wrong(__FUNCTION__, sprintf(__('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>'), '3.3'); } $wp_scripts = new WP_Scripts(); } $wp_scripts->remove($handle); }
/** * Remove a registered script. * * @since r16 * @see WP_Scripts::remove() For parameter information. */ function wp_deregister_script($handle) { global $wp_scripts; if (!is_a($wp_scripts, 'WP_Scripts')) { if (!did_action('init')) { _doing_it_wrong(__FUNCTION__, sprintf(__('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>'), '3.3'); } $wp_scripts = new WP_Scripts(); } // Do not allow accidental or negligent deregistering of critical scripts in the admin. Show minimal remorse if the correct hook is used. if (is_admin() && 'admin_enqueue_scripts' !== current_filter()) { $no = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone'); if (in_array($handle, $no)) { $message = sprintf(__('Do not deregister the %1$s script in the administration area. To target the frontend theme, use the %2$s hook.'), "<code>{$handle}</code>", '<code>wp_enqueue_scripts</code>'); _doing_it_wrong(__FUNCTION__, $message, '3.6'); return; } } $wp_scripts->remove($handle); }
/** * Filter wp_default_scripts * * Removes an extra jQuery Script * * @since 5.0.0 * * @param \WP_Scripts $scripts The Default WordPress scripts. * * @return void */ function filter_wp_default_scripts($scripts) { if (!is_admin()) { $scripts->remove('jquery'); $scripts->add('jquery', false, array('jquery-core'), '1.12.3'); } }
/** * Register scripts. * * This will be moved to script-loader.php in #coremerge. * * @param WP_Scripts $wp_scripts Scripts. */ function register_scripts($wp_scripts) { $handle = 'customize-partial-refresh-pane'; $src = $this->dir_url . 'js/customize-partial-refresh-pane.js'; $deps = array('customize-controls', 'jquery', 'wp-util'); $in_footer = true; $wp_scripts->add($handle, $src, $deps, $this->get_version(), $in_footer); $handle = 'customize-widgets-hacks'; $src = $this->dir_url . 'js/customize-widgets-hacks.js'; $deps = array('customize-widgets'); $in_footer = true; $wp_scripts->add($handle, $src, $deps, $this->get_version(), $in_footer); $handle = 'customize-partial-refresh-preview'; $src = $this->dir_url . 'js/customize-partial-refresh-preview.js'; $deps = array('customize-preview', 'wp-util'); $in_footer = true; $wp_scripts->add($handle, $src, $deps, $this->get_version(), $in_footer); $handle = 'customize-preview-nav-menus'; $src = $this->dir_url . 'js/customize-preview-nav-menus.js'; $deps = array('customize-preview', 'customize-partial-refresh-preview'); $in_footer = true; $wp_scripts->remove($handle); $wp_scripts->add($handle, $src, $deps, $this->get_version(), $in_footer); $handle = 'customize-preview-widgets'; $src = $this->dir_url . 'js/customize-preview-widgets.js'; $deps = array('customize-preview', 'customize-partial-refresh-preview'); $in_footer = true; $wp_scripts->remove($handle); $wp_scripts->add($handle, $src, $deps, $this->get_version(), $in_footer); }
/** * Dequeue jQuery migrate. * * @since 1.0.0 * * @access private * @param WP_Scripts $scripts Default scripts. */ public function dequeue_jquery_migrate($scripts) { if (!is_admin()) { $scripts->remove('jquery'); $scripts->add('jquery', false, array('jquery-core'), false); } }