PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / RegisterWidgets.php
shop-press / Elementor Last commit date
control 2 weeks ago template-library 2 weeks ago widgets 2 weeks ago ControlsWidgets.php 2 weeks ago EditorCondition.php 2 weeks ago EditorScripts.php 1 year ago Integration.php 1 year ago RegisterWidgets.php 1 year ago ShopPressStyler.php 2 weeks ago ShopPressWidgets.php 2 weeks ago
RegisterWidgets.php
532 lines
1 <?php
2 /**
3 * Register Widgets.
4 *
5 * @package ShopPress
6 */
7
8 namespace ShopPress\Elementor;
9
10 defined( 'ABSPATH' ) || exit;
11
12 class RegisterWidgets {
13 /**
14 * Init Register Widgets.
15 *
16 * @since 1.2.0
17 */
18 public static function init() {
19 self::hooks();
20 }
21
22 /**
23 * Init hooks.
24 *
25 * @since 1.2.0
26 */
27 private static function hooks() {
28 add_action( 'elementor/widgets/register', array( __CLASS__, 'register_widgets' ) );
29 }
30
31 /**
32 * Retrieves the list of widgets.
33 *
34 * @since 1.2.0
35 *
36 * @return array
37 */
38 public static function get_widgets_list() {
39 $widgets = array(
40 'product-collection' => array(
41 'editor_type' => 'general',
42 'class_name' => 'ProductsLoop',
43 'is_pro' => false,
44 'path_key' => 'products/products-loop',
45 ),
46 'cart-table' => array(
47 'editor_type' => 'cart',
48 'class_name' => 'CartTable',
49 'is_pro' => false,
50 'path_key' => 'cart/cart-table',
51 ),
52 'cart-totals' => array(
53 'editor_type' => 'cart',
54 'class_name' => 'CartTotals',
55 'is_pro' => false,
56 'path_key' => 'cart/cart-totals',
57 ),
58 'cart-coupon' => array(
59 'editor_type' => 'cart',
60 'class_name' => 'CartCoupon',
61 'is_pro' => false,
62 'path_key' => 'cart/cart-coupon',
63 ),
64 'cross-sell-products' => array(
65 'editor_type' => 'cart',
66 'class_name' => 'ProductsLoop\CrossSellProducts',
67 'is_pro' => false,
68 'path_key' => 'products/cross-sell-products',
69 ),
70 'cart-empty-message' => array(
71 'editor_type' => 'empty_cart',
72 'class_name' => 'CartEmptyMessage',
73 'is_pro' => false,
74 'path_key' => 'empty-cart/cart-empty-message',
75 ),
76 'return-to-shop' => array(
77 'editor_type' => 'empty_cart',
78 'class_name' => 'ReturnToShop',
79 'is_pro' => false,
80 'type' => 'empty-cart',
81 'path_key' => 'empty-cart/return-to-shop',
82 ),
83 'additional-fields' => array(
84 'editor_type' => 'checkout',
85 'class_name' => 'AdditionalFields',
86 'is_pro' => false,
87 'path_key' => 'checkout/additional-fields',
88 ),
89 'form-billing' => array(
90 'editor_type' => 'checkout',
91 'class_name' => 'FormBilling',
92 'is_pro' => false,
93 'path_key' => 'checkout/form-billing',
94 ),
95 'form-coupon' => array(
96 'editor_type' => 'checkout',
97 'class_name' => 'FormCoupon',
98 'is_pro' => false,
99 'path_key' => 'checkout/form-coupon',
100 ),
101 'login-form' => array(
102 'editor_type' => 'checkout',
103 'class_name' => 'LoginForm',
104 'is_pro' => false,
105 'path_key' => 'checkout/login-form',
106 ),
107 'order-review' => array(
108 'editor_type' => 'checkout',
109 'class_name' => 'OrderReview',
110 'is_pro' => false,
111 'path_key' => 'checkout/order-review',
112 ),
113 'payment-method' => array(
114 'editor_type' => 'checkout',
115 'class_name' => 'PaymentMethod',
116 'is_pro' => false,
117 'path_key' => 'checkout/payment-method',
118 ),
119 'shipping-form' => array(
120 'editor_type' => 'checkout',
121 'class_name' => 'FormShipping',
122 'is_pro' => false,
123 'path_key' => 'checkout/shipping-form',
124 ),
125 'my-account' => array(
126 'editor_type' => 'my_account',
127 'class_name' => 'MyAccount',
128 'is_pro' => false,
129 'path_key' => 'my-account/my-account',
130 ),
131 'dashboard' => array(
132 'editor_type' => 'dashboard',
133 'class_name' => 'Dashboard',
134 'is_pro' => false,
135 'path_key' => 'my-account/dashboard',
136 ),
137 'addresses' => array(
138 'editor_type' => 'addresses',
139 'class_name' => 'Addresses',
140 'is_pro' => false,
141 'path_key' => 'my-account/addresses',
142 ),
143 'downloads' => array(
144 'editor_type' => 'downloads',
145 'class_name' => 'Downloads',
146 'is_pro' => false,
147 'path_key' => 'my-account/downloads',
148 ),
149 'edit-account' => array(
150 'editor_type' => 'account_details',
151 'class_name' => 'EditAccount',
152 'is_pro' => false,
153 'path_key' => 'my-account/edit-account',
154 ),
155 'orders' => array(
156 'editor_type' => 'orders',
157 'class_name' => 'Orders',
158 'is_pro' => false,
159 'path_key' => 'my-account/orders',
160 ),
161 'login-form' => array(
162 'editor_type' => 'login_register_form',
163 'class_name' => 'MyAccountLogin',
164 'is_pro' => false,
165 'path_key' => 'my-account/login',
166 ),
167 'user-notifications' => array(
168 'editor_type' => 'notifications',
169 'class_name' => 'UserNotifications',
170 'is_pro' => false,
171 'path_key' => 'my-account/notifications',
172 ),
173 'categories-grid' => array(
174 'editor_type' => 'general',
175 'class_name' => 'CategoriesGrid',
176 'is_pro' => false,
177 'path_key' => 'general/categories-grid',
178 ),
179 'orders-tracking' => array(
180 'editor_type' => 'general',
181 'class_name' => 'OrdersTracking',
182 'is_pro' => false,
183 'path_key' => 'general/orders-tracking',
184 ),
185 'shop-products' => array(
186 'editor_type' => 'shop',
187 'class_name' => 'ShopProducts',
188 'is_pro' => false,
189 'path_key' => 'products/shop-products',
190 ),
191 'filters' => array(
192 'editor_type' => 'shop',
193 'class_name' => 'Filters',
194 'is_pro' => false,
195 'path_key' => 'shop/filters',
196 ),
197 'result-count' => array(
198 'editor_type' => 'shop',
199 'class_name' => 'ResultCount',
200 'is_pro' => false,
201 'path_key' => 'shop/result-count',
202 ),
203 'catalog-ordering' => array(
204 'editor_type' => 'shop',
205 'class_name' => 'CatalogOrdering',
206 'is_pro' => false,
207 'path_key' => 'shop/catalog-ordering',
208 ),
209 'archive-title' => array(
210 'editor_type' => 'archive',
211 'class_name' => 'ArchiveTitle',
212 'is_pro' => false,
213 'path_key' => 'general/archive-title',
214 ),
215 'ajax-search' => array(
216 'editor_type' => 'general',
217 'class_name' => 'AjaxSearch',
218 'is_pro' => false,
219 'path_key' => 'general/ajax-search',
220 ),
221 'single-title' => array(
222 'editor_type' => 'single',
223 'class_name' => 'Title',
224 'is_pro' => false,
225 'path_key' => 'single-product/title',
226 ),
227 'single-price' => array(
228 'editor_type' => 'single',
229 'class_name' => 'Price',
230 'is_pro' => false,
231 'path_key' => 'single-product/price',
232 ),
233 'single-image' => array(
234 'editor_type' => 'single',
235 'class_name' => 'Image',
236 'is_pro' => false,
237 'path_key' => 'single-product/image',
238 ),
239 'single-add-to-cart' => array(
240 'editor_type' => 'single',
241 'class_name' => 'AddToCart',
242 'is_pro' => false,
243 'path_key' => 'single-product/add-to-cart',
244 ),
245 'single-description' => array(
246 'editor_type' => 'single',
247 'class_name' => 'Description',
248 'is_pro' => false,
249 'path_key' => 'single-product/description',
250 ),
251 'single-content' => array(
252 'editor_type' => 'single',
253 'class_name' => 'Content',
254 'is_pro' => false,
255 'path_key' => 'single-product/content',
256 ),
257 'single-rating' => array(
258 'editor_type' => 'single',
259 'class_name' => 'Rating',
260 'is_pro' => false,
261 'path_key' => 'single-product/rating',
262 ),
263 'single-review' => array(
264 'editor_type' => 'single',
265 'class_name' => 'Review',
266 'is_pro' => false,
267 'path_key' => 'single-product/review',
268 ),
269 'single-tags' => array(
270 'editor_type' => 'single',
271 'class_name' => 'Tags',
272 'is_pro' => false,
273 'path_key' => 'single-product/tags',
274 ),
275 'single-categories' => array(
276 'editor_type' => 'single',
277 'class_name' => 'Categories',
278 'is_pro' => false,
279 'path_key' => 'single-product/categories',
280 ),
281 'single-sku' => array(
282 'editor_type' => 'single',
283 'class_name' => 'SKU',
284 'is_pro' => false,
285 'path_key' => 'single-product/sku',
286 ),
287 'single-stock' => array(
288 'editor_type' => 'single',
289 'class_name' => 'Stock',
290 'is_pro' => false,
291 'path_key' => 'single-product/stock',
292 ),
293 'single-stock-progress-bar' => array(
294 'editor_type' => 'single',
295 'class_name' => 'StockProgressBar',
296 'is_pro' => false,
297 'path_key' => 'single-product/stock-progress-bar',
298 ),
299 'single-breadcrumb' => array(
300 'editor_type' => 'single',
301 'class_name' => 'Breadcrumb',
302 'is_pro' => false,
303 'path_key' => 'single-product/breadcrumb',
304 ),
305 'single-navigation' => array(
306 'editor_type' => 'single',
307 'class_name' => 'Navigation',
308 'is_pro' => false,
309 'path_key' => 'single-product/navigation',
310 ),
311 'single-attributes' => array(
312 'editor_type' => 'single',
313 'class_name' => 'Attributes',
314 'is_pro' => false,
315 'path_key' => 'single-product/attributes',
316 ),
317 'single-tabs' => array(
318 'editor_type' => 'single',
319 'class_name' => 'Tabs',
320 'is_pro' => false,
321 'path_key' => 'single-product/tabs',
322 ),
323 'single-weight' => array(
324 'editor_type' => 'single',
325 'class_name' => 'Weight',
326 'is_pro' => false,
327 'path_key' => 'single-product/weight',
328 ),
329 'single-call-for-price' => array(
330 'editor_type' => 'single',
331 'class_name' => 'CallForPrice',
332 'is_pro' => false,
333 'path_key' => 'single-product/call-for-price',
334 ),
335 'single-suggest-price' => array(
336 'editor_type' => 'single',
337 'class_name' => 'SuggestPrice',
338 'is_pro' => false,
339 'path_key' => 'single-product/suggest-price',
340 ),
341 'single-sale-badge' => array(
342 'editor_type' => 'single',
343 'class_name' => 'OnSale',
344 'is_pro' => false,
345 'path_key' => 'single-product/sale-badge',
346 ),
347 'single-sharing' => array(
348 'editor_type' => 'single',
349 'class_name' => 'Sharing',
350 'is_pro' => false,
351 'path_key' => 'single-product/sharing',
352 ),
353 'single-related-products' => array(
354 'editor_type' => 'single',
355 'class_name' => 'RelatedProducts',
356 'is_pro' => false,
357 'path_key' => 'products/related-products',
358 ),
359 'up-sell-products' => array(
360 'editor_type' => 'single',
361 'class_name' => 'ProductsLoop\UpSellProducts',
362 'is_pro' => false,
363 'path_key' => 'products/up-sell-products',
364 ),
365 'single-discount' => array(
366 'editor_type' => 'single',
367 'class_name' => 'Discount',
368 'is_pro' => false,
369 'path_key' => 'single-product/discount',
370 ),
371 'single-meta' => array(
372 'editor_type' => 'single',
373 'class_name' => 'Meta',
374 'is_pro' => false,
375 'path_key' => 'single-product/meta',
376 ),
377 'loop-title' => array(
378 'editor_type' => 'loop',
379 'class_name' => 'LoopBuilder\Title',
380 'is_pro' => false,
381 'path_key' => 'loop/title',
382 ),
383 'loop-price' => array(
384 'editor_type' => 'loop',
385 'class_name' => 'LoopBuilder\Price',
386 'is_pro' => false,
387 'path_key' => 'loop/price',
388 ),
389 'loop-thumbnail' => array(
390 'editor_type' => 'loop',
391 'class_name' => 'LoopBuilder\Thumbnail',
392 'is_pro' => false,
393 'path_key' => 'loop/thumbnail',
394 ),
395 'loop-add-to-cart' => array(
396 'editor_type' => 'loop',
397 'class_name' => 'LoopBuilder\AddToCart',
398 'is_pro' => false,
399 'path_key' => 'loop/add-to-cart',
400 ),
401 'loop-description' => array(
402 'editor_type' => 'loop',
403 'class_name' => 'LoopBuilder\Description',
404 'is_pro' => false,
405 'path_key' => 'loop/description',
406 ),
407 'loop-rating' => array(
408 'editor_type' => 'loop',
409 'class_name' => 'LoopBuilder\Rating',
410 'is_pro' => false,
411 'path_key' => 'loop/rating',
412 ),
413 'loop-review' => array(
414 'editor_type' => 'loop',
415 'class_name' => 'LoopBuilder\Review',
416 'is_pro' => false,
417 'path_key' => 'loop/review',
418 ),
419 'loop-tags' => array(
420 'editor_type' => 'loop',
421 'class_name' => 'LoopBuilder\Tags',
422 'is_pro' => false,
423 'path_key' => 'loop/tags',
424 ),
425 'loop-categories' => array(
426 'editor_type' => 'loop',
427 'class_name' => 'LoopBuilder\Categories',
428 'is_pro' => false,
429 'path_key' => 'loop/categories',
430 ),
431 'loop-sku' => array(
432 'editor_type' => 'loop',
433 'class_name' => 'LoopBuilder\SKU',
434 'is_pro' => false,
435 'path_key' => 'loop/sku',
436 ),
437 'loop-stock' => array(
438 'editor_type' => 'loop',
439 'class_name' => 'LoopBuilder\Stock',
440 'is_pro' => false,
441 'path_key' => 'loop/stock',
442 ),
443 'loop-sale-flash' => array(
444 'editor_type' => 'loop',
445 'class_name' => 'LoopBuilder\OnSale',
446 'is_pro' => false,
447 'path_key' => 'loop/sale-flash',
448 ),
449 'loop-discount' => array(
450 'editor_type' => 'loop',
451 'class_name' => 'LoopBuilder\Discount',
452 'is_pro' => false,
453 'path_key' => 'loop/discount',
454 ),
455 'recently-viewed-products' => array(
456 'editor_type' => 'general',
457 'class_name' => 'RecentlyViewedProducts',
458 'is_pro' => false,
459 'path_key' => 'general/recently-viewed-products',
460 ),
461 'order-details' => array(
462 'editor_type' => 'thank_you',
463 'class_name' => 'ThankyouOrderDetails',
464 'is_pro' => false,
465 'path_key' => 'thankyou/order-details',
466 ),
467 'order-details-customer' => array(
468 'editor_type' => 'thank_you',
469 'class_name' => 'ThankyouOrderCustomerDetails',
470 'is_pro' => false,
471 'path_key' => 'thankyou/order-details-customer',
472 ),
473 'thankyou-order-review' => array(
474 'editor_type' => 'thank_you',
475 'class_name' => 'ThankyouOrderReview',
476 'is_pro' => false,
477 'path_key' => 'thankyou/order-review',
478 ),
479 'header-toggle' => array(
480 'editor_type' => 'general',
481 'class_name' => 'HeaderToggle',
482 'is_pro' => false,
483 'path_key' => 'general/header-toggle',
484 ),
485 'mini-cart' => array(
486 'editor_type' => 'general',
487 'class_name' => 'MiniCart',
488 'is_pro' => false,
489 'path_key' => 'general/mini-cart',
490 ),
491 'single-qr' => array(
492 'editor_type' => 'single',
493 'class_name' => 'QR',
494 'is_pro' => false,
495 'path_key' => 'single-product/qr',
496 ),
497 );
498
499 return apply_filters( 'shoppress/elementor/widgets', $widgets );
500 }
501
502 /**
503 * Register Widgets
504 *
505 * @since 1.2.0
506 *
507 * @param Widgets_Manager $widgets_manager Elementor widgets manager.
508 */
509 public static function register_widgets( $widgets_manager ) {
510 $widgets_list = self::get_widgets_list();
511
512 foreach ( $widgets_list as $key => $widget ) {
513
514 if ( EditorCondition::is_editor_page( $widget['editor_type'] ) ) {
515
516 $widget_path = ( true === $widget['is_pro'] && defined( 'SHOPPRESS_PRO_PATH' ) ) ? SHOPPRESS_PRO_PATH : SHOPPRESS_PATH;
517 $custom_path = $widget['custom_path'] ?? false;
518 $widget_file = $custom_path ? $custom_path : $widget_path . 'Elementor/widgets/' . $widget['path_key'] . '/config.php';
519 if ( file_exists( $widget_file ) ) {
520 require_once $widget_file;
521 }
522
523 $namespace = $widget['is_pro'] === true ? 'ShopPressPro' : 'ShopPress';
524 $class_name = $namespace . '\\Elementor\\Widgets\\' . $widget['class_name'];
525 if ( class_exists( $class_name ) ) {
526 $widgets_manager->register( new $class_name() );
527 }
528 }
529 }
530 }
531 }
532