is_ssl() - WordPress 函数参考中文文档

返回介绍

is_ssl()

发布于 2017-09-11 字数3685 浏览 932 评论 0

is_ssl()

Determines if SSL is used.


描述


返回值

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

更新日志

Version 描述
4.6.0 Moved from functions.php to load.php.
2.6.0 Introduced.

相关函数

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

上一篇:is_site_admin()

下一篇:is_sticky()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!