'GET', 'callback' => [$this, 'show'], 'permission_callback' => [Routes::class, 'canManage'], ]); register_rest_route(Routes::NAMESPACE, '/privacy/guidance', [ [ 'methods' => 'GET', 'callback' => [$this, 'showGuidance'], 'permission_callback' => [Routes::class, 'canManage'], ], [ 'methods' => 'POST', 'callback' => [$this, 'updateGuidance'], 'permission_callback' => [Routes::class, 'canManage'], 'args' => [ 'enabled' => ['type' => 'boolean', 'required' => true], ], ], ]); } public function show(): WP_REST_Response { return new WP_REST_Response($this->map->summary()); } public function showGuidance(): WP_REST_Response { return new WP_REST_Response(['enabled' => $this->guidance->enabled()]); } public function updateGuidance(WP_REST_Request $request): WP_REST_Response { $this->guidance->set((bool) $request->get_param('enabled')); return $this->showGuidance(); } }