From 3ea8ca6d04c9ddeea0d9895b1c66217c4ba7a52c Mon Sep 17 00:00:00 2001 From: Dave Ryan Date: Thu, 21 Nov 2024 17:13:24 -0700 Subject: [PATCH 1/2] remove is_admin check failing rest API hits --- includes/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Config.php b/includes/Config.php index 554dade..672b001 100644 --- a/includes/Config.php +++ b/includes/Config.php @@ -37,7 +37,7 @@ public static function get_wp_config_initialization_constants() { */ public static function get_site_capability( $capability ) { // Only fetch capabilities in the admin when a user is logged in - if ( ! is_admin() || ! is_user_logged_in() ) { + if ( ! is_user_logged_in() ) { return false; } $site_capabilities = new SiteCapabilities(); From a96eaa6937573aa25345c1211ba3e015ff4393f5 Mon Sep 17 00:00:00 2001 From: Dave Ryan Date: Thu, 21 Nov 2024 21:58:17 -0700 Subject: [PATCH 2/2] Update logic check to use manage_options --- includes/Config.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/Config.php b/includes/Config.php index 672b001..f912811 100644 --- a/includes/Config.php +++ b/includes/Config.php @@ -36,12 +36,12 @@ public static function get_wp_config_initialization_constants() { * @return boolean */ public static function get_site_capability( $capability ) { - // Only fetch capabilities in the admin when a user is logged in - if ( ! is_user_logged_in() ) { - return false; + // Allow fetch if in admin area or if authenticated user can manage options + if ( is_admin() || current_user_can( 'manage_options' ) ) { + $site_capabilities = new SiteCapabilities(); + return $site_capabilities->get( $capability ); } - $site_capabilities = new SiteCapabilities(); - return $site_capabilities->get( $capability ); + return false; } /**