Making WordPress.org

Changeset 3932


Ignore:
Timestamp:
09/02/2016 09:00:51 PM (8 years ago)
Author:
coffee2code
Message:

Profiles Activity Notifier: Switch to singleton implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-profiles-wp-activity-notifier/wporg-profiles-wp-activity-notifier.php

    r3931 r3932  
    1111    private $activity_handler_url = 'https://profiles.wordpress.org/wp-admin/admin-ajax.php';
    1212
    13     public function __construct() {
     13    /**
     14     * @var WPOrg_WP_Activity_Notifier The singleton instance.
     15     */
     16    private static $instance;
     17
     18    /**
     19     * Returns always the same instance of this plugin.
     20     *
     21     * @return Plugin
     22     */
     23    public static function get_instance() {
     24        if ( ! self::$instance ) {
     25            self::$instance = new self();
     26        }
     27        return self::$instance;
     28    }
     29
     30    private function __construct() {
    1431        add_action( 'init', array( $this, 'init' ) );
    1532    }
     
    406423}
    407424
    408 new WPOrg_WP_Activity_Notifier();
     425WPOrg_WP_Activity_Notifier::get_instance();
Note: See TracChangeset for help on using the changeset viewer.