Last active
April 4, 2016 09:51
-
-
Save johnnypea/cfda788c66f8e9216f7ea05f65826294 to your computer and use it in GitHub Desktop.
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 | |
/* | |
Plugin Name: My Plugin | |
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates | |
Description: This describes my plugin in a short sentence | |
Version: 1.0.0 | |
Author: Webikon (John Doe) | |
Author URI: http://URI_Of_The_Plugin_Author | |
License: GPL2 | |
License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
Domain Path: /languages | |
Text Domain: my-plugin | |
*/ | |
/** | |
* Main MyPlugin Class. | |
* | |
* @class MyPlugin | |
* @version 1.0.0 | |
*/ | |
class MyPlugin { | |
/** | |
* The single instance of the class. | |
* | |
* @var MyPlugin | |
* @since 1.0.0 | |
*/ | |
protected static $_instance = null; | |
/** | |
* Custom Property. | |
* | |
* @var $custom_property | |
*/ | |
public $custom_property = null; | |
/** | |
* Main MyPlugin Instance. | |
* | |
* Ensures only one instance of MyPlugin is loaded or can be loaded. | |
* | |
* @since 1.0.0 | |
* @static | |
* @see MyPlugin() | |
* @return MyPlugin - Main instance. | |
*/ | |
public static function instance() { | |
if ( is_null( self::$_instance ) ) { | |
self::$_instance = new self(); | |
} | |
return self::$_instance; | |
} | |
/** | |
* Custom Method. | |
* @return custom_method() | |
*/ | |
public function custom_method() { | |
return 'Custom Method'; | |
} | |
} | |
/** | |
* Main instance of MyPlugin. | |
* | |
* Returns the main instance of MyPlugin to prevent the need to use globals. | |
* | |
* @since 1.0.0 | |
* @return MyPlugin | |
*/ | |
function MyPlugin() { | |
return MyPlugin::instance(); | |
} | |
//Now we can easily access any available properties and methods of MyPlugin object | |
MyPlugin()->custom_property; | |
MyPlugin()->custom_method(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment