1|2|3|all)/(?Pcsv|apache|nginx|json)', array( $this->get_route( WP_REST_Server::READABLE, 'route_export' ), ) ); } public function route_export( WP_REST_Request $request ) { $module = $request['module']; $format = 'json'; if ( in_array( $request['format'], array( 'csv', 'apache', 'nginx', 'json' ) ) ) { $format = $request['format']; } $export = Red_FileIO::export( $module, $format ); if ( $export === false ) { return $this->add_error_details( new WP_Error( 'redirect', 'Invalid module' ), __LINE__ ); } return array( 'data' => $export['data'], 'total' => $export['total'], ); } }