wp_is_using_https()WP 5.7.0

Checks if the site is using HTTPS.

For a successful HTTPS check, it must be specified for both front and admin URLs (home and site URL). I remind you that in WP core it can be under a different URL:

1 time — 0.0034051 sec (very slow) | 50000 times — 7.82 sec (fast) | PHP 7.4.8, WP 5.7.1

No Hooks.

Returns

bool. true when HTTPS is used for the front and admin URLs (home and site URL). false when HTTPS is not used for at least one URL.

Usage

wp_is_using_https();

Examples

#1 A simple example of how to use

if ( wp_is_using_https() ) {
	// Site works over a secure HTTPS protocol
} else {
	// The site works via the standard HTTP protocol
}

Notes

See: wp_is_home_url_using_https()
See: wp_is_site_url_using_https()

Changelog

Since 5.7.0 Introduced.

wp_is_using_https() code WP 7.1

function wp_is_using_https() {
	if ( ! wp_is_home_url_using_https() ) {
		return false;
	}

	return wp_is_site_url_using_https();
}