PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.0-dev3
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 +20 -123 4.3.0-beta23.23.0-dev3 View file →
@@ -2,16 +2,12 @@
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;
9 +use Elementor\Modules\NestedElements\Module as NestedElementsModule;
14 10 use Elementor\Modules\NestedTabs\Widgets\NestedTabs;
15 11
16 12 if ( ! defined( 'ABSPATH' ) ) {
17 13 exit; // Exit if accessed directly.
@@ -51,20 +47,12 @@
51 47 *
52 48 * @return array
53 49 */
54 50 private array $promoted_widgets = [
55 - 'container' => [
51 + NestedElementsModule::EXPERIMENT_NAME => [
56 52 NestedTabs::class,
57 53 Nested_Accordion::class,
58 54 ],
59 - 'atomic_widgets' => [
60 - Atomic_Heading::class,
61 - Atomic_Image::class,
62 - Atomic_Paragraph::class,
63 - Atomic_Button::class,
64 - Atomic_Svg::class,
65 - Atomic_Divider::class,
66 - ],
67 55 ];
68 56
69 57 /**
70 58 * Init widgets.
@@ -73,14 +61,12 @@
73 61 * and register each Elementor and WordPress widget.
74 62 *
75 63 * @since 2.0.0
76 64 * @access private
77 - */
65 + */
78 66 private function init_widgets() {
79 67 $build_widgets_filename = [
80 - 'common-base',
81 68 'common',
82 - 'common-optimized',
83 69 'inner-section',
84 70 'heading',
85 71 'image',
86 72 'text-editor',
@@ -110,8 +96,9 @@
110 96 'menu-anchor',
111 97 'sidebar',
112 98 'read-more',
113 99 'rating',
100 + 'share-buttons',
114 101 ];
115 102
116 103 $this->_widget_types = [];
117 104
@@ -167,9 +154,9 @@
167 154 * plugin authors can filter the black list.
168 155 *
169 156 * @since 2.0.0
170 157 * @access private
171 - */
158 + */
172 159 private function register_wp_widgets() {
173 160 global $wp_widget_factory;
174 161
175 162 // Allow themes/plugins to filter out their widgets.
@@ -208,9 +195,9 @@
208 195 * Require Elementor widget base class.
209 196 *
210 197 * @since 2.0.0
211 198 * @access private
212 - */
199 + */
213 200 private function require_files() {
214 201 require ELEMENTOR_PATH . 'includes/base/widget-base.php';
215 202 }
216 203
@@ -236,9 +223,9 @@
236 223 *
237 224 * @param Widget_Base $widget Elementor widget.
238 225 *
239 226 * @return true True if the widget was registered.
240 - */
227 + */
241 228 public function register_widget_type( Widget_Base $widget ) {
242 229 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
243 230 __METHOD__,
244 231 '3.5.0',
@@ -306,9 +293,9 @@
306 293 *
307 294 * @param string $name Widget name.
308 295 *
309 296 * @return true True if the widget was unregistered, False otherwise.
310 - */
297 + */
311 298 public function unregister_widget_type( $name ) {
312 299 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
313 300 __METHOD__,
314 301 '3.5.0',
@@ -350,9 +337,9 @@
350 337 *
351 338 * @param string $widget_name Optional. Widget name. Default is null.
352 339 *
353 340 * @return Widget_Base|Widget_Base[]|null Registered widget types.
354 - */
341 + */
355 342 public function get_widget_types( $widget_name = null ) {
356 343 if ( is_null( $this->_widget_types ) ) {
357 344 $this->init_widgets();
358 345 }
@@ -372,9 +359,9 @@
372 359 * @since 1.0.0
373 360 * @access public
374 361 *
375 362 * @return array Registered widget types with each widget config.
376 - */
363 + */
377 364 public function get_widget_types_config() {
378 365 $config = [];
379 366
380 367 foreach ( $this->get_widget_types() as $widget_key => $widget ) {
@@ -384,9 +371,9 @@
384 371 return $config;
385 372 }
386 373
387 374 /**
388 - * @throws \Exception If current user don't have permissions to edit the post.
375 + * @throws \Exception
389 376 */
390 377 public function ajax_get_widget_types_controls_config( array $data ) {
391 378 Plugin::$instance->documents->check_permissions( $data['editor_post_id'] );
392 379
@@ -407,35 +394,8 @@
407 394
408 395 return $config;
409 396 }
410 397
411 - /**
412 - * @throws \Exception If current user don't have permissions to edit the post.
413 - */
414 - public function ajax_refresh_widgets_config( array $data ) {
415 - Plugin::$instance->documents->check_permissions( $data['editor_post_id'] );
416 -
417 - wp_raise_memory_limit( 'admin' );
418 -
419 - $widgets = [];
420 -
421 - foreach ( $this->get_widget_types() as $widget_key => $widget ) {
422 - $widget_config = $widget->get_config();
423 -
424 - // get_config() omits controls when the stack isn't initialized yet (see Widget_Base::get_initial_config).
425 - // During an AJAX refresh the instances are fresh, so we force-initialize and merge them explicitly.
426 - $widget_config['controls'] = $widget->get_stack( false )['controls'];
427 - $widget_config['tabs_controls'] = $widget->get_tabs_controls();
428 -
429 - $widgets[ $widget_key ] = $widget_config;
430 - }
431 -
432 - return [
433 - 'widgets' => $widgets,
434 - 'categories' => Plugin::$instance->elements_manager->get_categories(),
435 - ];
436 - }
437 -
438 398 public function ajax_get_widgets_default_value_translations( array $data = [] ) {
439 399 $locale = empty( $data['locale'] )
440 400 ? get_locale()
441 401 : $data['locale'];
@@ -519,9 +479,9 @@
519 479 *
520 480 * @param array $request Ajax request.
521 481 *
522 482 * @return bool|string Rendered widget form.
523 - * @throws \Exception If current user don't have permissions to edit the post.
483 + * @throws \Exception
524 484 */
525 485 public function ajax_get_wp_widget_form( $request ) {
526 486 Plugin::$instance->documents->check_permissions( $request['editor_post_id'] );
527 487
@@ -559,9 +519,9 @@
559 519 * template, for all the registered widget types.
560 520 *
561 521 * @since 1.0.0
562 522 * @access public
563 - */
523 + */
564 524 public function render_widgets_content() {
565 525 foreach ( $this->get_widget_types() as $widget ) {
566 526 $widget->print_template();
567 527 }
@@ -576,9 +536,9 @@
576 536 * @since 1.3.0
577 537 * @access public
578 538 *
579 539 * @return array Registered widget types with settings keys for each widget.
580 - */
540 + */
581 541 public function get_widgets_frontend_settings_keys() {
582 542 $keys = [];
583 543
584 544 foreach ( $this->get_widget_types() as $widget_type_name => $widget_type ) {
@@ -592,63 +552,8 @@
592 552 return $keys;
593 553 }
594 554
595 555 /**
596 - * Widgets with styles.
597 - *
598 - * This method returns the list of all the widgets in the `/includes/`
599 - * folder that have styles.
600 - *
601 - * @since 3.24.0
602 - * @access public
603 - *
604 - * @return array The names of the widgets that have styles.
605 - */
606 - public function widgets_with_styles(): array {
607 - return [
608 - 'counter',
609 - 'divider',
610 - 'google_maps',
611 - 'heading',
612 - 'image',
613 - 'image-carousel',
614 - 'menu-anchor',
615 - 'rating',
616 - 'social-icons',
617 - 'spacer',
618 - 'testimonial',
619 - 'text-editor',
620 - 'video',
621 - ];
622 - }
623 -
624 - /**
625 - * Widgets with responsive styles.
626 - *
627 - * This method returns the list of all the widgets in the `/includes/`
628 - * folder that have responsive styles.
629 - *
630 - * @since 3.24.0
631 - * @access public
632 - *
633 - * @return array The names of the widgets that have responsive styles.
634 - */
635 - public function widgets_with_responsive_styles(): array {
636 - return [
637 - 'accordion',
638 - 'alert',
639 - 'icon-box',
640 - 'icon-list',
641 - 'image-box',
642 - 'image-gallery',
643 - 'progress',
644 - 'star-rating',
645 - 'tabs',
646 - 'toggle',
647 - ];
648 - }
649 -
650 - /**
651 556 * Enqueue widgets scripts.
652 557 *
653 558 * Enqueue all the scripts defined as a dependency for each widget.
654 559 *
@@ -653,9 +558,9 @@
653 558 * Enqueue all the scripts defined as a dependency for each widget.
654 559 *
655 560 * @since 1.3.0
656 561 * @access public
657 - */
562 + */
658 563 public function enqueue_widgets_scripts() {
659 564 foreach ( $this->get_widget_types() as $widget ) {
660 565 $widget->enqueue_scripts();
661 566 }
@@ -660,14 +565,8 @@
660 565 $widget->enqueue_scripts();
661 566 }
662 567 }
663 568
664 - public function register_frontend_handlers() {
665 - foreach ( $this->get_widget_types() as $widget ) {
666 - $widget->register_frontend_handlers();
667 - }
668 - }
669 -
670 569 /**
671 570 * Enqueue widgets styles
672 571 *
673 572 * Enqueue all the styles defined as a dependency for each widget
@@ -742,9 +641,9 @@
742 641 * Initializing Elementor widgets manager.
743 642 *
744 643 * @since 1.0.0
745 644 * @access public
746 - */
645 + */
747 646 public function __construct() {
748 647 $this->require_files();
749 648
750 649 add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
@@ -764,10 +663,8 @@
764 663 $ajax_manager->register_ajax_action( 'render_widget', [ $this, 'ajax_render_widget' ] );
765 664 $ajax_manager->register_ajax_action( 'editor_get_wp_widget_form', [ $this, 'ajax_get_wp_widget_form' ] );
766 665 $ajax_manager->register_ajax_action( 'get_widgets_config', [ $this, 'ajax_get_widget_types_controls_config' ] );
767 666
768 - $ajax_manager->register_ajax_action( 'refresh_widgets_config', [ $this, 'ajax_refresh_widgets_config' ] );
769 -
770 667 $ajax_manager->register_ajax_action( 'get_widgets_default_value_translations', function ( array $data ) {
771 668 return $this->ajax_get_widgets_default_value_translations( $data );
772 669 } );
773 670 }
@@ -772,13 +669,13 @@
772 669 } );
773 670 }
774 671
775 672 /**
776 - * @param string $experiment_name
777 - * @param array $classes
673 + * @param $experiment_name
674 + * @param $classes
778 675 * @return void
779 676 */
780 - public function register_promoted_active_widgets( string $experiment_name, array $classes ): void {
677 + public function register_promoted_active_widgets( string $experiment_name, array $classes ) : void {
781 678 if ( ! Plugin::$instance->experiments->is_feature_active( $experiment_name ) || empty( $classes ) ) {
782 679 return;
783 680 }
784 681