--- a/wp/wp-admin/includes/ms.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/includes/ms.php Tue Dec 15 13:49:49 2020 +0100
@@ -20,7 +20,7 @@
return $file;
}
- if ( $file['error'] != '0' ) { // there's already an error
+ if ( '0' != $file['error'] ) { // There's already an error.
return $file;
}
@@ -32,12 +32,12 @@
$file_size = filesize( $file['tmp_name'] );
if ( $space_left < $file_size ) {
- /* translators: %s: required disk space in kilobytes */
+ /* translators: %s: Required disk space in kilobytes. */
$file['error'] = sprintf( __( 'Not enough space to upload. %s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) );
}
if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
- /* translators: %s: maximum allowed file size in kilobytes */
+ /* translators: %s: Maximum allowed file size in kilobytes. */
$file['error'] = sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) );
}
@@ -45,7 +45,7 @@
$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
}
- if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
+ if ( '0' != $file['error'] && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
}
@@ -61,7 +61,7 @@
* @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 is false.
+ * @param bool $drop True if site's database tables should be dropped. Default false.
*/
function wpmu_delete_blog( $blog_id, $drop = false ) {
global $wpdb;
@@ -129,7 +129,7 @@
*
* @since 3.0.0
*
- * @todo Merge with wp_delete_user() ?
+ * @todo Merge with wp_delete_user()?
*
* @global wpdb $wpdb WordPress database abstraction object.
*
@@ -160,10 +160,12 @@
* Fires before a user is deleted from the network.
*
* @since MU (3.0.0)
+ * @since 5.5.0 Added the `$user` parameter.
*
- * @param int $id ID of the user about to be deleted from the network.
+ * @param int $id ID of the user about to be deleted from the network.
+ * @param WP_User $user WP_User object of the user about to be deleted from the network.
*/
- do_action( 'wpmu_delete_user', $id );
+ do_action( 'wpmu_delete_user', $id, $user );
$blogs = get_blogs_of_user( $id );
@@ -177,7 +179,7 @@
wp_delete_post( $post_id );
}
- // Clean links
+ // Clean links.
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
if ( $link_ids ) {
@@ -200,7 +202,7 @@
clean_user_cache( $user );
/** This action is documented in wp-admin/includes/user.php */
- do_action( 'deleted_user', $id, null );
+ do_action( 'deleted_user', $id, null, $user );
return true;
}
@@ -220,14 +222,14 @@
$space_allowed = get_space_allowed();
if ( ! is_numeric( $space_allowed ) ) {
- $space_allowed = 10; // Default space allowed is 10 MB
+ $space_allowed = 10; // Default space allowed is 10 MB.
}
$space_used = get_space_used();
if ( ( $space_allowed - $space_used ) < 0 ) {
if ( $echo ) {
printf(
- /* translators: %s: allowed space allocation */
+ /* translators: %s: Allowed space allocation. */
__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
size_format( $space_allowed * MB_IN_BYTES )
);
@@ -249,19 +251,11 @@
$percent_used = ( $space_used / $space_allowed ) * 100;
- if ( $space_allowed > 1000 ) {
- $space = number_format( $space_allowed / KB_IN_BYTES );
- /* translators: Gigabytes */
- $space .= __( 'GB' );
- } else {
- $space = number_format( $space_allowed );
- /* translators: Megabytes */
- $space .= __( 'MB' );
- }
+ $space = size_format( $space_allowed * MB_IN_BYTES );
?>
<strong>
<?php
- /* translators: Storage space that's been used. 1: Percentage of used space, 2: Total space allowed in megabytes or gigabytes */
+ /* translators: Storage space that's been used. 1: Percentage of used space, 2: Total space allowed in megabytes or gigabytes. */
printf( __( 'Used: %1$s%% of %2$s' ), number_format( $percent_used ), $space );
?>
</strong>
@@ -312,59 +306,6 @@
}
/**
- * Update the status of a user in the database.
- *
- * Used in core to mark a user as spam or "ham" (not spam) in Multisite.
- *
- * @since 3.0.0
- *
- * @global wpdb $wpdb WordPress database abstraction object.
- *
- * @param int $id The user ID.
- * @param string $pref The column in the wp_users table to update the user's status
- * in (presumably user_status, spam, or deleted).
- * @param int $value The new status for the user.
- * @param null $deprecated Deprecated as of 3.0.2 and should not be used.
- * @return int The initially passed $value.
- */
-function update_user_status( $id, $pref, $value, $deprecated = null ) {
- global $wpdb;
-
- if ( null !== $deprecated ) {
- _deprecated_argument( __FUNCTION__, '3.0.2' );
- }
-
- $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
-
- $user = new WP_User( $id );
- clean_user_cache( $user );
-
- if ( $pref == 'spam' ) {
- if ( $value == 1 ) {
- /**
- * Fires after the user is marked as a SPAM user.
- *
- * @since 3.0.0
- *
- * @param int $id ID of the user marked as SPAM.
- */
- do_action( 'make_spam_user', $id );
- } else {
- /**
- * Fires after the user is marked as a HAM user. Opposite of SPAM.
- *
- * @since 3.0.0
- *
- * @param int $id ID of the user marked as HAM.
- */
- do_action( 'make_ham_user', $id );
- }
- }
-
- return $value;
-}
-
-/**
* Cleans the user cache for a specific user.
*
* @since 3.0.0
@@ -375,7 +316,8 @@
function refresh_user_details( $id ) {
$id = (int) $id;
- if ( ! $user = get_userdata( $id ) ) {
+ $user = get_userdata( $id );
+ if ( ! $user ) {
return false;
}
@@ -608,7 +550,7 @@
* if `$taxonomy` is 'category' or 'post_tag'.
*/
function sync_category_tag_slugs( $term, $taxonomy ) {
- if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
+ if ( global_terms_enabled() && ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) ) {
if ( is_object( $term ) ) {
$term->slug = sanitize_title( $term->name );
} else {
@@ -639,10 +581,21 @@
$blog_name = get_bloginfo( 'name' );
if ( empty( $blogs ) ) {
- wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
+ wp_die(
+ sprintf(
+ /* translators: 1: Site title. */
+ __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ),
+ $blog_name
+ ),
+ 403
+ );
}
- $output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
+ $output = '<p>' . sprintf(
+ /* translators: 1: Site title. */
+ __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ),
+ $blog_name
+ ) . '</p>';
$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
$output .= '<h3>' . __( 'Your Sites' ) . '</h3>';
@@ -693,11 +646,11 @@
foreach ( (array) $lang_files as $val ) {
$code_lang = basename( $val, '.mo' );
- if ( $code_lang == 'en_US' ) { // American English
+ if ( 'en_US' === $code_lang ) { // American English.
$flag = true;
$ae = __( 'American English' );
$output[ $ae ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
- } elseif ( $code_lang == 'en_GB' ) { // British English
+ } elseif ( 'en_GB' === $code_lang ) { // British English.
$flag = true;
$be = __( 'British English' );
$output[ $be ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
@@ -707,11 +660,11 @@
}
}
- if ( $flag === false ) { // WordPress english
+ if ( false === $flag ) { // WordPress English.
$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . '</option>';
}
- // Order by name
+ // Order by name.
uksort( $output, 'strnatcasecmp' );
/**
@@ -733,7 +686,7 @@
*
* @since 3.0.0
*
- * @global int $wp_db_version The version number of the database.
+ * @global int $wp_db_version WordPress database version.
* @global string $pagenow
*
* @return false False if the current user is not a super admin.
@@ -745,12 +698,16 @@
return false;
}
- if ( 'upgrade.php' == $pagenow ) {
+ if ( 'upgrade.php' === $pagenow ) {
return;
}
if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) {
- echo "<div class='update-nag'>" . sprintf( __( '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>';
+ echo "<div class='update-nag notice notice-warning inline'>" . 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>';
}
}
@@ -770,10 +727,10 @@
if ( is_subdomain_install() ) {
return $data;
}
- if ( $data['post_type'] != 'page' ) {
+ if ( 'page' !== $data['post_type'] ) {
return $data;
}
- if ( ! isset( $data['post_name'] ) || $data['post_name'] == '' ) {
+ if ( ! isset( $data['post_name'] ) || '' === $data['post_name'] ) {
return $data;
}
if ( ! is_main_site() ) {
@@ -804,7 +761,7 @@
?>
<table class="form-table" role="presentation">
<tr>
- <?php /* translators: My sites label */ ?>
+ <?php /* translators: My Sites label. */ ?>
<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th>
<td>
<?php
@@ -858,7 +815,7 @@
* @return bool True if network can be edited, otherwise false.
*/
function can_edit_network( $network_id ) {
- if ( $network_id == get_current_network_id() ) {
+ if ( get_current_network_id() == $network_id ) {
$result = true;
} else {
$result = false;
@@ -901,7 +858,7 @@
?>
<h1><?php esc_html_e( 'Users' ); ?></h1>
- <?php if ( 1 == count( $users ) ) : ?>
+ <?php if ( 1 === count( $users ) ) : ?>
<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
<?php else : ?>
<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
@@ -916,16 +873,29 @@
?>
<table class="form-table" role="presentation">
<?php
- foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) {
- if ( $user_id != '' && $user_id != '0' ) {
+ $allusers = (array) $_POST['allusers'];
+ foreach ( $allusers as $user_id ) {
+ if ( '' !== $user_id && '0' != $user_id ) {
$delete_user = get_userdata( $user_id );
if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) {
- wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) );
+ wp_die(
+ sprintf(
+ /* translators: %s: User login. */
+ __( 'Warning! User %s cannot be deleted.' ),
+ $delete_user->user_login
+ )
+ );
}
- if ( in_array( $delete_user->user_login, $site_admins ) ) {
- wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '<em>' . $delete_user->user_login . '</em>' ) );
+ if ( in_array( $delete_user->user_login, $site_admins, true ) ) {
+ wp_die(
+ sprintf(
+ /* translators: %s: User login. */
+ __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ),
+ '<em>' . $delete_user->user_login . '</em>'
+ )
+ );
}
?>
<tr>
@@ -940,7 +910,7 @@
<td><fieldset><p><legend>
<?php
printf(
- /* translators: user login */
+ /* translators: %s: User login. */
__( 'What should be done with content owned by %s?' ),
'<em>' . $delete_user->user_login . '</em>'
);
@@ -954,24 +924,33 @@
'fields' => array( 'ID', 'user_login' ),
)
);
+
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_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>";
$user_list = '';
+
foreach ( $blog_users as $user ) {
- if ( ! in_array( $user->ID, $allusers ) ) {
+ if ( ! in_array( (int) $user->ID, $allusers, true ) ) {
$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
}
}
- if ( '' == $user_list ) {
+
+ if ( '' === $user_list ) {
$user_list = $admin_out;
}
+
$user_dropdown .= $user_list;
$user_dropdown .= "</select>\n";
?>
<ul style="list-style:none;">
- <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
+ <li>
+ <?php
+ /* translators: %s: Link to user's site. */
+ printf( __( 'Site: %s' ), $user_site );
+ ?>
+ </li>
<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID; ?>]" value="delete" checked="checked" />
<?php _e( 'Delete all content.' ); ?></label></li>
<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID; ?>]" value="reassign" />
@@ -997,7 +976,7 @@
/** This action is documented in wp-admin/users.php */
do_action( 'delete_user_form', $current_user, $allusers );
- if ( 1 == count( $users ) ) :
+ if ( 1 === count( $users ) ) :
?>
<p><?php _e( 'Once you hit “Confirm Deletion”, the user will be permanently removed.' ); ?></p>
<?php else : ?>
@@ -1039,7 +1018,7 @@
*
* @since 4.6.0
*
- * @param $args {
+ * @param array $args {
* Optional. Array or string of Query parameters. Default empty array.
*
* @type int $blog_id The site ID. Default is the current site.
@@ -1094,8 +1073,8 @@
)
);
- // Parse arguments
- $r = wp_parse_args(
+ // Parse arguments.
+ $parsed_args = wp_parse_args(
$args,
array(
'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
@@ -1104,36 +1083,36 @@
)
);
- // Setup the links array
+ // Setup the links array.
$screen_links = array();
- // Loop through tabs
- foreach ( $r['links'] as $link_id => $link ) {
+ // Loop through tabs.
+ foreach ( $parsed_args['links'] as $link_id => $link ) {
- // Skip link if user can't access
- if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) {
+ // Skip link if user can't access.
+ if ( ! current_user_can( $link['cap'], $parsed_args['blog_id'] ) ) {
continue;
}
- // Link classes
+ // Link classes.
$classes = array( 'nav-tab' );
// Aria-current attribute.
$aria_current = '';
- // Selected is set by the parent OR assumed by the $pagenow global
- if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
+ // Selected is set by the parent OR assumed by the $pagenow global.
+ if ( $parsed_args['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
$classes[] = 'nav-tab-active';
$aria_current = ' aria-current="page"';
}
- // Escape each class
+ // Escape each class.
$esc_classes = implode( ' ', $classes );
- // Get the URL for this link
- $url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
+ // Get the URL for this link.
+ $url = add_query_arg( array( 'id' => $parsed_args['blog_id'] ), network_admin_url( $link['url'] ) );
- // Add link to nav links
+ // Add link to nav links.
$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '"' . $aria_current . '>' . esc_html( $link['label'] ) . '</a>';
}
@@ -1158,7 +1137,11 @@
'<p>' . __( 'The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.' ) . '</p>' .
'<p>' . __( '<strong>Info</strong> — The site URL is rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.' ) . '</p>' .
'<p>' . __( '<strong>Users</strong> — This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.' ) . '</p>' .
- '<p>' . sprintf( __( '<strong>Themes</strong> — This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
+ '<p>' . sprintf(
+ /* translators: %s: URL to Network Themes screen. */
+ __( '<strong>Themes</strong> — This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ),
+ network_admin_url( 'themes.php' )
+ ) . '</p>' .
'<p>' . __( '<strong>Settings</strong> — This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.' ) . '</p>',
);
}
@@ -1172,6 +1155,6 @@
*/
function get_site_screen_help_sidebar_content() {
return '<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>';
}