Replacing Scripts in Admin Load_Scripts

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:

Read More

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?

Related posts

Leave a Reply

1 comment

  1. 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