Created
January 21, 2013 23:30
-
-
Save ebinnion/4590551 to your computer and use it in GitHub Desktop.
Enqueue Script and Js in Plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('template_redirect', 'audience_intel_add_js'); | |
function audience_intel_add_js() { | |
// enqueue script | |
wp_enqueue_script( 'audience_intel_js', | |
plugins_url( 'js/script.js' , __FILE__ ), | |
array('jquery'), audience_intel_version, true | |
); | |
// Get current page protocol | |
$protocol = isset( $_SERVER["HTTPS"] ) ? 'https://' : 'http://'; | |
// Outpit admin-ajax.php URL with same protocol as current page | |
$params = array( | |
'ajaxurl' => admin_url('admin-ajax.php', $protocol) | |
); | |
wp_localize_script( 'audience_intel_js', 'audience_intel_js', $params ); | |
wp_register_style( 'audience-intel-style', plugins_url('css/plugin.css', __FILE__) ); | |
wp_enqueue_style( 'audience-intel-style' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment