| @@ -408,35 +408,8 @@ | ||
| 408 | 408 | |
| 409 | 409 | return $config; |
| 410 | 410 | } |
| 411 | 411 | |
| 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 | 412 | public function ajax_get_widgets_default_value_translations( array $data = [] ) { |
| 440 | 413 | $locale = empty( $data['locale'] ) |
| 441 | 414 | ? get_locale() |
| 442 | 415 | : $data['locale']; |
| @@ -764,10 +737,8 @@ | ||
| 764 | 737 | public function register_ajax_actions( Ajax $ajax_manager ) { |
| 765 | 738 | $ajax_manager->register_ajax_action( 'render_widget', [ $this, 'ajax_render_widget' ] ); |
| 766 | 739 | $ajax_manager->register_ajax_action( 'editor_get_wp_widget_form', [ $this, 'ajax_get_wp_widget_form' ] ); |
| 767 | 740 | $ajax_manager->register_ajax_action( 'get_widgets_config', [ $this, 'ajax_get_widget_types_controls_config' ] ); |
| 768 | - | |
| 769 | - $ajax_manager->register_ajax_action( 'refresh_widgets_config', [ $this, 'ajax_refresh_widgets_config' ] ); | |
| 770 | 741 | |
| 771 | 742 | $ajax_manager->register_ajax_action( 'get_widgets_default_value_translations', function ( array $data ) { |
| 772 | 743 | return $this->ajax_get_widgets_default_value_translations( $data ); |
| 773 | 744 | } ); |