site_by_path_segments_count
云策文档标注
概述
site_by_path_segments_count 是一个 WordPress 过滤器,用于控制在基于域名和路径搜索站点时考虑的路由段数量。它允许开发者调整默认行为,以更精确地匹配站点。
关键要点
- 过滤器名称:site_by_path_segments_count
- 主要用途:过滤在搜索站点时考虑的路由段数量,影响 get_site_by_path() 函数的行为
- 参数:$segments(整数或 null,表示考虑的路由段数)、$domain(字符串,请求的域名)、$path(字符串,请求的完整路径)
- 默认行为:WordPress 默认只考虑网络路径后的一个路由段
- 引入版本:WordPress 3.9.0
代码示例
$segments = apply_filters( 'site_by_path_segments_count', $segments, $domain, $path );注意事项
当 $segments 参数为 null 时,仅在已知请求路径应匹配特定站点时使用,否则可能导致意外结果。
原文内容
Filters the number of path segments to consider when searching for a site.
Parameters
$segmentsint|null-
The number of path segments to consider. WordPress by default looks at one path segment following the network path. The function default of null only makes sense when you know the requested path should match a site.
$domainstring-
The requested domain.
$pathstring-
The requested path, in full.
Source
$segments = apply_filters( 'site_by_path_segments_count', $segments, $domain, $path );
Changelog
| Version | Description |
|---|---|
| 3.9.0 | Introduced. |