WP_REST_Server::CREATABLE, 'callback' => array( $this, 'run' ), 'permission_callback' => array( $this, 'permission_check' ), ) ); } /** * Administrators only. * * The report names the security and caching layers in front of the site * and quotes response headers back. That is reconnaissance in the wrong * hands, and useless in any hands that cannot act on it. * * @return bool */ public function permission_check(): bool { return current_user_can( 'manage_options' ); } /** * Run every check. * * @return WP_REST_Response */ public function run(): WP_REST_Response { $results = CheckRunner::run_all(); $response = new WP_REST_Response( array( 'checks' => $results, 'report' => SupportReport::build( $results ), ) ); // The payload describes this site's security posture, and it is also // a point-in-time snapshot — a cached copy would be both a leak and a // lie about the state of the site. return CacheHeaders::apply_to_rest_response( $response ); } }