| @@ -84,20 +84,8 @@ | ||
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | register_rest_route( |
| 87 | 87 | self::NS, |
| 88 | - '/plans/groups/(?P<id>\d+)/order', | |
| 89 | - array( | |
| 90 | - array( | |
| 91 | - 'methods' => WP_REST_Server::EDITABLE, | |
| 92 | - 'callback' => array( $this, 'update_group_order' ), | |
| 93 | - 'permission_callback' => $perm, | |
| 94 | - ), | |
| 95 | - ) | |
| 96 | - ); | |
| 97 | - | |
| 98 | - register_rest_route( | |
| 99 | - self::NS, | |
| 100 | 88 | '/plans/terms', |
| 101 | 89 | array( |
| 102 | 90 | array( |
| 103 | 91 | 'methods' => WP_REST_Server::CREATABLE, |
| @@ -385,44 +373,8 @@ | ||
| 385 | 373 | |
| 386 | 374 | PlanRepository::update_group( $id, $params ); |
| 387 | 375 | |
| 388 | 376 | return rest_ensure_response( PlanRepository::get_group_tree( $id ) ); |
| 389 | - } | |
| 390 | - | |
| 391 | - /** | |
| 392 | - * PUT /plans/groups/{id}/order - save the admin display order of the | |
| 393 | - * group's durations and/or products (drag-and-drop on the detail page). | |
| 394 | - * | |
| 395 | - * Stored in the group's `data` JSON as `term_order` / `product_order` | |
| 396 | - * (lists of ids), merged so the rest of `data` is left as it was. | |
| 397 | - * | |
| 398 | - * @param WP_REST_Request $request Request. | |
| 399 | - * | |
| 400 | - * @return \WP_REST_Response|WP_Error | |
| 401 | - */ | |
| 402 | - public function update_group_order( WP_REST_Request $request ) { | |
| 403 | - $id = (int) $request['id']; | |
| 404 | - $group = PlanRepository::get_group( $id ); | |
| 405 | - | |
| 406 | - if ( ! $group ) { | |
| 407 | - return $this->not_found(); | |
| 408 | - } | |
| 409 | - | |
| 410 | - $params = $this->read_params( $request ); | |
| 411 | - $data = is_array( $group['data'] ) ? $group['data'] : array(); | |
| 412 | - | |
| 413 | - foreach ( array( | |
| 414 | - 'terms' => 'term_order', | |
| 415 | - 'products' => 'product_order', | |
| 416 | - ) as $param => $key ) { | |
| 417 | - if ( isset( $params[ $param ] ) && is_array( $params[ $param ] ) ) { | |
| 418 | - $data[ $key ] = array_values( array_unique( array_filter( array_map( 'absint', $params[ $param ] ) ) ) ); | |
| 419 | - } | |
| 420 | - } | |
| 421 | - | |
| 422 | - PlanRepository::update_group( $id, array( 'data' => $data ) ); | |
| 423 | - | |
| 424 | - return rest_ensure_response( array( 'success' => true ) ); | |
| 425 | 377 | } |
| 426 | 378 | |
| 427 | 379 | /** |
| 428 | 380 | * DELETE /plans/groups/{id} - delete group + cascade. |