diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/network/site-new.php --- a/wp/wp-admin/network/site-new.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/network/site-new.php Tue Dec 15 13:49:49 2020 +0100 @@ -8,10 +8,10 @@ */ /** Load WordPress Administration Bootstrap */ -require_once( dirname( __FILE__ ) . '/admin.php' ); +require_once __DIR__ . '/admin.php'; /** WordPress Translation Installation API */ -require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); +require_once ABSPATH . 'wp-admin/includes/translation-install.php'; if ( ! current_user_can( 'create_sites' ) ) { wp_die( __( 'Sorry, you are not allowed to add sites to this network.' ) ); @@ -29,11 +29,11 @@ get_current_screen()->set_help_sidebar( '

' . __( 'For more information:' ) . '

' . - '

' . __( 'Documentation on Site Management' ) . '

' . + '

' . __( 'Documentation on Site Management' ) . '

' . '

' . __( 'Support Forums' ) . '

' ); -if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) { +if ( isset( $_REQUEST['action'] ) && 'add-site' === $_REQUEST['action'] ) { check_admin_referer( 'add-blog', '_wpnonce_add-blog' ); if ( ! is_array( $_POST['blog'] ) ) { @@ -42,18 +42,20 @@ $blog = $_POST['blog']; $domain = ''; + + $blog['domain'] = trim( $blog['domain'] ); if ( preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) { $domain = strtolower( $blog['domain'] ); } - // If not a subdomain installation, make sure the domain isn't a reserved word + // If not a subdomain installation, make sure the domain isn't a reserved word. if ( ! is_subdomain_install() ) { $subdirectory_reserved_names = get_subdirectory_reserved_names(); - if ( in_array( $domain, $subdirectory_reserved_names ) ) { + if ( in_array( $domain, $subdirectory_reserved_names, true ) ) { wp_die( - /* translators: %s: reserved names list */ sprintf( + /* translators: %s: Reserved names list. */ __( 'The following words are reserved for use by WordPress functions and cannot be used as blog names: %s' ), '' . implode( ', ', $subdirectory_reserved_names ) . '' ) @@ -71,7 +73,7 @@ if ( isset( $_POST['WPLANG'] ) ) { if ( '' === $_POST['WPLANG'] ) { $meta['WPLANG'] = ''; // en_US - } elseif ( in_array( $_POST['WPLANG'], get_available_languages() ) ) { + } elseif ( in_array( $_POST['WPLANG'], get_available_languages(), true ) ) { $meta['WPLANG'] = $_POST['WPLANG']; } elseif ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) { $language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) ); @@ -104,7 +106,7 @@ $password = 'N/A'; $user_id = email_exists( $email ); - if ( ! $user_id ) { // Create a new user with a random password + if ( ! $user_id ) { // Create a new user with a random password. /** * Fires immediately before a new user is created via the network site-new.php page. * @@ -137,6 +139,7 @@ $wpdb->hide_errors(); $id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, get_current_network_id() ); $wpdb->show_errors(); + if ( ! is_wp_error( $id ) ) { if ( ! is_super_admin( $user_id ) && ! get_user_option( 'primary_blog', $user_id ) ) { update_user_option( $user_id, 'primary_blog', $id, true ); @@ -145,12 +148,12 @@ wp_mail( get_site_option( 'admin_email' ), sprintf( - /* translators: %s: network name */ + /* translators: New site notification email subject. %s: Network title. */ __( '[%s] New Site Created' ), get_network()->site_name ), sprintf( - /* translators: 1: user login, 2: site url, 3: site name/title */ + /* translators: New site notification email. 1: User login, 2: Site URL, 3: Site title. */ __( 'New site created by %1$s @@ -185,9 +188,9 @@ if ( isset( $_GET['update'] ) ) { $messages = array(); - if ( 'added' == $_GET['update'] ) { + if ( 'added' === $_GET['update'] ) { $messages[] = sprintf( - /* translators: 1: dashboard url, 2: network admin edit url */ + /* translators: 1: Dashboard URL, 2: Network admin edit URL. */ __( 'Site added. Visit Dashboard or Edit Site' ), esc_url( get_admin_url( absint( $_GET['id'] ) ) ), network_admin_url( 'site-info.php?id=' . absint( $_GET['id'] ) ) @@ -200,7 +203,7 @@ wp_enqueue_script( 'user-suggest' ); -require( ABSPATH . 'wp-admin/admin-header.php' ); +require_once ABSPATH . 'wp-admin/admin-header.php'; ?> @@ -216,7 +219,7 @@

*' ); @@ -229,12 +232,12 @@ - .domain ); ?> + .domain ); ?> domain . get_network()->path ?> - + ' . __( 'Only lowercase letters (a-z), numbers, and hyphens are allowed.' ) . '

'; @@ -258,7 +261,7 @@ $lang = get_site_option( 'WPLANG' ); // Use English if the default isn't available. - if ( ! in_array( $lang, $languages ) ) { + if ( ! in_array( $lang, $languages, true ) ) { $lang = ''; } @@ -298,4 +301,4 @@