is_ssl()
Determines if SSL is used.
Description #Description
Return #Return
(bool) True if SSL, otherwise false.
Source #Source
File: wp-includes/load.php
function is_ssl() { if ( isset( $_SERVER['HTTPS'] ) ) { if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) { return true; } if ( '1' == $_SERVER['HTTPS'] ) { return true; } } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { return true; } return false; }
Expand full source code Collapse full source code View on Trac
Changelog #Changelog
Version | Description |
---|---|
4.6.0 | Moved from functions.php to load.php. |
2.6.0 | Introduced. |
Related #Related
Used By #Used By
Used By | Description |
---|---|
wp-includes/class-wp-recovery-mode.php: WP_Recovery_Mode::redirect_protected() |
Redirects the current request to allow recovering multiple errors in one go. |
wp-includes/class-wp-recovery-mode-cookie-service.php: WP_Recovery_Mode_Cookie_Service::set_cookie() |
Sets the recovery mode cookie. |
wp-admin/includes/class-wp-debug-data.php: WP_Debug_Data::debug_data() |
Static function for generating site debug data when required. |
wp-admin/includes/class-wp-site-health.php: WP_Site_Health::get_test_https_status() |
Test if your site is serving content over HTTPS. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::get_allowed_urls() |
Get URLs allowed to be previewed. |
wp-includes/ms-load.php: ms_load_current_site_and_network() |
Identifies the network and site of a requested domain and path and populates the corresponding network and site global objects as part of the multisite bootstrap process. |
wp-includes/rest-api.php: get_rest_url() |
Retrieves the URL to a REST endpoint on a site. |
wp-includes/media.php: wp_calculate_image_srcset() |
A helper function to calculate the image sources to include in a ‘srcset’ attribute. |
wp-includes/admin-bar.php: wp_admin_bar_customize_menu() |
Adds the “Customize” link to the Toolbar. |
wp-includes/link-template.php: get_avatar_data() |
Retrieves default data about the avatar. |
wp-admin/includes/ajax-actions.php: wp_ajax_parse_embed() |
Apply [embed] Ajax handlers to a string. |
wp-admin/includes/dashboard.php: wp_dashboard_browser_nag() | |
wp-includes/pluggable.php: wp_parse_auth_cookie() |
Parses a cookie into its components. |
wp-includes/pluggable.php: wp_set_auth_cookie() |
Sets the authentication cookies based on user ID. |
wp-includes/pluggable.php: auth_redirect() |
Checks if a user is logged in, if not it redirects them to the login page. |
wp-includes/general-template.php: wp_login_form() |
Provides a simple login form for use anywhere within WordPress. |
wp-includes/functions.php: wp_auth_check_html() |
Output the HTML that shows the wp-login dialog when the user is no longer logged in. |
wp-includes/functions.php: wp_guess_url() |
Guess the URL for the site. |
wp-includes/link-template.php: set_url_scheme() |
Sets the scheme for a URL. |
wp-includes/link-template.php: network_home_url() |
Retrieves the home URL for the current network. |
wp-includes/link-template.php: get_home_url() |
Retrieves the URL for a given site where the front end is accessible. |
wp-includes/class-wp-admin-bar.php: WP_Admin_Bar::__get() | |
wp-includes/user.php: wp_signon() |
Authenticates and logs a user in with ‘remember’ capability. |
wp-includes/post.php: wp_get_attachment_url() |
Retrieve the URL for an attachment. |
wp-includes/canonical.php: redirect_canonical() |
Redirects incoming links to the proper URL based on the site url. |
wp-includes/ms-functions.php: filter_SSL() |
Formats a URL to use https. |
User Contributed Notes #User Contributed Notes
You must log in before being able to contribute a note or feedback.
With load balancers
It won’t work for websites behind some load balancers, especially Network Solutions hosted websites. To bodgy up a fix, save this gist into the plugins folder and enable it. For details, read “WordPress is_ssl() doesn’t work behind some load balancers.”
Websites behind load balancers or reverse proxies that support HTTP_X_FORWARDED_PROTO can be fixed by adding the following code to the wp-config.php file, above the require_once call: