wp_update_https_detection_errors

The timeline below displays how wordpress function wp_update_https_detection_errors has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors.
 *
 * This internal function is called by a regular Cron hook to ensure HTTPS support is detected and maintained.
 *
 * @since 5.7.0
 * @deprecated 6.4.0 The `wp_update_https_detection_errors()` function is no longer used and has been replaced by
 *                   `wp_get_https_detection_errors()`. Previously the function was called by a regular Cron hook to
 *                    update the `https_detection_errors` option, but this is no longer necessary as the errors are
 *                    retrieved directly in Site Health and no longer used outside of Site Health.
 * @access private
 */
function wp_update_https_detection_errors()
{
    _deprecated_function(__FUNCTION__, '6.4.0');
    /**
     * Short-circuits the process of detecting errors related to HTTPS support.
     *
     * Returning a `WP_Error` from the filter will effectively short-circuit the default logic of trying a remote
     * request to the site over HTTPS, storing the errors array from the returned `WP_Error` instead.
     *
     * @since 5.7.0
     * @deprecated 6.4.0 The `wp_update_https_detection_errors` filter is no longer used and has been replaced by `pre_wp_get_https_detection_errors`.
     *
     * @param null|WP_Error $pre Error object to short-circuit detection,
     *                           or null to continue with the default behavior.
     */
    $support_errors = apply_filters('pre_wp_update_https_detection_errors', null);
    if (is_wp_error($support_errors)) {
        update_option('https_detection_errors', $support_errors->errors);
        return;
    }
    $support_errors = wp_get_https_detection_errors();
    update_option('https_detection_errors', $support_errors);
}

WordPress Version: 5.7

/**
 * Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors.
 *
 * This internal function is called by a regular Cron hook to ensure HTTPS support is detected and maintained.
 *
 * @since 5.7.0
 * @access private
 */
function wp_update_https_detection_errors()
{
    /**
     * Short-circuits the process of detecting errors related to HTTPS support.
     *
     * Returning a `WP_Error` from the filter will effectively short-circuit the default logic of trying a remote
     * request to the site over HTTPS, storing the errors array from the returned `WP_Error` instead.
     *
     * @since 5.7.0
     *
     * @param null|WP_Error $pre Error object to short-circuit detection,
     *                           or null to continue with the default behavior.
     */
    $support_errors = apply_filters('pre_wp_update_https_detection_errors', null);
    if (is_wp_error($support_errors)) {
        update_option('https_detection_errors', $support_errors->errors);
        return;
    }
    $support_errors = new WP_Error();
    $response = wp_remote_request(home_url('/', 'https'), array('headers' => array('Cache-Control' => 'no-cache'), 'sslverify' => true));
    if (is_wp_error($response)) {
        $unverified_response = wp_remote_request(home_url('/', 'https'), array('headers' => array('Cache-Control' => 'no-cache'), 'sslverify' => false));
        if (is_wp_error($unverified_response)) {
            $support_errors->add('https_request_failed', __('HTTPS request failed.'));
        } else {
            $support_errors->add('ssl_verification_failed', __('SSL verification failed.'));
        }
        $response = $unverified_response;
    }
    if (!is_wp_error($response)) {
        if (200 !== wp_remote_retrieve_response_code($response)) {
            $support_errors->add('bad_response_code', wp_remote_retrieve_response_message($response));
        } elseif (false === wp_is_local_html_output(wp_remote_retrieve_body($response))) {
            $support_errors->add('bad_response_source', __('It looks like the response did not come from this site.'));
        }
    }
    update_option('https_detection_errors', $support_errors->errors);
}