Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php // used here only for enabling syntax highlighting. Leave this out if it's already included in your plugin file.
  2.  
  3. // Fires after WordPress has finished loading, but before any headers are sent.
  4. add_action( 'init', 'script_enqueuer' );
  5.  
  6. function script_enqueuer() {
  7.  
  8. // Register the JS file with a unique handle, file location, and an array of dependencies
  9. wp_register_script( "liker_script", plugin_dir_url(__FILE__).'liker_script.js', array('jquery') );
  10.  
  11. // localize the script to your domain name, so that you can reference the url to admin-ajax.php file easily
  12. wp_localize_script( 'liker_script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
  13.  
  14. // enqueue jQuery library and the script you registered above
  15. wp_enqueue_script( 'jquery' );
  16. wp_enqueue_script( 'liker_script' );
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement