返回介绍

network_home_url()

发布于 2017-09-11 02:00:41 字数 4123 浏览 998 评论 0 收藏 0

network_home_url( string $path = '',  string $scheme = null )

Retrieves the home URL for the current network.


description

Returns the home URL with the appropriate protocol, ‘https’ is_ssl() and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.


参数

$path

(string) (Optional) Path relative to the home URL.

Default value: ''

$scheme

(string) (Optional) Scheme to give the home URL context. Accepts 'http', 'https', or 'relative'.

Default value: null


返回值

(string) Home URL link with optional path appended.


源代码

File: wp-includes/link-template.php

function network_home_url( $path = '', $scheme = null ) {
	if ( ! is_multisite() )
		return home_url($path, $scheme);

	$current_network = get_network();
	$orig_scheme = $scheme;

	if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
		$scheme = is_ssl() && ! is_admin() ? 'https' : 'http';

	if ( 'relative' == $scheme )
		$url = $current_network->path;
	else
		$url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );

	if ( $path && is_string( $path ) )
		$url .= ltrim( $path, '/' );

	/**
	 * Filters the network home URL.
	 *
	 * @since 3.0.0
	 *
	 * @param string      $url         The complete network home URL including scheme and path.
	 * @param string      $path        Path relative to the network home URL. Blank string
	 *                                 if no path is specified.
	 * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
	 *                                 'relative' or null.
	 */
	return apply_filters( 'network_home_url', $url, $path, $orig_scheme);
}

更新日志

Versiondescription
3.0.0Introduced.

相关函数

Uses

  • wp-includes/ms-blogs.php: get_network()
  • wp-includes/load.php: is_multisite()
  • wp-includes/load.php: is_admin()
  • wp-includes/load.php: is_ssl()
  • wp-includes/link-template.php: set_url_scheme()
  • wp-includes/link-template.php: network_home_url
  • wp-includes/link-template.php: home_url()
  • wp-includes/plugin.php: apply_filters()
  • Show 3 more uses Hide more uses

Used By

  • wp-login.php: retrieve_password()
  • wp-login.php: login_header()
  • wp-admin/includes/class-wp-automatic-updater.php: WP_Automatic_Updater::send_debug_email()
  • wp-admin/includes/export.php: wxr_site_url()
  • wp-admin/includes/ms.php: update_option_new_admin_email()
  • wp-admin/includes/ms.php: send_confirmation_on_profile_email()
  • wp-admin/includes/upgrade.php: wp_install_defaults()
  • wp-includes/ms-functions.php: maybe_redirect_404()
  • wp-includes/ms-blogs.php: get_blogaddress_by_name()
  • Show 4 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

    Basic Example

    
    $url = network_home_url();
    echo $url;
    

    Output: http://www.example.com

    Note the lack of a trailing slash.

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

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

发布评论

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