| @@ -385,9 +385,9 @@ | ||
| 385 | 385 | return $config; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | - * @throws \Exception If current user don't have permissions to edit the post. | |
| 389 | + * @throws \Exception Exception. | |
| 390 | 390 | */ |
| 391 | 391 | public function ajax_get_widget_types_controls_config( array $data ) { |
| 392 | 392 | Plugin::$instance->documents->check_permissions( $data['editor_post_id'] ); |
| 393 | 393 | |
| @@ -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']; |
| @@ -520,9 +493,9 @@ | ||
| 520 | 493 | * |
| 521 | 494 | * @param array $request Ajax request. |
| 522 | 495 | * |
| 523 | 496 | * @return bool|string Rendered widget form. |
| 524 | - * @throws \Exception If current user don't have permissions to edit the post. | |
| 497 | + * @throws \Exception If there is an error processing the request. | |
| 525 | 498 | */ |
| 526 | 499 | public function ajax_get_wp_widget_form( $request ) { |
| 527 | 500 | Plugin::$instance->documents->check_permissions( $request['editor_post_id'] ); |
| 528 | 501 | |
| @@ -661,14 +634,8 @@ | ||
| 661 | 634 | $widget->enqueue_scripts(); |
| 662 | 635 | } |
| 663 | 636 | } |
| 664 | 637 | |
| 665 | - public function register_frontend_handlers() { | |
| 666 | - foreach ( $this->get_widget_types() as $widget ) { | |
| 667 | - $widget->register_frontend_handlers(); | |
| 668 | - } | |
| 669 | - } | |
| 670 | - | |
| 671 | 638 | /** |
| 672 | 639 | * Enqueue widgets styles |
| 673 | 640 | * |
| 674 | 641 | * Enqueue all the styles defined as a dependency for each widget |
| @@ -764,10 +731,8 @@ | ||
| 764 | 731 | public function register_ajax_actions( Ajax $ajax_manager ) { |
| 765 | 732 | $ajax_manager->register_ajax_action( 'render_widget', [ $this, 'ajax_render_widget' ] ); |
| 766 | 733 | $ajax_manager->register_ajax_action( 'editor_get_wp_widget_form', [ $this, 'ajax_get_wp_widget_form' ] ); |
| 767 | 734 | $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 | 735 | |
| 771 | 736 | $ajax_manager->register_ajax_action( 'get_widgets_default_value_translations', function ( array $data ) { |
| 772 | 737 | return $this->ajax_get_widgets_default_value_translations( $data ); |
| 773 | 738 | } ); |