PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev4
Elementor Website Builder – more than just a page builder v3.26.0-dev4
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 4.0.7 All 451 releases
← All changes | includes/managers/widgets.php +17 -65 4.2.33.26.0-dev4 View file →
@@ -2,15 +2,10 @@
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 9 use Elementor\Modules\NestedElements\Module as NestedElementsModule;
15 10 use Elementor\Modules\NestedTabs\Widgets\NestedTabs;
16 11
@@ -56,16 +51,8 @@
56 51 NestedElementsModule::EXPERIMENT_NAME => [
57 52 NestedTabs::class,
58 53 Nested_Accordion::class,
59 54 ],
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 - ],
68 55 ];
69 56
70 57 /**
71 58 * Init widgets.
@@ -74,9 +61,9 @@
74 61 * and register each Elementor and WordPress widget.
75 62 *
76 63 * @since 2.0.0
77 64 * @access private
78 - */
65 + */
79 66 private function init_widgets() {
80 67 $build_widgets_filename = [
81 68 'common-base',
82 69 'common',
@@ -168,9 +155,9 @@
168 155 * plugin authors can filter the black list.
169 156 *
170 157 * @since 2.0.0
171 158 * @access private
172 - */
159 + */
173 160 private function register_wp_widgets() {
174 161 global $wp_widget_factory;
175 162
176 163 // Allow themes/plugins to filter out their widgets.
@@ -209,9 +196,9 @@
209 196 * Require Elementor widget base class.
210 197 *
211 198 * @since 2.0.0
212 199 * @access private
213 - */
200 + */
214 201 private function require_files() {
215 202 require ELEMENTOR_PATH . 'includes/base/widget-base.php';
216 203 }
217 204
@@ -237,9 +224,9 @@
237 224 *
238 225 * @param Widget_Base $widget Elementor widget.
239 226 *
240 227 * @return true True if the widget was registered.
241 - */
228 + */
242 229 public function register_widget_type( Widget_Base $widget ) {
243 230 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
244 231 __METHOD__,
245 232 '3.5.0',
@@ -307,9 +294,9 @@
307 294 *
308 295 * @param string $name Widget name.
309 296 *
310 297 * @return true True if the widget was unregistered, False otherwise.
311 - */
298 + */
312 299 public function unregister_widget_type( $name ) {
313 300 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
314 301 __METHOD__,
315 302 '3.5.0',
@@ -351,9 +338,9 @@
351 338 *
352 339 * @param string $widget_name Optional. Widget name. Default is null.
353 340 *
354 341 * @return Widget_Base|Widget_Base[]|null Registered widget types.
355 - */
342 + */
356 343 public function get_widget_types( $widget_name = null ) {
357 344 if ( is_null( $this->_widget_types ) ) {
358 345 $this->init_widgets();
359 346 }
@@ -373,9 +360,9 @@
373 360 * @since 1.0.0
374 361 * @access public
375 362 *
376 363 * @return array Registered widget types with each widget config.
377 - */
364 + */
378 365 public function get_widget_types_config() {
379 366 $config = [];
380 367
381 368 foreach ( $this->get_widget_types() as $widget_key => $widget ) {
@@ -385,9 +372,9 @@
385 372 return $config;
386 373 }
387 374
388 375 /**
389 - * @throws \Exception If current user don't have permissions to edit the post.
376 + * @throws \Exception
390 377 */
391 378 public function ajax_get_widget_types_controls_config( array $data ) {
392 379 Plugin::$instance->documents->check_permissions( $data['editor_post_id'] );
393 380
@@ -408,35 +395,8 @@
408 395
409 396 return $config;
410 397 }
411 398
412 - /**
413 - * @throws \Exception If current user don't have permissions to edit the post.
414 - */
415 - public function ajax_refresh_widgets_config( array $data ) {
416 - Plugin::$instance->documents->check_permissions( $data['editor_post_id'] );
417 -
418 - wp_raise_memory_limit( 'admin' );
419 -
420 - $widgets = [];
421 -
422 - foreach ( $this->get_widget_types() as $widget_key => $widget ) {
423 - $widget_config = $widget->get_config();
424 -
425 - // get_config() omits controls when the stack isn't initialized yet (see Widget_Base::get_initial_config).
426 - // During an AJAX refresh the instances are fresh, so we force-initialize and merge them explicitly.
427 - $widget_config['controls'] = $widget->get_stack( false )['controls'];
428 - $widget_config['tabs_controls'] = $widget->get_tabs_controls();
429 -
430 - $widgets[ $widget_key ] = $widget_config;
431 - }
432 -
433 - return [
434 - 'widgets' => $widgets,
435 - 'categories' => Plugin::$instance->elements_manager->get_categories(),
436 - ];
437 - }
438 -
439 399 public function ajax_get_widgets_default_value_translations( array $data = [] ) {
440 400 $locale = empty( $data['locale'] )
441 401 ? get_locale()
442 402 : $data['locale'];
@@ -520,9 +480,9 @@
520 480 *
521 481 * @param array $request Ajax request.
522 482 *
523 483 * @return bool|string Rendered widget form.
524 - * @throws \Exception If current user don't have permissions to edit the post.
484 + * @throws \Exception
525 485 */
526 486 public function ajax_get_wp_widget_form( $request ) {
527 487 Plugin::$instance->documents->check_permissions( $request['editor_post_id'] );
528 488
@@ -560,9 +520,9 @@
560 520 * template, for all the registered widget types.
561 521 *
562 522 * @since 1.0.0
563 523 * @access public
564 - */
524 + */
565 525 public function render_widgets_content() {
566 526 foreach ( $this->get_widget_types() as $widget ) {
567 527 $widget->print_template();
568 528 }
@@ -577,9 +537,9 @@
577 537 * @since 1.3.0
578 538 * @access public
579 539 *
580 540 * @return array Registered widget types with settings keys for each widget.
581 - */
541 + */
582 542 public function get_widgets_frontend_settings_keys() {
583 543 $keys = [];
584 544
585 545 foreach ( $this->get_widget_types() as $widget_type_name => $widget_type ) {
@@ -654,9 +614,9 @@
654 614 * Enqueue all the scripts defined as a dependency for each widget.
655 615 *
656 616 * @since 1.3.0
657 617 * @access public
658 - */
618 + */
659 619 public function enqueue_widgets_scripts() {
660 620 foreach ( $this->get_widget_types() as $widget ) {
661 621 $widget->enqueue_scripts();
662 622 }
@@ -661,14 +621,8 @@
661 621 $widget->enqueue_scripts();
662 622 }
663 623 }
664 624
665 - public function register_frontend_handlers() {
666 - foreach ( $this->get_widget_types() as $widget ) {
667 - $widget->register_frontend_handlers();
668 - }
669 - }
670 -
671 625 /**
672 626 * Enqueue widgets styles
673 627 *
674 628 * Enqueue all the styles defined as a dependency for each widget
@@ -743,9 +697,9 @@
743 697 * Initializing Elementor widgets manager.
744 698 *
745 699 * @since 1.0.0
746 700 * @access public
747 - */
701 + */
748 702 public function __construct() {
749 703 $this->require_files();
750 704
751 705 add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
@@ -765,10 +719,8 @@
765 719 $ajax_manager->register_ajax_action( 'render_widget', [ $this, 'ajax_render_widget' ] );
766 720 $ajax_manager->register_ajax_action( 'editor_get_wp_widget_form', [ $this, 'ajax_get_wp_widget_form' ] );
767 721 $ajax_manager->register_ajax_action( 'get_widgets_config', [ $this, 'ajax_get_widget_types_controls_config' ] );
768 722
769 - $ajax_manager->register_ajax_action( 'refresh_widgets_config', [ $this, 'ajax_refresh_widgets_config' ] );
770 -
771 723 $ajax_manager->register_ajax_action( 'get_widgets_default_value_translations', function ( array $data ) {
772 724 return $this->ajax_get_widgets_default_value_translations( $data );
773 725 } );
774 726 }
@@ -773,13 +725,13 @@
773 725 } );
774 726 }
775 727
776 728 /**
777 - * @param string $experiment_name
778 - * @param array $classes
729 + * @param $experiment_name
730 + * @param $classes
779 731 * @return void
780 732 */
781 - 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 {
782 734 if ( ! Plugin::$instance->experiments->is_feature_active( $experiment_name ) || empty( $classes ) ) {
783 735 return;
784 736 }
785 737