PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev5
Elementor Website Builder – more than just a page builder v3.26.0-dev5
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 +19 -66 4.3.0-beta23.26.0-dev5 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,9 +61,9 @@
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 68 'common-base',
81 69 'common',
@@ -167,9 +155,9 @@
167 155 * plugin authors can filter the black list.
168 156 *
169 157 * @since 2.0.0
170 158 * @access private
171 - */
159 + */
172 160 private function register_wp_widgets() {
173 161 global $wp_widget_factory;
174 162
175 163 // Allow themes/plugins to filter out their widgets.
@@ -208,9 +196,9 @@
208 196 * Require Elementor widget base class.
209 197 *
210 198 * @since 2.0.0
211 199 * @access private
212 - */
200 + */
213 201 private function require_files() {
214 202 require ELEMENTOR_PATH . 'includes/base/widget-base.php';
215 203 }
216 204
@@ -236,9 +224,9 @@
236 224 *
237 225 * @param Widget_Base $widget Elementor widget.
238 226 *
239 227 * @return true True if the widget was registered.
240 - */
228 + */
241 229 public function register_widget_type( Widget_Base $widget ) {
242 230 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
243 231 __METHOD__,
244 232 '3.5.0',
@@ -306,9 +294,9 @@
306 294 *
307 295 * @param string $name Widget name.
308 296 *
309 297 * @return true True if the widget was unregistered, False otherwise.
310 - */
298 + */
311 299 public function unregister_widget_type( $name ) {
312 300 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
313 301 __METHOD__,
314 302 '3.5.0',
@@ -350,9 +338,9 @@
350 338 *
351 339 * @param string $widget_name Optional. Widget name. Default is null.
352 340 *
353 341 * @return Widget_Base|Widget_Base[]|null Registered widget types.
354 - */
342 + */
355 343 public function get_widget_types( $widget_name = null ) {
356 344 if ( is_null( $this->_widget_types ) ) {
357 345 $this->init_widgets();
358 346 }
@@ -372,9 +360,9 @@
372 360 * @since 1.0.0
373 361 * @access public
374 362 *
375 363 * @return array Registered widget types with each widget config.
376 - */
364 + */
377 365 public function get_widget_types_config() {
378 366 $config = [];
379 367
380 368 foreach ( $this->get_widget_types() as $widget_key => $widget ) {
@@ -384,9 +372,9 @@
384 372 return $config;
385 373 }
386 374
387 375 /**
388 - * @throws \Exception If current user don't have permissions to edit the post.
376 + * @throws \Exception
389 377 */
390 378 public function ajax_get_widget_types_controls_config( array $data ) {
391 379 Plugin::$instance->documents->check_permissions( $data['editor_post_id'] );
392 380
@@ -407,35 +395,8 @@
407 395
408 396 return $config;
409 397 }
410 398
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 399 public function ajax_get_widgets_default_value_translations( array $data = [] ) {
439 400 $locale = empty( $data['locale'] )
440 401 ? get_locale()
441 402 : $data['locale'];
@@ -519,9 +480,9 @@
519 480 *
520 481 * @param array $request Ajax request.
521 482 *
522 483 * @return bool|string Rendered widget form.
523 - * @throws \Exception If current user don't have permissions to edit the post.
484 + * @throws \Exception
524 485 */
525 486 public function ajax_get_wp_widget_form( $request ) {
526 487 Plugin::$instance->documents->check_permissions( $request['editor_post_id'] );
527 488
@@ -559,9 +520,9 @@
559 520 * template, for all the registered widget types.
560 521 *
561 522 * @since 1.0.0
562 523 * @access public
563 - */
524 + */
564 525 public function render_widgets_content() {
565 526 foreach ( $this->get_widget_types() as $widget ) {
566 527 $widget->print_template();
567 528 }
@@ -576,9 +537,9 @@
576 537 * @since 1.3.0
577 538 * @access public
578 539 *
579 540 * @return array Registered widget types with settings keys for each widget.
580 - */
541 + */
581 542 public function get_widgets_frontend_settings_keys() {
582 543 $keys = [];
583 544
584 545 foreach ( $this->get_widget_types() as $widget_type_name => $widget_type ) {
@@ -653,9 +614,9 @@
653 614 * Enqueue all the scripts defined as a dependency for each widget.
654 615 *
655 616 * @since 1.3.0
656 617 * @access public
657 - */
618 + */
658 619 public function enqueue_widgets_scripts() {
659 620 foreach ( $this->get_widget_types() as $widget ) {
660 621 $widget->enqueue_scripts();
661 622 }
@@ -660,14 +621,8 @@
660 621 $widget->enqueue_scripts();
661 622 }
662 623 }
663 624
664 - public function register_frontend_handlers() {
665 - foreach ( $this->get_widget_types() as $widget ) {
666 - $widget->register_frontend_handlers();
667 - }
668 - }
669 -
670 625 /**
671 626 * Enqueue widgets styles
672 627 *
673 628 * Enqueue all the styles defined as a dependency for each widget
@@ -742,9 +697,9 @@
742 697 * Initializing Elementor widgets manager.
743 698 *
744 699 * @since 1.0.0
745 700 * @access public
746 - */
701 + */
747 702 public function __construct() {
748 703 $this->require_files();
749 704
750 705 add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
@@ -764,10 +719,8 @@
764 719 $ajax_manager->register_ajax_action( 'render_widget', [ $this, 'ajax_render_widget' ] );
765 720 $ajax_manager->register_ajax_action( 'editor_get_wp_widget_form', [ $this, 'ajax_get_wp_widget_form' ] );
766 721 $ajax_manager->register_ajax_action( 'get_widgets_config', [ $this, 'ajax_get_widget_types_controls_config' ] );
767 722
768 - $ajax_manager->register_ajax_action( 'refresh_widgets_config', [ $this, 'ajax_refresh_widgets_config' ] );
769 -
770 723 $ajax_manager->register_ajax_action( 'get_widgets_default_value_translations', function ( array $data ) {
771 724 return $this->ajax_get_widgets_default_value_translations( $data );
772 725 } );
773 726 }
@@ -772,13 +725,13 @@
772 725 } );
773 726 }
774 727
775 728 /**
776 - * @param string $experiment_name
777 - * @param array $classes
729 + * @param $experiment_name
730 + * @param $classes
778 731 * @return void
779 732 */
780 - public function register_promoted_active_widgets( string $experiment_name, array $classes ): void {
733 + public function register_promoted_active_widgets( string $experiment_name, array $classes ) : void {
781 734 if ( ! Plugin::$instance->experiments->is_feature_active( $experiment_name ) || empty( $classes ) ) {
782 735 return;
783 736 }
784 737