Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. function enqueue_mp3_scripts_init($form, $is_ajax) {
  2.          if ( $is_ajax ) {
  3.         wp_enqueue_script( 'mp3-script', plugin_dir_url(__FILE__) . 'js/scripts.js', array('jquery'), 1.0 ); // jQuery will be included automatically
  4.         wp_localize_script( 'mp3-script', 'mp3_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); // setting ajaxurl
  5.          }
  6.         }
  7.  
  8. add_action('gform_enqueue_scripts', 'enqueue_mp3_scripts_init', 10, 2);
  9.  
  10. function ajax_mp3_func() {
  11.    
  12.     if( isset($_POST['files']) )  {
  13.         echo $_POST['files'];              
  14.         }
  15.        
  16.     die(); // stop executing script
  17. }
  18.  
  19. add_action( 'wp_ajax_ajax_mp3', 'ajax_mp3_func' ); // ajax for logged in users
  20. 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