johnwatkins0/wp-singleton

There is no license information available for the latest version (1.0.0) of this package.

A singleton trait for use in WordPress projects

1.0.0 2019-01-13 22:42 UTC

This package is auto-updated.

Last update: 2024-04-11 13:50:59 UTC


README

A singleton trait for use in WordPress projects

Example

use JohnWatkins0\WPSingleton\Singleton;

class My_Class {
    use Singleton;

    protected function init() {
        // Do stuff when the object is first created.
    }
}

My_Class::get_instance(); // Retrieve an instance.
My_Class::get_instance(); // Same instance as above.
new My_Class(); // Error.