network_site_url()

 

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 );
}

参数:network_site_url( string $path = '', string $scheme = null )

返回具有适当协议的站点URL,如果是_ssl(),则返回‘HTTPS’,否则返回‘HTTP’。如果$scheme是‘HTTP’或‘HTTPS’,则会覆盖is_ssl()。

  • 设置_url_方案()

Path relative to the site URL. Scheme to give the site URL context. Accepts 'http', 'https', or 'relative'.

(字符串)附加了可选路径的站点URL链接。

$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

{acontent3}

  1. 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;
    

You must log in before being able to contribute a note or feedback.

12.50% (1) 次Baidu访问
25.00% (2) 次Google访问
50.00% (4) 次Sogou访问
12.50% (1) 次sm访问
  • 蜘蛛:Baidu,1次,更新时间:2019-04-24 20:17:15
  • 蜘蛛:Google,2次,更新时间:2019-05-25 11:09:35
  • 蜘蛛:Sogou,4次,更新时间:2019-05-05 15:02:14
  • 蜘蛛:sm,1次,更新时间:2019-05-21 03:27:21

参与评论