wp_is_home_url_using_https()
云策文档标注
概述
wp_is_home_url_using_https() 函数用于检查当前站点 URL 是否使用 HTTPS 协议。它通过解析 home_url() 的 scheme 部分来判断,返回布尔值。
关键要点
- 函数返回布尔值:true 表示使用 HTTPS,false 表示不使用。
- 内部实现基于 wp_parse_url() 解析 home_url() 的 scheme。
- 该函数自 WordPress 5.7.0 版本引入。
相关函数
- wp_parse_url(): 包装 PHP 的 parse_url(),确保跨 PHP 版本返回值一致。
- home_url(): 获取当前站点前端可访问的 URL。
- wp_is_using_https(): 检查网站是否使用 HTTPS。
原文内容
Checks whether the current site URL is using HTTPS.
Description
See also
Source
function wp_is_home_url_using_https() {
return 'https' === wp_parse_url( home_url(), PHP_URL_SCHEME );
}
Changelog
| Version | Description |
|---|---|
| 5.7.0 | Introduced. |