~canonical-sysadmins/wordpress/4.6.1

« back to all changes in this revision

Viewing changes to wp-admin/includes/ms.php

  • Committer: Nick Moffitt
  • Date: 2016-04-14 10:44:19 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: nick.moffitt@canonical.com-20160414104419-w6lxcr3ru4enc2w5
Merge WP4.5 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
}
49
49
 
50
50
/**
51
 
 * Delete a blog.
 
51
 * Delete a site.
52
52
 *
53
53
 * @since 3.0.0
54
54
 *
55
55
 * @global wpdb $wpdb WordPress database abstraction object.
56
56
 *
57
 
 * @param int  $blog_id Blog ID.
58
 
 * @param bool $drop    True if blog's table should be dropped. Default is false.
 
57
 * @param int  $blog_id Site ID.
 
58
 * @param bool $drop    True if site's database tables should be dropped. Default is false.
59
59
 */
60
60
function wpmu_delete_blog( $blog_id, $drop = false ) {
61
61
        global $wpdb;
68
68
 
69
69
        $blog = get_blog_details( $blog_id );
70
70
        /**
71
 
         * Fires before a blog is deleted.
 
71
         * Fires before a site is deleted.
72
72
         *
73
73
         * @since MU
74
74
         *
75
 
         * @param int  $blog_id The blog ID.
76
 
         * @param bool $drop    True if blog's table should be dropped. Default is false.
 
75
         * @param int  $blog_id The site ID.
 
76
         * @param bool $drop    True if site's table should be dropped. Default is false.
77
77
         */
78
78
        do_action( 'delete_blog', $blog_id, $drop );
79
79
 
108
108
        }
109
109
 
110
110
        if ( $drop ) {
111
 
                $uploads = wp_upload_dir();
 
111
                $uploads = wp_get_upload_dir();
112
112
 
113
113
                $tables = $wpdb->tables( 'blog' );
114
114
                /**
115
 
                 * Filter the tables to drop when the blog is deleted.
 
115
                 * Filter the tables to drop when the site is deleted.
116
116
                 *
117
117
                 * @since MU
118
118
                 *
119
 
                 * @param array $tables  The blog tables to be dropped.
120
 
                 * @param int   $blog_id The ID of the blog to drop tables for.
 
119
                 * @param array $tables  The site tables to be dropped.
 
120
                 * @param int   $blog_id The ID of the site to drop tables for.
121
121
                 */
122
122
                $drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $blog_id );
123
123
 
128
128
                $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
129
129
 
130
130
                /**
131
 
                 * Filter the upload base directory to delete when the blog is deleted.
 
131
                 * Filter the upload base directory to delete when the site is deleted.
132
132
                 *
133
133
                 * @since MU
134
134
                 *
135
135
                 * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir()
136
 
                 * @param int    $blog_id            The blog ID.
 
136
                 * @param int    $blog_id            The site ID.
137
137
                 */
138
138
                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
139
139
                $dir = rtrim( $dir, DIRECTORY_SEPARATOR );
309
309
 
310
310
        $current_user = wp_get_current_user();
311
311
        $content = str_replace( '###USERNAME###', $current_user->user_login, $content );
312
 
        $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content );
 
312
        $content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash='.$hash ) ), $content );
313
313
        $content = str_replace( '###EMAIL###', $value, $content );
314
314
        $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
315
315
        $content = str_replace( '###SITEURL###', network_home_url(), $content );
342
342
 
343
343
                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
344
344
                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) );
345
 
                        delete_option( $current_user->ID . '_new_email' );
 
345
                        delete_user_meta( $current_user->ID, '_new_email' );
346
346
                        return;
347
347
                }
348
348
 
349
349
                $hash = md5( $_POST['email'] . time() . mt_rand() );
350
350
                $new_user_email = array(
351
 
                                'hash' => $hash,
352
 
                                'newemail' => $_POST['email']
353
 
                                );
354
 
                update_option( $current_user->ID . '_new_email', $new_user_email );
 
351
                        'hash' => $hash,
 
352
                        'newemail' => $_POST['email']
 
353
                );
 
354
                update_user_meta( $current_user->ID, '_new_email', $new_user_email );
355
355
 
356
356
                /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
357
357
                $email_text = __( 'Howdy ###USERNAME###,
403
403
 * after email address change.
404
404
 *
405
405
 * @since 3.0.0
 
406
 *
 
407
 * @global string $pagenow
406
408
 */
407
409
function new_user_email_admin_notice() {
408
 
        if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
409
 
                echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
 
410
        global $pagenow;
 
411
        if ( 'profile.php' === $pagenow && isset( $_GET['updated'] ) && $email = get_user_meta( get_current_user_id(), '_new_email', true ) ) {
 
412
                /* translators: %s: New email address */
 
413
                echo '<div class="notice notice-info"><p>' . sprintf( __( 'Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.' ), '<code>' . esc_html( $email['newemail'] ) . '</code>' ) . '</p></div>';
 
414
        }
410
415
}
411
416
 
412
417
/**
413
 
 * Check whether a blog has used its allotted upload space.
 
418
 * Check whether a site has used its allotted upload space.
414
419
 *
415
420
 * @since MU
416
421
 *
437
442
}
438
443
 
439
444
/**
440
 
 * Displays the amount of disk space used by the current blog. Not used in core.
 
445
 * Displays the amount of disk space used by the current site. Not used in core.
441
446
 *
442
447
 * @since MU
443
448
 */
462
467
}
463
468
 
464
469
/**
465
 
 * Get the remaining upload space for this blog.
 
470
 * Get the remaining upload space for this site.
466
471
 *
467
472
 * @since MU
468
473
 *
478
483
}
479
484
 
480
485
/**
481
 
 * Displays the edit blog upload space setting form on the Edit Blog screen.
 
486
 * Displays the site upload space quota setting form on the Edit Site Settings screen.
482
487
 *
483
488
 * @since 3.0.0
484
489
 *
485
 
 * @param int $id The ID of the blog to display the setting for.
 
490
 * @param int $id The ID of the site to display the setting for.
486
491
 */
487
492
function upload_space_setting( $id ) {
488
493
        switch_to_blog( $id );
743
748
 *
744
749
 * @since 3.0.0
745
750
 *
746
 
 * @global int $wp_db_version The version number of the database.
 
751
 * @global int    $wp_db_version The version number of the database.
 
752
 * @global string $pagenow
747
753
 *
748
754
 * @return false False if the current user is not a super admin.
749
755
 */
750
756
function site_admin_notice() {
751
 
        global $wp_db_version;
752
 
        if ( !is_super_admin() )
 
757
        global $wp_db_version, $pagenow;
 
758
 
 
759
        if ( ! is_super_admin() ) {
753
760
                return false;
754
 
        if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version )
 
761
        }
 
762
 
 
763
        if ( 'upgrade.php' == $pagenow ) {
 
764
                return;
 
765
        }
 
766
 
 
767
        if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) {
755
768
                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>";
 
769
        }
756
770
}
757
771
 
758
772
/**
1074
1088
        </table>
1075
1089
        <?php
1076
1090
        /** This action is documented in wp-admin/users.php */
1077
 
        do_action( 'delete_user_form', $current_user );
 
1091
        do_action( 'delete_user_form', $current_user, $allusers );
1078
1092
 
1079
1093
        if ( 1 == count( $users ) ) : ?>
1080
1094
                <p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
1093
1107
 * Print JavaScript in the header on the Network Settings screen.
1094
1108
 *
1095
1109
 * @since 4.1.0
1096
 
*/
 
1110
 */
1097
1111
function network_settings_add_js() {
1098
1112
?>
1099
1113
<script type="text/javascript">