Question

I'm currently creating a plugin that requires me to overwrite one of the Wordpress admin panel javascript files. I have recreated the file with the changes, I need to know how to replace the existing file that gets loaded in load_scripts.php (the script needs to be added in the same order).

I was hoping something like this would do the job:

wp_register_script('admin-widgets', WP_PLUGIN_URL. '/oak-automated-sidebars/oak-widgets.js'); wp_enqueue_script('admin-widgets');

But it doesn't seem to work, the original script is still loaded. Any suggestions?

Was it helpful?

Solution

You need to first deregister the script using wp_deregister_script

 wp_deregister_script( 'admin-widgets' );

then use your code to re-register the script using your own js file:

wp_register_script('admin-widgets', WP_PLUGIN_URL. '/oak-automated-sidebars/oak-widgets.js'); 
wp_enqueue_script('admin-widgets');

Hope this Helps

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top