PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.2.3
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.2.3
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 / class.php

class.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.2.3, at includes/elementor/class.php

262 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sellkit\Elementor;
4
5 use Elementor\Plugin as Elementor;
6 use Elementor\Utils as ElementorUtils;
7
8 defined( 'ABSPATH' ) || die();
9
10 /**
11 * SellKit Elementor class.
12 *
13 * @since 1.1.0
14 */
15 class Sellkit_Elementor {
16
17 /**
18 * Class instance.
19 *
20 * @since 1.1.0
21 * @var Sellkit_Elementor
22 */
23 private static $instance = null;
24
25 /**
26 * Modules.
27 *
28 * @since 1.1.0
29 * @var array
30 */
31 public $modules = [];
32
33 /**
34 * Get a class instance.
35 *
36 * @since 1.1.0
37 *
38 * @return Sellkit_Elementor Class
39 */
40 public static function get_instance() {
41 if ( is_null( self::$instance ) ) {
42 self::$instance = new self();
43 }
44
45 return self::$instance;
46 }
47
48 /**
49 * Class constructor.
50 *
51 * @since 1.1.0
52 */
53 public function __construct() {
54 add_action( 'elementor/init', [ $this, 'init' ] );
55 add_action( 'elementor/frontend/after_register_scripts', [ $this, 'frontend_register_scripts' ], 10 );
56 add_action( 'elementor/frontend/after_register_styles', [ $this, 'frontend_register_styles' ], 10 );
57 add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'frontend_enqueue_styles' ], 10 );
58 add_action( 'elementor/frontend/after_enqueue_scripts', [ $this, 'frontend_enqueue_scripts' ], 10 );
59 add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'editor_enqueue_styles' ], 10 );
60
61 spl_autoload_register( [ $this, 'autoload' ] );
62 remove_theme_support( 'wc-product-gallery-lightbox' );
63 }
64
65 /**
66 * Initialize.
67 *
68 * @since 1.1.0
69 */
70 public function init() {
71 $this->register_modules();
72
73 // Add this category, after basic category.
74 Elementor::$instance->elements_manager->add_category(
75 'sellkit',
76 [
77 'title' => __( 'Sellkit', 'sellkit' ),
78 'icon' => 'fa fa-plug',
79 ],
80 1
81 );
82 }
83
84 /**
85 * Initialize.
86 *
87 * @since 1.1.0
88 */
89 public function register_modules() {
90 // phpcs:disable
91 $modules = [
92 'base/base-widget',
93 'base/base-module',
94 'base/upsell-base-widget',
95 'modules/checkout',
96 'modules/order-cart-details',
97 'modules/order-details',
98 'modules/dynamic-keywords',
99 'modules/product-price',
100 'modules/product-images',
101 'modules/product-title',
102 'modules/product-description',
103 'modules/product-quantity',
104 'modules/accept-reject-button',
105 ];
106 // phpcs:enable
107
108 foreach ( $modules as $module ) {
109 // Prepare module data.
110 $module_data = explode( '/', $module );
111 $module_path = $module_data[0];
112 $module_name = $module_data[1];
113
114 // Prepare class name.
115 $class_name = str_replace( '-', ' ', $module_name );
116 $class_name = str_replace( ' ', '_', ucwords( $class_name ) );
117 $class_name = "Sellkit_Elementor_{$class_name}";
118 $class_name .= ( 'base' === $module_path ) ? '' : '_Module';
119
120 // Prepare class path.
121 $class_path = "elementor/{$module}";
122 $class_path .= ( 'base' === $module_path ) ? '' : '/module';
123
124 // Require.
125 sellkit()->load_files( [ $class_path ] );
126
127 if ( 'base' === $module_path ) {
128 continue;
129 }
130
131 // Register.
132 if ( $class_name::is_active() ) {
133 $this->modules[ $module_name ] = $class_name::get_instance();
134 }
135 }
136 }
137
138 /**
139 * Autoload classes based on namespace.
140 *
141 * @since 1.1.0
142 * @access public
143 *
144 * @param string $class Name of class.
145 */
146 public function autoload( $class ) {
147 // Return if sellkit name space is not set.
148 if ( class_exists( $class ) || 0 !== stripos( $class, __NAMESPACE__ ) ) {
149 return;
150 }
151
152 $filename = str_replace( __NAMESPACE__ . '\\', '', $class );
153 $filename = str_replace( '\\', DIRECTORY_SEPARATOR, $filename );
154 $filename = str_replace( '_', '-', $filename );
155 $filename = sellkit()->plugin_dir() . '/includes/elementor/' . strtolower( $filename ) . '.php';
156
157 // Return if file is not found.
158 if ( ! file_exists( $filename ) ) {
159 return;
160 }
161
162 include $filename;
163 }
164
165 /**
166 * Register front-end scripts
167 *
168 * @since 1.1.0
169 */
170 public function frontend_register_scripts() {
171 $suffix = ElementorUtils::is_script_debug() ? '' : '.min';
172
173 wp_register_script(
174 'sellkit-initialize-widgets',
175 sellkit()->plugin_url() . 'assets/dist/js/elementor-init' . $suffix . '.js',
176 [ 'jquery', 'wc-checkout' ],
177 sellkit()->version(),
178 true
179 );
180
181 wp_localize_script( 'sellkit-initialize-widgets', 'sellkit_elementor', $this->get_localize_data() );
182 }
183
184 /**
185 * Get localize data.
186 *
187 * @return array
188 */
189 public function get_localize_data() {
190 return [
191 'nonce' => wp_create_nonce( 'sellkit_elementor' ),
192 ];
193 }
194
195 /**
196 * Registers styles.
197 *
198 * Registers all the front-end styles.
199 *
200 * Fires after Elementor front-end styles are registered.
201 *
202 * @since 1.1.0
203 * @access public
204 */
205 public function frontend_register_styles() {
206 $rtl = is_rtl() ? '-rtl' : '';
207 $suffix = ElementorUtils::is_script_debug() ? '' : '.min';
208
209 wp_register_style(
210 'sellkit-frontend',
211 sellkit()->plugin_url() . 'assets/dist/css/frontend' . $rtl . $suffix . '.css',
212 [ 'font-awesome' ],
213 sellkit()->version()
214 );
215 }
216
217 /**
218 * Enqueue all the front-end styles.
219 *
220 * Fires after Elementor front-end styles are enqueued.
221 *
222 * @since 1.1.0
223 * @access public
224 */
225 public function frontend_enqueue_styles() {
226 wp_enqueue_style( 'sellkit-frontend' );
227 }
228
229 /**
230 * Enqueue all the front-end scripts.
231 *
232 * Fires after Elementor front-end scripts are enqueued.
233 *
234 * @since 1.1.0
235 * @access public
236 */
237 public function frontend_enqueue_scripts() {
238 wp_enqueue_script( 'sellkit-initialize-widgets' );
239 }
240
241 /**
242 * Enqueue all the editor styles.
243 *
244 * Fires after Elementor editor style are enqueued.
245 *
246 * @since 1.1.0
247 * @access public
248 */
249 public function editor_enqueue_styles() {
250 $suffix = ElementorUtils::is_script_debug() ? '' : '.min';
251
252 wp_enqueue_style(
253 'sellkit-element-icons',
254 sellkit()->plugin_url() . 'assets/dist/css/editor' . $suffix . '.css',
255 [],
256 sellkit()->version()
257 );
258 }
259 }
260
261 Sellkit_Elementor::get_instance();
262