Referencing files in JavaScript in WordPress Plugin

Use wp_localize_script. function pr_add_link_sound () { //Register the script first wp_register_script(‘add_sound’, plugins_url( ‘add_sound.js’, __FILE__ ), array(‘jquery’), ”, true); //Localize the sound file url to use in the script $args = array( ‘sound1’ => plugins_url( ‘sound.mp3’, __FILE__ ), ); wp_localize_script( ‘add_sound’, ‘PRSound’, $args ); //Enqueue the script wp_enqueue_script(‘add_sound’); } You can reference the sound in the … Read more

Overwriting a plugin function

Unless the plugin itself provides hooks that you can use, or has been written is such a way as to be replaceable (a dicey proposition for a plugin), you can’t. This isn’t a WordPress restriction. It is a PHP one. You cannot “overload” or redefine functions in PHP. You will get a fatal error.