PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.2
Elementor Website Builder – more than just a page builder v3.17.2
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | includes/managers/widgets.php +28 -133 4.0.73.17.2 View file →
@@ -2,17 +2,11 @@
2 2 namespace Elementor;
3 3
4 4 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
5 5 use Elementor\Core\Utils\Collection;
6 +use Elementor\Core\Utils\Exceptions;
6 7 use Elementor\Core\Utils\Force_Locale;
7 -use Elementor\Modules\AtomicWidgets\Elements\Atomic_Button\Atomic_Button;
8 -use Elementor\Modules\AtomicWidgets\Elements\Atomic_Divider\Atomic_Divider;
9 -use Elementor\Modules\AtomicWidgets\Elements\Atomic_Heading\Atomic_Heading;
10 -use Elementor\Modules\AtomicWidgets\Elements\Atomic_Image\Atomic_Image;
11 -use Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph\Atomic_Paragraph;
12 -use Elementor\Modules\AtomicWidgets\Elements\Atomic_Svg\Atomic_Svg;
13 8 use Elementor\Modules\NestedAccordion\Widgets\Nested_Accordion;
14 -use Elementor\Modules\NestedElements\Module as NestedElementsModule;
15 9 use Elementor\Modules\NestedTabs\Widgets\NestedTabs;
16 10
17 11 if ( ! defined( 'ABSPATH' ) ) {
18 12 exit; // Exit if accessed directly.
@@ -48,40 +42,26 @@
48 42 * @since 3.15.0
49 43 * @access private
50 44 *
51 45 * @var Widget_Base[]
52 - *
53 - * @return array
54 46 */
55 - private array $promoted_widgets = [
56 - NestedElementsModule::EXPERIMENT_NAME => [
57 - NestedTabs::class,
58 - Nested_Accordion::class,
59 - ],
60 - 'atomic_widgets' => [
61 - Atomic_Heading::class,
62 - Atomic_Image::class,
63 - Atomic_Paragraph::class,
64 - Atomic_Button::class,
65 - Atomic_Svg::class,
66 - Atomic_Divider::class,
67 - ],
47 + private $_promoted_widgets = [
48 + 'nested-elements' => NestedTabs::class,
49 + 'nested-accordion' => Nested_Accordion::class,
68 50 ];
69 51
70 52 /**
71 53 * Init widgets.
72 54 *
73 - * Initialize Elementor widgets manager. Include all the widgets files
55 + * Initialize Elementor widgets manager. Include all the the widgets files
74 56 * and register each Elementor and WordPress widget.
75 57 *
76 58 * @since 2.0.0
77 59 * @access private
78 - */
60 + */
79 61 private function init_widgets() {
80 62 $build_widgets_filename = [
81 - 'common-base',
82 63 'common',
83 - 'common-optimized',
84 64 'inner-section',
85 65 'heading',
86 66 'image',
87 67 'text-editor',
@@ -115,10 +95,8 @@
115 95 ];
116 96
117 97 $this->_widget_types = [];
118 98
119 - $this->register_promoted_widgets();
120 -
121 99 foreach ( $build_widgets_filename as $widget_filename ) {
122 100 include ELEMENTOR_PATH . 'includes/widgets/' . $widget_filename . '.php';
123 101
124 102 $class_name = str_replace( '-', '_', $widget_filename );
@@ -127,8 +105,10 @@
127 105
128 106 $this->register( new $class_name() );
129 107 }
130 108
109 + $this->register_promoted_widgets();
110 +
131 111 $this->register_wp_widgets();
132 112
133 113 /**
134 114 * After widgets registered.
@@ -168,9 +148,9 @@
168 148 * plugin authors can filter the black list.
169 149 *
170 150 * @since 2.0.0
171 151 * @access private
172 - */
152 + */
173 153 private function register_wp_widgets() {
174 154 global $wp_widget_factory;
175 155
176 156 // Allow themes/plugins to filter out their widgets.
@@ -209,9 +189,9 @@
209 189 * Require Elementor widget base class.
210 190 *
211 191 * @since 2.0.0
212 192 * @access private
213 - */
193 + */
214 194 private function require_files() {
215 195 require ELEMENTOR_PATH . 'includes/base/widget-base.php';
216 196 }
217 197
@@ -237,9 +217,9 @@
237 217 *
238 218 * @param Widget_Base $widget Elementor widget.
239 219 *
240 220 * @return true True if the widget was registered.
241 - */
221 + */
242 222 public function register_widget_type( Widget_Base $widget ) {
243 223 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
244 224 __METHOD__,
245 225 '3.5.0',
@@ -253,11 +233,12 @@
253 233 * Register a new widget type.
254 234 *
255 235 * @param \Elementor\Widget_Base $widget_instance Elementor Widget.
256 236 *
257 - * @return bool True if the widget was registered.
237 + * @return true True if the widget was registered.
258 238 * @since 3.5.0
259 239 * @access public
240 + *
260 241 */
261 242 public function register( Widget_Base $widget_instance ) {
262 243 if ( is_null( $this->_widget_types ) ) {
263 244 $this->init_widgets();
@@ -262,22 +243,8 @@
262 243 if ( is_null( $this->_widget_types ) ) {
263 244 $this->init_widgets();
264 245 }
265 246
266 - /**
267 - * Should widget be registered.
268 - *
269 - * @since 3.18.0
270 - *
271 - * @param bool $should_register Should widget be registered. Default is `true`.
272 - * @param \Elementor\Widget_Base $widget_instance Widget instance.
273 - */
274 - $should_register = apply_filters( 'elementor/widgets/is_widget_enabled', true, $widget_instance );
275 -
276 - if ( ! $should_register ) {
277 - return false;
278 - }
279 -
280 247 $this->_widget_types[ $widget_instance->get_name() ] = $widget_instance;
281 248
282 249 return true;
283 250 }
@@ -290,10 +257,14 @@
290 257 * @return void
291 258 */
292 259 private function register_promoted_widgets() {
293 260
294 - foreach ( $this->promoted_widgets as $experiment_name => $classes ) {
295 - $this->register_promoted_active_widgets( $experiment_name, $classes );
261 + foreach ( $this->_promoted_widgets as $module_name => $class_name ) {
262 +
263 + if ( Plugin::$instance->experiments->is_feature_active( $module_name ) ) {
264 + $instance = new $class_name();
265 + $this->_widget_types[ $instance->get_name() ] = $instance;
266 + }
296 267 }
297 268 }
298 269
299 270 /**
@@ -307,9 +278,9 @@
307 278 *
308 279 * @param string $name Widget name.
309 280 *
310 281 * @return true True if the widget was unregistered, False otherwise.
311 - */
282 + */
312 283 public function unregister_widget_type( $name ) {
313 284 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
314 285 __METHOD__,
315 286 '3.5.0',
@@ -351,9 +322,9 @@
351 322 *
352 323 * @param string $widget_name Optional. Widget name. Default is null.
353 324 *
354 325 * @return Widget_Base|Widget_Base[]|null Registered widget types.
355 - */
326 + */
356 327 public function get_widget_types( $widget_name = null ) {
357 328 if ( is_null( $this->_widget_types ) ) {
358 329 $this->init_widgets();
359 330 }
@@ -373,9 +344,9 @@
373 344 * @since 1.0.0
374 345 * @access public
375 346 *
376 347 * @return array Registered widget types with each widget config.
377 - */
348 + */
378 349 public function get_widget_types_config() {
379 350 $config = [];
380 351
381 352 foreach ( $this->get_widget_types() as $widget_key => $widget ) {
@@ -385,9 +356,9 @@
385 356 return $config;
386 357 }
387 358
388 359 /**
389 - * @throws \Exception If current user don't have permissions to edit the post.
360 + * @throws \Exception
390 361 */
391 362 public function ajax_get_widget_types_controls_config( array $data ) {
392 363 Plugin::$instance->documents->check_permissions( $data['editor_post_id'] );
393 364
@@ -493,9 +464,9 @@
493 464 *
494 465 * @param array $request Ajax request.
495 466 *
496 467 * @return bool|string Rendered widget form.
497 - * @throws \Exception If current user don't have permissions to edit the post.
468 + * @throws \Exception
498 469 */
499 470 public function ajax_get_wp_widget_form( $request ) {
500 471 Plugin::$instance->documents->check_permissions( $request['editor_post_id'] );
501 472
@@ -533,9 +504,9 @@
533 504 * template, for all the registered widget types.
534 505 *
535 506 * @since 1.0.0
536 507 * @access public
537 - */
508 + */
538 509 public function render_widgets_content() {
539 510 foreach ( $this->get_widget_types() as $widget ) {
540 511 $widget->print_template();
541 512 }
@@ -550,9 +521,9 @@
550 521 * @since 1.3.0
551 522 * @access public
552 523 *
553 524 * @return array Registered widget types with settings keys for each widget.
554 - */
525 + */
555 526 public function get_widgets_frontend_settings_keys() {
556 527 $keys = [];
557 528
558 529 foreach ( $this->get_widget_types() as $widget_type_name => $widget_type ) {
@@ -566,63 +537,8 @@
566 537 return $keys;
567 538 }
568 539
569 540 /**
570 - * Widgets with styles.
571 - *
572 - * This method returns the list of all the widgets in the `/includes/`
573 - * folder that have styles.
574 - *
575 - * @since 3.24.0
576 - * @access public
577 - *
578 - * @return array The names of the widgets that have styles.
579 - */
580 - public function widgets_with_styles(): array {
581 - return [
582 - 'counter',
583 - 'divider',
584 - 'google_maps',
585 - 'heading',
586 - 'image',
587 - 'image-carousel',
588 - 'menu-anchor',
589 - 'rating',
590 - 'social-icons',
591 - 'spacer',
592 - 'testimonial',
593 - 'text-editor',
594 - 'video',
595 - ];
596 - }
597 -
598 - /**
599 - * Widgets with responsive styles.
600 - *
601 - * This method returns the list of all the widgets in the `/includes/`
602 - * folder that have responsive styles.
603 - *
604 - * @since 3.24.0
605 - * @access public
606 - *
607 - * @return array The names of the widgets that have responsive styles.
608 - */
609 - public function widgets_with_responsive_styles(): array {
610 - return [
611 - 'accordion',
612 - 'alert',
613 - 'icon-box',
614 - 'icon-list',
615 - 'image-box',
616 - 'image-gallery',
617 - 'progress',
618 - 'star-rating',
619 - 'tabs',
620 - 'toggle',
621 - ];
622 - }
623 -
624 - /**
625 541 * Enqueue widgets scripts.
626 542 *
627 543 * Enqueue all the scripts defined as a dependency for each widget.
628 544 *
@@ -627,9 +543,9 @@
627 543 * Enqueue all the scripts defined as a dependency for each widget.
628 544 *
629 545 * @since 1.3.0
630 546 * @access public
631 - */
547 + */
632 548 public function enqueue_widgets_scripts() {
633 549 foreach ( $this->get_widget_types() as $widget ) {
634 550 $widget->enqueue_scripts();
635 551 }
@@ -634,14 +550,8 @@
634 550 $widget->enqueue_scripts();
635 551 }
636 552 }
637 553
638 - public function register_frontend_handlers() {
639 - foreach ( $this->get_widget_types() as $widget ) {
640 - $widget->register_frontend_handlers();
641 - }
642 - }
643 -
644 554 /**
645 555 * Enqueue widgets styles
646 556 *
647 557 * Enqueue all the styles defined as a dependency for each widget
@@ -716,9 +626,9 @@
716 626 * Initializing Elementor widgets manager.
717 627 *
718 628 * @since 1.0.0
719 629 * @access public
720 - */
630 + */
721 631 public function __construct() {
722 632 $this->require_files();
723 633
724 634 add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
@@ -741,21 +651,6 @@
741 651
742 652 $ajax_manager->register_ajax_action( 'get_widgets_default_value_translations', function ( array $data ) {
743 653 return $this->ajax_get_widgets_default_value_translations( $data );
744 654 } );
745 - }
746 -
747 - /**
748 - * @param string $experiment_name
749 - * @param array $classes
750 - * @return void
751 - */
752 - public function register_promoted_active_widgets( string $experiment_name, array $classes ): void {
753 - if ( ! Plugin::$instance->experiments->is_feature_active( $experiment_name ) || empty( $classes ) ) {
754 - return;
755 - }
756 -
757 - foreach ( $classes as $class_name ) {
758 - $this->register( new $class_name() );
759 - }
760 655 }
761 656 }