Created
March 20, 2015 12:34
-
-
Save woodwardtw/252b6d671f3728506f0b to your computer and use it in GitHub Desktop.
basic plugin for addthisevent.com with detailed comments
This file contains 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
<?php | |
/** | |
* Plugin Name: Add This Event JS. | |
* Plugin URI: https://addthisevent.com/ | |
* Description: Simply adds the addthisevent.com js to the footer. | |
* Version:1.0.0 | |
* Author: Tom Woodward | |
* Author URI: http://bionicteaching.com | |
* License: GPL2 | |
*/ | |
//register scripts | |
function ate_scripts() { | |
wp_register_script( 'add_this_event', //give the script a handle | |
'https://addthisevent.com/libs/1.5.8/ate.min.js', //location of an external script | |
array(), //put any scripts that have to load first for this script to work between the () | |
'scriptversion 1.5.8', //script version | |
true); //true to put it in the footer, false to put it in the header | |
wp_register_script( 'add_this_events_prefs', | |
plugins_url( '/js/prefs.js', __FILE__ ), //location of an internal plugin script, like Spanish adj goes first | |
array(add_this_event), //this script is reliant on the add_this_event | |
'1', | |
true); | |
wp_register_style('add_this_event_css', //loads a CSS file, note small differences from js loading style vs script | |
plugins_url( '/ate.css', __FILE__ ), | |
array(), | |
'1', | |
'all'); //media type | |
//enque scripts | |
wp_enqueue_script('add_this_event'); //enque the script by its handle | |
wp_enqueue_script('add_this_events_prefs'); | |
wp_enqueue_style('add_this_event_css'); //enque the style by its handle | |
} | |
add_action( 'wp_enqueue_scripts', 'ate_scripts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment