WP_Site_Health::get_test_https_status(): array
- Since
- 5.2.0, 5.7.0
- Source
wp-admin/includes/class-wp-site-health.php:1473
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.
Compatibility
- WordPress
- since 5.7.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
array- The test results.
Performance profile
How much work a call to WP_Site_Health::get_test_https_status() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Expensive
- Scaling
- Constant
- Instructions
- 47–142
- Plugin surface
- None
- Called by
- 0
Reaches an outbound HTTP request via wp_remote_request().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 274.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below WP_Site_Health::get_test_https_status() - httpoutbound HTTP request
wp_remote_request()one call below WP_Site_Health::get_test_https_status() - optionoption read or write
get_option()one call below WP_Site_Health::get_test_https_status()
Further down the call graph this can also reach cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 13 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Site_Health::get_test_https_status() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
wp_is_using_https() | 47 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https() |
!wp_is_using_https() && wp_is_site_url_using_https() && !wp_is_https_supported() && $update_url === false | 96 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), wp_get_update_https_url(), __() |
!wp_is_using_https() && wp_is_site_url_using_https() && wp_is_https_supported() && !defined('WP_HOME') && !defined('WP_SITEURL') && !current_user_can() | 99 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), __(), current_user_can() |
!wp_is_using_https() && !wp_is_site_url_using_https() && !wp_is_https_supported() && $update_url === false | 103–104 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), wp_get_update_https_url(), __() |
!wp_is_using_https() && !wp_is_site_url_using_https() && wp_is_https_supported() && !defined('WP_HOME') && !defined('WP_SITEURL') && !current_user_can() | 106–107 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), __(), current_user_can() |
!wp_is_using_https() && wp_is_site_url_using_https() && !wp_is_https_supported() && $update_url !== false | 106 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), wp_get_update_https_url(), esc_url(), __(), __() |
!wp_is_using_https() && wp_is_site_url_using_https() && wp_is_https_supported() | 107–109 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), __(), __(), sprintf() |
!wp_is_using_https() && !wp_is_site_url_using_https() && !wp_is_https_supported() && $update_url !== false | 113–114 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), wp_get_update_https_url(), esc_url(), __(), __() |
!wp_is_using_https() && !wp_is_site_url_using_https() && wp_is_https_supported() | 114–117 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), __(), __(), sprintf() |
!wp_is_using_https() && wp_is_site_url_using_https() && wp_is_https_supported() && !defined('WP_HOME') && !defined('WP_SITEURL') && current_user_can() && empty($direct_update_url) | 130 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), __(), current_user_can(), admin_url(), wp_nonce_url(), add_query_arg(), wp_get_direct_update_https_url(), esc_url(), __(), sprintf() |
!wp_is_using_https() && wp_is_site_url_using_https() && wp_is_https_supported() && !defined('WP_HOME') && !defined('WP_SITEURL') && current_user_can() && !empty($direct_update_url) | 134 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), __(), current_user_can(), admin_url(), wp_nonce_url(), add_query_arg(), wp_get_direct_update_https_url(), esc_url(), __(), __(), sprintf() |
!wp_is_using_https() && !wp_is_site_url_using_https() && wp_is_https_supported() && !defined('WP_HOME') && !defined('WP_SITEURL') && current_user_can() && empty($direct_update_url) | 137–138 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), __(), current_user_can(), admin_url(), wp_nonce_url(), add_query_arg(), wp_get_direct_update_https_url(), esc_url(), __(), sprintf() |
1 further outcome, up to 142 instructions
!wp_is_using_https() && !wp_is_site_url_using_https() && wp_is_https_supported() && !defined('WP_HOME') && !defined('WP_SITEURL') && current_user_can() && !empty($direct_update_url) | 141–142 | wp_get_https_detection_errors(), wp_get_default_update_https_url(), __(), __(), __(), esc_url(), __(), __(), wp_is_using_https(), __(), wp_is_site_url_using_https(), is_ssl(), __(), admin_url(), esc_url(), admin_url(), esc_url(), sprintf(), wp_is_https_supported(), __(), current_user_can(), admin_url(), wp_nonce_url(), add_query_arg(), wp_get_direct_update_https_url(), esc_url(), __(), __(), sprintf() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 274 | 47–142 | 10 | |
| 8.5 | 274 | 47–142 | 10 | |
| 8.4 | 274 | 47–142 | 10 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 280 | 47–144 | 10 | |
| 8.2 | 280 | 47–144 | 10 | |
| 8.1 | 280 | 47–144 | 10 | |
| 7.4 | 280 | 47–144 | 10 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
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 code
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' ) ) ); } }Changelog
Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.