| @@ -10,9 +10,8 @@ | ||
| 10 | 10 | use Elementor\Modules\AtomicWidgets\Elements\Atomic_Image\Atomic_Image; |
| 11 | 11 | use Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph\Atomic_Paragraph; |
| 12 | 12 | use Elementor\Modules\AtomicWidgets\Elements\Atomic_Svg\Atomic_Svg; |
| 13 | 13 | use Elementor\Modules\NestedAccordion\Widgets\Nested_Accordion; |
| 14 | -use Elementor\Modules\NestedElements\Module as NestedElementsModule; | |
| 15 | 14 | use Elementor\Modules\NestedTabs\Widgets\NestedTabs; |
| 16 | 15 | |
| 17 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | 17 | exit; // Exit if accessed directly. |
| @@ -52,9 +51,9 @@ | ||
| 52 | 51 | * |
| 53 | 52 | * @return array |
| 54 | 53 | */ |
| 55 | 54 | private array $promoted_widgets = [ |
| 56 | - NestedElementsModule::EXPERIMENT_NAME => [ | |
| 55 | + 'container' => [ | |
| 57 | 56 | NestedTabs::class, |
| 58 | 57 | Nested_Accordion::class, |
| 59 | 58 | ], |
| 60 | 59 | 'atomic_widgets' => [ |
| @@ -408,8 +407,35 @@ | ||
| 408 | 407 | |
| 409 | 408 | return $config; |
| 410 | 409 | } |
| 411 | 410 | |
| 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 | + | |
| 412 | 438 | public function ajax_get_widgets_default_value_translations( array $data = [] ) { |
| 413 | 439 | $locale = empty( $data['locale'] ) |
| 414 | 440 | ? get_locale() |
| 415 | 441 | : $data['locale']; |
| @@ -737,8 +763,10 @@ | ||
| 737 | 763 | public function register_ajax_actions( Ajax $ajax_manager ) { |
| 738 | 764 | $ajax_manager->register_ajax_action( 'render_widget', [ $this, 'ajax_render_widget' ] ); |
| 739 | 765 | $ajax_manager->register_ajax_action( 'editor_get_wp_widget_form', [ $this, 'ajax_get_wp_widget_form' ] ); |
| 740 | 766 | $ajax_manager->register_ajax_action( 'get_widgets_config', [ $this, 'ajax_get_widget_types_controls_config' ] ); |
| 767 | + | |
| 768 | + $ajax_manager->register_ajax_action( 'refresh_widgets_config', [ $this, 'ajax_refresh_widgets_config' ] ); | |
| 741 | 769 | |
| 742 | 770 | $ajax_manager->register_ajax_action( 'get_widgets_default_value_translations', function ( array $data ) { |
| 743 | 771 | return $this->ajax_get_widgets_default_value_translations( $data ); |
| 744 | 772 | } ); |