Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function enqueue_mp3_scripts_init($form, $is_ajax) {
- if ( $is_ajax ) {
- wp_enqueue_script( 'mp3-script', plugin_dir_url(__FILE__) . 'js/scripts.js', array('jquery'), 1.0 ); // jQuery will be included automatically
- wp_localize_script( 'mp3-script', 'mp3_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); // setting ajaxurl
- }
- }
- add_action('gform_enqueue_scripts', 'enqueue_mp3_scripts_init', 10, 2);
- function ajax_mp3_func() {
- if( isset($_POST['files']) ) {
- echo $_POST['files'];
- }
- die(); // stop executing script
- }
- add_action( 'wp_ajax_ajax_mp3', 'ajax_mp3_func' ); // ajax for logged in users
- add_action( 'wp_ajax_nopriv_ajax_mp3', 'ajax_mp3_func' ); // ajax for not logged in users
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement