1
0
Fork 0
mirror of https://github.com/inretio/WordPress-Plugin-Boilerplate synced 2024-04-27 00:51:04 +03:00

implemented the singleton pattern

This commit is contained in:
Tom McFarlin 2013-05-07 17:00:38 -04:00
parent 11af5e0d11
commit 6d141e700f

View file

@ -29,21 +29,37 @@ License:
// TODO: rename this class to a proper name for your plugin
class PluginName {
/*--------------------------------------------*
* Attributes
*--------------------------------------------*/
/** Refers to a single instance of this class. */
private static $instance;
/*--------------------------------------------*
* Constructor
*--------------------------------------------*/
/**
* Creates or returns an instance of this class.
*
* @return PluginName A single instance of this class.
*/
public function get_instance() {
return null == self::$instance ? new self : self::$instance;
} // end get_instance;
/**
* Initializes the plugin by setting localization, filters, and administration functions.
*/
function __construct() {
private function __construct() {
// Load plugin text domain
add_action( 'init', array( $this, 'plugin_textdomain' ) );
// Add the options page and menu item
// Uncomment the following line to enable the Settings Page for the plugin
# add_action('admin_menu', array( $this, 'plugin_admin_menu' ) );
# add_action('admin_menu', array( $this, 'plugin_admin_menu' ) );
// Register admin styles and scripts
// If the Settings page has been activated (above), the scripts and styles
@ -232,4 +248,4 @@ class PluginName {
} // end class
// TODO: Update the instantiation call of your plugin to the name given at the class definition
$plugin_name = new PluginName();
PluginName::get_instance();