PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.1
3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 2.8.17 2.8.18 All 259 releases
wpfunnels / includes / core / traits / singleton-trait.php

singleton-trait.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.1, at includes/core/traits/singleton-trait.php

40 lines 746 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Singleton trait
4 *
5 * @package WPFunnels\Traits
6 */
7 namespace WPFunnels\Traits;
8
9 trait SingletonTrait {
10
11 private static $instance;
12
13 protected function __construct() {}
14
15 /**
16 * Get class instance.
17 *
18 * @return object Instance.
19 */
20 public static function getInstance() {
21 if (!self::$instance) {
22 // new self() will refer to the class that uses the trait
23 self::$instance = new self();
24 }
25
26 return self::$instance;
27 }
28
29 /**
30 * Prevent cloning.
31 */
32 public function __clone() {}
33
34
35 public function __wakeup() {
36 wc_doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.', 'wpfnl' ), '4.6' );
37 die();
38 }
39 }
40