namespace = 'aether/v1'; $this->rest_base = 'test'; } public function register_routes(): void { register_rest_route( $this->namespace, '/' . $this->rest_base, [ [ 'methods' => WP_REST_Server::READABLE, 'callback' => [ $this, 'get_items' ], 'permission_callback' => [ $this, 'get_items_permissions_check' ], 'args' => $this->get_collection_params(), ] ] ); } /** * Retrieves the query params for the items collection. * * @return array Collection parameters. */ public function get_collection_params() { return []; } /** * Retrieves a collection of items. * * @param WP_REST_Request $request Full details about the request. * * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function get_items( $request ) { $items = [ 'foo' => 'bar' ]; $response = rest_ensure_response( $items ); return $response; } /** * Checks if a given request has access to read the items. * * @param WP_REST_Request $request Full details about the request. * * @return true|WP_Error True if the request has read access, WP_Error object otherwise. */ public function get_items_permissions_check( $request ) { return true; } }