Last active
April 4, 2016 09:51
-
-
Save johnnypea/cfda788c66f8e9216f7ea05f65826294 to your computer and use it in GitHub Desktop.
Revisions
-
johnnypea revised this gist
Apr 4, 2016 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -72,7 +72,6 @@ public function custom_method() { * @return MyPlugin */ function MyPlugin() { return MyPlugin::instance(); } -
johnnypea revised this gist
Apr 4, 2016 . 1 changed file with 0 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -46,25 +46,18 @@ class 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'; } } @@ -81,7 +74,6 @@ public function custom_method() { function MyPlugin() { return MyPlugin::instance(); } //Now we can easily access any available properties and methods of MyPlugin object -
johnnypea revised this gist
Apr 4, 2016 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,6 @@ class MyPlugin { * * @var $custom_property */ public $custom_property = null; /** -
johnnypea revised this gist
Apr 4, 2016 . 1 changed file with 0 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,6 @@ * @class MyPlugin * @version 1.0.0 */ class MyPlugin { /** @@ -27,7 +26,6 @@ class MyPlugin { * @var MyPlugin * @since 1.0.0 */ protected static $_instance = null; /** @@ -48,7 +46,6 @@ class MyPlugin { * @see MyPlugin() * @return MyPlugin - Main instance. */ public static function instance() { if ( is_null( self::$_instance ) ) { @@ -65,7 +62,6 @@ public static function instance() { * Custom Method. * @return custom_method() */ public function custom_method() { return 'Custom Method'; @@ -83,7 +79,6 @@ public function custom_method() { * @since 1.0.0 * @return MyPlugin */ function MyPlugin() { return MyPlugin::instance(); -
johnnypea created this gist
Apr 4, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,97 @@ <?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();