mirror of
https://github.com/inretio/WordPress-Plugin-Boilerplate
synced 2024-12-22 20:03:53 +02:00
* Moving the boilerplate to its own directory
* Adding an improved README * Removing unused features of the boilerplate * Officially tagging as 1.0
This commit is contained in:
parent
47edae47e6
commit
e4bbd52ae0
10 changed files with 75 additions and 22 deletions
50
README.md
Normal file
50
README.md
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# WordPress Plugin Boilerplate
|
||||||
|
|
||||||
|
The WordPress Plugin Boilerplate serves as a foundation off of which to build your WordPress widgets.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* The Plugin Boilerplate is fully-based on the WordPress [Plugin API](http://codex.wordpress.org/Plugin_API)
|
||||||
|
* Uses [PHPDoc](http://en.wikipedia.org/wiki/PHPDoc) conventions for easily following the code
|
||||||
|
* Liberal use of `TODO` to guide you through what you need to change
|
||||||
|
* Uses a strict file organization scheme to make sure the assets are easily maintainable
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The WordPress Plugin Boilerplate is ready to activate as-is (though it includes no real functionality).
|
||||||
|
|
||||||
|
1. Copy the `plugin-boilerplate` directory into your `wp-content/plugins` directory
|
||||||
|
2. Navigate to the "Plugins" dashboard page
|
||||||
|
3. Locate the menu item that reads "TODO"
|
||||||
|
4. Click on "Activate"
|
||||||
|
|
||||||
|
This will activate the WordPress Plugin Boilerplate. Because the Boilerplate has no real functionality, nothing will be added to WordPress; however, this demonstrates exactly how your plugin should behave as you're working with it.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The WordPress Plugin Boilerplate is licensed under the GPL v2 or later.
|
||||||
|
|
||||||
|
> This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License, version 2, as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
> This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
> You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
### 1.0 (29 November 2012)
|
||||||
|
|
||||||
|
* Official Release
|
||||||
|
|
||||||
|
## Author Information
|
||||||
|
|
||||||
|
The WordPress Plugin Boilerplate was originally started and is maintained by [Tom McFarlin](http://twitter.com/tommcfarlin/).
|
||||||
|
|
||||||
|
The project is open-source and receives contributions from awesome WordPress Developers throughout the world.
|
|
@ -1 +1 @@
|
||||||
/* This stylesheet is used to style the admin option form of the widget. */
|
/* This stylesheet is used to style the admin option form of the plugin. */
|
|
@ -38,8 +38,8 @@ class PluginName {
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct() {
|
||||||
|
|
||||||
// load plugin text domain
|
// Load plugin text domain
|
||||||
add_action( 'init', array( $this, 'textdomain' ) );
|
add_action( 'init', array( $this, 'plugin_textdomain' ) );
|
||||||
|
|
||||||
// Register admin styles and scripts
|
// Register admin styles and scripts
|
||||||
add_action( 'admin_print_styles', array( $this, 'register_admin_styles' ) );
|
add_action( 'admin_print_styles', array( $this, 'register_admin_styles' ) );
|
||||||
|
@ -49,6 +49,7 @@ class PluginName {
|
||||||
add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) );
|
add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) );
|
||||||
add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_scripts' ) );
|
add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_scripts' ) );
|
||||||
|
|
||||||
|
// Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively.
|
||||||
register_activation_hook( __FILE__, array( $this, 'activate' ) );
|
register_activation_hook( __FILE__, array( $this, 'activate' ) );
|
||||||
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
|
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
|
||||||
register_uninstall_hook( __FILE__, array( $this, 'uninstall' ) );
|
register_uninstall_hook( __FILE__, array( $this, 'uninstall' ) );
|
||||||
|
@ -72,44 +73,46 @@ class PluginName {
|
||||||
/**
|
/**
|
||||||
* Fired when the plugin is activated.
|
* 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
|
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
|
||||||
*/
|
*/
|
||||||
public function activate( $network_wide ) {
|
public function activate( $network_wide ) {
|
||||||
// TODO define activation functionality here
|
// TODO: Define activation functionality here
|
||||||
} // end activate
|
} // end activate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when the plugin is deactivated.
|
* 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
|
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
|
||||||
*/
|
*/
|
||||||
public function deactivate( $network_wide ) {
|
public function deactivate( $network_wide ) {
|
||||||
// TODO define deactivation functionality here
|
// TODO: Define deactivation functionality here
|
||||||
} // end deactivate
|
} // end deactivate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when the plugin is uninstalled.
|
* Fired when the plugin is uninstalled.
|
||||||
*
|
*
|
||||||
* @params $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
|
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
|
||||||
*/
|
*/
|
||||||
public function uninstall( $network_wide ) {
|
public function uninstall( $network_wide ) {
|
||||||
// TODO define uninstall functionality here
|
// TODO: Define uninstall functionality here
|
||||||
} // end uninstall
|
} // end uninstall
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the plugin text domain for translation
|
* Loads the plugin text domain for translation
|
||||||
*/
|
*/
|
||||||
public function textdomain() {
|
public function plugin_textdomain() {
|
||||||
|
|
||||||
// TODO: replace "plugin-name-locale" with a unique value for your plugin
|
// 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_plugin_textdomain( 'plugin-name-locale', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
|
||||||
}
|
|
||||||
|
} // end plugin_textdomain
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers and enqueues admin-specific styles.
|
* Registers and enqueues admin-specific styles.
|
||||||
*/
|
*/
|
||||||
public function register_admin_styles() {
|
public function register_admin_styles() {
|
||||||
|
|
||||||
// TODO change 'plugin-name' to the name of your plugin
|
// TODO: Change 'plugin-name' to the name of your plugin
|
||||||
wp_enqueue_style( 'plugin-name-admin-styles', plugins_url( 'plugin-name/css/admin.css' ) );
|
wp_enqueue_style( 'plugin-name-admin-styles', plugins_url( 'plugin-name/css/admin.css' ) );
|
||||||
|
|
||||||
} // end register_admin_styles
|
} // end register_admin_styles
|
||||||
|
@ -119,7 +122,7 @@ class PluginName {
|
||||||
*/
|
*/
|
||||||
public function register_admin_scripts() {
|
public function register_admin_scripts() {
|
||||||
|
|
||||||
// TODO change 'plugin-name' to the name of your plugin
|
// TODO: Change 'plugin-name' to the name of your plugin
|
||||||
wp_enqueue_script( 'plugin-name-admin-script', plugins_url( 'plugin-name/js/admin.js' ) );
|
wp_enqueue_script( 'plugin-name-admin-script', plugins_url( 'plugin-name/js/admin.js' ) );
|
||||||
|
|
||||||
} // end register_admin_scripts
|
} // end register_admin_scripts
|
||||||
|
@ -129,7 +132,7 @@ class PluginName {
|
||||||
*/
|
*/
|
||||||
public function register_plugin_styles() {
|
public function register_plugin_styles() {
|
||||||
|
|
||||||
// TODO change 'plugin-name' to the name of your plugin
|
// TODO: Change 'plugin-name' to the name of your plugin
|
||||||
wp_enqueue_style( 'plugin-name-plugin-styles', plugins_url( 'plugin-name/css/display.css' ) );
|
wp_enqueue_style( 'plugin-name-plugin-styles', plugins_url( 'plugin-name/css/display.css' ) );
|
||||||
|
|
||||||
} // end register_plugin_styles
|
} // end register_plugin_styles
|
||||||
|
@ -139,7 +142,7 @@ class PluginName {
|
||||||
*/
|
*/
|
||||||
public function register_plugin_scripts() {
|
public function register_plugin_scripts() {
|
||||||
|
|
||||||
// TODO change 'plugin-name' to the name of your plugin
|
// TODO: Change 'plugin-name' to the name of your plugin
|
||||||
wp_enqueue_script( 'plugin-name-plugin-script', plugins_url( 'plugin-name/js/display.js' ) );
|
wp_enqueue_script( 'plugin-name-plugin-script', plugins_url( 'plugin-name/js/display.js' ) );
|
||||||
|
|
||||||
} // end register_plugin_scripts
|
} // end register_plugin_scripts
|
||||||
|
@ -149,7 +152,7 @@ class PluginName {
|
||||||
*---------------------------------------------*/
|
*---------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: Actions are points in the execution of a page or process
|
* NOTE: Actions are points in the execution of a page or process
|
||||||
* lifecycle that WordPress fires.
|
* lifecycle that WordPress fires.
|
||||||
*
|
*
|
||||||
* WordPress Actions: http://codex.wordpress.org/Plugin_API#Actions
|
* WordPress Actions: http://codex.wordpress.org/Plugin_API#Actions
|
||||||
|
@ -157,11 +160,11 @@ class PluginName {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function action_method_name() {
|
function action_method_name() {
|
||||||
// TODO define your action method here
|
// TODO: Define your action method here
|
||||||
} // end action_method_name
|
} // end action_method_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: Filters are points of execution in which WordPress modifies data
|
* NOTE: Filters are points of execution in which WordPress modifies data
|
||||||
* before saving it or sending it to the browser.
|
* before saving it or sending it to the browser.
|
||||||
*
|
*
|
||||||
* WordPress Filters: http://codex.wordpress.org/Plugin_API#Filters
|
* WordPress Filters: http://codex.wordpress.org/Plugin_API#Filters
|
||||||
|
@ -169,10 +172,10 @@ class PluginName {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function filter_method_name() {
|
function filter_method_name() {
|
||||||
// TODO define your filter method here
|
// TODO: Define your filter method here
|
||||||
} // end filter_method_name
|
} // end filter_method_name
|
||||||
|
|
||||||
} // end class
|
} // end class
|
||||||
|
|
||||||
// TODO: update the instantiation call of your plugin to the name given at the class definition
|
// TODO: Update the instantiation call of your plugin to the name given at the class definition
|
||||||
$plugin_name = new PluginName();
|
$plugin_name = new PluginName();
|
|
@ -1 +1 @@
|
||||||
<!-- This file is used to markup the administration form of the plugin.. -->
|
<!-- This file is used to markup the administration form of the plugin. -->
|
Loading…
Reference in a new issue