There is a plugin that's conflicting with mine when the user loads the admin pages of my plugin, therefore I want to deregister and remove the conflicting script on these pages.
Here is the code for the conflicting script:-
add_action( 'admin_head', 'function_name' );
function function_name() {
if ( is_admin() ) {
wp_enqueue_script(
'script_name',
plugins_url('/js/some_javascript_file.js', __FILE__ )
);
}
}
So In my code I check to see if the user is in our admin pages and if so I try to deregister the script as follows:-
function admin_hc_deregister_conflicts() {
wp_deregister_script('script_name');
}
add_action('admin_head', array($this,'admin_hc_deregister_conflicts'),11);
The problem is that the script is still being loaded in my admin area causing a lot of problems!
Please can someone advise:-
i) Is it possible to remove a script that has been enqueued but not registered? ii) What can I add to my plugin to remove this script from being loaded in our admin pages so that there are no conflicts?
Thanks in advance!
admin_headis the wrong action to enqueue a script, but there's nothing you can do about that! – Milo Jan 7 at 17:35