filter_SSL()过滤URL并格式化为SSL

目录

描述

Filters a URL and formats it as https if necessary (is_ssl() and force_ssl_content() are both true).

filter_SSL() 描述

用法

<?php filter_SSL$url ?>

filter_SSL() 用法

参数

$url

(string) (必填) The URL to format

默认值: None

filter_SSL() 参数

示例

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

<?php

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

$url = filter_SSL( $url );

echo $url; // 'https://example.com/' or 'http://example.com/' as needed.

?>

filter_SSL() 示例

注意

  • If $url is not a string, the Site Address is returned.
  • 使用到 set_url_scheme() to set the scheme to https when needed.

filter_SSL() 注意

历史

添加于 版本: 2.8.5

filter_SSL() 历史

源文件

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

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Formats a URL to use https.
 *
 * Useful as a filter.
 *
 * @since 2.8.5
 *
 * @param string URL
 * @return string URL with https as the scheme
 */
function filter_SSL( $url ) {
	if ( ! is_string( $url ) )
		return get_bloginfo( 'url' ); // Return home blog url with proper scheme

	if ( force_ssl_content() && is_ssl() )
		$url = set_url_scheme( $url, 'https' );

	return $url;
}

filter_SSL() 源文件

相关