diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/ms.php --- 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'] . ' ' . __( 'Back' ) . '' ); } @@ -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 ); ?> @@ -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 = '

' . 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 ) . '

'; + $output = '

' . 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 + ) . '

'; $output .= '

' . __( '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.' ) . '

'; $output .= '

' . __( 'Your Sites' ) . '

'; @@ -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 ] = ''; - } elseif ( $code_lang == 'en_GB' ) { // British English + } elseif ( 'en_GB' === $code_lang ) { // British English. $flag = true; $be = __( 'British English' ); $output[ $be ] = ''; @@ -707,11 +660,11 @@ } } - if ( $flag === false ) { // WordPress english + if ( false === $flag ) { // WordPress English. $output[] = ''; } - // 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 "
" . sprintf( __( 'Thank you for Updating! Please visit the Upgrade Network page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . '
'; + echo "
" . sprintf( + /* translators: %s: URL to Upgrade Network screen. */ + __( 'Thank you for Updating! Please visit the Upgrade Network page to update all your sites.' ), + esc_url( network_admin_url( 'upgrade.php' ) ) + ) . '
'; } } @@ -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 @@ ?> - +