get_routes(); $rest_key = '/' . $namespace . '/' . $endpoint; if ( isset( $routes[ $rest_key ] ) && isset( $routes[ $rest_key ][0] ) ) { $request = new \WP_REST_Request( 'PUT' ); $request->set_headers( $server->get_headers( wp_unslash( $_SERVER ) ) ); $request->set_body( $server->get_raw_data() ); $check_required = $request->has_valid_params(); if ( is_wp_error( $check_required ) ) { wp_send_json_error( '-1' ); } else { $check_sanitized = $request->sanitize_params(); if ( is_wp_error( $check_sanitized ) ) { wp_send_json_error( '-2' ); } } if ( call_user_func( $routes[ $rest_key ][0]['permission_callback'], $request ) ) { $rest_response = call_user_func( $routes[ $rest_key ][0]['callback'], $request ); if ( ! is_wp_error( $rest_response ) && ! empty( $rest_response->data ) ) { wp_send_json( $rest_response->data, $rest_response->status ); } } } } wp_die(); } /** * Register the routes for the objects of the controller. */ public function register_routes() { Template_Kit_Search::get_instance(); Photos_Search::get_instance(); Template_Kit_Import::get_instance(); Template_Kit_Install::get_instance(); Subscription_API::get_instance(); Banners::get_instance(); Project_Name::get_instance(); Settings::get_instance(); Photos_Import::get_instance(); Requirements::get_instance(); } }