get_network_by_path()
云策文档标注
概述
get_network_by_path() 函数用于根据域名和路径检索最匹配的网络。在 WordPress 4.4.0 版本中,它被转换为 WP_Network::get_by_path() 的包装器。
关键要点
- 函数作用:基于域名和路径查找最接近的网络匹配。
- 参数:$domain(必需,字符串类型,要检查的域名)、$path(必需,字符串类型,要检查的路径)、$segments(可选,整数或 null,路径段数,默认为 null 或完整路径)。
- 返回值:成功时返回 WP_Network 对象,未找到网络时返回 false。
- 内部实现:直接调用 WP_Network::get_by_path() 方法。
- 相关函数:WP_Network::get_by_path() 位于 wp-includes/class-wp-network.php。
- 版本历史:自 WordPress 3.9.0 引入。
代码示例
function get_network_by_path( $domain, $path, $segments = null ) {
return WP_Network::get_by_path( $domain, $path, $segments );
}
原文内容
Retrieves the closest matching network for a domain and path.
Description
{@internal In 4.4.0, converted to a wrapper for WP_Network::get_by_path()}
Parameters
$domainstringrequired-
Domain to check.
$pathstringrequired-
Path to check.
$segmentsint|nulloptional-
Path segments to use. Defaults to null, or the full path.
Default:
null
Source
function get_network_by_path( $domain, $path, $segments = null ) {
return WP_Network::get_by_path( $domain, $path, $segments );
}
Changelog
| Version | Description |
|---|---|
| 3.9.0 | Introduced. |