From 580d79157c0443068ffdfc3677a8edde35137036 Mon Sep 17 00:00:00 2001 From: Hsu-Pei-Chun Date: Thu, 25 Dec 2025 00:37:10 +0800 Subject: [PATCH] fix: add type check for REST API response header --- functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index bd0deff..b880e59 100644 --- a/functions.php +++ b/functions.php @@ -79,7 +79,9 @@ public function add_security_headers() { * Add headers to REST API responses */ public function add_rest_api_headers($response) { - $response->header('X-Robots-Tag', 'noindex, nofollow'); + if ($response instanceof WP_REST_Response) { + $response->header('X-Robots-Tag', 'noindex, nofollow'); + } return $response; }