PluginProbe ʕ •ᴥ•ʔ
Royal Addons for Elementor – Addons and Templates Kit for Elementor / 1.7.1064
Royal Addons for Elementor – Addons and Templates Kit for Elementor v1.7.1064
1.7.1064 1.7.1063 1.7.1062 1.7.1061 1.7.1060 1.7.1059 1.7.1058 trunk 1.0.0 1.1.0 1.2 1.3 1.3.1 1.3.2 1.3.21 1.3.22 1.3.23 1.3.24 1.3.25 1.3.26 1.3.27 1.3.28 1.3.29 1.3.30 1.3.31 1.3.32 1.3.33 1.3.34 1.3.35 1.3.36 1.3.37 1.3.38 1.3.39 1.3.40 1.3.41 1.3.42 1.3.43 1.3.44 1.3.45 1.3.46 1.3.47 1.3.48 1.3.49 1.3.50 1.3.51 1.3.52 1.3.53 1.3.54 1.3.55 1.3.56 1.3.57 1.3.58 1.3.59 1.3.60 1.3.61 1.3.62 1.3.63 1.3.64 1.3.65 1.3.66 1.3.67 1.3.68 1.3.69 1.3.70 1.3.71 1.3.72 1.3.73 1.3.74 1.3.75 1.3.76 1.3.77 1.3.78 1.3.79 1.3.80 1.3.81 1.3.82 1.3.83 1.3.84 1.3.85 1.3.86 1.3.87 1.3.88 1.3.89 1.3.90 1.3.91 1.3.92 1.3.93 1.3.94 1.3.95 1.3.96 1.3.97 1.3.971 1.3.972 1.3.973 1.3.974 1.3.975 1.3.976 1.3.977 1.3.978 1.3.979 1.3.980 1.3.981 1.3.982 1.3.983 1.3.984 1.3.985 1.3.986 1.3.987 1.7.1 1.7.1001 1.7.1002 1.7.1003 1.7.1004 1.7.1005 1.7.1006 1.7.1007 1.7.1008 1.7.1009 1.7.1010 1.7.1011 1.7.1012 1.7.1013 1.7.1014 1.7.1015 1.7.1016 1.7.1017 1.7.1018 1.7.1019 1.7.1020 1.7.1021 1.7.1022 1.7.1023 1.7.1024 1.7.1025 1.7.1026 1.7.1027 1.7.1028 1.7.1029 1.7.1030 1.7.1031 1.7.1032 1.7.1033 1.7.1034 1.7.1035 1.7.1036 1.7.1037 1.7.1038 1.7.1039 1.7.1040 1.7.1041 1.7.1042 1.7.1043 1.7.1044 1.7.1045 1.7.1046 1.7.1047 1.7.1048 1.7.1049 1.7.1050 1.7.1051 1.7.1052 1.7.1053 1.7.1054 1.7.1055 1.7.1056 1.7.1057
royal-elementor-addons / base / module-base.php
royal-elementor-addons / base Last commit date
module-base.php 5 days ago
module-base.php
98 lines
1 <?php
2 namespace WprAddons\Base;
3
4 abstract class Module_Base {
5
6 /**
7 * @var \ReflectionClass
8 */
9 private $reflection;
10
11 private $components = [];
12
13 /**
14 * @var Module_Base
15 */
16 protected static $_instances = [];
17
18 /**
19 * Throw error on object clone
20 *
21 * The whole idea of the singleton design pattern is that there is a single
22 * object therefore, we don't want the object to be cloned.
23 *
24 * @since 1.0
25 * @return void
26 */
27 public function __clone() {
28 // Cloning instances of the class is forbidden
29 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin huh?', 'wpr-addons' ), '1.0' );
30 }
31
32 /**
33 * Disable unserializing of the class
34 *
35 * @since 1.0
36 * @return void
37 */
38 public function __wakeup() {
39 // Unserializing instances of the class is forbidden
40 _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin huh?', 'wpr-addons' ), '1.0' );
41 }
42
43 public static function class_name() {
44 return get_called_class();
45 }
46
47 /**
48 * @return Module_Base
49 */
50 public static function instance() {
51 if ( empty( static::$_instances[ static::class_name() ] ) ) {
52 static::$_instances[ static::class_name() ] = new static();
53 }
54
55 return static::$_instances[ static::class_name() ];
56 }
57
58 abstract public function get_name();
59
60 public function get_assets_url() {
61 return WPR_ADDONS_MODULES_URL . $this->get_name() . '/assets/';
62 }
63
64 public function get_widgets() {
65 return [];
66 }
67
68 public function __construct() {
69 $this->reflection = new \ReflectionClass( $this );
70
71 // GOGA
72 // add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] );
73 add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] );
74 }
75
76 public function init_widgets() {
77 $widget_manager = \Elementor\Plugin::instance()->widgets_manager;
78
79 foreach ( $this->get_widgets() as $widget ) {
80 $class_name = $this->reflection->getNamespaceName() .'\Widgets\\'. $widget;
81 // $widget_manager->register_widget_type( new $class_name() );
82 $widget_manager->register( new $class_name() );
83 }
84 }
85
86 public function add_component( $id, $instance ) {
87 $this->components[ $id ] = $instance;
88 }
89
90 public function get_component( $id ) {
91 if ( isset( $this->components[ $id ] ) ) {
92 return $this->components[ $id ];
93 }
94
95 return false;
96 }
97 }
98