25, 'redirection' => 4, 'sslverify' => (bool) apply_filters( 'https_local_ssl_verify', false ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- core filter. 'user-agent' => 'A11yMate/' . A11YMATE_VERSION . ' (+loopback scan; ' . home_url() . ')', 'cookies' => array(), 'reject_unsafe_urls' => false, 'limit_response_size' => 4 * MB_IN_BYTES, 'headers' => array( 'Accept' => 'text/html,application/xhtml+xml' ), ); /** * Filter the loopback request arguments (for example to add basic-auth credentials on a staging site). * * @param array $args Arguments for wp_remote_get(). * @param string $url URL being fetched. */ $args = apply_filters( 'a11ymate_fetch_args', $args, $url ); $res = wp_remote_get( $url, $args ); if ( is_wp_error( $res ) ) { return array( 'code' => 0, 'html' => '', 'error' => $res->get_error_message(), ); } $code = (int) wp_remote_retrieve_response_code( $res ); $ct = (string) wp_remote_retrieve_header( $res, 'content-type' ); if ( '' !== $ct && false === stripos( $ct, 'html' ) ) { return array( 'code' => $code, 'html' => '', 'error' => sprintf( /* translators: %s: content type */ __( 'Not an HTML page (%s).', 'a11ymate' ), $ct ), ); } return array( 'code' => $code, 'html' => (string) wp_remote_retrieve_body( $res ), 'error' => '', ); } }