PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.2.1
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.2.1
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / includes / elementor / base / base-module.php

base-module.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.2.1, at includes/elementor/base/base-module.php

100 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || die();
4
5 /**
6 * Class Sellkit_Elementor_Base_Module
7 *
8 * @since 1.1.0
9 */
10 abstract class Sellkit_Elementor_Base_Module {
11
12 /**
13 * The class instance.
14 *
15 * @var array
16 */
17 public static $instances = [];
18
19 /**
20 * Get the current class name.
21 *
22 * @since 1.1.0
23 * @return string
24 */
25 public static function class_name() {
26 return get_called_class();
27 }
28
29 /**
30 * Gets the instance.
31 *
32 * @since 1.1.0
33 * @return mixed
34 */
35 public static function get_instance() {
36 if ( empty( static::$instances[ static::class_name() ] ) ) {
37 static::$instances[ static::class_name() ] = new static();
38 }
39
40 return static::$instances[ static::class_name() ];
41 }
42
43 /**
44 *
45 * Gets the widgets
46 *
47 * @since 1.1.0
48 * @return array
49 */
50 public function get_widgets() {
51 return [];
52 }
53
54 /**
55 * Class constructor
56 *
57 * @since 1.1.0
58 * Sellkit_Elementor_Base_Module constructor.
59 */
60 public function __construct() {
61 add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ] );
62 }
63
64 /**
65 * Register widgets.
66 *
67 * @since 1.1.0
68 * @param object $widgets_manager Widgets manager.
69 */
70 public function register_widgets( $widgets_manager ) {
71 foreach ( $this->get_widgets() as $widget_name ) {
72 // Prepare class name.
73 $class_name = str_replace( '-', ' ', $widget_name );
74 $class_name = str_replace( ' ', '_', ucwords( $class_name ) );
75 $class_name = "Sellkit_Elementor_{$class_name}_Widget";
76
77 // Prepare class path.
78 $class_path = "elementor/modules/{$widget_name}/widgets/{$widget_name}";
79
80 // Require.
81 sellkit()->load_files( [ $class_path ] );
82
83 // Register.
84 if ( $class_name::is_active() ) {
85 $widgets_manager->register_widget_type( new $class_name() );
86 }
87 }
88 }
89
90 /**
91 * Check if the module is active.
92 *
93 * @since 1.1.0
94 * @return bool
95 */
96 public static function is_active() {
97 return true;
98 }
99 }
100