templateService = $templateService; } /** * @param WP_REST_Request> $request * @return WP_REST_Response * @throws ForbiddenException */ public function handle(WP_REST_Request $request): WP_REST_Response { // Verify the nonce Sanitizer::verifyNonce($request->get_header('X-WP-Nonce')); $templates = $this->templateService->getAllTemplates(); $categories = $this->templateService->getTemplateCategories(); return new WP_REST_Response([ 'success' => true, 'data' => [ 'templates' => $templates, 'categories' => $categories ] ], 200); } }