wp/wp-admin/includes/ms.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
--- a/wp/wp-admin/includes/ms.php	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-admin/includes/ms.php	Fri Sep 05 18:40:08 2025 +0200
@@ -8,7 +8,7 @@
  */
 
 /**
- * Determine if uploaded file exceeds space quota.
+ * Determines whether uploaded file exceeds space quota.
  *
  * @since 3.0.0
  *
@@ -53,19 +53,15 @@
 }
 
 /**
- * Delete a site.
+ * Deletes a site.
  *
  * @since 3.0.0
  * @since 5.1.0 Use wp_delete_site() internally to delete the site row from the database.
  *
- * @global wpdb $wpdb WordPress database abstraction object.
- *
  * @param int  $blog_id Site ID.
  * @param bool $drop    True if site's database tables should be dropped. Default false.
  */
 function wpmu_delete_blog( $blog_id, $drop = false ) {
-	global $wpdb;
-
 	$blog_id = (int) $blog_id;
 
 	$switch = false;
@@ -130,16 +126,21 @@
 }
 
 /**
- * Delete a user from the network and remove from all sites.
+ * Deletes a user and all of their posts from the network.
+ *
+ * This function:
+ *
+ * - Deletes all posts (of all post types) authored by the user on all sites on the network
+ * - Deletes all links owned by the user on all sites on the network
+ * - Removes the user from all sites on the network
+ * - Deletes the user from the database
  *
  * @since 3.0.0
  *
- * @todo Merge with wp_delete_user()?
- *
  * @global wpdb $wpdb WordPress database abstraction object.
  *
  * @param int $id The user ID.
- * @return bool True if the user was deleted, otherwise false.
+ * @return bool True if the user was deleted, false otherwise.
  */
 function wpmu_delete_user( $id ) {
 	global $wpdb;
@@ -213,7 +214,7 @@
 }
 
 /**
- * Check whether a site has used its allotted upload space.
+ * Checks whether a site has used its allotted upload space.
  *
  * @since MU (3.0.0)
  *
@@ -269,12 +270,12 @@
 }
 
 /**
- * Get the remaining upload space for this site.
+ * Gets the remaining upload space for this site.
  *
  * @since MU (3.0.0)
  *
- * @param int $size Current max size in bytes
- * @return int Max size in bytes
+ * @param int $size Current max size in bytes.
+ * @return int Max size in bytes.
  */
 function fix_import_form_size( $size ) {
 	if ( upload_is_user_over_quota( false ) ) {
@@ -304,8 +305,15 @@
 	<tr>
 		<th><label for="blog-upload-space-number"><?php _e( 'Site Upload Space Quota' ); ?></label></th>
 		<td>
-			<input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" id="blog-upload-space-number" aria-describedby="blog-upload-space-desc" value="<?php echo $quota; ?>" />
-			<span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e( 'Size in megabytes' ); ?></span> <?php _e( 'MB (Leave blank for network default)' ); ?></span>
+			<input type="number" step="1" min="0" style="width: 100px"
+				name="option[blog_upload_space]" id="blog-upload-space-number"
+				aria-describedby="blog-upload-space-desc" value="<?php echo esc_attr( $quota ); ?>" />
+			<span id="blog-upload-space-desc"><span class="screen-reader-text">
+				<?php
+				/* translators: Hidden accessibility text. */
+				_e( 'Size in megabytes' );
+				?>
+			</span> <?php _e( 'MB (Leave blank for network default)' ); ?></span>
 		</td>
 	</tr>
 	<?php
@@ -544,29 +552,6 @@
 }
 
 /**
- * Synchronizes category and post tag slugs when global terms are enabled.
- *
- * @since 3.0.0
- *
- * @param WP_Term|array $term     The term.
- * @param string        $taxonomy The taxonomy for `$term`. Should be 'category' or 'post_tag', as these are
- *                                the only taxonomies which are processed by this function; anything else
- *                                will be returned untouched.
- * @return WP_Term|array Returns `$term`, after filtering the 'slug' field with `sanitize_title()`
- *                       if `$taxonomy` is 'category' or 'post_tag'.
- */
-function sync_category_tag_slugs( $term, $taxonomy ) {
-	if ( global_terms_enabled() && ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) ) {
-		if ( is_object( $term ) ) {
-			$term->slug = sanitize_title( $term->name );
-		} else {
-			$term['slug'] = sanitize_title( $term['name'] );
-		}
-	}
-	return $term;
-}
-
-/**
  * Displays an access denied message when a user tries to view a site's dashboard they
  * do not have access to.
  *
@@ -709,11 +694,20 @@
 	}
 
 	if ( (int) get_site_option( 'wpmu_upgrade_site' ) !== $wp_db_version ) {
-		echo "<div class='update-nag notice notice-warning inline'>" . sprintf(
+		$upgrade_network_message = sprintf(
 			/* translators: %s: URL to Upgrade Network screen. */
 			__( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ),
 			esc_url( network_admin_url( 'upgrade.php' ) )
-		) . '</div>';
+		);
+
+		wp_admin_notice(
+			$upgrade_network_message,
+			array(
+				'type'               => 'warning',
+				'additional_classes' => array( 'update-nag', 'inline' ),
+				'paragraph_wrap'     => false,
+			)
+		);
 	}
 }
 
@@ -751,7 +745,7 @@
 
 	while ( $c < 10 && get_id_from_blogname( $post_name ) ) {
 		$post_name .= mt_rand( 1, 10 );
-		$c++;
+		++$c;
 	}
 
 	if ( $post_name !== $data['post_name'] ) {
@@ -806,7 +800,7 @@
 				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
 			}
 		} else {
-			echo 'N/A';
+			_e( 'Not available' );
 		}
 		?>
 		</td>
@@ -816,7 +810,7 @@
 }
 
 /**
- * Whether or not we can edit this network from this page.
+ * Determines whether or not this network from this page can be edited.
  *
  * By default editing of network is restricted to the Network Admin for that `$network_id`.
  * This function allows for this to be overridden.
@@ -824,7 +818,7 @@
  * @since 3.1.0
  *
  * @param int $network_id The network ID to check.
- * @return bool True if network can be edited, otherwise false.
+ * @return bool True if network can be edited, false otherwise.
  */
 function can_edit_network( $network_id ) {
 	if ( get_current_network_id() === (int) $network_id ) {
@@ -845,7 +839,7 @@
 }
 
 /**
- * Thickbox image paths for Network Admin.
+ * Prints thickbox image paths for Network Admin.
  *
  * @since 3.1.0
  *
@@ -861,6 +855,7 @@
 
 /**
  * @param array $users
+ * @return bool
  */
 function confirm_delete_users( $users ) {
 	$current_user = wp_get_current_user();
@@ -938,8 +933,11 @@
 					);
 
 					if ( is_array( $blog_users ) && ! empty( $blog_users ) ) {
-						$user_site      = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
-						$user_dropdown  = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>';
+						$user_site     = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
+						$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' .
+								/* translators: Hidden accessibility text. */
+								__( 'Select a user' ) .
+							'</label>';
 						$user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>";
 						$user_list      = '';
 
@@ -1004,7 +1002,7 @@
 }
 
 /**
- * Print JavaScript in the header on the Network Settings screen.
+ * Prints JavaScript in the header on the Network Settings screen.
  *
  * @since 4.1.0
  */
@@ -1014,8 +1012,10 @@
 jQuery( function($) {
 	var languageSelect = $( '#WPLANG' );
 	$( 'form' ).on( 'submit', function() {
-		// Don't show a spinner for English and installed languages,
-		// as there is nothing to download.
+		/*
+		 * Don't show a spinner for English and installed languages,
+		 * as there is nothing to download.
+		 */
 		if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
 			$( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' );
 		}
@@ -1169,6 +1169,6 @@
  */
 function get_site_screen_help_sidebar_content() {
 	return '<p><strong>' . __( 'For more information:' ) . '</strong></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>';
+		'<p>' . __( '<a href="https://developer.wordpress.org/advanced-administration/multisite/admin/#network-admin-sites-screen">Documentation on Site Management</a>' ) . '</p>' .
+		'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support forums</a>' ) . '</p>';
 }