返回介绍

is_ssl()

发布于 2017-09-11 01:27:07 字数 3685 浏览 1068 评论 0 收藏 0

is_ssl()

Determines if SSL is used.


description


返回值

(bool) True if SSL, otherwise false.


源代码

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;
}

更新日志

Versiondescription
4.6.0Moved from functions.php to load.php.
2.6.0Introduced.

相关函数

Used By

  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::get_allowed_urls()
  • wp-includes/ms-load.php: ms_load_current_site_and_network()
  • wp-includes/rest-api.php: get_rest_url()
  • wp-includes/media.php: wp_calculate_image_srcset()
  • wp-includes/admin-bar.php: wp_admin_bar_customize_menu()
  • wp-includes/link-template.php: get_avatar_data()
  • wp-admin/includes/ajax-actions.php: wp_ajax_parse_embed()
  • wp-admin/includes/plugin-install.php: install_plugin_information()
  • wp-admin/includes/dashboard.php: wp_dashboard_browser_nag()
  • wp-includes/pluggable.php: wp_parse_auth_cookie()
  • wp-includes/pluggable.php: wp_set_auth_cookie()
  • wp-includes/pluggable.php: auth_redirect()
  • wp-includes/general-template.php: wp_login_form()
  • wp-includes/functions.php: wp_auth_check_html()
  • wp-includes/functions.php: wp_guess_url()
  • wp-includes/link-template.php: set_url_scheme()
  • wp-includes/link-template.php: network_home_url()
  • wp-includes/link-template.php: get_home_url()
  • wp-includes/class-wp-admin-bar.php: WP_Admin_Bar::__get()
  • wp-includes/user.php: wp_signon()
  • wp-includes/post.php: wp_get_attachment_url()
  • wp-includes/canonical.php: redirect_canonical()
  • wp-includes/ms-functions.php: filter_SSL()
  • Show 18 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    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:

    
    if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
        $_SERVER['HTTPS'] = 'on';
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文