Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@EranSch
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EranSch/f0d4c2b0e6073f128638 to your computer and use it in GitHub Desktop.
Save EranSch/f0d4c2b0e6073f128638 to your computer and use it in GitHub Desktop.
Singleton style plugin reference
if ( ! defined( 'ABSPATH' ) ) exit;
add_action( 'plugins_loaded', array( 'Plugin_Class_Name', 'get_instance' ) );
class Plugin_Class_Name {
private static $instance = null;
public static function get_instance() {
if ( ! isset( self::$instance ) )
self::$instance = new self;
return self::$instance;
}
private function __construct() {
// Register hooks and shit here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment