1
0
Fork 0
mirror of https://github.com/inretio/WordPress-Plugin-Boilerplate synced 2024-12-22 20:03:53 +02: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,14 +29,30 @@ 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' ) );
@ -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();