ms_site_not_found
云策文档标注
概述
ms_site_not_found 是一个 WordPress 多站点动作钩子,在网络可确定但站点无法找到时触发。此钩子主要用于处理站点缺失情况,通常涉及重定向和退出操作。
关键要点
- 触发时机:当网络(WP_Network)可确定,但基于域名和路径搜索站点失败时触发。
- 参数:$current_site(WP_Network 对象,已确定的网络)、$domain(字符串,用于搜索站点的域名)、$path(字符串,用于搜索站点的路径)。
- 用途:在站点未找到时,开发者可以挂钩此动作执行自定义逻辑,如重定向到默认页面或记录错误。
- 相关函数:由 ms_load_current_site_and_network() 在 wp-includes/ms-load.php 中调用,作为多站点引导过程的一部分。
- 版本历史:自 WordPress 3.9.0 版本引入。
原文内容
Fires when a network can be determined but a site cannot.
Description
At the time of this action, the only recourse is to redirect somewhere and exit. If you want to declare a particular site, do so earlier.
Parameters
$current_siteWP_Network-
The network that had been determined.
$domainstring-
The domain used to search for a site.
$pathstring-
The path used to search for a site.
Source
do_action( 'ms_site_not_found', $current_site, $domain, $path );
Changelog
| Version | Description |
|---|---|
| 3.9.0 | Introduced. |