Skip to content

Instantly share code, notes, and snippets.

@afragen
Created April 26, 2017 18:43
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 afragen/b85f3284508b8c1b0d535bc4c1e45ef2 to your computer and use it in GitHub Desktop.
Save afragen/b85f3284508b8c1b0d535bc4c1e45ef2 to your computer and use it in GitHub Desktop.
A Better WordPress Singleton
<?php
//http://jamesdigioia.com/a-better-wordpress-singleton/
class PluginClass
{
protected static $instance = null;
public function __construct($file)
{
if (static::$instance !== null) {
throw new Exception;
}
static::$instance = $this;
}
public static function get()
{
return static::$instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment