PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.0.6
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.0.6
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
templately / includes / Utils / Base.php

Base.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! 3.0.6, at includes/Utils/Base.php

77 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Templately\Utils;
4
5 use Templately\Core\Module;
6 use Templately\Core\Platform;
7
8 abstract class Base {
9 /**
10 * Holds the plugin instance.
11 *
12 * @since 2.0.0
13 * @access protected
14 * @static
15 *
16 * @var Base
17 */
18 private static $instances = [];
19
20 /**
21 * Disable class cloning and throw an error on object clone.
22 *
23 * The whole idea of the singleton design pattern is that there is a single
24 * object. Therefore, we don't want the object to be cloned.
25 *
26 * @access public
27 * @since 2.0.0
28 */
29 public function __clone() {
30 // Cloning instances of the class is forbidden.
31 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'templately' ), '1.0.0' );
32 }
33
34 /**
35 * Disable un-serializing of the class.
36 *
37 * @access public
38 * @since 2.0.0
39 */
40 public function __wakeup() {
41 // Un-serializing instances of the class is forbidden.
42 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'templately' ), '1.0.0' );
43 }
44
45 /**
46 * Sets up a single instance of the plugin.
47 *
48 * @since 2.0.0
49 * @access public
50 * @static
51 *
52 * @return static An instance of the class.
53 */
54 public static function get_instance( ...$args ) {
55 $module = get_called_class();
56 if ( ! isset( self::$instances[ $module ] ) ) {
57 self::$instances[ $module ] = new $module( ...$args );
58 }
59
60 return self::$instances[ $module ];
61 }
62
63 /**
64 * Determine the plugin module to make platform based things happened.
65 *
66 * @param string $id
67 * @return Platform|null
68 */
69 public function platform( $id ){
70 $platform = Module::get_instance()->active( $id );
71 if( ! is_null( $platform ) ) {
72 return $platform;
73 }
74
75 return null;
76 }
77 }