← All changes
|
jetpack_vendor/automattic/jetpack-search/src/class-rest-controller.php
+0
-60
16.3-beta
→
16.3-a.1
View file →
| @@ -182,24 +182,8 @@ | ||
| 182 | 182 | ) |
| 183 | 183 | ); |
| 184 | 184 | register_rest_route( |
| 185 | 185 | static::$namespace, |
| 186 | - '/search/plan/activate-free', | |
| 187 | - array( | |
| 188 | - 'methods' => WP_REST_Server::EDITABLE, | |
| 189 | - 'callback' => array( $this, 'activate_free_plan' ), | |
| 190 | - 'permission_callback' => array( $this, 'require_admin_privilege_callback' ), | |
| 191 | - 'args' => array( | |
| 192 | - 'source' => array( | |
| 193 | - 'type' => 'string', | |
| 194 | - 'required' => false, | |
| 195 | - 'sanitize_callback' => 'sanitize_key', | |
| 196 | - ), | |
| 197 | - ), | |
| 198 | - ) | |
| 199 | - ); | |
| 200 | - register_rest_route( | |
| 201 | - static::$namespace, | |
| 202 | 186 | '/search/plan/deactivate', |
| 203 | 187 | array( |
| 204 | 188 | 'methods' => WP_REST_Server::EDITABLE, |
| 205 | 189 | 'callback' => array( $this, 'deactivate_plan' ), |
| @@ -440,16 +424,8 @@ | ||
| 440 | 424 | } |
| 441 | 425 | return true; |
| 442 | 426 | } |
| 443 | 427 | |
| 444 | - if ( true === $reader_chat && ( ! $this->plan->supports_search() || $this->plan->is_free_plan() ) ) { | |
| 445 | - return new WP_Error( | |
| 446 | - 'rest_forbidden', | |
| 447 | - esc_html__( 'Site Chat requires a paid Jetpack Search plan.', 'jetpack-search-pkg' ), | |
| 448 | - array( 'status' => 403 ) | |
| 449 | - ); | |
| 450 | - } | |
| 451 | - | |
| 452 | 428 | // AI Answers requires a paid Search plan; reject the write outright. |
| 453 | 429 | if ( true === $ai_answers_enabled && ! Search_Blocks::supports_paid_search() ) { |
| 454 | 430 | return new WP_Error( |
| 455 | 431 | 'rest_forbidden', |
| @@ -628,44 +604,8 @@ | ||
| 628 | 604 | array( |
| 629 | 605 | 'code' => 'success', |
| 630 | 606 | ) |
| 631 | 607 | ); |
| 632 | - } | |
| 633 | - | |
| 634 | - /** | |
| 635 | - * Grant the free Search product to this site instead of sending the user to a $0 checkout. | |
| 636 | - * | |
| 637 | - * POST `jetpack/v4/search/plan/activate-free` | |
| 638 | - * | |
| 639 | - * @since 8.3.0 | |
| 640 | - * | |
| 641 | - * @param WP_REST_Request $request - REST request. | |
| 642 | - * @return WP_REST_Response|WP_Error Errors carry `checkout_fallback`, which the dashboard | |
| 643 | - * branches on to decide whether to fall back to checkout. | |
| 644 | - */ | |
| 645 | - public function activate_free_plan( $request ) { | |
| 646 | - /* | |
| 647 | - * Another plugin can load an older My Jetpack before this package's copy registers, and | |
| 648 | - * that copy has no such method. Degrade to the checkout the dashboard still has. | |
| 649 | - */ | |
| 650 | - if ( ! method_exists( Search_Product::class, 'activate_free_product' ) ) { | |
| 651 | - return new WP_Error( | |
| 652 | - 'jetpack_search_free_activation_unavailable', | |
| 653 | - __( 'Jetpack Search Free could not be activated for this site.', 'jetpack-search-pkg' ), | |
| 654 | - array( | |
| 655 | - 'status' => 501, | |
| 656 | - 'checkout_fallback' => true, | |
| 657 | - ) | |
| 658 | - ); | |
| 659 | - } | |
| 660 | - | |
| 661 | - $source = $request->get_param( 'source' ); | |
| 662 | - $result = Search_Product::activate_free_product( $source ? $source : 'search-dashboard' ); | |
| 663 | - if ( is_wp_error( $result ) ) { | |
| 664 | - return $result; | |
| 665 | - } | |
| 666 | - | |
| 667 | - return rest_ensure_response( $result ); | |
| 668 | 608 | } |
| 669 | 609 | |
| 670 | 610 | /** |
| 671 | 611 | * Deactivate plan: turn off search module and instant search. |