@@ -100,20 +100,28 @@ public function get_registration_args(): array {
100
100
rest_get_endpoint_args_for_schema ( OD_Strict_URL_Metric::get_json_schema () )
101
101
),
102
102
'callback ' => array ( $ this , 'handle_rest_request ' ),
103
- 'permission_callback ' => static function () {
104
- // Needs to be available to unauthenticated visitors.
105
- if ( OD_Storage_Lock::is_locked () ) {
106
- return new WP_Error (
107
- 'url_metric_storage_locked ' ,
108
- __ ( 'URL Metric storage is presently locked for the current IP. ' , 'optimization-detective ' ),
109
- array ( 'status ' => 423 )
110
- );
111
- }
112
- return true ;
113
- },
103
+ 'permission_callback ' => array ( $ this , 'permission_callback ' ),
114
104
);
115
105
}
116
106
107
+ /**
108
+ * Permission callback for the REST API endpoint.
109
+ *
110
+ * @return true|WP_Error True if the request has permission, WP_Error object otherwise.
111
+ */
112
+ public function permission_callback () {
113
+
114
+ // Needs to be available to unauthenticated visitors.
115
+ if ( OD_Storage_Lock::is_locked () ) {
116
+ return new WP_Error (
117
+ 'url_metric_storage_locked ' ,
118
+ __ ( 'URL Metric storage is presently locked for the current IP. ' , 'optimization-detective ' ),
119
+ array ( 'status ' => 423 )
120
+ );
121
+ }
122
+ return true ;
123
+ }
124
+
117
125
/**
118
126
* Determines if the HTTP origin is an authorized one.
119
127
*
0 commit comments