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

返回介绍

network_site_url()

发布于 2017-09-11 字数4032 浏览 951 评论 0

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

Retrieves the site URL for the current network.


描述

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


参数

$path

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

Default value: ”

$scheme

(string)
(Optional)
Scheme to give the site URL context. Accepts ‘http’, ‘https’, or ‘relative’.

Default value: null


返回值

(string) Site URL link with optional path appended.


源代码

File: wp-includes/link-template.php

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

	$current_network = get_network();

	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 site URL.
	 *
	 * @since 3.0.0
	 *
	 * @param string      $url    The complete network site URL including scheme and path.
	 * @param string      $path   Path relative to the network site URL. Blank string if
	 *                            no path is specified.
	 * @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https',
	 *                            'relative' or null.
	 */
	return apply_filters( 'network_site_url', $url, $path, $scheme );
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • wp-includes/ms-blogs.php:
    get_network()
  • wp-includes/load.php:
    is_multisite()
  • wp-includes/link-template.php:
    set_url_scheme()
  • wp-includes/link-template.php:
    network_site_url
  • wp-includes/link-template.php:
    site_url()
  • wp-includes/plugin.php:
    apply_filters()
  • Show 1 more use
    Hide more uses


Used By

  • wp-login.php:
    retrieve_password()
  • wp-includes/pluggable.php:
    wp_new_user_notification()
  • wp-includes/general-template.php:
    wp_lostpassword_url()
  • wp-includes/link-template.php:
    network_admin_url()
  • wp-includes/link-template.php:
    user_admin_url()
  • wp-includes/update.php:
    wp_version_check()
  • wp-includes/canonical.php:
    redirect_canonical()
  • wp-includes/ms-functions.php:
    wpmu_signup_blog_notification()
  • Show 3 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
    Output: http://www.example.com/wordpress/

    
    // Get the current site's URL
    $url = network_site_url();
    echo $url;
    
  2. With https specification
    Output: https://www.example.com/contact-us/

    
    // Get a secure URL for a specific page within the current site
    $url = network_site_url('/contact-us/', 'https');
    echo $url;
    

上一篇:network_settings_add_js()

下一篇:network_step1()

发布评论

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

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