Skip to content

Instantly share code, notes, and snippets.

@johnnypea
Last active April 4, 2016 09:51
Show Gist options
  • Select an option

  • Save johnnypea/cfda788c66f8e9216f7ea05f65826294 to your computer and use it in GitHub Desktop.

Select an option

Save johnnypea/cfda788c66f8e9216f7ea05f65826294 to your computer and use it in GitHub Desktop.

Revisions

  1. johnnypea revised this gist Apr 4, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion wordpress-plugin.php
    Original file line number Diff line number Diff line change
    @@ -72,7 +72,6 @@ public function custom_method() {
    * @return MyPlugin
    */
    function MyPlugin() {

    return MyPlugin::instance();
    }

  2. johnnypea revised this gist Apr 4, 2016. 1 changed file with 0 additions and 8 deletions.
    8 changes: 0 additions & 8 deletions wordpress-plugin.php
    Original 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
  3. johnnypea revised this gist Apr 4, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion wordpress-plugin.php
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,6 @@ class MyPlugin {
    *
    * @var $custom_property
    */

    public $custom_property = null;

    /**
  4. johnnypea revised this gist Apr 4, 2016. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions wordpress-plugin.php
    Original 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();
  5. johnnypea created this gist Apr 4, 2016.
    97 changes: 97 additions & 0 deletions wordpress-plugin.php
    Original 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();