wp/wp-admin/network/site-new.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- 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(
 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
-	'<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>' ) . '</p>' .
+	'<p>' . __( '<a href="https://wordpress.org/support/article/network-admin-sites-screen/">Documentation on Site Management</a>' ) . '</p>' .
 	'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>'
 );
 
-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' ),
 					'<code>' . implode( '</code>, <code>', $subdirectory_reserved_names ) . '</code>'
 				)
@@ -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. <a href="%1$s">Visit Dashboard</a> or <a href="%2$s">Edit Site</a>' ),
 			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 @@
 <p>
 <?php
 printf(
-	/* translators: %s: asterisk to mark required form fields. */
+	/* translators: %s: Asterisk symbol (*). */
 	__( 'Required fields are marked %s' ),
 	'<span class="required">*</span>'
 );
@@ -229,12 +232,12 @@
 			<th scope="row"><label for="site-address"><?php _e( 'Site Address (URL)' ); ?> <span class="required">*</span></label></th>
 			<td>
 			<?php if ( is_subdomain_install() ) { ?>
-				<input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" required /><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', get_network()->domain ); ?></span>
+				<input name="blog[domain]" type="text" class="regular-text ltr" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" required /><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', get_network()->domain ); ?></span>
 				<?php
 			} else {
 				echo get_network()->domain . get_network()->path
 				?>
-				<input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" required />
+				<input name="blog[domain]" type="text" class="regular-text ltr" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" required />
 				<?php
 			}
 			echo '<p class="description" id="site-address-desc">' . __( 'Only lowercase letters (a-z), numbers, and hyphens are allowed.' ) . '</p>';
@@ -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 @@
 	</form>
 </div>
 <?php
-require( ABSPATH . 'wp-admin/admin-footer.php' );
+require_once ABSPATH . 'wp-admin/admin-footer.php';