WP_REST_Server::READABLE, 'callback' => array( __CLASS__, 'read' ), 'permission_callback' => array( __CLASS__, 'permission' ), ), ) ); } /** * @return true|WP_Error */ public static function permission() { if ( current_user_can( 'manage_options' ) ) { return true; } return new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to read the log verification.', '404ops-activity-log' ), array( 'status' => rest_authorization_required_code() ) ); } /** The verdict, or `never_verified`. */ public static function read(): WP_REST_Response { $last = Verifier::last(); return new WP_REST_Response( array( 'verdict' => (string) ( $last['verdict'] ?? 'never_verified' ), 'running' => Verifier::running(), 'finished' => isset( $last['finished'] ) ? gmdate( 'c', (int) $last['finished'] ) : null, 'rows' => (int) ( $last['rows'] ?? 0 ), 'sealed' => (int) ( $last['sealed'] ?? 0 ), 'redacted' => (int) ( $last['redacted'] ?? 0 ), 'unsealed' => (int) ( $last['unsealed'] ?? 0 ), 'imported' => (int) ( $last['imported'] ?? 0 ), 'counts' => (object) ( $last['counts'] ?? array() ), 'findings' => array_values( (array) ( $last['findings'] ?? array() ) ), 'config_backed' => Key::config_backed(), ) ); } }