wppaste
WordPress

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
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.

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

Reaches an outbound HTTP request via wp_remote_request().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
47–142

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 274.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()one call below WP_Site_Health::get_test_https_status()
  • httpoutbound HTTP requestwp_remote_request()one call below WP_Site_Health::get_test_https_status()
  • optionoption read or writeget_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.

WhenInstructionsCalls it makes
wp_is_using_https()47wp_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 === false96wp_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()99wp_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 === false103–104wp_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–107wp_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 !== false106wp_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–109wp_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 !== false113–114wp_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–117wp_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)130wp_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)134wp_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–138wp_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–142wp_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

PHPCompiledExecutedBranchesNotes
8.6-dev27447–14210
8.527447–14210
8.427447–142106 fewer instructions than PHP 8.3
8.328047–14410
8.228047–14410
8.128047–14410
7.428047–14410

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

Show all 14

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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.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.