PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / traits / singleton.php

singleton.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/traits/singleton.php

48 lines 836 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Singleton
4 *
5 * @version 1.0.0
6 * @since 0.0.4
7 */
8
9 namespace StoreEngine\Traits;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 trait Singleton {
16
17 protected static $instance;
18
19 public static function init() {
20 return self::get_instance();
21 }
22
23 public static function get_instance() {
24 if ( null === self::$instance ) {
25 self::$instance = new self();
26 }
27
28 return self::$instance;
29 }
30
31 protected function __construct() {
32 }
33
34 /**
35 * Cloning is forbidden.
36 */
37 public function __clone() {
38 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'storeengine' ), '0.0.4' );
39 }
40
41 /**
42 * Unserializing instances of this class is forbidden.
43 */
44 public function __wakeup() {
45 _doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing instances of this class is forbidden.', 'storeengine' ), '0.0.4' );
46 }
47 }
48