WP_Site_Health::get_test_https_status(): array
- Since
- 5.2.0, 5.7.0
- Source
wp-admin/includes/class-wp-site-health.php:1463
Tests if the site is serving content over HTTPS.
Description
Many sites have varying degrees of HTTPS support, the most common of which is sites that have it enabled, but only if you visit the right site address.
Return
array- The test results.
Uses · 14
- wp_get_https_detection_errors()Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors.
- wp_get_default_update_https_url()Gets the default URL to learn more about updating the site to use HTTPS.
- __()Retrieves the translation of $text.
- esc_url()Checks and cleans a URL.
- wp_is_using_https()Checks whether the website is using HTTPS.
- wp_is_site_url_using_https()Checks whether the current site's URL where WordPress is stored is using HTTPS.
- is_ssl()Determines if SSL is used.
- admin_url()Retrieves the URL to the admin area for the current site.
- wp_is_https_supported()Checks whether HTTPS is supported for the server and domain.
- current_user_can()Returns whether the current user has the specified capability.
- add_query_arg()Retrieves a modified URL query string.
- wp_nonce_url()Retrieves URL with nonce added to URL query.
Show all 14
- wp_get_direct_update_https_url()Gets the URL for directly updating the site to use HTTPS.
- wp_get_update_https_url()Gets the URL to learn more about updating the site to use HTTPS.
Source
public function get_test_https_status() { /* * Check HTTPS detection results. */ $errors = wp_get_https_detection_errors(); $default_update_url = wp_get_default_update_https_url(); $result = array( 'label' => __( 'Your website is using an active HTTPS connection' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Security' ), 'color' => 'blue', ), 'description' => sprintf( '<p>%s</p>', __( 'An HTTPS connection is a more secure way of browsing the web. Many services now have HTTPS as a requirement. HTTPS allows you to take advantage of new features that can increase site speed, improve search rankings, and gain the trust of your visitors by helping to protect their online privacy.' ) ), 'actions' => sprintf( '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', esc_url( $default_update_url ), __( 'Learn more about why you should use HTTPS' ), /* translators: Hidden accessibility text. */ __( '(opens in a new tab)' ) ), 'test' => 'https_status', ); if ( ! wp_is_using_https() ) { /* * If the website is not using HTTPS, provide more information * about whether it is supported and how it can be enabled. */ $result['status'] = 'recommended'; $result['label'] = __( 'Your website does not use HTTPS' ); if ( wp_is_site_url_using_https() ) { if ( is_ssl() ) { $result['description'] = sprintf( '<p>%s</p>', sprintf( /* translators: %s: URL to Settings > General > Site Address. */ __( 'You are accessing this website using HTTPS, but your <a href="%s">Site Address</a> is not set up to use HTTPS by default.' ), esc_url( admin_url( 'options-general.php' ) . '#home' ) ) ); } else { $result['description'] = sprintf( '<p>%s</p>', sprintf( /* translators: %s: URL to Settings > General > Site Address. */ __( 'Your <a href="%s">Site Address</a> is not set up to use HTTPS.' ), esc_url( admin_url( 'options-general.php' ) . '#home' ) ) ); } } else { if ( is_ssl() ) { $result['description'] = sprintf( '<p>%s</p>', sprintf( /* translators: 1: URL to Settings > General > WordPress Address, 2: URL to Settings > General > Site Address. */ __( 'You are accessing this website using HTTPS, but your <a href="%1$s">WordPress Address</a> and <a href="%2$s">Site Address</a> are not set up to use HTTPS by default.' ), esc_url( admin_url( 'options-general.php' ) . '#siteurl' ), esc_url( admin_url( 'options-general.php' ) . '#home' ) ) ); } else { $result['description'] = sprintf( '<p>%s</p>', sprintf( /* translators: 1: URL to Settings > General > WordPress Address, 2: URL to Settings > General > Site Address. */ __( 'Your <a href="%1$s">WordPress Address</a> and <a href="%2$s">Site Address</a> are not set up to use HTTPS.' ), esc_url( admin_url( 'options-general.php' ) . '#siteurl' ), esc_url( admin_url( 'options-general.php' ) . '#home' ) ) ); } }History
Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
5.7.0
Updated to rely on wp_is_using_https() and wp_is_https_supported().from the docblock
5.2.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-admin/includes/class-wp-site-health.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.