@@ -424,8 +424,7 @@ public function create( $args, $assoc_args ) {
424
424
425
425
// If not a subdomain install, make sure the domain isn't a reserved word
426
426
if ( ! is_subdomain_install () ) {
427
- // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Calling WordPress native hook.
428
- $ subdirectory_reserved_names = apply_filters ( 'subdirectory_reserved_names ' , [ 'page ' , 'comments ' , 'blog ' , 'files ' , 'feed ' ] );
427
+ $ subdirectory_reserved_names = $ this ->get_subdirectory_reserved_names ();
429
428
if ( in_array ( $ base , $ subdirectory_reserved_names , true ) ) {
430
429
WP_CLI ::error ( 'The following words are reserved and cannot be used as blog names: ' . implode ( ', ' , $ subdirectory_reserved_names ) );
431
430
}
@@ -552,7 +551,7 @@ public function generate( $args, $assoc_args ) {
552
551
$ is_subdomain_install = is_subdomain_install ();
553
552
// If not a subdomain install, make sure the domain isn't a reserved word
554
553
if ( ! $ is_subdomain_install ) {
555
- $ subdirectory_reserved_names = get_subdirectory_reserved_names ();
554
+ $ subdirectory_reserved_names = $ this -> get_subdirectory_reserved_names ();
556
555
if ( in_array ( $ base , $ subdirectory_reserved_names , true ) ) {
557
556
WP_CLI ::error ( 'The following words are reserved and cannot be used as blog names: ' . implode ( ', ' , $ subdirectory_reserved_names ) );
558
557
}
@@ -646,6 +645,35 @@ public function generate( $args, $assoc_args ) {
646
645
}
647
646
}
648
647
648
+ /**
649
+ * Retrieves a list of reserved site on a sub-directory Multisite installation.
650
+ *
651
+ * Works on older WordPress versions where get_subdirectory_reserved_names() does not exist.
652
+ *
653
+ * @return string[] Array of reserved names.
654
+ */
655
+ private function get_subdirectory_reserved_names () {
656
+ if ( function_exists ( 'get_subdirectory_reserved_names ' ) ) {
657
+ return get_subdirectory_reserved_names ();
658
+ }
659
+
660
+ $ names = array (
661
+ 'page ' ,
662
+ 'comments ' ,
663
+ 'blog ' ,
664
+ 'files ' ,
665
+ 'feed ' ,
666
+ 'wp-admin ' ,
667
+ 'wp-content ' ,
668
+ 'wp-includes ' ,
669
+ 'wp-json ' ,
670
+ 'embed ' ,
671
+ );
672
+
673
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Calling WordPress native hook.
674
+ return apply_filters ( 'subdirectory_reserved_names ' , $ names );
675
+ }
676
+
649
677
/**
650
678
* Gets network data for a given id.
651
679
*
0 commit comments