您可以筛选domain_exists
, 在注册站点之前运行的检查。如果返回正整数,WordPress将不会创建该站点。尽管名称不同,该过滤器也允许您检查路径。
未测试的示例代码:
add_filter( \'domain_exists\', function( $result, $domain, $path ) {
// Already taken, no need for further checks.
if ( $result ) {
return $result;
}
$blacklist = [
\'domains\' => [
\'assets.example.com\',
\'wordpress.example.com\',
],
\'paths\' => [
\'wp-admin\',
\'wp-includes\',
\'wp-content\',
],
];
if ( in_array( $domain, $blacklist[\'domains\'] ) ) {
return 1;
}
$path = trim( $path, \'/\' );
if ( empty ( $path) ) {
return $result;
}
if ( in_array( $path, $blacklist[\'paths\'] ) ) {
return 1;
}
return $result;
}, 10, 3 );