filter_SSL()

过滤URL并格式化为SSL

描述

过滤 URL 并在必要时将其格式化为 https(is_ssl) 和 force_ssl_content() 都是真的)

用法

<?php filter_SSL( $url ) ?>

参数

$url

(string) (必填) The URL to format
(字符串)(必填)要格式化的网址

默认值: None

示例

<?php

$url = ‘http://example.com/’;
$url = 'http://example.com/';

$url = filter_SSL( $url );
$url = filter_SSL( $url );

echo $url; // ‘https://example.com/’ or ‘http://example.com/’ as needed.
回声$url;根据需要“https://example.com/”或“http://example.com/”。

?>

注意

If $url is not a string, the Site Address is returned.
如果$url不是字符串,则返回站点地址。

使用到 set_url_scheme() to set the scheme to https when needed.
使用到 set_url_scheme() 以在需要时将方案设置为 https。

历史

添加于 版本: 2.8.5

源文件

filter_SSL() 函数的代码位于 wp-includes/ms-functions.php

/**
* Formats a URL to use https.
* 格式化网址以使用 https。
*
* Useful as a filter.
* 用作过滤器。
*
* @since 2.8.5 * @since 2.8.5
*
* @param string URL
* @param字符串网址
* @return string URL with https as the scheme
* @return以 https 为方案的字符串 URL
*/

function filter_SSL( $url ) {
函数 filter_SSL( $url ) {

if ( ! is_string( $url ) )
如果 ( ! is_string( $url ) )

return get_bloginfo( ‘url’ ); // Return home blog url with proper scheme
返回 get_bloginfo( '网址' );使用适当的方案返回主页博客网址

if ( force_ssl_content() && is_ssl() )
if ( force_ssl_content() && is_ssl() )

$url = set_url_scheme( $url, ‘https’ );
$url = set_url_scheme( $url, 'https' );

return $url; 返回$url;

}

相关

set_url_scheme(), is_ssl(), force_ssl_content()
set_url_scheme(), is_ssl(), force_ssl_content()

原文:http://codex.wordpress.org/Function_Reference/filter_SSL

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索