Created
March 28, 2013 10:11
-
-
Save gish/5262145 to your computer and use it in GitHub Desktop.
Functions file pattern for WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( | |
'plugins_loaded', | |
array( My_Plugin::get_instance(), 'setup' ) | |
); | |
class My_Plugin | |
{ | |
/** | |
* Instance of this class | |
* | |
* @see get_instance() | |
* @type My_Plugin | |
*/ | |
protected static $instance = null; | |
/** | |
* Access to the working instance of this class | |
* | |
* @wp-hook init | |
* @return My_Plugin | |
*/ | |
public static function get_instance() | |
{ | |
null === self::$instance and self::$instance = new self; | |
return self::$instance; | |
} | |
/** | |
* Constructor. Intentionally left empty and public. | |
* | |
* @see setup() | |
*/ | |
public function __construct() {} | |
/** | |
* Sets the theme up by adding init actions | |
* @wp-hook plugins_loaded | |
*/ | |
public function setup() | |
{ | |
// Do all initialization, such as adding filters | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment