1
0
Fork 0
mirror of https://github.com/inretio/WordPress-Plugin-Boilerplate synced 2024-12-22 20:03:53 +02:00

Removing constants, updating documentation for activation/deactivation function, adding TODO's

This commit is contained in:
Tom McFarlin 2012-04-09 21:41:17 -04:00
parent 0957a12af4
commit d62ab3343e

View file

@ -29,18 +29,6 @@ License:
// TODO: rename this class to a proper name for yuour plugin
class PluginName {
/*--------------------------------------------*
* Constants
*--------------------------------------------*/
/**
* TODO: update these values to reflect the name and slug of your plugin.
*/
const name = 'Plugin Name';
const slug = 'plugin-name-slug';
/*--------------------------------------------*
* Constructor
*--------------------------------------------*/
@ -50,10 +38,8 @@ class PluginName {
*/
function __construct() {
// Define constants used throughout the plugin
$this->init_plugin_constants();
load_plugin_textdomain( PLUGIN_LOCALE, false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
// TODO: replace "plugin-name-locale" with a unique value for your plugin
load_plugin_textdomain( 'plugin-name-locale', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
// Load JavaScript and stylesheets
$this->register_scripts_and_styles();
@ -77,19 +63,23 @@ class PluginName {
} // end constructor
/**
* Fired when the plugin is activated.
*
* @params $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
*/
function activate( $network_wide ) {
/*
TODO define activation functionality here
$network_wide is true if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
*/
}
// TODO define activation functionality here
} // end activate
function deactivate($network_wide) {
/*
TODO define deactivation functionality here
$network_wide is true if WPMU superadmin uses "Network Deactivate" action, false if WPMU is disabled or plugin is deactivated on an individual blog
/**
* Fired when the plugin is deactivated.
*
* @params $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
*/
}
function deactivate( $network_wide ) {
// TODO define deactivation functionality here
} // end deactivate
/*--------------------------------------------*
* Core Functions
@ -123,51 +113,26 @@ class PluginName {
* Private Functions
*---------------------------------------------*/
/**
* Initializes constants used for convenience throughout
* the plugin.
*/
private function init_plugin_constants() {
/* TODO
*
* Define this as the name of your plugin. This is what shows
* in the Widgets area of WordPress.
*
* For example: WordPress Widget Boilerplate.
*/
if ( !defined( 'PLUGIN_NAME' ) ) {
define( 'PLUGIN_NAME', self::name );
} // end if
/* TODO
*
* this is the slug of your plugin used in initializing it with
* the WordPress API.
* This should also be the
* directory in which your plugin resides. Use hyphens.
*
* For example: wordpress-widget-boilerplate
*/
if ( !defined( 'PLUGIN_SLUG' ) ) {
define( 'PLUGIN_SLUG', self::slug );
} // end if
} // end init_plugin_constants
/**
* Registers and enqueues stylesheets for the administration panel and the
* public facing site.
*/
private function register_scripts_and_styles() {
if ( is_admin() ) {
$this->load_file( self::slug . '-admin-script', '/js/admin.js', true );
$this->load_file( self::slug . '-admin-style', '/css/admin.css' );
// TODO replace 'plugin-slug-' with a unique value for your plugin
$this->load_file( 'plugin-slug-admin-script', '/js/admin.js', true );
$this->load_file( 'plugin-slug-admin-style', '/css/admin.css' );
} else {
$this->load_file( self::slug . '-script', '/js/widget.js', true );
$this->load_file( self::slug . '-style', '/css/widget.css' );
// TODO replace 'plugin-slug-' with a unique value for your plugin
$this->load_file( 'plugin-slug-script', '/js/widget.js', true );
$this->load_file( 'plugin-slug-style', '/css/widget.css' );
} // end if/else
} // end register_scripts_and_styles
/**
@ -183,13 +148,19 @@ class PluginName {
$file = plugin_dir_path( __FILE__ ) . $file_path;
if( file_exists( $file ) ) {
if( $is_script ) {
wp_register_script( $name, $url, array( 'jquery' ) );
wp_enqueue_script( $name );
} else {
wp_register_style( $name, $url );
wp_enqueue_style( $name );
} // end if
} // end if
} // end load_file