public
Created — forked from jasonrhodes/myplugin.php

A simple plugin to properly include css and javascript files into a WordPress site. * -(these files won't be minified and concatenated unless you use WP Total Cache or something similar.)

  • Download Gist
myplugin.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<?php
/**
* @package MyPlugin
* @version 1.0
*
* Plugin Name: MyPlugin
* Plugin URI: http://myurl.com/myplugin
* Description: A simple plugin to properly include css and javascript files into a WordPress site.
* -(these files won't be minified and concatenated unless you use WP Total Cache or something similar.)
* Author: Jason Rhodes
* Version: 1.0
* Author URI: http://jasonthings.com
*/
 
// Note: Always prefix your plugin function names, constants, etc.
// For more on why, see Nacin's article: http://wp.me/pQEdq-2B
 
define('PREFIX_MYPLUGIN_VERSION', '1.0.0');
define('PREFIX_MYPLUGIN_PLUGIN_URL', plugin_dir_url( __FILE__ ));
 
function prefix_myplugin_init() {
 
/* First, learn about how to register scripts and styles,
* how to register dependencies, the difference between the handle
* and the filename, etc.
* http://codex.wordpress.org/Function_Reference/wp_register_script
* http://codex.wordpress.org/Function_Reference/wp_register_style
*/
 
// If you have CSS to include, drop the css files into your plugin directory and queue them like so:
wp_register_style('prefix_myplugin.css', PREFIX_MYPLUGIN_PLUGIN_URL . 'myplugin.css');
wp_enqueue_style('prefix_myplugin.css');
 
// For JavaScript files, drop the .js files into your plugin directory and queue them here:
wp_register_script('prefix_myplugin.js', PREFIX_MYPLUGIN_PLUGIN_URL . 'myplugin.js', array('jquery'), "1.0.0", true);
wp_enqueue_script('prefix_myplugin.js');
 
}
add_action('init', 'prefix_myplugin_init');

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.