self::TIMEOUT, 'redirection' => 0, 'sslverify' => $sslverify, 'headers' => array( 'Cache-Control' => 'no-cache', ), 'user-agent' => '' !== $user_agent ? $user_agent : $this->get_default_user_agent(), ); $response = wp_remote_get( $url, $args ); if ( is_wp_error( $response ) ) { return $response; } return array( 'url' => $url, 'code' => (int) wp_remote_retrieve_response_code( $response ), 'headers' => wp_remote_retrieve_headers( $response ), 'body' => (string) wp_remote_retrieve_body( $response ), ); } /** * Returns the user agent used when the caller does not specify one. * * @return string User agent. */ public function get_default_user_agent(): string { return 'AI Blackout Self-Test/' . AIBLACKOUT_VERSION . '; ' . home_url( '/' ); } /** * Whether loopback requests are likely to work at all. * * @return bool True when a basic request to the home page succeeds. */ public function is_available(): bool { $response = $this->get( '/' ); return ! is_wp_error( $response ); } }