检查当前博客的状态。
原型
ms_site_check()
描述
检查博客是否已删除,处于非活动状态,已存档或已发送垃圾邮件。
返回值
(true|string)
成功时返回true,或包含的drop-in文件。
源文件
路径:wp-includes/ms-load.php
<?php
...
function ms_site_check() {
/**
* Filters checking the status of the current blog.
*
* @since 3.0.0
*
* @param bool null Whether to skip the blog status check. Default null.
*/
$check = apply_filters( 'ms_site_check', null );
if ( null !== $check )
return true;
// Allow super admins to see blocked sites
if ( is_super_admin() )
return true;
$blog = get_site();
if ( '1' == $blog->deleted ) {
if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
return WP_CONTENT_DIR . '/blog-deleted.php';
else
wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) );
}
if ( '2' == $blog->deleted ) {
if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) {
return WP_CONTENT_DIR . '/blog-inactive.php';
} else {
$admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', '[email protected]' . get_network()->domain ) );
wp_die(
/* translators: %s: admin email link */
sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ),
sprintf( '<a href="mailto:%s">%s</a>', $admin_email )
)
);
}
}
if ( $blog->archived == '1' || $blog->spam == '1' ) {
if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) )
return WP_CONTENT_DIR . '/blog-suspended.php';
else
wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) );
}
return true;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/ms_site_check/