diff -r c7c34916027a -r 177826044cd9 wp/wp-admin/includes/ms.php --- a/wp/wp-admin/includes/ms.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-admin/includes/ms.php Mon Oct 14 18:28:13 2019 +0200 @@ -16,26 +16,29 @@ * @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise. */ function check_upload_size( $file ) { - if ( get_site_option( 'upload_space_check_disabled' ) ) + if ( get_site_option( 'upload_space_check_disabled' ) ) { return $file; + } - if ( $file['error'] != '0' ) // there's already an error + if ( $file['error'] != '0' ) { // there's already an error return $file; + } - if ( defined( 'WP_IMPORTING' ) ) + if ( defined( 'WP_IMPORTING' ) ) { return $file; + } $space_left = get_upload_space_available(); $file_size = filesize( $file['tmp_name'] ); if ( $space_left < $file_size ) { - /* translators: 1: Required disk space in kilobytes */ - $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) ); + /* 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: 1: Maximum allowed file size in kilobytes */ - $file['error'] = sprintf( __( 'This file is too big. Files must be less than %1$s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) ); + /* 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 ) ); } if ( upload_is_user_over_quota( false ) ) { @@ -53,6 +56,7 @@ * Delete 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. * @@ -69,26 +73,6 @@ } $blog = get_site( $blog_id ); - /** - * Fires before a site is deleted. - * - * @since MU (3.0.0) - * - * @param int $blog_id The site ID. - * @param bool $drop True if site's table should be dropped. Default is false. - */ - do_action( 'delete_blog', $blog_id, $drop ); - - $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) ); - - // Remove users from this blog. - if ( ! empty( $users ) ) { - foreach ( $users as $user_id ) { - remove_user_from_blog( $user_id, $blog_id ); - } - } - - update_blog_status( $blog_id, 'deleted', 1 ); $current_network = get_network(); @@ -110,81 +94,34 @@ } if ( $drop ) { - $uploads = wp_get_upload_dir(); + wp_delete_site( $blog_id ); + } else { + /** This action is documented in wp-includes/ms-blogs.php */ + do_action_deprecated( 'delete_blog', array( $blog_id, false ), '5.1.0' ); - $tables = $wpdb->tables( 'blog' ); - /** - * Filters the tables to drop when the site is deleted. - * - * @since MU (3.0.0) - * - * @param array $tables The site tables to be dropped. - * @param int $blog_id The ID of the site to drop tables for. - */ - $drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $blog_id ); + $users = get_users( + array( + 'blog_id' => $blog_id, + 'fields' => 'ids', + ) + ); - foreach ( (array) $drop_tables as $table ) { - $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); + // Remove users from this blog. + if ( ! empty( $users ) ) { + foreach ( $users as $user_id ) { + remove_user_from_blog( $user_id, $blog_id ); + } } - $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) ); - - /** - * Filters the upload base directory to delete when the site is deleted. - * - * @since MU (3.0.0) - * - * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir() - * @param int $blog_id The site ID. - */ - $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id ); - $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); - $top_dir = $dir; - $stack = array($dir); - $index = 0; - - while ( $index < count( $stack ) ) { - // Get indexed directory from stack - $dir = $stack[$index]; + update_blog_status( $blog_id, 'deleted', 1 ); - $dh = @opendir( $dir ); - if ( $dh ) { - while ( ( $file = @readdir( $dh ) ) !== false ) { - if ( $file == '.' || $file == '..' ) - continue; - - if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) { - $stack[] = $dir . DIRECTORY_SEPARATOR . $file; - } elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) { - @unlink( $dir . DIRECTORY_SEPARATOR . $file ); - } - } - @closedir( $dh ); - } - $index++; - } - - $stack = array_reverse( $stack ); // Last added dirs are deepest - foreach ( (array) $stack as $dir ) { - if ( $dir != $top_dir) - @rmdir( $dir ); - } - - clean_blog_cache( $blog ); + /** This action is documented in wp-includes/ms-blogs.php */ + do_action_deprecated( 'deleted_blog', array( $blog_id, false ), '5.1.0' ); } - /** - * Fires after the site is deleted from the network. - * - * @since 4.8.0 - * - * @param int $blog_id The site ID. - * @param bool $drop True if site's tables should be dropped. Default is false. - */ - do_action( 'deleted_blog', $blog_id, $drop ); - - if ( $switch ) + if ( $switch ) { restore_current_blog(); + } } /** @@ -206,11 +143,12 @@ return false; } - $id = (int) $id; + $id = (int) $id; $user = new WP_User( $id ); - if ( !$user->exists() ) + if ( ! $user->exists() ) { return false; + } // Global super-administrators are protected, and cannot be deleted. $_super_admins = get_super_admins(); @@ -243,8 +181,9 @@ $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) ); if ( $link_ids ) { - foreach ( $link_ids as $link_id ) + foreach ( $link_ids as $link_id ) { wp_delete_link( $link_id ); + } } restore_current_blog(); @@ -252,8 +191,9 @@ } $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); - foreach ( $meta as $mid ) + foreach ( $meta as $mid ) { delete_metadata_by_mid( 'user', $mid ); + } $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); @@ -274,8 +214,9 @@ * @return bool True if user is over upload space quota, otherwise false. */ function upload_is_user_over_quota( $echo = true ) { - if ( get_site_option( 'upload_space_check_disabled' ) ) + if ( get_site_option( 'upload_space_check_disabled' ) ) { return false; + } $space_allowed = get_space_allowed(); if ( ! is_numeric( $space_allowed ) ) { @@ -284,8 +225,13 @@ $space_used = get_space_used(); if ( ( $space_allowed - $space_used ) < 0 ) { - if ( $echo ) - _e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' ); + if ( $echo ) { + printf( + /* 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 ) + ); + } return true; } else { return false; @@ -299,7 +245,7 @@ */ function display_space_usage() { $space_allowed = get_space_allowed(); - $space_used = get_space_used(); + $space_used = get_space_used(); $percent_used = ( $space_used / $space_allowed ) * 100; @@ -313,10 +259,12 @@ $space .= __( 'MB' ); } ?> - + + ?> +
' . 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( __( '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 .= '{$blog->blogname} | "; $output .= '' . __( 'Visit Dashboard' ) . ' | ' . - '' . __( 'View Site' ) . ' | '; + '' . __( 'View Site' ) . ''; $output .= '
1 ) { $found = false; ?> userblog_id ); } } elseif ( count( $all_blogs ) == 1 ) { $blog = reset( $all_blogs ); echo esc_url( get_home_url( $blog->userblog_id ) ); - if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list. + if ( $primary_blog != $blog->userblog_id ) { // Set the primary blog again if it's out of sync with blog list. update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id ); + } } else { - echo "N/A"; + echo 'N/A'; } ?> | @@ -719,10 +858,11 @@ * @return bool True if network can be edited, otherwise false. */ function can_edit_network( $network_id ) { - if ( $network_id == get_current_network_id() ) + if ( $network_id == get_current_network_id() ) { $result = true; - else + } else { $result = false; + } /** * Filters whether this network can be edited from this page. @@ -743,15 +883,14 @@ * @access private */ function _thickbox_path_admin_subfolder() { -?> + ?> -ID ) . '">' . $current_user->user_login . ''; ?> -
"; + echo ''; } else { ?> - |
-
+ if ( 1 == count( $users ) ) :
+ ?>
-
+ ?>
- array( 'label' => __( 'Info' ), 'url' => 'site-info.php', 'cap' => 'manage_sites' ),
- 'site-users' => array( 'label' => __( 'Users' ), 'url' => 'site-users.php', 'cap' => 'manage_sites' ),
- 'site-themes' => array( 'label' => __( 'Themes' ), 'url' => 'site-themes.php', 'cap' => 'manage_sites' ),
- 'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php', 'cap' => 'manage_sites' )
- ) );
+ $links = apply_filters(
+ 'network_edit_site_nav_links',
+ array(
+ 'site-info' => array(
+ 'label' => __( 'Info' ),
+ 'url' => 'site-info.php',
+ 'cap' => 'manage_sites',
+ ),
+ 'site-users' => array(
+ 'label' => __( 'Users' ),
+ 'url' => 'site-users.php',
+ 'cap' => 'manage_sites',
+ ),
+ 'site-themes' => array(
+ 'label' => __( 'Themes' ),
+ 'url' => 'site-themes.php',
+ 'cap' => 'manage_sites',
+ ),
+ 'site-settings' => array(
+ 'label' => __( 'Settings' ),
+ 'url' => 'site-settings.php',
+ 'cap' => 'manage_sites',
+ ),
+ )
+ );
// Parse arguments
- $r = wp_parse_args( $args, array(
- 'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
- 'links' => $links,
- 'selected' => 'site-info',
- ) );
+ $r = wp_parse_args(
+ $args,
+ array(
+ 'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
+ 'links' => $links,
+ 'selected' => 'site-info',
+ )
+ );
// Setup the links array
$screen_links = array();
@@ -943,9 +1118,13 @@
// 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'] ) {
- $classes[] = 'nav-tab-active';
+ $classes[] = 'nav-tab-active';
+ $aria_current = ' aria-current="page"';
}
// Escape each class
@@ -955,13 +1134,13 @@
$url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
// Add link to nav links
- $screen_links[ $link_id ] = '' . esc_html( $link['label'] ) . '';
+ $screen_links[ $link_id ] = '' . esc_html( $link['label'] ) . '';
}
// All done!
- echo ' | '; + echo ''; + echo ''; } /** @@ -974,13 +1153,13 @@ function get_site_screen_help_tab_args() { return array( 'id' => 'overview', - 'title' => __('Overview'), + 'title' => __( 'Overview' ), 'content' => - '' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . ' ' . - '' . __('Info — 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.') . ' ' . - '' . __('Users — 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.') . ' ' . - '' . sprintf( __('Themes — 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 Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . ' ' . - '' . __('Settings — 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.') . ' ' + '' . __( 'The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.' ) . ' ' . + '' . __( 'Info — 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.' ) . ' ' . + '' . __( 'Users — 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.' ) . ' ' . + '' . sprintf( __( 'Themes — 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 Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . ' ' . + '' . __( 'Settings — 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.' ) . ' ', ); } @@ -992,7 +1171,7 @@ * @return string Help sidebar content. */ function get_site_screen_help_sidebar_content() { - return '' . __('For more information:') . ' ' . - '' . __('Documentation on Site Management') . ' ' . - '' . __('Support Forums') . ' '; + return '' . __( 'For more information:' ) . ' ' . + '' . __( 'Documentation on Site Management' ) . ' ' . + '' . __( 'Support Forums' ) . ' '; } |