Make WordPress Core

Changeset 13918


Ignore:
Timestamp:
04/01/2010 09:21:27 PM (17 years ago)
Author:
markjaquith
Message:

Huge MS refactoring and code cleanup. see #12460. props ocean90.

Location:
trunk/wp-admin
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/ms.dev.css

    r13660 r13918  
    1 /* Blog Switcher */
    2 
    3 #all-my-blogs-tab a.current {
    4         position: relative;
    5         padding-bottom: 10px;
    6 }
    7 
    8 #all-my-blogs {
    9         position: absolute;
    10         top: 30px;
    11         left: 0;
    12         right: 0;
    13         _width: 100%; /* IE6 Hack */
    14         margin: 4px 7px;
    15         padding: 6px 10px;
    16         font-size: 12px;
    17 }
    18 
    19 #all-my-blogs * {
    20         margin: 0;
    21 }
    22 
    23 form#all-my-blogs p, form#all-my-blogs p * {
    24         vertical-align: middle;
    25 }
    26 
    27 #all-my-blogs a {
    28         font-size: 10px;
    29         text-decoration: underline;
    30         margin: 0 14px;
    31 }
    32 
    33 #all-my-blogs a:hover, #all-my-blogs a:active  {
    34         text-decoration: none;
    35 }
    36 
    37 form#wpmu-search {
    38         position:absolute;
    39         right:0;
    40         top:0;
    41 }
    42 
    431/* Site Admin Menu */
    442#adminmenu .menu-icon-site div.wp-menu-image {
    … …  
    508}
    519
    52 /* Dashboard: MU Specific Data */
     10/* Dashboard: MS Specific Data */
    5311#dashboard_right_now p.musub {
    5412        margin-top: 12px;
    … …  
    6018        font-size: 16px;
    6119}
     20
     21#dashboard_right_now div.musubtable {
     22        border-top: none;
     23}
     24
     25/* No drag and drop on ms-sites.php */
     26.ms-sites-php .postbox h3 {
     27        cursor: auto;
     28}
     29
     30.ms-sites-php .postbox .description {
     31        margin:10px 0 0px;
     32        padding:0px 10px 10px;
     33        border-bottom:1px solid #DFDFDF;
     34}
     35
     36/* Background Color for Site Status */
    6237tr.site-deleted {
    63         background:#f55;
     38        background: #ff8573;
    6439}
    6540tr.site-spammed {
    66         background:#faa;
     41        background: #faa;
    6742}
    6843tr.site-archived {
    69         background:#fee;
     44        background:#ffebe8;
    7045}
     46tr.site-mature {
     47        background: #fecac2;
     48}
  • trunk/wp-admin/includes/ms.php

    r13896 r13918  
    2828                $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s Kb in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
    2929        if ( upload_is_user_over_quota( false ) ) {
    30                 $file['error'] = __('You have used your space quota. Please delete files before uploading.');
     30                $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
    3131        }
    3232        if ( $file['error'] != '0' )
    … …  
    4646 * @return void
    4747 */
    48 function wpmu_delete_blog($blog_id, $drop = false) {
     48function wpmu_delete_blog( $blog_id, $drop = false ) {
    4949        global $wpdb;
    5050
    51         $switched = false;
     51        $switch = false;
    5252        if ( $blog_id != $wpdb->blogid ) {
    5353                $switch = true;
    54                 switch_to_blog($blog_id);
    55         }
    56 
    57         do_action('delete_blog', $blog_id, $drop);
    58 
    59         $users = get_users_of_blog($blog_id);
     54                switch_to_blog( $blog_id );
     55        }
     56
     57        $blog_prefix = $wpdb->get_blog_prefix( $blog_id );
     58
     59        do_action( 'delete_blog', $blog_id, $drop );
     60
     61        $users = get_users_of_blog( $blog_id );
    6062
    6163        // Remove users from this blog.
    62         if ( !empty($users) ) {
    63                 foreach ($users as $user) {
    64                         remove_user_from_blog($user->user_id, $blog_id);
     64        if ( ! empty( $users ) ) {
     65                foreach ( $users as $user ) {
     66                        remove_user_from_blog( $user->user_id, $blog_id) ;
    6567                }
    6668        }
    … …  
    6971
    7072        if ( $drop ) {
    71                 $drop_tables = $wpdb->get_results("show tables LIKE '". $wpdb->base_prefix . $blog_id . "\_%'", ARRAY_A);
     73                $drop_tables = $wpdb->get_results( "SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A );
    7274                $drop_tables = apply_filters( 'wpmu_drop_tables', $drop_tables );
    7375
    … …  
    7678                        $wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" );
    7779                }
    78                 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id) );
     80                $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) );
    7981                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
    80                 $dir = rtrim($dir, DIRECTORY_SEPARATOR);
     82                $dir = rtrim( $dir, DIRECTORY_SEPARATOR );
    8183                $top_dir = $dir;
    8284                $stack = array($dir);
    8385                $index = 0;
    8486
    85                 while ( $index < count($stack) ) {
     87                while ( $index < count( $stack ) ) {
    8688                        # Get indexed directory from stack
    8789                        $dir = $stack[$index];
    8890
    89                         $dh = @ opendir($dir);
     91                        $dh = @opendir( $dir );
    9092                        if ( $dh ) {
    91                                 while ( ($file = @ readdir($dh)) !== false ) {
    92                                         if ($file == '.' or $file == '..')
     93                                while ( ( $file = @readdir( $dh ) ) !== false ) {
     94                                        if ( $file == '.' || $file == '..' )
    9395                                                continue;
    9496
    95                                         if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
     97                                        if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) )
    9698                                                $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
    97                                         else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file))
    98                                                 @ unlink($dir . DIRECTORY_SEPARATOR . $file);
     99                                        else if ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) )
     100                                                @unlink( $dir . DIRECTORY_SEPARATOR . $file );
    99101                                }
    100102                        }
    … …  
    102104                }
    103105
    104                 $stack = array_reverse($stack);  // Last added dirs are deepest
     106                $stack = array_reverse( $stack );  // Last added dirs are deepest
    105107                foreach( (array) $stack as $dir ) {
    106108                        if ( $dir != $top_dir)
    107                         @rmdir($dir);
    108                 }
    109         }
    110         $wpdb->query( $wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s", 'wp_{$blog_id}_autosave_draft_ids') );
    111         $blogs = get_site_option( "blog_list" );
     109                        @rmdir( $dir );
     110                }
     111        }
     112
     113        $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}autosave_draft_ids'" );
     114        $blogs = get_site_option( 'blog_list' );
    112115        if ( is_array( $blogs ) ) {
    113116                foreach ( $blogs as $n => $blog ) {
    114                         if ( $blog[ 'blog_id' ] == $blog_id )
    115                                 unset( $blogs[ $n ] );
     117                        if ( $blog['blog_id'] == $blog_id )
     118                                unset( $blogs[$n] );
    116119                }
    117120                update_site_option( 'blog_list', $blogs );
    … …  
    123126
    124127// @todo Merge with wp_delete_user() ?
    125 function wpmu_delete_user($id) {
     128function wpmu_delete_user( $id ) {
    126129        global $wpdb;
    127130
    128131        $id = (int) $id;
    129132
    130         do_action('wpmu_delete_user', $id);
    131 
    132         $blogs = get_blogs_of_user($id);
    133 
    134         if ( ! empty($blogs) ) {
    135                 foreach ($blogs as $blog) {
    136                         switch_to_blog($blog->userblog_id);
    137                         remove_user_from_blog($id, $blog->userblog_id);
    138 
    139                         $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
     133        do_action( 'wpmu_delete_user', $id );
     134
     135        $blogs = get_blogs_of_user( $id );
     136
     137        if ( ! empty( $blogs ) ) {
     138                foreach ( $blogs as $blog ) {
     139                        switch_to_blog( $blog->userblog_id );
     140                        remove_user_from_blog( $id, $blog->userblog_id );
     141
     142                        $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
    140143                        foreach ( (array) $post_ids as $post_id ) {
    141                                 wp_delete_post($post_id);
     144                                wp_delete_post( $post_id );
    142145                        }
    143146
    144147                        // Clean links
    145                         $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) );
     148                        $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
    146149
    147150                        if ( $link_ids ) {
    148151                                foreach ( $link_ids as $link_id )
    149                                         wp_delete_link($link_id);
     152                                        wp_delete_link( $link_id );
    150153                        }
    151154
    … …  
    154157        }
    155158
    156         $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
    157         $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
    158 
    159         clean_user_cache($id);
     159        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id ) );
     160        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
     161
     162        clean_user_cache( $id );
    160163
    161164        // allow for commit transaction
    162         do_action('deleted_user', $id);
     165        do_action( 'deleted_user', $id );
    163166
    164167        return true;
    … …  
    170173                return false;
    171174
    172     screen_icon('tools');
     175    screen_icon();
    173176    ?>
    174         <h2><?php esc_html_e('Users'); ?></h2>
    175         <p><?php _e( 'Transfer posts before deleting users:' ); ?></p>
    176         <form action="ms-edit.php?action=allusers" method="post">
    177         <input type="hidden" name="alluser_transfer_delete" />
     177        <h2><?php esc_html_e( 'Users' ); ?></h2>
     178        <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
     179        <form action="ms-edit.php?action=dodelete" method="post">
     180        <input type="hidden" name="dodelete" />
    178181    <?php
    179         wp_nonce_field( 'allusers' );
     182        wp_nonce_field( 'ms-users-delete' );
    180183        $site_admins = get_site_option( 'site_admins', array( 'admin' ) );
    181184        $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>";
    … …  
    192195
    193196                        if ( !empty( $blogs ) ) {
    194                                 echo '<p><strong>' . sprintf( __( 'Sites from %s:' ), $delete_user->user_login ) . '</strong></p>';
     197                                ?>
     198                                <br /><fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
     199                                <?php
    195200                                foreach ( (array) $blogs as $key => $details ) {
    196201                                        $blog_users = get_users_of_blog( $details->userblog_id );
    197202                                        if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
    198                                                 echo "<p><a href='http://{$details->domain}{$details->path}'>{$details->blogname}</a> ";
    199                                                 echo "<select name='blog[$val][{$key}]'>";
    200                                                 $out = '';
     203                                                $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
     204                                                $user_dropdown = "<select name='blog[$val][{$key}]'>";
     205                                                $user_list = '';
    201206                                                foreach ( $blog_users as $user ) {
    202207                                                        if ( $user->user_id != $val && !in_array( $user->user_id, $allusers ) )
    203                                                                 $out .= "<option value='{$user->user_id}'>{$user->user_login}</option>";
     208                                                                $user_list .= "<option value='{$user->user_id}'>{$user->user_login}</option>";
    204209                                                }
    205                                                 if ( $out == '' )
    206                                                         $out = $admin_out;
    207                                                 echo $out;
    208                                                 echo "</select>\n";
     210                                                if ( '' == $user_list )
     211                                                        $user_list = $admin_out;
     212                                                $user_dropdown .= $user_list;
     213                                                $user_dropdown .= "</select>\n";
     214                                                ?>
     215                                                <ul style="list-style:none;">
     216                                                        <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
     217                                                        <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
     218                                                        <?php _e( 'Delete all posts and links.' ); ?></label></li>
     219                                                        <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
     220                                                        <?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
     221                                                </ul>
     222                                                <?php
    209223                                        }
    210224                                }
     225                                echo "</fieldset>";
    211226                        }
    212227                }
    213228        }
    214229        ?>
    215     <br class="clear" />
    216     <input type="submit" class="button-secondary delete" value="<?php _e( 'Delete user and transfer posts' ); ?> " />
     230        <p class="submit"><input type="submit" class="button-secondary delete" value="<?php esc_attr_e( 'Confirm Deletion' ); ?>" /></p>
    217231        </form>
    218232    <?php
    … …  
    226240                switch_to_blog( $blog_id );
    227241
    228         $blog_allowed_themes = get_option( "allowedthemes" );
     242        $blog_allowed_themes = get_option( 'allowedthemes' );
    229243        if ( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes
    230                 $blog_allowed_themes = get_option( "allowed_themes" );
     244                $blog_allowed_themes = get_option( 'allowed_themes' );
    231245
    232246                if ( is_array( $blog_allowed_themes ) ) {
    233247                        foreach( (array) $themes as $key => $theme ) {
    234                                 $theme_key = esc_html( $theme[ 'Stylesheet' ] );
    235                                 if ( isset( $blog_allowed_themes[ $key ] ) == true ) {
    236                                         $blog_allowedthemes[ $theme_key ] = 1;
     248                                $theme_key = esc_html( $theme['Stylesheet'] );
     249                                if ( isset( $blog_allowed_themes[$key] ) == true ) {
     250                                        $blog_allowedthemes[$theme_key] = 1;
    237251                                }
    238252                        }
    239253                        $blog_allowed_themes = $blog_allowedthemes;
    240                         add_option( "allowedthemes", $blog_allowed_themes );
    241                         delete_option( "allowed_themes" );
     254                        add_option( 'allowedthemes', $blog_allowed_themes );
     255                        delete_option( 'allowed_themes' );
    242256                }
    243257        }
    … …  
    249263}
    250264
    251 function update_option_new_admin_email($old_value, $value) {
     265function update_option_new_admin_email( $old_value, $value ) {
    252266        if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
    253267                return;
    … …  
    255269        $hash = md5( $value. time() .mt_rand() );
    256270        $new_admin_email = array(
    257                 "hash" => $hash,
    258                 "newemail" => $value
     271                'hash' => $hash,
     272                'newemail' => $value
    259273        );
    260274        update_option( 'adminhash', $new_admin_email );
    261275
    262         $content = apply_filters( 'new_admin_email_content', __("Dear user,
     276        $content = apply_filters( 'new_admin_email_content', __( "Dear user,
    263277
    264278You recently requested to have the administration email address on
    … …  
    274288Regards,
    275289All at ###SITENAME###
    276 ###SITEURL###"), $new_admin_email );
    277 
    278         $content = str_replace('###ADMIN_URL###', esc_url(admin_url('options.php?adminhash='.$hash)), $content);
    279         $content = str_replace('###EMAIL###', $value, $content);
    280         $content = str_replace('###SITENAME###', get_site_option( 'site_name' ), $content);
    281         $content = str_replace('###SITEURL###', network_home_url(), $content);
    282 
    283         wp_mail( $value, sprintf(__('[%s] New Admin Email Address'), get_option('blogname')), $content );
    284 }
    285 add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
     290###SITEURL### "), $new_admin_email );
     291
     292        $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content );
     293        $content = str_replace( '###EMAIL###', $value, $content );
     294        $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
     295        $content = str_replace( '###SITEURL###', network_home_url(), $content );
     296
     297        wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), get_option( 'blogname' ) ), $content );
     298}
     299add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
    286300
    287301function send_confirmation_on_profile_email() {
    … …  
    290304                $errors = new WP_Error();
    291305
    292         if ( $current_user->id != $_POST[ 'user_id' ] )
     306        if ( $current_user->id != $_POST['user_id'] )
    293307                return false;
    294308
    295         if ( $current_user->user_email != $_POST[ 'email' ] ) {
    296                 if ( !is_email( $_POST[ 'email' ] ) ) {
     309        if ( $current_user->user_email != $_POST['email'] ) {
     310                if ( !is_email( $_POST['email'] ) ) {
    297311                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) );
    298312                        return;
    299313                }
    300314
    301                 if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST[ 'email' ] ) ) ) {
     315                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
    302316                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address is already used." ), array( 'form-field' => 'email' ) );
    303317                        delete_option( $current_user->ID . '_new_email' );
    … …  
    305319                }
    306320
    307                 $hash = md5( $_POST[ 'email' ] . time() . mt_rand() );
     321                $hash = md5( $_POST['email'] . time() . mt_rand() );
    308322                $new_user_email = array(
    309                                 "hash" => $hash,
    310                                 "newemail" => $_POST[ 'email' ]
     323                                'hash' => $hash,
     324                                'newemail' => $_POST['email']
    311325                                );
    312326                update_option( $current_user->ID . '_new_email', $new_user_email );
    313327
    314                 $content = apply_filters( 'new_user_email_content', __("Dear user,
     328                $content = apply_filters( 'new_user_email_content', __( "Dear user,
    315329
    316330You recently requested to have the email address on your account changed.
    … …  
    325339Regards,
    326340All at ###SITENAME###
    327 ###SITEURL###"), $new_user_email );
    328 
    329                 $content = str_replace('###ADMIN_URL###', esc_url(admin_url('profile.php?newuseremail='.$hash)), $content);
    330                 $content = str_replace('###EMAIL###', $_POST[ 'email' ], $content);
    331                 $content = str_replace('###SITENAME###', get_site_option( 'site_name' ), $content);
    332                 $content = str_replace('###SITEURL###', network_home_url(), $content);
    333 
    334                 wp_mail( $_POST[ 'email' ], sprintf(__('[%s] New Email Address'), get_option('blogname')), $content );
    335                 $_POST[ 'email' ] = $current_user->user_email;
     341###SITEURL###" ), $new_user_email );
     342
     343                $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
     344                $content = str_replace( '###EMAIL###', $_POST['email'], $content);
     345                $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
     346                $content = str_replace( '###SITEURL###', network_home_url(), $content );
     347
     348                wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), get_option( 'blogname' ) ), $content );
     349                $_POST['email'] = $current_user->user_email;
    336350        }
    337351}
    … …  
    340354function new_user_email_admin_notice() {
    341355        global $current_user;
    342         if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET[ 'updated' ] ) && $email = get_option( $current_user->ID . '_new_email' ) )
    343                 echo "<div id='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email[ 'newemail' ] ) . "</div>";
     356        if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( $current_user->ID . '_new_email' ) )
     357                echo "<div id='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
    344358}
    345359add_action( 'admin_notices', 'new_user_email_admin_notice' );
    … …  
    349363        $allowed_themes = get_site_option( 'allowedthemes' );
    350364        if ( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) {
    351                 $allowed_themes = get_site_option( "allowed_themes" ); // convert old allowed_themes format
     365                $allowed_themes = get_site_option( 'allowed_themes' ); // convert old allowed_themes format
    352366                if ( !is_array( $allowed_themes ) ) {
    353367                        $allowed_themes = array();
    354368                } else {
    355369                        foreach( (array) $themes as $key => $theme ) {
    356                                 $theme_key = esc_html( $theme[ 'Stylesheet' ] );
     370                                $theme_key = esc_html( $theme['Stylesheet'] );
    357371                                if ( isset( $allowed_themes[ $key ] ) == true ) {
    358372                                        $allowedthemes[ $theme_key ] = 1;
    … …  
    377391
    378392        $dir_name = trailingslashit( BLOGUPLOADDIR );
    379         if ( !(is_dir($dir_name) && is_readable($dir_name)) )
     393        if ( !( is_dir( $dir_name) && is_readable( $dir_name ) ) )
    380394                return true;
    381395
    382         $dir = dir($dir_name);
     396        $dir = dir( $dir_name );
    383397        $size = 0;
    384398
    … …  
    386400                if ( $file != '.' && $file != '..' ) {
    387401                        if ( is_dir( $dir_name . $file) ) {
    388                                 $size += get_dirsize($dir_name . $file);
     402                                $size += get_dirsize( $dir_name . $file );
    389403                        } else {
    390                                 $size += filesize($dir_name . $file);
     404                                $size += filesize( $dir_name . $file );
    391405                        }
    392406                }
    … …  
    395409        $size = $size / 1024 / 1024;
    396410
    397         if ( ($space_allowed - $size) <= 0 )
     411        if ( ( $space_allowed - $size ) <= 0 )
    398412                return false;
    399413
    … …  
    407421 */
    408422function get_space_allowed() {
    409         $space_allowed = get_option('blog_upload_space');
     423        $space_allowed = get_option( 'blog_upload_space' );
    410424        if ( $space_allowed == false )
    411                 $space_allowed = get_site_option('blog_upload_space');
    412         if ( empty($space_allowed) || !is_numeric($space_allowed) )
     425                $space_allowed = get_site_option( 'blog_upload_space' );
     426        if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) )
    413427                $space_allowed = 50;
    414428
    … …  
    418432function display_space_usage() {
    419433        $space = get_space_allowed();
    420         $used = get_dirsize( BLOGUPLOADDIR )/1024/1024;
     434        $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
    421435
    422436        if ( $used > $space )
    … …  
    427441        if ( $space > 1000 ) {
    428442                $space = number_format( $space / 1024 );
    429                 $space .= __('GB');
     443                $space .= __( 'GB' );
    430444        } else {
    431                 $space .= __('MB');
     445                $space .= __( 'MB' );
    432446        }
    433447        ?>
    434         <strong><?php printf(__('Used: %1s%% of %2s'), number_format($percentused), $space );?></strong>
     448        <strong><?php printf( __( 'Used: %1s%% of %2s' ), number_format( $percentused ), $space );?></strong>
    435449        <?php
    436450}
    … …  
    442456
    443457        $quota = get_space_allowed();
    444         $used = get_dirsize( BLOGUPLOADDIR )/1024/1024;
     458        $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
    445459
    446460        if ( $used > $quota )
    … …  
    448462        else
    449463                $percentused = ( $used / $quota ) * 100;
    450         $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved') : 'spam';
     464        $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
    451465        $used = round( $used, 2 );
    452466        $percentused = number_format( $percentused );
    453467
    454468        ?>
    455         <p class="sub musub"><?php _e('Storage Space'); ?></p>
    456         <div class="table">
     469        <p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
     470        <div class="table table_content musubtable">
    457471        <table>
    458472                <tr class="first">
    459                         <td class="first b b-posts"><?php printf( __( '<a href="upload.php" title="Manage Uploads" class="musublink">%sMB</a>' ), $quota ); ?></td>
    460                         <td class="t posts"><?php _e('Space Allowed'); ?></td>
    461                         <td class="b b-comments"><?php printf( __( '<a href="upload.php" title="Manage Uploads" class="musublink">%1sMB (%2$s%%)</a>' ), $used, $percentused ); ?></td>
    462                         <td class="last t comments <?php echo $used_color;?>"><?php _e('Space Used');?></td>
     473                        <td class="first b b-posts"><?php printf( __( '<a href="' . esc_url( admin_url( 'upload.php' ) ) . '" title="Manage Uploads" class="musublink">%sMB</a>' ), $quota ); ?></td>
     474                        <td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
    463475                </tr>
    464476        </table>
    465477        </div>
     478        <div class="table table_discussion musubtable">
     479        <table>
     480                <tr class="first">
     481                        <td class="b b-comments"><?php printf( __( '<a href="' . esc_url( admin_url( 'upload.php' ) ) . '" title="Manage Uploads" class="musublink">%1sMB (%2$s%%)</a>' ), $used, $percentused ); ?></td>
     482                        <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
     483                </tr>
     484        </table>
     485        </div>
     486        <br class="clear" />
    466487        <?php
    467488}
    468 if ( current_user_can('edit_posts') )
    469         add_action('activity_box_end', 'dashboard_quota');
     489if ( current_user_can( 'edit_posts' ) )
     490        add_action( 'activity_box_end', 'dashboard_quota' );
    470491
    471492// Edit blog upload space setting on Edit Blog page
    472493function upload_space_setting( $id ) {
    473         $quota = get_blog_option($id, "blog_upload_space");
     494        $quota = get_blog_option( $id, 'blog_upload_space' );
    474495        if ( !$quota )
    475496                $quota = '';
    … …  
    477498        ?>
    478499        <tr>
    479                 <th><?php _e('Site Upload Space Quota'); ?></th>
    480                 <td><input type="text" size="3" name="option[blog_upload_space]" value="<?php echo $quota; ?>" /><?php _e('MB (Leave blank for network default)'); ?></td>
     500                <th><?php _e( 'Site Upload Space Quota '); ?></th>
     501                <td><input type="text" size="3" name="option[blog_upload_space]" value="<?php echo $quota; ?>" /> <?php _e( 'MB (Leave blank for network default)' ); ?></td>
    481502        </tr>
    482503        <?php
    483504}
    484 add_action('wpmueditblogaction', 'upload_space_setting');
     505add_action( 'wpmueditblogaction', 'upload_space_setting' );
    485506
    486507function update_user_status( $id, $pref, $value, $refresh = 1 ) {
    … …  
    490511
    491512        if ( $refresh == 1 )
    492                 refresh_user_details($id);
     513                refresh_user_details( $id );
    493514
    494515        if ( $pref == 'spam' ) {
    495516                if ( $value == 1 )
    496                         do_action( "make_spam_user", $id );
     517                        do_action( 'make_spam_user', $id );
    497518                else
    498                         do_action( "make_ham_user", $id );
     519                        do_action( 'make_ham_user', $id );
    499520        }
    500521
    … …  
    502523}
    503524
    504 function refresh_user_details($id) {
     525function refresh_user_details( $id ) {
    505526        $id = (int) $id;
    506527
    … …  
    508529                return false;
    509530
    510         clean_user_cache($id);
     531        clean_user_cache( $id );
    511532
    512533        return $id;
    … …  
    514535
    515536function format_code_lang( $code = '' ) {
    516         $code = strtolower(substr($code, 0, 2));
    517         $lang_codes = array('aa' => 'Afar',  'ab' => 'Abkhazian',  'af' => 'Afrikaans',  'ak' => 'Akan',  'sq' => 'Albanian',  'am' => 'Amharic',  'ar' => 'Arabic',  'an' => 'Aragonese',  'hy' => 'Armenian',  'as' => 'Assamese',  'av' => 'Avaric',  'ae' => 'Avestan',  'ay' => 'Aymara',  'az' => 'Azerbaijani',  'ba' => 'Bashkir',  'bm' => 'Bambara',  'eu' => 'Basque',  'be' => 'Belarusian',  'bn' => 'Bengali',  'bh' => 'Bihari',  'bi' => 'Bislama',  'bs' => 'Bosnian',  'br' => 'Breton',  'bg' => 'Bulgarian',  'my' => 'Burmese',  'ca' => 'Catalan; Valencian',  'ch' => 'Chamorro',  'ce' => 'Chechen',  'zh' => 'Chinese',  'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic',  'cv' => 'Chuvash',  'kw' => 'Cornish',  'co' => 'Corsican',  'cr' => 'Cree',  'cs' => 'Czech',  'da' => 'Danish',  'dv' => 'Divehi; Dhivehi; Maldivian',  'nl' => 'Dutch; Flemish',  'dz' => 'Dzongkha',  'en' => 'English',  'eo' => 'Esperanto',  'et' => 'Estonian',  'ee' => 'Ewe',  'fo' => 'Faroese',  'fj' => 'Fijian',  'fi' => 'Finnish',  'fr' => 'French',  'fy' => 'Western Frisian',  'ff' => 'Fulah',  'ka' => 'Georgian',  'de' => 'German',  'gd' => 'Gaelic; Scottish Gaelic',  'ga' => 'Irish',  'gl' => 'Galician',  'gv' => 'Manx',  'el' => 'Greek, Modern',  'gn' => 'Guarani',  'gu' => 'Gujarati',  'ht' => 'Haitian; Haitian Creole',  'ha' => 'Hausa',  'he' => 'Hebrew',  'hz' => 'Herero',  'hi' => 'Hindi',  'ho' => 'Hiri Motu',  'hu' => 'Hungarian',  'ig' => 'Igbo',  'is' => 'Icelandic',  'io' => 'Ido',  'ii' => 'Sichuan Yi',  'iu' => 'Inuktitut',  'ie' => 'Interlingue',  'ia' => 'Interlingua (International Auxiliary Language Association)',  'id' => 'Indonesian',  'ik' => 'Inupiaq',  'it' => 'Italian',  'jv' => 'Javanese',  'ja' => 'Japanese',  'kl' => 'Kalaallisut; Greenlandic',  'kn' => 'Kannada',  'ks' => 'Kashmiri',  'kr' => 'Kanuri',  'kk' => 'Kazakh',  'km' => 'Central Khmer',  'ki' => 'Kikuyu; Gikuyu',  'rw' => 'Kinyarwanda',  'ky' => 'Kirghiz; Kyrgyz',  'kv' => 'Komi',  'kg' => 'Kongo',  'ko' => 'Korean',  'kj' => 'Kuanyama; Kwanyama',  'ku' => 'Kurdish',  'lo' => 'Lao',  'la' => 'Latin',  'lv' => 'Latvian',  'li' => 'Limburgan; Limburger; Limburgish',  'ln' => 'Lingala',  'lt' => 'Lithuanian',  'lb' => 'Luxembourgish; Letzeburgesch',  'lu' => 'Luba-Katanga',  'lg' => 'Ganda',  'mk' => 'Macedonian',  'mh' => 'Marshallese',  'ml' => 'Malayalam',  'mi' => 'Maori',  'mr' => 'Marathi',  'ms' => 'Malay',  'mg' => 'Malagasy',  'mt' => 'Maltese',  'mo' => 'Moldavian',  'mn' => 'Mongolian',  'na' => 'Nauru',  'nv' => 'Navajo; Navaho',  'nr' => 'Ndebele, South; South Ndebele',  'nd' => 'Ndebele, North; North Ndebele',  'ng' => 'Ndonga',  'ne' => 'Nepali',  'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian',  'nb' => 'Bokmål, Norwegian, Norwegian Bokmål',  'no' => 'Norwegian',  'ny' => 'Chichewa; Chewa; Nyanja',  'oc' => 'Occitan, Provençal',  'oj' => 'Ojibwa',  'or' => 'Oriya',  'om' => 'Oromo',  'os' => 'Ossetian; Ossetic',  'pa' => 'Panjabi; Punjabi',  'fa' => 'Persian',  'pi' => 'Pali',  'pl' => 'Polish',  'pt' => 'Portuguese',  'ps' => 'Pushto',  'qu' => 'Quechua',  'rm' => 'Romansh',  'ro' => 'Romanian',  'rn' => 'Rundi',  'ru' => 'Russian',  'sg' => 'Sango',  'sa' => 'Sanskrit',  'sr' => 'Serbian',  'hr' => 'Croatian',  'si' => 'Sinhala; Sinhalese',  'sk' => 'Slovak',  'sl' => 'Slovenian',  'se' => 'Northern Sami',  'sm' => 'Samoan',  'sn' => 'Shona',  'sd' => 'Sindhi',  'so' => 'Somali',  'st' => 'Sotho, Southern',  'es' => 'Spanish; Castilian',  'sc' => 'Sardinian',  'ss' => 'Swati',  'su' => 'Sundanese',  'sw' => 'Swahili',  'sv' => 'Swedish',  'ty' => 'Tahitian',  'ta' => 'Tamil',  'tt' => 'Tatar',  'te' => 'Telugu',  'tg' => 'Tajik',  'tl' => 'Tagalog',  'th' => 'Thai',  'bo' => 'Tibetan',  'ti' => 'Tigrinya',  'to' => 'Tonga (Tonga Islands)',  'tn' => 'Tswana',  'ts' => 'Tsonga',  'tk' => 'Turkmen',  'tr' => 'Turkish',  'tw' => 'Twi',  'ug' => 'Uighur; Uyghur',  'uk' => 'Ukrainian',  'ur' => 'Urdu',  'uz' => 'Uzbek',  've' => 'Venda',  'vi' => 'Vietnamese',  'vo' => 'Volapük',  'cy' => 'Welsh',  'wa' => 'Walloon'
    518 ,  'wo' => 'Wolof',  'xh' => 'Xhosa',  'yi' => 'Yiddish',  'yo' => 'Yoruba',  'za' => 'Zhuang; Chuang',  'zu' => 'Zulu');
    519         $lang_codes = apply_filters('lang_codes', $lang_codes, $code);
     537        $code = strtolower( substr( $code, 0, 2 ) );
     538        $lang_codes = array(
     539                'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali',
     540                'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree',
     541                'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijjian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic',
     542                'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue',
     543                'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz',
     544                'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam',
     545                'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål',
     546                'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian',
     547                'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili',
     548                'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek',
     549                've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
     550        $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
    520551        return strtr( $code, $lang_codes );
    521552}
    … …  
    526557                        $term->slug = sanitize_title( $term->name );
    527558                } else {
    528                         $term[ 'slug' ] = sanitize_title( $term[ 'name' ] );
     559                        $term['slug'] = sanitize_title( $term['name'] );
    529560                }
    530561        }
    … …  
    536567        global $current_user;
    537568        $c = 0;
    538         if ( isset( $_GET[ 'c' ] ) )
    539                 $c = (int)$_GET[ 'c' ];
     569        if ( isset( $_GET['c'] ) )
     570                $c = (int) $_GET['c'];
    540571
    541572        if ( $c >= 5 ) {
    … …  
    547578        $dashboard_blog = get_dashboard_blog();
    548579        if ( is_object( $blog ) ) {
    549                 wp_redirect( get_admin_url($blog->blog_id, '?c=' . $c) ); // redirect and count to 5, "just in case"
     580                wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
    550581                exit;
    551582        }
    … …  
    565596                }
    566597                $blog = get_blog_details( get_user_meta( $current_user->ID, 'primary_blog', true ) );
    567                 $protocol = ( is_ssl() ? 'https://' : 'http://' );
    568                 wp_redirect( $protocol . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case"
     598                        wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) );
    569599                exit;
    570600        }
    … …  
    590620                if ( $code_lang == 'en_US' ) { // American English
    591621                        $flag = true;
    592                         $ae = __('American English');
    593                         $output[$ae] = '<option value="'.$code_lang.'"'.(($current == $code_lang) ? ' selected="selected"' : '').'> '.$ae.'</option>';
     622                        $ae = __( 'American English' );
     623                        $output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang ) . '> ' . $ae . '</option>';
    594624                } elseif ( $code_lang == 'en_GB' ) { // British English
    595625                        $flag = true;
    596                         $be = __('British English');
    597                         $output[$be] = '<option value="'.$code_lang.'"'.(($current == $code_lang) ? ' selected="selected"' : '').'> '.$be.'</option>';
     626                        $be = __( 'British English' );
     627                        $output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang ) . '> ' . $be . '</option>';
    598628                } else {
    599                         $translated = format_code_lang($code_lang);
    600                         $output[$translated] =  '<option value="'.$code_lang.'"'.(($current == $code_lang) ? ' selected="selected"' : '').'> '.$translated.'</option>';
    601                 }
    602 
    603         }
    604 
    605         if ( $flag === false ) { // WordPress english
    606                 $output[] = '<option value=""'.((empty($current)) ? ' selected="selected"' : '').'>'.__('English')."</option>";
    607         }
     629                        $translated = format_code_lang( $code_lang );
     630                        $output[$translated] =  '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang ) . '> ' . esc_html ( $translated ) . '</option>';
     631                }
     632
     633        }
     634
     635        if ( $flag === false ) // WordPress english
     636                $output[] = '<option value=""' . selected( $current, '' ) . '>' . __( 'English' ) . "</option>";
    608637
    609638        // Order by name
    610         uksort($output, 'strnatcasecmp');
    611 
    612         $output = apply_filters('mu_dropdown_languages', $output, $lang_files, $current);
    613         echo implode("\n\t", $output);
     639        uksort( $output, 'strnatcasecmp' );
     640
     641        $output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
     642        echo implode( "\n\t", $output );
    614643}
    615644
    … …  
    638667                return;
    639668
    640         if ( !empty( $_GET[ 'feed_dismiss' ] ) )
    641                 update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss' ], true );
     669        if ( !empty( $_GET['feed_dismiss'] ) )
     670                update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET['feed_dismiss'], true );
    642671
    643672        $url = get_site_option( 'admin_notice_feed' );
    … …  
    667696                return false;
    668697        if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version )
    669                 echo "<div id='update-nag'>" . __( 'Thank you for Updating! Please visit the <a href="ms-upgrade-network.php">Update Network</a> page to update all your sites.' ) . "</div>";
     698                echo "<div id='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Update Network</a> page to update all your sites.' ), esc_url( admin_url( 'ms-upgrade-network.php' ) ) ) . "</div>";
    670699}
    671700add_action( 'admin_notices', 'site_admin_notice' );
    … …  
    674703        if ( is_subdomain_install() )
    675704                return $data;
    676         if ( $data[ 'post_type' ] != 'page' )
     705        if ( $data['post_type'] != 'page' )
    677706                return $data;
    678         if ( !isset( $data[ 'post_name' ] ) || $data[ 'post_name' ] == '' )
     707        if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
    679708                return $data;
    680709        if ( !is_main_site() )
    681710                return $data;
    682711
    683         $post_name = $data[ 'post_name' ];
     712        $post_name = $data['post_name'];
    684713        $c = 0;
    685714        while( $c < 10 && get_id_from_blogname( $post_name ) ) {
    … …  
    687716                $c ++;
    688717        }
    689         if ( $post_name != $data[ 'post_name' ] ) {
    690                 $data[ 'post_name' ] = $post_name;
     718        if ( $post_name != $data['post_name'] ) {
     719                $data['post_name'] = $post_name;
    691720        }
    692721        return $data;
    … …  
    700729        <tr>
    701730        <?php /* translators: My sites label */ ?>
    702                 <th scope="row"><?php _e('Primary Site'); ?></th>
     731                <th scope="row"><?php _e( 'Primary Site' ); ?></th>
    703732                <td>
    704733                <?php
    705734                $all_blogs = get_blogs_of_user( $current_user->ID );
    706                 $primary_blog = get_user_meta($current_user->ID, 'primary_blog', true);
     735                $primary_blog = get_user_meta( $current_user->ID, 'primary_blog', true );
    707736                if ( count( $all_blogs ) > 1 ) {
    708737                        $found = false;
    … …  
    712741                                        if ( $primary_blog == $blog->userblog_id )
    713742                                                $found = true;
    714                                         ?><option value='<?php echo $blog->userblog_id ?>'<?php if ( $primary_blog == $blog->userblog_id ) echo ' selected="selected"' ?>><?php echo get_home_url($blog->userblog_id) ?></option><?php
     743                                        ?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog,  $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
    715744                                } ?>
    716745                        </select>
    … …  
    739768                return;
    740769        $mu_media_buttons = get_site_option( 'mu_media_buttons', array() );
    741         if ( empty($mu_media_buttons[ 'image' ]) && current_theme_supports( 'post-thumbnails' ) ) {
    742                 echo "<div id='update-nag'>" . sprintf( __( "Warning! The current theme supports post thumbnails. You must enable image uploads on <a href='%s'>the options page</a> for it to work." ), admin_url( 'ms-options.php' ) ) . "</div>";
     770        if ( empty($mu_media_buttons['image']) && current_theme_supports( 'post-thumbnails' ) ) {
     771                echo "<div id='update-nag'>" . sprintf( __( "Warning! The current theme supports post thumbnails. You must enable image uploads on <a href='%s'>the options page</a> for it to work." ), esc_url( admin_url( 'ms-options.php' ) ) ) . "</div>";
    743772        }
    744773}
    … …  
    761790 */
    762791function _admin_notice_multisite_activate_plugins_page() {
    763         $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href="ms-options.php#menu">' . __( 'Activate' ) . '</a>' );
     792        $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href="' . esc_url( admin_url( 'ms-options.php#menu' ) ) . '">' . __( 'Activate' ) . '</a>' );
    764793        echo "<div class='error'><p>$message</p></div>";
    765794}
  • trunk/wp-admin/ms-delete-site.php

    r13022 r13918  
    11<?php
    2 require_once('admin.php');
     2require_once( './admin.php' );
    33
    44if ( !is_multisite() )
    5         wp_die( __('Multisite support is not enabled.') );
     5        wp_die( __( 'Multisite support is not enabled.' ) );
    66
    77// @todo Create a delete blog cap.
    8 if ( ! current_user_can('manage_options') )
    9         wp_die(__('You do not have sufficient permissions to delete this blog.'));
     8if ( ! current_user_can( 'manage_options' ) )
     9        wp_die(__( 'You do not have sufficient permissions to delete this site.'));
     10       
     11if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) {
     12        if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) {
     13                wpmu_delete_blog( $wpdb->blogid );
     14                wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), $current_site->site_name ) );
     15        } else {
     16                wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) );
     17        }
     18}
    1019
    11 $action = isset($_POST['action']) ? $_POST['action'] : 'splash';
     20$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
    1221
    13 $title = __('Delete Blog');
     22$title = __( 'Delete Site' );
    1423$parent_file = 'tools.php';
    15 require_once('admin-header.php');
     24require_once( './admin-header.php' );
    1625
    1726echo '<div class="wrap">';
    1827screen_icon();
    19 echo '<h2>'. esc_html($title) .'</h2>';
     28echo '<h2>' . esc_html( $title ) . '</h2>';
    2029
    21 if ( isset($_POST['action']) && $_POST['action'] == "deleteblog" && isset($_POST['confirmdelete']) && $_POST['confirmdelete'] == '1' ) {
    22         $hash = wp_generate_password(20, false);
    23         update_option( "delete_blog_hash", $hash );
    24         $url_delete = admin_url('ms-delete-site.php?h=' . $hash);
    25         $msg = __("Dear User,
    26 You recently clicked the 'Delete Blog' link on your blog and filled in a
     30if ( isset( $_POST['action'] ) && $_POST['action'] == 'deleteblog' && isset( $_POST['confirmdelete'] ) && $_POST['confirmdelete'] == '1' ) {
     31        $hash = wp_generate_password( 20, false );
     32        update_option( 'delete_blog_hash', $hash );
     33
     34        $url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) );
     35
     36        $content = apply_filters( 'delete_site_email_content', __( "Dear User,
     37You recently clicked the 'Delete Site' link on your site and filled in a
    2738form on that page.
    28 If you really want to delete your blog, click the link below. You will not
     39If you really want to delete your site, click the link below. You will not
    2940be asked to confirm again so only click this link if you are absolutely certain:
    30 URL_DELETE
     41###URL_DELETE###
    3142
    32 If you delete your blog, please consider opening a new blog here
    33 some time in the future! (But remember your current blog and username
     43If you delete your site, please consider opening a new site here
     44some time in the future! (But remember your current site and username
    3445are gone forever.)
    3546
    3647Thanks for using the site,
    3748Webmaster
    38 SITE_NAME
    39 ");
    40         $msg = str_replace( "URL_DELETE", $url_delete, $msg );
    41         $msg = str_replace( "SITE_NAME", $current_site->site_name, $msg );
    42         wp_mail( get_option( "admin_email" ), "[ " . get_option( "blogname" ) . " ] ".__("Delete My Blog"), $msg );
     49###SITE_NAME###" ) );
     50
     51        $content = str_replace( '###URL_DELETE###', $url_delete, $content );
     52        $content = str_replace( '###SITE_NAME###', $current_site->site_name, $content );
     53
     54        wp_mail( get_option( 'admin_email' ), "[ " . get_option( 'blogname' ) . " ] ".__( 'Delete My Site' ), $content );
    4355        ?>
    44         <p><?php _e('Thank you. Please check your email for a link to confirm your action. Your blog will not be deleted until this link is clicked.') ?></p>
     56
     57        <p><?php _e( 'Thank you. Please check your email for a link to confirm your action. Your site will not be deleted until this link is clicked. ') ?></p>
     58
     59<?php } else {
     60        ?>
     61        <p><?php printf( __( 'If you do not want to use your %s site any more, you can delete it using the form below. When you click <strong>Delete My Site Permanently</strong> you will be sent an email with a link in it. Click on this link to delete your site.'), $current_site->site_name); ?></p>
     62        <p><?php _e( 'Remember, once deleted your site cannot be restored.' ) ?></p>
     63
     64        <form method="post" name="deletedirect">
     65                <input type="hidden" name="action" value="deleteblog" />
     66                <p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf( __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), is_subdomain_install() ? $current_blog->domain : $current_site->domain . $current_site->path ); ?></strong></label></p>
     67                <p class="submit"><input type="submit" value="<?php esc_attr_e( 'Delete My Site Permanently' ) ?>" /></p>
     68        </form>
    4569        <?php
    46 } elseif ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option('delete_blog_hash') != false ) {
    47         if ( get_option('delete_blog_hash') == $_GET['h'] ) {
    48                 wpmu_delete_blog( $wpdb->blogid );
    49                 echo "<p>" . sprintf(__('Thank you for using %s, your blog has been deleted. Happy trails to you until we meet again.'), $current_site->site_name) . "</p>";
    50         } else {
    51                 echo "<p>" . __("I'm sorry, the link you clicked is stale. Please select another option.") . "</p>";
    52         }
    53 } else {
    54 ?>
    55 <p><?php printf(__('If you do not want to use your %s blog any more, you can delete it using the form below. When you click <strong>Delete My Blog</strong> you will be sent an email with a link in it. Click on this link to delete your blog.'), $current_site->site_name); ?></p>
    56 <p><?php _e('Remember, once deleted your blog cannot be restored.') ?></p>
    57 <form method='post' name='deletedirect'>
    58 <input type='hidden' name='action' value='deleteblog' />
    59 <p><input id='confirmdelete' type='checkbox' name='confirmdelete' value='1' /> <label for='confirmdelete'><strong><?php printf( __("I'm sure I want to permanently disable my blog, and I am aware I can never get it back or use %s again."), $current_blog->domain); ?></strong></label></p>
    60 <p class="submit"><input type='submit' value='<?php esc_attr_e('Delete My Blog Permanently') ?>' /></p>
    61 </form>
    62 <?php
    6370}
    6471echo '</div>';
    6572
    66 include('admin-footer.php');
     73include( './admin-footer.php' );
    6774?>
  • trunk/wp-admin/ms-edit.php

    r13796 r13918  
    11<?php
    2 require_once('admin.php');
     2require_once( './admin.php' );
    33
    44if ( !is_multisite() )
    5         wp_die( __('Multisite support is not enabled.') );
    6 
    7 do_action('wpmuadminedit', '');
    8 
    9 if ( isset($_GET[ 'id' ]) )
    10         $id = intval( $_GET[ 'id' ] );
    11 elseif ( isset($_POST[ 'id' ]) )
    12         $id = intval( $_POST[ 'id' ] );
    13 
    14 if ( isset( $_POST['ref'] ) == false && !empty($_SERVER['HTTP_REFERER']) )
    15         $_POST['ref'] = $_SERVER['HTTP_REFERER'];
     5        wp_die( __( 'Multisite support is not enabled.' ) );
     6
     7do_action( 'wpmuadminedit' , '');
     8
     9if ( isset( $_GET['id' ]) )
     10        $id = intval( $_GET['id'] );
     11elseif ( isset( $_POST['id'] ) )
     12        $id = intval( $_POST['id'] );
    1613
    1714switch ( $_GET['action'] ) {
    18         case "siteoptions":
    19                 check_admin_referer('siteoptions');
     15        case 'siteoptions':
     16                check_admin_referer( 'siteoptions' );
    2017                if ( ! current_user_can( 'manage_network_options' ) )
    21                         wp_die( __('You do not have permission to access this page.') );
     18                        wp_die( __( 'You do not have permission to access this page.' ) );
    2219
    2320                if ( empty( $_POST ) )
    24                         wp_die( __("You probably need to go back to the <a href='ms-options.php'>options page</a>") );
    25 
    26                 if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array($_POST['WPLANG'], get_available_languages()) ) )
    27                         update_site_option( "WPLANG", $_POST['WPLANG'] );
     21                        wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">options page</a>.', esc_url( admin_url( 'ms-options.php' ) ) ) ) );
     22
     23                if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) )
     24                        update_site_option( 'WPLANG', $_POST['WPLANG'] );
    2825
    2926                if ( is_email( $_POST['admin_email'] ) )
    30                         update_site_option( "admin_email", $_POST['admin_email'] );
     27                        update_site_option( 'admin_email', $_POST['admin_email'] );
    3128
    3229                $illegal_names = split( ' ', $_POST['illegal_names'] );
    … …  
    3633                                $names[] = trim( $name );
    3734                }
    38                 update_site_option( "illegal_names", $names );
     35                update_site_option( 'illegal_names', $names );
    3936
    4037                if ( $_POST['limited_email_domains'] != '' ) {
    41                         $limited_email_domains = str_replace( ' ', "\n", $_POST[ 'limited_email_domains' ] );
     38                        $limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] );
    4239                        $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) );
    4340                        $limited_email = array();
    … …  
    4744                                        $limited_email[] = trim( $domain );
    4845                        }
    49                         update_site_option( "limited_email_domains", $limited_email );
    50                 } else {
    51                         update_site_option( "limited_email_domains", '' );
     46                        update_site_option( 'limited_email_domains', $limited_email );
     47                } else {
     48                        update_site_option( 'limited_email_domains', '' );
    5249                }
    5350
    5451                if ( $_POST['banned_email_domains'] != '' ) {
    55                         $banned_email_domains = split( "\n", stripslashes( $_POST[ 'banned_email_domains' ] ) );
     52                        $banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) );
    5653                        $banned = array();
    5754                        foreach ( (array) $banned_email_domains as $domain ) {
    … …  
    6057                                        $banned[] = trim( $domain );
    6158                        }
    62                         update_site_option( "banned_email_domains", $banned );
    63                 } else {
    64                         update_site_option( "banned_email_domains", '' );
    65                 }
    66                 update_site_option( 'default_user_role', $_POST[ 'default_user_role' ] );
    67                 if ( trim( $_POST[ 'dashboard_blog_orig' ] ) == '' )
    68                         $_POST[ 'dashboard_blog_orig' ] = $current_site->blog_id;
    69                 if ( trim( $_POST[ 'dashboard_blog' ] ) == '' ) {
    70                         $_POST[ 'dashboard_blog' ] = $current_site->blog_id;
     59                        update_site_option( 'banned_email_domains', $banned );
     60                } else {
     61                        update_site_option( 'banned_email_domains', '' );
     62                }
     63                update_site_option( 'default_user_role', $_POST['default_user_role'] );
     64                if ( trim( $_POST['dashboard_blog_orig'] ) == '' )
     65                        $_POST['dashboard_blog_orig'] = $current_site->blog_id;
     66                if ( trim( $_POST['dashboard_blog'] ) == '' ) {
     67                        $_POST['dashboard_blog'] = $current_site->blog_id;
    7168                        $dashboard_blog_id = $current_site->blog_id;
    7269                } else {
    73                         $dashboard_blog = untrailingslashit( sanitize_user( str_replace( '.', '', str_replace( $current_site->domain . $current_site->path, '', $_POST[ 'dashboard_blog' ] ) ) ) );
     70                        $dashboard_blog = untrailingslashit( sanitize_user( str_replace( '.', '', str_replace( $current_site->domain . $current_site->path, '', $_POST['dashboard_blog'] ) ) ) );
    7471                        $blog_details = get_blog_details( $dashboard_blog );
    7572                        if ( false === $blog_details ) {
    … …  
    8481                                }
    8582                                $wpdb->hide_errors();
    86                                 $dashboard_blog_id = wpmu_create_blog( $domain, $path, __( 'My Dashboard' ), $current_user->id , array( "public" => 0 ), $current_site->id );
     83                                $dashboard_blog_id = wpmu_create_blog( $domain, $path, __( 'My Dashboard' ), $current_user->id , array( 'public' => 0 ), $current_site->id );
    8784                                $wpdb->show_errors();
    8885                        } else {
    … …  
    9289                if ( is_wp_error( $dashboard_blog_id ) )
    9390                        wp_die( __( 'Problem creating dashboard blog: ' ) . $dashboard_blog_id->get_error_message() );
    94                 if ( $_POST[ 'dashboard_blog_orig' ] != $_POST[ 'dashboard_blog' ] ) {
     91                if ( $_POST['dashboard_blog_orig'] != $_POST['dashboard_blog'] ) {
    9592                        $users = get_users_of_blog( get_site_option( 'dashboard_blog' ) );
    9693                        $move_users = array();
    … …  
    107104                        }
    108105                }
    109                 update_site_option( "dashboard_blog", $dashboard_blog_id );
     106                update_site_option( 'dashboard_blog', $dashboard_blog_id );
    110107                // global terms
    111                 if ( !global_terms_enabled() && ! empty( $_POST[ 'global_terms_enabled' ] ) ) {
     108                if ( !global_terms_enabled() && ! empty( $_POST['global_terms_enabled'] ) ) {
    112109                        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    113110                        // create global terms table
    … …  
    115112                }
    116113                $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'admin_notice_feed', 'global_terms_enabled' );
    117                 $checked_options = array('mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1 );
     114                $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1 );
    118115                foreach ( $checked_options as $option_name => $option_unchecked_value ) {
    119                         if ( ! isset($_POST[ $option_name ]) )
    120                                 $_POST[ $option_name ] = $option_unchecked_value;
     116                        if ( ! isset( $_POST[$option_name] ) )
     117                                $_POST[$option_name] = $option_unchecked_value;
    121118                }
    122119                foreach ( $options as $option_name ) {
    123                         if ( ! isset($_POST[ $option_name ]) )
     120                        if ( ! isset($_POST[$option_name]) )
    124121                                continue;
    125                         $value = stripslashes_deep( $_POST[ $option_name ] );
     122                        $value = stripslashes_deep( $_POST[$option_name] );
    126123                        update_site_option( $option_name, $value );
    127124                }
    … …  
    130127                do_action( 'update_wpmu_options' );
    131128
    132                 wp_redirect( add_query_arg( "updated", "true", 'ms-options.php' ) );
    133                 exit();
    134         break;
    135         case "addblog":
    136                 check_admin_referer('add-blog');
    137 
    138                 if ( ! current_user_can( 'manage_sites' ) )
    139                         wp_die( __('You do not have permission to access this page.') );
    140 
    141                 if ( is_array( $_POST[ 'blog' ] ) == false )
    142                         wp_die( "Can't create an empty site." );
     129                wp_redirect( add_query_arg( 'updated', 'true', admin_url( 'ms-options.php' ) ) );
     130                exit();
     131        break;
     132        case 'addblog':
     133                check_admin_referer( 'add-blog' );
     134
     135                if ( ! current_user_can( 'manage_sites' ) )
     136                        wp_die( __( 'You do not have permission to access this page.' ) );
     137
     138                if ( is_array( $_POST['blog'] ) == false )
     139                        wp_die(  __( "Can't create an empty site." ) );
    143140                $blog = $_POST['blog'];
    144141                $domain = '';
    145                 if ( ! preg_match( '/(--)/', $blog[ 'domain' ] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog[ 'domain' ] ) )
    146                         $domain = strtolower( $blog[ 'domain' ] );
    147                 $email = sanitize_email( $blog[ 'email' ] );
    148                 $title = $blog[ 'title' ];
     142                if ( ! preg_match( '/(--)/', $blog['domain'] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) )
     143                        $domain = strtolower( $blog['domain'] );
     144                $email = sanitize_email( $blog['email'] );
     145                $title = $blog['title'];
    149146
    150147                if ( empty( $domain ) )
    … …  
    153150                        wp_die( __( 'Missing email address.' ) );
    154151                if ( !is_email( $email ) )
    155                         wp_die( __( 'Invalid email address' ) );
     152                        wp_die( __( 'Invalid email address.' ) );
    156153
    157154                if ( is_subdomain_install() ) {
    158                         $newdomain = $domain.".".$current_site->domain;
     155                        $newdomain = $domain . '.' . $current_site->domain;
    159156                        $path = $base;
    160157                } else {
    161158                        $newdomain = $current_site->domain;
    162                         $path = $base.$domain.'/';
     159                        $path = $base . $domain . '/';
    163160                }
    164161
    … …  
    169166                        $user_id = wpmu_create_user( $domain, $password, $email );
    170167                        if ( false == $user_id )
    171                                 wp_die( __('There was an error creating the user') );
     168                                wp_die( __( 'There was an error creating the user.' ) );
    172169                        else
    173                                 wp_new_user_notification($user_id, $password);
     170                                wp_new_user_notification( $user_id, $password );
    174171                }
    175172
    176173                $wpdb->hide_errors();
    177                 $id = wpmu_create_blog($newdomain, $path, $title, $user_id , array( "public" => 1 ), $current_site->id);
     174                $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );
    178175                $wpdb->show_errors();
    179                 if ( !is_wp_error($id) ) {
     176                if ( !is_wp_error( $id ) ) {
    180177                        $dashboard_blog = get_dashboard_blog();
    181178                        if ( get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id )
    182179                                update_user_option( $user_id, 'primary_blog', $id, true );
    183                         $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain.$path, stripslashes( $title ) );
    184                         wp_mail( get_site_option('admin_email'),  sprintf(__('[%s] New Site Created'), $current_site->site_name), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
    185                         wpmu_welcome_notification( $id, $user_id, $password, $title, array( "public" => 1 ) );
    186                         wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add-blog'), $_SERVER['HTTP_REFERER'] ) );
     180                        $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) );
     181                        wp_mail( get_site_option('admin_email'),  sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
     182                        wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) );
     183                        wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add-blog' ), wp_get_referer() ) );
    187184                        exit();
    188185                } else {
    … …  
    191188        break;
    192189
    193         case "updateblog":
    194                 check_admin_referer('editblog');
    195                 if ( ! current_user_can( 'manage_sites' ) )
    196                         wp_die( __('You do not have permission to access this page.') );
     190        case 'updateblog':
     191                check_admin_referer( 'editblog' );
     192                if ( ! current_user_can( 'manage_sites' ) )
     193                        wp_die( __( 'You do not have permission to access this page.' ) );
    197194
    198195                if ( empty( $_POST ) )
    199                         wp_die( __('You probably need to go back to the <a href="ms-sites.php">sites page</a>') );
     196                        wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">sites page</a>', esc_url( admin_url( 'ms-sites.php' ) ) ) ) );
     197
     198                switch_to_blog( $id );
    200199
    201200                // themes
    202                 if ( isset($_POST[ 'theme' ]) && is_array( $_POST[ 'theme' ] ) )
    203                         $_POST[ 'option' ][ 'allowedthemes' ] = $_POST[ 'theme' ];
    204                 else
    205                         $_POST[ 'option' ][ 'allowedthemes' ] = '';
    206 
    207                 switch_to_blog( $id );
    208                 if ( is_array( $_POST[ 'option' ] ) ) {
     201                $allowedthemes = array();
     202                if ( isset($_POST['theme']) && is_array( $_POST['theme'] ) ) {
     203                        foreach ( $_POST['theme'] as $theme => $val ) {
     204                                if ( 'on' == $val )
     205                                        $allowedthemes[$theme] = true;
     206                        }
     207                }
     208                update_option( 'allowedthemes',  $allowedthemes );
     209
     210                // options
     211                if ( is_array( $_POST['option'] ) ) {
    209212                        $c = 1;
    210                         $count = count( $_POST[ 'option' ] );
     213                        $count = count( $_POST['option'] );
    211214                        foreach ( (array) $_POST['option'] as $key => $val ) {
    212215                                if ( $key === 0 || is_array( $val ) )
    … …  
    220223                }
    221224
     225                // home and siteurl
    222226                if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) {
    223                         $blog_address = get_blogaddress_by_domain($_POST['blog']['domain'], $_POST['blog']['path']);
     227                        $blog_address = get_blogaddress_by_domain( $_POST['blog']['domain'], $_POST['blog']['path'] );
    224228                        if ( get_option( 'siteurl' ) !=  $blog_address )
    225                                 update_option( 'siteurl', $blog_address);
     229                                update_option( 'siteurl', $blog_address );
    226230
    227231                        if ( get_option( 'home' ) != $blog_address )
    … …  
    232236                delete_option( 'rewrite_rules' );
    233237
    234                 // update blogs count
    235                 delete_site_transient( "blog_count" );
    236 
    237238                // update blogs table
    238                 $blog_data = stripslashes_deep($_POST[ 'blog' ]);
    239                 update_blog_details($id, $blog_data);
     239                $blog_data = stripslashes_deep( $_POST['blog'] );
     240                update_blog_details( $id, $blog_data );
    240241
    241242                // get blog prefix
    … …  
    243244
    244245                // user roles
    245                 if ( isset( $_POST[ 'role' ] ) && is_array( $_POST[ 'role' ] ) == true ) {
    246                         $newroles = $_POST[ 'role' ];
     246                if ( isset( $_POST['role'] ) && is_array( $_POST['role'] ) == true ) {
     247                        $newroles = $_POST['role'];
     248
    247249                        reset( $newroles );
    248250                        foreach ( (array) $newroles as $userid => $role ) {
    249                                 $user = new WP_User($userid);
     251                                $user = new WP_User( $userid );
    250252                                if ( ! $user )
    251253                                        continue;
    252                                 $user->for_blog($id);
    253                                 $user->set_role($role);
     254                                $user->for_blog( $id );
     255                                $user->set_role( $role );
    254256                        }
    255257                }
    256258
    257259                // remove user
    258                 if ( isset( $_POST[ 'blogusers' ] ) && is_array( $_POST[ 'blogusers' ] ) ) {
    259                         reset( $_POST[ 'blogusers' ] );
    260                         foreach ( (array) $_POST[ 'blogusers' ] as $key => $val )
     260                if ( isset( $_POST['blogusers'] ) && is_array( $_POST['blogusers'] ) ) {
     261                        reset( $_POST['blogusers'] );
     262                        foreach ( (array) $_POST['blogusers'] as $key => $val )
    261263                                remove_user_from_blog( $key, $id );
    262264                }
    263265
    264266                // change password
    265                 if ( isset( $_POST[ 'user_password' ] ) && is_array( $_POST[ 'user_password' ] ) ) {
    266                         reset( $_POST[ 'user_password' ] );
    267                         $newroles = $_POST[ 'role' ];
    268                         foreach ( (array) $_POST[ 'user_password' ] as $userid => $pass ) {
    269                                 unset( $_POST[ 'role' ] );
    270                                 $_POST[ 'role' ] = $newroles[ $userid ];
     267                if ( isset( $_POST['user_password'] ) && is_array( $_POST['user_password'] ) ) {
     268                        reset( $_POST['user_password'] );
     269                        $newroles = $_POST['role'];
     270                        foreach ( (array) $_POST['user_password'] as $userid => $pass ) {
     271                                unset( $_POST['role'] );
     272                                $_POST['role'] = $newroles[ $userid ];
    271273                                if ( $pass != '' ) {
    272274                                        $cap = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '{$userid}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" );
    273275                                        $userdata = get_userdata($userid);
    274                                         $_POST[ 'pass1' ] = $_POST[ 'pass2' ] = $pass;
    275                                         $_POST[ 'email' ] = $userdata->user_email;
    276                                         $_POST[ 'rich_editing' ] = $userdata->rich_editing;
     276                                        $_POST['pass1'] = $_POST['pass2'] = $pass;
     277                                        $_POST['email'] = $userdata->user_email;
     278                                        $_POST['rich_editing'] = $userdata->rich_editing;
    277279                                        edit_user( $userid );
    278280                                        if ( $cap == null )
    … …  
    280282                                }
    281283                        }
    282                         unset( $_POST[ 'role' ] );
    283                         $_POST[ 'role' ] = $newroles;
    284                 }
    285 
    286                 // add user?
    287                 if ( isset( $_POST[ 'user_password' ] ) && !empty( $_POST[ 'newuser' ] ) ) {
    288                         $newuser = $_POST[ 'newuser' ];
     284                        unset( $_POST['role'] );
     285                        $_POST['role'] = $newroles;
     286                }
     287
     288                // add user
     289                if ( !empty( $_POST['newuser'] ) ) {
     290                        $newuser = $_POST['newuser'];
    289291                        $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) );
    290292                        if ( $userid ) {
    291                                 $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='wp_" . $id . "_capabilities'" );
     293                                $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" );
    292294                                if ( $user == false )
    293                                         add_user_to_blog($id, $userid, $_POST[ 'new_role' ]);
     295                                        add_user_to_blog( $id, $userid, $_POST['new_role'] );
    294296                        }
    295297                }
    296298                do_action( 'wpmu_update_blog_options' );
    297299                restore_current_blog();
    298                 wpmu_admin_do_redirect( "ms-sites.php?action=editblog&updated=true&id=".$id );
    299         break;
    300 
    301         case "deleteblog":
     300                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'editblog', 'id' => $id ), wp_get_referer() ) );
     301        break;
     302
     303        case 'deleteblog':
    302304                check_admin_referer('deleteblog');
    303305                if ( ! current_user_can( 'manage_sites' ) )
    304                         wp_die( __('You do not have permission to access this page.') );
     306                        wp_die( __( 'You do not have permission to access this page.' ) );
    305307
    306308                if ( $id != '0' && $id != $current_site->blog_id )
    307309                        wpmu_delete_blog( $id, true );
    308310
    309                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'delete'), $_POST[ 'ref' ] ) );
    310                 exit();
    311         break;
    312 
    313         case "allblogs":
    314                 if ( isset($_POST['doaction']) || isset($_POST['doaction2']) ) {
    315                         check_admin_referer('bulk-sites');
    316 
    317                 if ( ! current_user_can( 'manage_sites' ) )
    318                         wp_die( __('You do not have permission to access this page.') );
    319 
    320                 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
    321                         $doaction = $doaction = ($_POST['action'] != -1) ? $_POST['action'] : $_POST['action2'];
    322 
    323 
    324                 foreach ( (array) $_POST[ 'allblogs' ] as $key => $val ) {
    325                         if ( $val != '0' && $val != $current_site->blog_id ) {
    326                                 switch ( $doaction ) {
    327                                         case 'delete':
    328                                                 $blogfunction = 'all_delete';
    329                                                 wpmu_delete_blog( $val, true );
     311                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
     312                exit();
     313        break;
     314
     315        case 'allblogs':
     316                if ( isset( $_POST['doaction']) || isset($_POST['doaction2'] ) ) {
     317                        check_admin_referer( 'bulk-ms-sites' );
     318
     319                        if ( ! current_user_can( 'manage_sites' ) )
     320                                wp_die( __( 'You do not have permission to access this page.' ) );
     321       
     322                        if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
     323                                $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
     324
     325
     326                        foreach ( (array) $_POST['allblogs'] as $key => $val ) {
     327                                if ( $val != '0' && $val != $current_site->blog_id ) {
     328                                        switch ( $doaction ) {
     329                                                case 'delete':
     330                                                        $blogfunction = 'all_delete';
     331                                                        wpmu_delete_blog( $val, true );
    330332                                                break;
    331                                         case 'spam':
    332                                                 $blogfunction = 'all_spam';
    333                                                 update_blog_status( $val, "spam", '1', 0 );
    334                                                 set_time_limit(60);
     333
     334                                                case 'spam':
     335                                                        $blogfunction = 'all_spam';
     336                                                        update_blog_status( $val, 'spam', '1', 0 );
     337                                                        set_time_limit( 60 );
    335338                                                break;
    336                                         case 'notspam':
    337                                                 $blogfunction = 'all_notspam';
    338                                                 update_blog_status( $val, "spam", '0', 0 );
    339                                                 set_time_limit(60);
     339
     340                                                case 'notspam':
     341                                                        $blogfunction = 'all_notspam';
     342                                                        update_blog_status( $val, 'spam', '0', 0 );
     343                                                        set_time_limit( 60 );
    340344                                                break;
     345                                        }
     346                                } else {
     347                                        wp_die( __( 'You are not allowed to change the current site.' ) );
    341348                                }
    342                         } else {
    343                                 wp_die( __('You are not allowed to change one of these sites.') );
    344                                 exit();
    345                         };
    346                 };
    347 
    348                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => $blogfunction), $_SERVER['HTTP_REFERER'] ) );
    349                 exit();
    350 
    351                 } else {
    352                         wp_redirect( admin_url("ms-sites.php") );
    353                 }
    354         break;
    355 
    356         case "archiveblog":
    357                 check_admin_referer('archiveblog');
    358                 if ( ! current_user_can( 'manage_sites' ) )
    359                         wp_die( __('You do not have permission to access this page.') );
    360 
    361                 update_blog_status( $id, "archived", '1' );
    362                 do_action( "archive_blog", $id );
    363                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'archive'), $_POST['ref'] ) );
    364                 exit();
    365         break;
    366 
    367         case "unarchiveblog":
    368                 check_admin_referer('unarchiveblog');
    369                 if ( ! current_user_can( 'manage_sites' ) )
    370                         wp_die( __('You do not have permission to access this page.') );
    371 
    372                 do_action( "unarchive_blog", $id );
    373                 update_blog_status( $id, "archived", '0' );
    374                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'unarchive'), $_POST['ref'] ) );
    375                 exit();
    376         break;
    377 
    378         case "activateblog":
    379                 check_admin_referer('activateblog');
    380                 if ( ! current_user_can( 'manage_sites' ) )
    381                         wp_die( __('You do not have permission to access this page.') );
    382 
    383                 update_blog_status( $id, "deleted", '0' );
    384                 do_action( "activate_blog", $id );
    385                 wp_redirect( add_query_arg( "updated", array('updated' => 'true', 'action' => 'activate'), $_POST['ref'] ) );
    386                 exit();
    387         break;
    388 
    389         case "deactivateblog":
    390                 check_admin_referer('deactivateblog');
    391                 if ( ! current_user_can( 'manage_sites' ) )
    392                         wp_die( __('You do not have permission to access this page.') );
    393 
    394                 do_action( "deactivate_blog", $id );
    395                 update_blog_status( $id, "deleted", '1' );
    396                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'deactivate'), $_POST['ref'] ) );
    397                 exit();
    398         break;
    399 
    400         case "unspamblog":
    401                 check_admin_referer('unspamblog');
    402                 if ( ! current_user_can( 'manage_sites' ) )
    403                         wp_die( __('You do not have permission to access this page.') );
    404 
    405                 update_blog_status( $id, "spam", '0' );
    406                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'unspam'), $_POST['ref'] ) );
    407                 exit();
    408         break;
    409 
    410         case "spamblog":
    411                 check_admin_referer('spamblog');
    412                 if ( ! current_user_can( 'manage_sites' ) )
    413                         wp_die( __('You do not have permission to access this page.') );
    414 
    415                 update_blog_status( $id, "spam", '1' );
    416                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'spam'), $_POST['ref'] ) );
    417                 exit();
    418         break;
    419 
    420         case "mature":
     349                        }
     350
     351                        wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
     352                        exit();
     353                } else {
     354                        wp_redirect( admin_url( 'ms-sites.php' ) );
     355                }
     356        break;
     357
     358        case 'archiveblog':
     359                check_admin_referer( 'archiveblog' );
     360                if ( ! current_user_can( 'manage_sites' ) )
     361                        wp_die( __( 'You do not have permission to access this page.' ) );
     362
     363                update_blog_status( $id, 'archived', '1' );
     364                do_action( 'archive_blog', $id );
     365                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
     366                exit();
     367        break;
     368
     369        case 'unarchiveblog':
     370                check_admin_referer( 'unarchiveblog' );
     371                if ( ! current_user_can( 'manage_sites' ) )
     372                        wp_die( __( 'You do not have permission to access this page.' ) );
     373
     374                do_action( 'unarchive_blog', $id );
     375                update_blog_status( $id, 'archived', '0' );
     376                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
     377                exit();
     378        break;
     379
     380        case 'activateblog':
     381                check_admin_referer( 'activateblog' );
     382                if ( ! current_user_can( 'manage_sites' ) )
     383                        wp_die( __( 'You do not have permission to access this page.' ) );
     384
     385                update_blog_status( $id, 'deleted', '0' );
     386                do_action( 'activate_blog', $id );
     387                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
     388                exit();
     389        break;
     390
     391        case 'deactivateblog':
     392                check_admin_referer( 'deactivateblog' );
     393                if ( ! current_user_can( 'manage_sites' ) )
     394                        wp_die( __( 'You do not have permission to access this page.' ) );
     395
     396                do_action( 'deactivate_blog', $id );
     397                update_blog_status( $id, 'deleted', '1' );
     398                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
     399                exit();
     400        break;
     401
     402        case 'unspamblog':
     403                check_admin_referer( 'unspamblog' );
     404                if ( ! current_user_can( 'manage_sites' ) )
     405                        wp_die( __( 'You do not have permission to access this page.' ) );
     406
     407                update_blog_status( $id, 'spam', '0' );
     408                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
     409                exit();
     410        break;
     411
     412        case 'spamblog':
     413                check_admin_referer( 'spamblog' );
     414                if ( ! current_user_can( 'manage_sites' ) )
     415                        wp_die( __( 'You do not have permission to access this page.' ) );
     416
     417                update_blog_status( $id, 'spam', '1' );
     418                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
     419                exit();
     420        break;
     421
     422        case 'matureblog':
     423                check_admin_referer( 'matureblog' );
     424                if ( ! current_user_can( 'manage_sites' ) )
     425                        wp_die( __( 'You do not have permission to access this page.' ) );
     426
    421427                update_blog_status( $id, 'mature', '1' );
    422428                do_action( 'mature_blog', $id );
    423                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'mature'), $_POST['ref'] ) );
    424                 exit();
    425         break;
    426 
    427         case "unmature":
     429                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
     430                exit();
     431        break;
     432
     433        case 'unmatureblog':
     434                check_admin_referer( 'unmatureblog' );
     435                if ( ! current_user_can( 'manage_sites' ) )
     436                        wp_die( __( 'You do not have permission to access this page.' ) );
     437
    428438                update_blog_status( $id, 'mature', '0' );
    429439                do_action( 'unmature_blog', $id );
    430                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'umature'), $_POST['ref'] ) );
     440                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
    431441                exit();
    432442        break;
    433443
    434444        // Themes
    435     case "updatethemes":
     445    case 'updatethemes':
    436446        if ( ! current_user_can( 'manage_network_themes' ) )
    437                 wp_die( __('You do not have permission to access this page.') );
     447                wp_die( __( 'You do not have permission to access this page.' ) );
    438448
    439449        if ( is_array( $_POST['theme'] ) ) {
    … …  
    446456                        update_site_option( 'allowedthemes', $allowed_themes );
    447457                }
    448                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'themes'), $_SERVER['HTTP_REFERER'] ) );
     458                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'themes' ),  wp_get_referer() ) );
    449459                exit();
    450460        break;
    451461
    452462        // Common
    453         case "confirm":
    454                 $referrer = ( isset($_GET['ref']) ) ? stripslashes($_GET['ref']) : $_SERVER['HTTP_REFERER'];
    455                 $referrer = esc_url($referrer);
     463        case 'confirm':
    456464                if ( !headers_sent() ) {
    457465                        nocache_headers();
    458466                        header( 'Content-Type: text/html; charset=utf-8' );
    459467                }
     468                if ( $current_site->blog_id == $id )   
     469                        wp_die( __( 'You are not allowed to change the current site.' ) );
    460470                ?>
    461471                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    462                 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists('language_attributes') ) language_attributes(); ?>>
     472                <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
    463473                        <head>
    464                                 <title><?php _e("WordPress &rsaquo; Confirm your action"); ?></title>
     474                                <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
    465475
    466476                                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    … …  
    468478                        </head>
    469479                        <body id="error-page">
    470                                 <h1 id="logo"><img alt="WordPress" src="<?php echo esc_url( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
    471                                 <form action='ms-edit.php?action=<?php echo esc_attr( $_GET[ 'action2' ] ) ?>' method='post'>
    472                                         <input type='hidden' name='action' value='<?php echo esc_attr( $_GET['action2'] ) ?>' />
    473                                         <input type='hidden' name='id' value='<?php echo esc_attr( $id ); ?>' />
    474                                         <input type='hidden' name='ref' value='<?php echo $referrer; ?>' />
    475                                         <?php wp_nonce_field( $_GET['action2'] ) ?>
    476                                         <p><?php echo esc_html( stripslashes($_GET['msg']) ); ?></p>
    477                                         <p class="submit"><input class="button" type='submit' value='<?php _e("Confirm"); ?>' /></p>
     480                                <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
     481                                <form action="ms-edit.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
     482                                        <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
     483                                        <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
     484                                        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
     485                                        <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
     486                                        <p><?php esc_html_e( stripslashes( $_GET['msg'] ) ); ?></p>
     487                                        <p class="submit"><input class="button" type="submit" value="<?php _e( 'Confirm' ); ?>" /></p>
    478488                                </form>
    479489                        </body>
    … …  
    482492        break;
    483493
    484         // Users (not used any more)
    485         case "deleteuser":
    486                 check_admin_referer('deleteuser');
    487                 if ( $id != '0' && $id != '1' )
    488                         wpmu_delete_user($id);
    489 
    490                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'delete'), $_POST['ref'] ) );
    491                 exit();
    492         break;
    493 
    494         case "allusers":
    495                 check_admin_referer('allusers');
     494        // Users
     495        case 'deleteuser':
    496496                if ( ! current_user_can( 'manage_network_users' ) )
    497                         wp_die( __('You do not have permission to access this page.') );
    498 
    499                 if ( isset($_POST['alluser_delete']) ) {
    500                         require_once('admin-header.php');
    501                         echo '<div class="wrap" style="position:relative;">';
     497                        wp_die( __( 'You do not have permission to access this page.' ) );
     498
     499                check_admin_referer( 'deleteuser' );
     500
     501                if ( $id != '0' && $id != '1' ) {
     502                        $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays
     503                        $title = __( 'Users' );
     504                        $parent_file = 'ms-admin.php';
     505                        require_once( 'admin-header.php' );
     506                        echo '<div class="wrap">';
    502507                        confirm_delete_users( $_POST['allusers'] );
    503508                        echo '</div>';
    504             require_once('admin-footer.php');
    505                 } elseif ( isset( $_POST[ 'alluser_transfer_delete' ] ) ) {
    506                         if ( is_array( $_POST[ 'blog' ] ) && !empty( $_POST[ 'blog' ] ) ) {
    507                                 foreach ( $_POST[ 'blog' ] as $id => $users ) {
    508                                         foreach ( $users as $blogid => $user_id ) {
     509            require_once( 'admin-footer.php' );
     510            exit();
     511                } else {
     512                        wp_redirect( admin_url( 'ms-users.php' ) );     
     513                }
     514        break;
     515
     516        case 'allusers':
     517                if ( ! current_user_can( 'manage_network_users' ) )
     518                        wp_die( __( 'You do not have permission to access this page.' ) );
     519
     520                if ( isset( $_POST['doaction']) || isset($_POST['doaction2'] ) ) {
     521                        check_admin_referer( 'bulk-ms-users' );
     522
     523                        if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
     524                                $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
     525
     526                        foreach ( (array) $_POST['allusers'] as $key => $val ) {
     527                                if ( $val != '' || $val != '0' ) {
     528                                        switch ( $doaction ) {
     529                                                case 'delete':
     530                                                        $title = __( 'Users' );
     531                                                        $parent_file = 'ms-admin.php';
     532                                                        require_once( 'admin-header.php' );
     533                                                        echo '<div class="wrap">';
     534                                                        confirm_delete_users( $_POST['allusers'] );
     535                                                        echo '</div>';
     536                                            require_once( 'admin-footer.php' );
     537                                            exit();
     538                                        break;
     539
     540                                                case 'superadmin':
     541                                                        $userfunction = 'add_superadmin';
     542                                                        $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
     543
     544                                                        $user = new WP_User( $val );
     545                                                        if ( ! in_array( $user->user_login, $super_admins ) ) {
     546                                                                if ( $current_site->blog_id )
     547                                                                        add_user_to_blog( $current_site->blog_id, $user->ID, 'administrator' );
     548
     549                                                                $super_admins[] = $user->user_login;
     550                                                                update_site_option( 'site_admins' , $super_admins );
     551                                                        }
     552                                                break;
     553
     554                                                case 'notsuperadmin':
     555                                                        $userfunction = 'remove_superadmin';
     556                                                        $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
     557                                                        $admin_email = get_site_option( 'admin_email' );
     558                                                       
     559                                                        $user = new WP_User( $val );
     560                                                        if ( $user->ID != $current_user->ID || $user->user_email != $admin_email ) {
     561                                                                foreach ( $super_admins as $key => $username ) {
     562                                                                        if ( $username == $user->user_login ) {
     563                                                                                unset( $super_admins[$key] );
     564                                                                                break;
     565                                                                        }
     566                                                                }
     567                                                        }
     568
     569                                                        update_site_option( 'site_admins' , $super_admins );
     570                                                break;
     571
     572                                                case 'spam':
     573                                                        $user = new WP_User( $val );
     574                                                        if ( in_array( $user->user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) )
     575                                                                wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network admnistrator.' ), esc_html( $user->user_login ) ) );
     576
     577                                                        $userfunction = 'all_spam';
     578                                                        $blogs = get_blogs_of_user( $val, true );
     579                                                        foreach ( (array) $blogs as $key => $details ) {
     580                                                                if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
     581                                                                        update_blog_status( $details->userblog_id, 'spam', '1' );
     582                                                        }
     583                                                        update_user_status( $val, 'spam', '1', 1 );
     584                                                break;
     585
     586                                                case 'notspam':
     587                                                        $userfunction = 'all_notspam';
     588                                                        $blogs = get_blogs_of_user( $val, true );
     589                                                        foreach ( (array) $blogs as $key => $details )
     590                                                                update_blog_status( $details->userblog_id, 'spam', '0' );
     591
     592                                                        update_user_status( $val, 'spam', '0', 1 );
     593                                                break;
     594                                        }               
     595                                }                       
     596                        }
     597
     598                        wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
     599                        exit();
     600                } else {
     601                        wp_redirect( admin_url( 'ms-users.php' ) );
     602                }
     603        break;
     604
     605        case 'dodelete':
     606                check_admin_referer( 'ms-users-delete' );
     607                if ( ! current_user_can( 'manage_network_users' ) )
     608                        wp_die( __( 'You do not have permission to access this page.' ) );
     609
     610                if ( is_array( $_POST['blog'] ) && ! empty( $_POST['blog'] ) ) {
     611                        foreach ( $_POST['blog'] as $id => $users ) {
     612                                foreach ( $users as $blogid => $user_id ) {
     613                                        if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
    509614                                                remove_user_from_blog( $id, $blogid, $user_id );
    510                                         }
     615                                        else
     616                                                remove_user_from_blog( $id, $blogid );
    511617                                }
    512618                        }
    513                         if ( is_array( $_POST[ 'user' ] ) && !empty( $_POST[ 'user' ] ) )
    514                                 foreach( $_POST[ 'user' ] as $id )
    515                                         wpmu_delete_user( $id );
    516 
    517                         wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'all_delete'), 'ms-users.php' ) );
    518                 } elseif ( isset( $_POST[ 'add_superadmin' ] ) ) {
    519                         $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
    520                         $mainblog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
    521                         foreach ( (array) $_POST['allusers'] as $key => $val ) {
    522                                 if ( $val == '' || $val == '0' )
    523                                         continue;
    524                                 $user = new WP_User( $val );
    525                                 if ( in_array( $user->user_login, $super_admins ) )
    526                                         continue;
    527                                 if ( $mainblog_id )
    528                                         add_user_to_blog( $mainblog_id, $user->ID, 'administrator' );
    529                                 $super_admins[] = $user->user_login;
    530                         }
    531                         update_site_option( 'site_admins' , $super_admins );
    532 
    533                         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add_superadmin' ), $_SERVER['HTTP_REFERER'] ) );
    534                 } elseif ( isset( $_POST[ 'remove_superadmin' ] ) ) {
    535                         $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
    536                         $admin_email = get_site_option( 'admin_email' );
    537                         foreach ( (array) $_POST['allusers'] as $key => $val ) {
    538                                 if ( $val == '' || $val == '0' )
    539                                         continue;
    540                                 $user = new WP_User( $val );
    541                                 if ( $user->ID == $current_user->ID || $user->user_email == $admin_email )
    542                                         continue;
    543                                 foreach ( $super_admins as $key => $username ) {
    544                                         if ( $username == $user->user_login ) {
    545                                                 unset( $super_admins[ $key ] );
    546                                                 break;
    547                                         }
    548                                 }
    549                         }
    550                         update_site_option( 'site_admins' , $super_admins );
    551 
    552                         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'remove_superadmin' ), $_SERVER['HTTP_REFERER'] ) );
    553                 } else {
    554                         foreach ( (array) $_POST['allusers'] as $key => $val ) {
    555                                 if ( $val == '' || $val == '0' )
    556                                         continue;
    557                                 $user = new WP_User( $val );
    558                                 if ( in_array( $user->user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) )
    559                                         wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network admnistrator.' ), $user->user_login ) );
    560                                 if ( isset($_POST['alluser_spam']) ) {
    561                                         $userfunction = 'all_spam';
    562                                         $blogs = get_blogs_of_user( $val, true );
    563                                         foreach ( (array) $blogs as $key => $details ) {
    564                                                 if ( $details->userblog_id == $current_site->blog_id ) { continue; } // main blog not a spam !
    565                                                 update_blog_status( $details->userblog_id, "spam", '1' );
    566                                         }
    567                                         update_user_status( $val, "spam", '1', 1 );
    568                                 } elseif ( isset($_POST['alluser_notspam']) ) {
    569                                         $userfunction = 'all_notspam';
    570                                         $blogs = get_blogs_of_user( $val, true );
    571                                         foreach ( (array) $blogs as $key => $details ) {
    572                                                 update_blog_status( $details->userblog_id, "spam", '0' );
    573                                         }
    574                                         update_user_status( $val, "spam", '0', 1 );
    575                                 }
    576                         }
    577                         wp_redirect( add_query_arg( array('updated' => 'true', 'action' => $userfunction), $_SERVER['HTTP_REFERER'] ) );
    578                 }
    579                 exit();
    580         break;
    581 
    582         case "adduser":
    583                 check_admin_referer('add-user');
     619                }
     620                $i = 0;
     621                if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
     622                        foreach( $_POST['user'] as $id ) {
     623                                wpmu_delete_user( $id );
     624                                $i++;   
     625                        }
     626
     627                if ( $i == 1 )
     628                        $deletefunction = 'delete';
     629                else
     630                        $deletefunction = 'all_delete';
     631
     632                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), admin_url( 'ms-users.php' ) ) );
     633        break;
     634
     635        case 'adduser':
     636                check_admin_referer( 'add-user' );
    584637                if ( ! current_user_can( 'manage_network_users' ) )
    585                         wp_die( __('You do not have permission to access this page.') );
    586 
    587                 if ( is_array( $_POST[ 'user' ] ) == false )
    588                         wp_die( __( "Cannot create an empty user." ) );
     638                        wp_die( __( 'You do not have permission to access this page.' ) );
     639
     640                if ( is_array( $_POST['user'] ) == false )
     641                        wp_die( __( 'Cannot create an empty user.' ) );
    589642                $user = $_POST['user'];
    590643                if ( empty($user['username']) && empty($user['email']) )
    591                         wp_die( __('Missing username and email.') );
     644                        wp_die( __( 'Missing username and email.' ) );
    592645                elseif ( empty($user['username']) )
    593                         wp_die( __('Missing username.') );
     646                        wp_die( __( 'Missing username.' ) );
    594647                elseif ( empty($user['email']) )
    595                         wp_die( __('Missing email.') );
     648                        wp_die( __( 'Missing email.' ) );
    596649
    597650                $password = wp_generate_password();
    598                 $user_id = wpmu_create_user(esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
     651                $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
    599652
    600653                if ( false == $user_id )
    601                         wp_die( __('Duplicated username or email address.') );
     654                        wp_die( __( 'Duplicated username or email address.' ) );
    602655                else
    603                         wp_new_user_notification($user_id, $password);
     656                        wp_new_user_notification( $user_id, $password );
    604657
    605658                if ( get_site_option( 'dashboard_blog' ) == false )
    … …  
    608661                        add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    609662
    610                 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add'), $_SERVER['HTTP_REFERER'] ) );
     663                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) );
    611664                exit();
    612665        break;
    613666
    614667        default:
    615                 wpmu_admin_do_redirect( "ms-admin.php" );
     668                wp_redirect( admin_url( 'ms-admin.php' ) );
    616669        break;
    617670}
  • trunk/wp-admin/ms-options.php

    r13884 r13918  
    11<?php
    2 require_once('admin.php');
     2require_once( './admin.php' );
    33
    44if ( !is_multisite() )
    5         wp_die( __('Multisite support is not enabled.') );
    6 
    7 $title = __('Network Options');
     5        wp_die( __( 'Multisite support is not enabled.' ) );
     6
     7$title = __( 'Network Options' );
    88$parent_file = 'ms-admin.php';
    99
    10 include('admin-header.php');
     10include( './admin-header.php' );
    1111
    1212if ( ! current_user_can( 'manage_network_options' ) )
    13     wp_die( __('You do not have permission to access this page.') );
     13    wp_die( __( 'You do not have permission to access this page.' ) );
    1414
    1515if (isset($_GET['updated'])) {
    1616        ?>
    17         <div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div>
     17        <div id="message" class="updated fade"><p><?php _e( 'Options saved.' ) ?></p></div>
    1818        <?php
    1919}
    … …  
    2222<div class="wrap">
    2323        <?php screen_icon(); ?>
    24         <h2><?php _e('Network Options') ?></h2>
     24        <h2><?php _e( 'Network Options' ) ?></h2>
    2525        <form method="post" action="ms-edit.php?action=siteoptions">
    26                 <?php wp_nonce_field( "siteoptions" ); ?>
    27                 <h3><?php _e('Operational Settings'); ?></h3>
    28                 <table class="form-table">
    29                         <tr valign="top">
    30                                 <th scope="row"><label for="site_name"><?php _e('Network Name') ?></label></th>
    31                                 <td>
    32                                         <input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr($current_site->site_name) ?>" />
    33                                         <br />
    34                                         <?php _e('What you would like to call this website.') ?>
    35                                 </td>
    36                         </tr>
    37 
    38                         <tr valign="top">
    39                                 <th scope="row"><label for="admin_email"><?php _e('Network Admin Email') ?></label></th>
     26                <?php wp_nonce_field( 'siteoptions' ); ?>
     27                <h3><?php _e( 'Operational Settings' ); ?></h3>
     28                <table class="form-table">
     29                        <tr valign="top">
     30                                <th scope="row"><label for="site_name"><?php _e( 'Network Name' ) ?></label></th>
     31                                <td>
     32                                        <input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr( $current_site->site_name ) ?>" />
     33                                        <br />
     34                                        <?php _e( 'What you would like to call this website.' ) ?>
     35                                </td>
     36                        </tr>
     37
     38                        <tr valign="top">
     39                                <th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ) ?></label></th>
    4040                                <td>
    4141                                        <input name="admin_email" type="text" id="admin_email" class="regular-text" value="<?php echo esc_attr( get_site_option('admin_email') ) ?>" />
    … …  
    4646
    4747                        <tr valign="top">
    48                                 <th scope="row"><?php _e('Global Terms') ?></th>
    49                                 <td>
    50                                 <label><input type='radio' id="global_terms_enabled" name="global_terms_enabled" value='1'<?php checked( get_site_option( 'global_terms_enabled' ), 1 ) ?>/> <?php _e( 'Maintain a global list of terms from all sites across the network.' ); ?></label><br />
    51                                 <label><input type='radio' id="global_terms_enabled" name="global_terms_enabled" value='0'<?php checked( get_site_option( 'global_terms_enabled' ), 0 ) ?>/> <?php _e( 'Disabled' ); ?></label></td>
    52                         </tr>
    53                 </table>
    54                 <h3><?php _e('Dashboard Settings'); ?></h3>
    55                 <table class="form-table">
    56                         <tr valign="top">
    57                                 <th scope="row"><label for="dashboard_blog"><?php _e('Dashboard Site') ?></label></th>
     48                                <th scope="row"><?php _e( 'Global Terms' ) ?></th>
     49                                <td>
     50                                <label><input type="radio" id="global_terms_enabled" name="global_terms_enabled" value="1"<?php checked( get_site_option( 'global_terms_enabled' ), 1 ) ?>/> <?php _e( 'Maintain a global list of terms from all sites across the network.' ); ?></label><br />
     51                                <label><input type="radio" id="global_terms_enabled" name="global_terms_enabled" value="0"<?php checked( get_site_option( 'global_terms_enabled' ), 0 ) ?>/> <?php _e( 'Disabled' ); ?></label></td>
     52                        </tr>
     53                </table>
     54                <h3><?php _e( 'Dashboard Settings' ); ?></h3>
     55                <table class="form-table">
     56                        <tr valign="top">
     57                                <th scope="row"><label for="dashboard_blog"><?php _e( 'Dashboard Site' ) ?></label></th>
    5858                                <td>
    5959                                        <?php
    … …  
    6464                                                $blogname = '';
    6565                                        }?>
    66                                         <input name="dashboard_blog_orig" type="hidden" id="dashboard_blog_orig" value="<?php echo esc_attr($blogname); ?>" />
    67                                         <input name="dashboard_blog" type="text" id="dashboard_blog" value="<?php echo esc_attr($blogname); ?>" class="regular-text" />
     66                                        <input name="dashboard_blog_orig" type="hidden" id="dashboard_blog_orig" value="<?php echo esc_attr( $blogname ); ?>" />
     67                                        <input name="dashboard_blog" type="text" id="dashboard_blog" value="<?php echo esc_attr( $blogname ); ?>" class="regular-text" />
    6868                                        <br />
    6969                                        <?php _e( "Site path ('dashboard', 'control', 'manager', etc) or blog id.<br />New users are added to this site as the user role defined below if they don't have a site. Leave blank for the main site. Users with the subscriber role on old site will be moved to the new site if changed. The new site will be created if it does not exist." ); ?>
    … …  
    7171                        </tr>
    7272                        <tr valign="top">
    73                                 <th scope="row"><label for="default_user_role"><?php _e('Dashboard User Default Role') ?></label></th>
     73                                <th scope="row"><label for="default_user_role"><?php _e( 'Dashboard User Default Role' ) ?></label></th>
    7474                                <td>
    7575                                        <select name="default_user_role" id="default_user_role"><?php
    … …  
    8282                        </tr>
    8383                        <tr valign="top">
    84                                 <th scope="row"><label for="admin_notice_feed"><?php _e('Admin Notice Feed') ?></label></th>
     84                                <th scope="row"><label for="admin_notice_feed"><?php _e( 'Admin Notice Feed' ) ?></label></th>
    8585                                <td><input name="admin_notice_feed" class="large-text" type="text" id="admin_notice_feed" value="<?php echo esc_attr( get_site_option( 'admin_notice_feed' ) ) ?>" size="80" /><br />
    8686                                <?php _e( 'Display the latest post from this RSS or Atom feed on all site dashboards. Leave blank to disable.' ); ?><br />
    87                                 <?php if ( get_site_option( 'admin_notice_feed' ) != network_home_url('feed/', 'http') )
    88                                         echo __( "A good one to use would be the feed from your main site: " ) . network_home_url('feed/'); ?></td>
    89                         </tr>
    90                 </table>
    91                 <h3><?php _e('Registration Settings'); ?></h3>
    92                 <table class="form-table">
    93                         <tr valign="top">
    94                                 <th scope="row"><?php _e('Allow new registrations') ?></th>
     87                               
     88                                <?php if ( get_site_option( 'admin_notice_feed' ) != get_home_url( $current_site->id, 'feed/' ) )
     89                                        echo __( 'A good one to use would be the feed from your main site: ' ) . esc_url( get_home_url( $current_site->id, 'feed/' ) ) ?></td>
     90                        </tr>
     91                </table>
     92                <h3><?php _e( 'Registration Settings' ); ?></h3>
     93                <table class="form-table">
     94                        <tr valign="top">
     95                                <th scope="row"><?php _e( 'Allow new registrations' ) ?></th>
    9596                                <?php
    96                                 if ( !get_site_option('registration') )
     97                                if ( !get_site_option( 'registration' ) )
    9798                                        update_site_option( 'registration', 'none' );
     99                                $reg = get_site_option( 'registration' );
    98100                                ?>
    99101                                <td>
    100                                         <label><input name="registration" type="radio" id="registration1" value='none'<?php checked( get_site_option('registration'), 'none') ?> /> <?php _e('Registration is disabled.'); ?></label><br />
    101                                         <label><input name="registration" type="radio" id="registration2" value='user'<?php checked( get_site_option('registration'), 'user') ?> /> <?php _e('User accounts may be registered.'); ?></label><br />
    102                                         <label><input name="registration" type="radio" id="registration3" value='blog'<?php checked( get_site_option('registration'), 'blog') ?> /> <?php _e('Logged in users may register new sites.'); ?></label><br />
    103                                         <label><input name="registration" type="radio" id="registration4" value='all'<?php checked( get_site_option('registration'), 'all') ?> /> <?php _e('Both sites and user accounts can be registered.'); ?></label><br />
    104                                         <p><?php _e('Disable or enable registration and who or what can be registered. (Default is disabled.)'); ?></p>
     102                                        <label><input name="registration" type="radio" id="registration1" value="none"<?php checked( $reg, 'none') ?> /> <?php _e( 'Registration is disabled.' ); ?></label><br />
     103                                        <label><input name="registration" type="radio" id="registration2" value="user"<?php checked( $reg, 'user') ?> /> <?php _e( 'User accounts may be registered.' ); ?></label><br />
     104                                        <label><input name="registration" type="radio" id="registration3" value="blog"<?php checked( $reg, 'blog') ?> /> <?php _e( 'Logged in users may register new sites.' ); ?></label><br />
     105                                        <label><input name="registration" type="radio" id="registration4" value="all"<?php checked( $reg, 'all') ?> /> <?php _e( 'Both sites and user accounts can be registered.' ); ?></label><br />
     106                                        <p><?php _e( 'Disable or enable registration and who or what can be registered. (Default is disabled.)' ); ?></p>
    105107                                        <?php if ( is_subdomain_install() ) {
    106                                                 echo '<p>' . __('If registration is disabled, please set <code>NOBLOGREDIRECT</code> in <code>wp-config.php</code> to a url you will redirect visitors to if they visit a non-existent site.') . '</p>';
     108                                                echo '<p>' . __( 'If registration is disabled, please set <code>NOBLOGREDIRECT</code> in <code>wp-config.php</code> to a url you will redirect visitors to if they visit a non-existent site.' ) . '</p>';
    107109                                        } ?>
    108110                                </td>
    … …  
    110112
    111113                        <tr valign="top">
    112                                 <th scope="row"><?php _e('Registration notification') ?></th>
     114                                <th scope="row"><?php _e( 'Registration notification' ) ?></th>
    113115                                <?php
    114                                 if ( !get_site_option('registrationnotification') )
     116                                if ( !get_site_option( 'registrationnotification' ) )
    115117                                        update_site_option( 'registrationnotification', 'yes' );
    116118                                ?>
    117119                                <td>
    118                                         <label><input name="registrationnotification" type="checkbox" id="registrationnotification" value='yes'<?php checked( get_site_option('registrationnotification'), 'yes' ) ?> /> <?php _e('Send the network admin an email notification every time someone registers a site or user account.') ?></label>
     120                                        <label><input name="registrationnotification" type="checkbox" id="registrationnotification" value="yes"<?php checked( get_site_option( 'registrationnotification' ), 'yes' ) ?> /> <?php _e( 'Send the network admin an email notification every time someone registers a site or user account.' ) ?></label>
    119121                                </td>
    120122                        </tr>
    121123
    122124                        <tr valign="top" id="addnewusers">
    123                                 <th scope="row"><?php _e('Add New Users') ?></th>
    124                                 <td>
    125                                         <label><input name="add_new_users" type="checkbox" id="add_new_users" value='1'<?php checked( get_site_option('add_new_users') ) ?> /> <?php _e('Allow site administrators to add new users to their site via the "Users->Add New" page.'); ?></label>
    126                                 </td>
    127                         </tr>
    128 
    129                         <tr valign="top">
    130                                 <th scope="row"><label for="illegal_names"><?php _e('Banned Names') ?></label></th>
    131                                 <td>
    132                                         <input name="illegal_names" type="text" id="illegal_names" class="large-text" value="<?php echo esc_attr( implode( " ", get_site_option('illegal_names') ) ); ?>" size="45" />
    133                                         <br />
    134                                         <?php _e('Users are not allowed to register these sites. Separate names by spaces.') ?>
    135                                 </td>
    136                         </tr>
    137 
    138                         <tr valign="top">
    139                                 <th scope="row"><label for="limited_email_domains"><?php _e('Limited Email Registrations') ?></label></th>
    140                                 <td>
    141                                         <?php $limited_email_domains = get_site_option('limited_email_domains');
     125                                <th scope="row"><?php _e( 'Add New Users' ) ?></th>
     126                                <td>
     127                                        <label><input name="add_new_users" type="checkbox" id="add_new_users" value="1"<?php checked( get_site_option( 'add_new_users' ) ) ?> /> <?php _e( 'Allow site administrators to add new users to their site via the "Users->Add New" page.' ); ?></label>
     128                                </td>
     129                        </tr>
     130
     131                        <tr valign="top">
     132                                <th scope="row"><label for="illegal_names"><?php _e( 'Banned Names' ) ?></label></th>
     133                                <td>
     134                                        <input name="illegal_names" type="text" id="illegal_names" class="large-text" value="<?php echo esc_attr( implode( " ", get_site_option( 'illegal_names' ) ) ); ?>" size="45" />
     135                                        <br />
     136                                        <?php _e( 'Users are not allowed to register these sites. Separate names by spaces.' ) ?>
     137                                </td>
     138                        </tr>
     139
     140                        <tr valign="top">
     141                                <th scope="row"><label for="limited_email_domains"><?php _e( 'Limited Email Registrations' ) ?></label></th>
     142                                <td>
     143                                        <?php $limited_email_domains = get_site_option( 'limited_email_domains' );
    142144                                        $limited_email_domains = str_replace( ' ', "\n", $limited_email_domains ); ?>
    143                                         <textarea name="limited_email_domains" id="limited_email_domains" cols='45' rows='5'><?php echo wp_htmledit_pre( $limited_email_domains == '' ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea>
    144                                         <br />
    145                                         <?php _e('If you want to limit site registrations to certain domains. Enter one domain per line.') ?>
     145                                        <textarea name="limited_email_domains" id="limited_email_domains" cols="45" rows="5"><?php echo wp_htmledit_pre( $limited_email_domains == '' ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea>
     146                                        <br />
     147                                        <?php _e( 'If you want to limit site registrations to certain domains. Enter one domain per line.' ) ?>
    146148                                </td>
    147149                        </tr>
    … …  
    150152                                <th scope="row"><label for="banned_email_domains"><?php _e('Banned Email Domains') ?></label></th>
    151153                                <td>
    152                                         <textarea name="banned_email_domains" id="banned_email_domains" cols='45' rows='5'><?php echo wp_htmledit_pre( get_site_option('banned_email_domains') == '' ? '' : implode( "\n", (array) get_site_option('banned_email_domains') ) ); ?></textarea>
     154                                        <textarea name="banned_email_domains" id="banned_email_domains" cols="45" rows="5"><?php echo wp_htmledit_pre( get_site_option( 'banned_email_domains' ) == '' ? '' : implode( "\n", (array) get_site_option( 'banned_email_domains' ) ) ); ?></textarea>
    153155                                        <br />
    154156                                        <?php _e('If you want to ban domains from site registrations. Enter one domain per line.') ?>
    … …  
    161163
    162164                        <tr valign="top">
    163                                 <th scope="row"><label for="welcome_email"><?php _e('Welcome Email') ?></label></th>
    164                                 <td>
    165                                         <textarea name="welcome_email" id="welcome_email" rows='5' cols='45' class="large-text"><?php echo stripslashes( get_site_option('welcome_email') ) ?></textarea>
    166                                         <br />
    167                                         <?php _e('The welcome email sent to new site owners.') ?>
    168                                 </td>
    169                         </tr>
    170                         <tr valign="top">
    171                                 <th scope="row"><label for="welcome_user_email"><?php _e('Welcome User Email') ?></label></th>
    172                                 <td>
    173                                         <textarea name="welcome_user_email" id="welcome_user_email" rows='5' cols='45' class="large-text"><?php echo stripslashes( get_site_option('welcome_user_email') ) ?></textarea>
    174                                         <br />
    175                                         <?php _e('The welcome email sent to new users.') ?>
    176                                 </td>
    177                         </tr>
    178                         <tr valign="top">
    179                                 <th scope="row"><label for="first_post"><?php _e('First Post') ?></label></th>
    180                                 <td>
    181                                         <textarea name="first_post" id="first_post" rows='5' cols='45' class="large-text"><?php echo stripslashes( get_site_option('first_post') ) ?></textarea>
    182                                         <br />
    183                                         <?php _e('The first post on a new site.') ?>
    184                                 </td>
    185                         </tr>
    186                         <tr valign="top">
    187                                 <th scope="row"><label for="first_page"><?php _e('First Page') ?></label></th>
    188                                 <td>
    189                                         <textarea name="first_page" id="first_page" rows='5' cols='45' class="large-text"><?php echo stripslashes( get_site_option('first_page') ) ?></textarea>
    190                                         <br />
    191                                         <?php _e('The first page on a new site.') ?>
    192                                 </td>
    193                         </tr>
    194                         <tr valign="top">
    195                                 <th scope="row"><label for="first_comment"><?php _e('First Comment') ?></label></th>
    196                                 <td>
    197                                         <textarea name="first_comment" id="first_comment" rows='5' cols='45' class="large-text"><?php echo stripslashes( get_site_option('first_comment') ) ?></textarea>
    198                                         <br />
    199                                         <?php _e('The first comment on a new site.') ?>
    200                                 </td>
    201                         </tr>
    202                         <tr valign="top">
    203                                 <th scope="row"><label for="first_comment_author"><?php _e('First Comment Author') ?></label></th>
    204                                 <td>
    205                                         <input type="text" size='40' name="first_comment_author" id="first_comment_author" value="<?php echo get_site_option('first_comment_author') ?>" />
    206                                         <br />
    207                                         <?php _e('The author of the first comment on a new site.') ?>
    208                                 </td>
    209                         </tr>
    210                         <tr valign="top">
    211                                 <th scope="row"><label for="first_comment_url"><?php _e('First Comment URL') ?></label></th>
    212                                 <td>
    213                                         <input type="text" size='40' name="first_comment_url" id="first_comment_url" value="<?php echo esc_attr(get_site_option('first_comment_url')) ?>" />
    214                                         <br />
    215                                         <?php _e('The URL for the first comment on a new site.') ?>
    216                                 </td>
    217                         </tr>
    218                 </table>
    219                 <h3><?php _e('Upload Settings'); ?></h3>
    220                 <table class="form-table">
    221                         <tr valign="top">
    222                                 <th scope="row"><?php _e('Media upload buttons') ?></th>
     165                                <th scope="row"><label for="welcome_email"><?php _e( 'Welcome Email' ) ?></label></th>
     166                                <td>
     167                                        <textarea name="welcome_email" id="welcome_email" rows="5" cols="45" class="large-text"><?php echo stripslashes( get_site_option( 'welcome_email' ) ) ?></textarea>
     168                                        <br />
     169                                        <?php _e( 'The welcome email sent to new site owners.' ) ?>
     170                                </td>
     171                        </tr>
     172                        <tr valign="top">
     173                                <th scope="row"><label for="welcome_user_email"><?php _e( 'Welcome User Email' ) ?></label></th>
     174                                <td>
     175                                <textarea name="welcome_user_email" id="welcome_user_email" rows="5" cols="45" class="large-text"><?php echo stripslashes( get_site_option( 'welcome_user_email' ) ) ?></textarea>
     176                                        <br />
     177                                        <?php _e( 'The welcome email sent to new users.' ) ?>
     178                                </td>
     179                        </tr>
     180                        <tr valign="top">
     181                                <th scope="row"><label for="first_post"><?php _e( 'First Post' ) ?></label></th>
     182                                <td>
     183                                        <textarea name="first_post" id="first_post" rows="5" cols="45" class="large-text"><?php echo stripslashes( get_site_option( 'first_post' ) ) ?></textarea>
     184                                        <br />
     185                                        <?php _e( 'The first post on a new site.' ) ?>
     186                                </td>
     187                        </tr>
     188                        <tr valign="top">
     189                                <th scope="row"><label for="first_page"><?php _e( 'First Page' ) ?></label></th>
     190                                <td>
     191                                        <textarea name="first_page" id="first_page" rows="5" cols="45" class="large-text"><?php echo stripslashes( get_site_option('first_page') ) ?></textarea>
     192                                        <br />
     193                                        <?php _e( 'The first page on a new site.' ) ?>
     194                                </td>
     195                        </tr>
     196                        <tr valign="top">
     197                                <th scope="row"><label for="first_comment"><?php _e( 'First Comment' ) ?></label></th>
     198                                <td>
     199                                        <textarea name="first_comment" id="first_comment" rows="5" cols="45" class="large-text"><?php echo stripslashes( get_site_option('first_comment') ) ?></textarea>
     200                                        <br />
     201                                        <?php _e( 'The first comment on a new site.' ) ?>
     202                                </td>
     203                        </tr>
     204                        <tr valign="top">
     205                                <th scope="row"><label for="first_comment_author"><?php _e( 'First Comment Author' ) ?></label></th>
     206                                <td>
     207                                        <input type="text" size="40" name="first_comment_author" id="first_comment_author" value="<?php echo get_site_option('first_comment_author') ?>" />
     208                                        <br />
     209                                        <?php _e( 'The author of the first comment on a new site.' ) ?>
     210                                </td>
     211                        </tr>
     212                        <tr valign="top">
     213                                <th scope="row"><label for="first_comment_url"><?php _e( 'First Comment URL' ) ?></label></th>
     214                                <td>
     215                                        <input type="text" size="40" name="first_comment_url" id="first_comment_url" value="<?php echo esc_attr( get_site_option( 'first_comment_url' ) ) ?>" />
     216                                        <br />
     217                                        <?php _e( 'The URL for the first comment on a new site.' ) ?>
     218                                </td>
     219                        </tr>
     220                </table>
     221                <h3><?php _e( 'Upload Settings' ); ?></h3>
     222                <table class="form-table">
     223                        <tr valign="top">
     224                                <th scope="row"><?php _e( 'Media upload buttons' ) ?></th>
    223225                                <?php $mu_media_buttons = get_site_option( 'mu_media_buttons', array() ); ?>
    224                                 <td><label><input type='checkbox' id="mu_media_buttons_image" name="mu_media_buttons[image]" value='1'<?php checked( !empty($mu_media_buttons[ 'image' ]) ) ?>/> <?php _e( 'Images' ); ?></label><br />
    225                                 <label><input type='checkbox' id="mu_media_buttons_video" name="mu_media_buttons[video]" value='1'<?php checked( !empty($mu_media_buttons[ 'video' ]) ) ?>/> <?php _e( 'Videos' ); ?></label><br />
    226                                 <label><input type='checkbox' id="mu_media_buttons_audio" name="mu_media_buttons[audio]" value='1'<?php checked( !empty($mu_media_buttons[ 'audio' ]) ) ?>/> <?php _e( 'Music' ); ?></label><br />
     226                                <td><label><input type="checkbox" id="mu_media_buttons_image" name="mu_media_buttons[image]" value="1"<?php checked( ! empty( $mu_media_buttons['image'] ) ) ?>/> <?php _e( 'Images' ); ?></label><br />
     227                                <label><input type="checkbox" id="mu_media_buttons_video" name="mu_media_buttons[video]" value="1"<?php checked( ! empty( $mu_media_buttons['video'] ) ) ?>/> <?php _e( 'Videos' ); ?></label><br />
     228                                <label><input type="checkbox" id="mu_media_buttons_audio" name="mu_media_buttons[audio]" value="1"<?php checked( ! empty( $mu_media_buttons['audio'] ) ) ?>/> <?php _e( 'Music' ); ?></label><br />
    227229                                <?php _e( 'The media upload buttons to display on the "Write Post" page. Make sure you update the allowed upload file types below as well.' ); ?></td>
    228230                        </tr>
    229231
    230232                        <tr valign="top">
    231                                 <th scope="row"><?php _e('Site upload space') ?></th>
    232                                 <td>
    233                                 <label><input type='checkbox' id="upload_space_check_disabled" name="upload_space_check_disabled" value='0'<?php checked( get_site_option( 'upload_space_check_disabled' ), 0 ) ?>/> <?php printf( __( 'Limit total size of files uploaded to %s MB' ), '<input name="blog_upload_space" type="text" id="blog_upload_space" value="' . esc_attr( get_site_option('blog_upload_space', 10) ) . '" size="3" />' ); ?></label><br />
    234                         </tr>
    235 
    236                         <tr valign="top">
    237                                 <th scope="row"><label for="upload_filetypes"><?php _e('Upload file types') ?></label></th>
     233                                <th scope="row"><?php _e( 'Site upload space' ) ?></th>
     234                                <td>
     235                                <label><input type="checkbox" id="upload_space_check_disabled" name="upload_space_check_disabled" value="0"<?php checked( get_site_option( 'upload_space_check_disabled' ), 0 ) ?>/> <?php printf( __( 'Limit total size of files uploaded to %s MB' ), '<input name="blog_upload_space" type="text" id="blog_upload_space" value="' . esc_attr( get_site_option('blog_upload_space', 10) ) . '" size="3" />' ); ?></label><br />
     236                        </tr>
     237
     238                        <tr valign="top">
     239                                <th scope="row"><label for="upload_filetypes"><?php _e( 'Upload file types' ) ?></label></th>
    238240                                <td><input name="upload_filetypes" type="text" id="upload_filetypes" class="large-text" value="<?php echo esc_attr( get_site_option('upload_filetypes', 'jpg jpeg png gif') ) ?>" size="45" /></td>
    239241                        </tr>
    240242
    241243                        <tr valign="top">
    242                                 <th scope="row"><label for="fileupload_maxk"><?php _e('Max upload file size') ?></label></th>
    243                                 <td><?php printf( _x( '%s KB', 'File size in kilobytes' ), '<input name="fileupload_maxk" type="text" id="fileupload_maxk" value="' . esc_attr( get_site_option('fileupload_maxk', 300 ) ) . '" size="5" />' ); ?></td>
     244                                <th scope="row"><label for="fileupload_maxk"><?php _e( 'Max upload file size' ) ?></label></th>
     245                                <td><?php printf( _x( '%s KB', 'File size in kilobytes' ), '<input name="fileupload_maxk" type="text" id="fileupload_maxk" value="' . esc_attr( get_site_option( 'fileupload_maxk', 300 ) ) . '" size="5" />' ); ?></td>
    244246                        </tr>
    245247                </table>
    … …  
    248250                $languages = get_available_languages();
    249251                if ( ! empty( $languages ) ) {
    250                         $lang = get_site_option('WPLANG');
     252                        $lang = get_site_option( 'WPLANG' );
    251253?>
    252                 <h3><?php _e('Network Wide Settings'); ?></h3>
     254                <h3><?php _e( 'Network Wide Settings' ); ?></h3>
    253255                <div class="updated inline"><p><strong><?php _e( 'Notice:' ); ?></strong> <?php _e( 'These settings may be overridden by site owners.' ); ?></p></div>
    254256                <table class="form-table">
    … …  
    256258                                ?>
    257259                                <tr valign="top">
    258                                         <th><label for="WPLANG"><?php _e('Default Language') ?></label></th>
     260                                        <th><label for="WPLANG"><?php _e( 'Default Language' ) ?></label></th>
    259261                                        <td>
    260262                                                <select name="WPLANG" id="WPLANG">
    261                                                         <?php mu_dropdown_languages( $languages, get_site_option('WPLANG') ); ?>
     263                                                        <?php mu_dropdown_languages( $languages, get_site_option( 'WPLANG' ) ); ?>
    262264                                                </select>
    263265                                        </td>
    … …  
    268270?>
    269271
    270                 <h3><?php _e('Menu Settings'); ?></h3>
     272                <h3><?php _e( 'Menu Settings' ); ?></h3>
    271273                <table id="menu" class="form-table">
    272274                        <tr valign="top">
    … …  
    277279                        $menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) );
    278280                        foreach ( (array) $menu_items as $key => $val ) {
    279                                 echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" .  ( isset( $menu_perms[ $key ] ) ? checked( $menu_perms[ $key ], '1', false ) : '' ) . " /> " . esc_html( $val ) . "</label><br/>";
     281                                echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" .  ( isset( $menu_perms[$key] ) ? checked( $menu_perms[$key], '1', false ) : '' ) . " /> " . esc_html( $val ) . "</label><br/>";
    280282                        }
    281283                        ?>
    … …  
    286288                <?php do_action( 'wpmu_options' ); // Add more options here ?>
    287289
    288                 <p class="submit"><input type="submit" class="button-primary" name="Submit" value="<?php esc_attr_e('Save Changes') ?>" /></p>
     290                <p class="submit"><input type="submit" class="button-primary" name="Submit" value="<?php esc_attr_e( 'Save Changes' ) ?>" /></p>
    289291        </form>
    290292</div>
    291293
    292 <?php include('./admin-footer.php'); ?>
     294<?php include( './admin-footer.php' ); ?>
  • trunk/wp-admin/ms-sites.php

    r13733 r13918  
    11<?php
    2 require_once('admin.php');
     2require_once( './admin.php' );
    33
    44if ( !is_multisite() )
    5         wp_die( __('Multisite support is not enabled.') );
    6 
    7 $title = __('Sites');
     5        wp_die( __( 'Multisite support is not enabled.' ) );
     6
     7$title = __( 'Sites' );
    88$parent_file = 'ms-admin.php';
    99
    1010wp_enqueue_script( 'admin-forms' );
    1111
    12 require_once('admin-header.php');
     12require_once( './admin-header.php' );
    1313
    1414if ( ! current_user_can( 'manage_sites' ) )
    15         wp_die( __('You do not have permission to access this page.') );
    16 
    17 $id = isset($_GET['id']) ? intval( $_GET['id'] ) : 0;
    18 $protocol = is_ssl() ? 'https://' : 'http://';
    19 
    20 if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) {
     15        wp_die( __( 'You do not have permission to access this page.' ) );
     16
     17$id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
     18
     19if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) {
    2120        ?>
    2221        <div id="message" class="updated fade"><p>
    2322                <?php
    24                 switch ($_GET['action']) {
     23                switch ( $_GET['action'] ) {
    2524                        case 'all_notspam':
    26                                 _e('Sites mark as not spam !');
     25                                _e( 'Sites mark as not spam.' );
    2726                        break;
    2827                        case 'all_spam':
    29                                 _e('Sites mark as spam !');
     28                                _e( 'Sites mark as spam.' );
    3029                        break;
    3130                        case 'all_delete':
    32                                 _e('Sites deleted !');
     31                                _e( 'Sites deleted.' );
    3332                        break;
    3433                        case 'delete':
    35                                 _e('Site deleted !');
     34                                _e( 'Site deleted.' );
    3635                        break;
    3736                        case 'add-blog':
    38                                 _e('Site added !');
     37                                _e( 'Site added.' );
    3938                        break;
    4039                        case 'archive':
    41                                 _e('Site archived !');
     40                                _e( 'Site archived.' );
    4241                        break;
    4342                        case 'unarchive':
    44                                 _e('Site unarchived !');
     43                                _e( 'Site unarchived.' );
    4544                        break;
    4645                        case 'activate':
    47                                 _e('Site activated !');
     46                                _e( 'Site activated.' );
    4847                        break;
    4948                        case 'deactivate':
    50                                 _e('Site deactivated !');
     49                                _e( 'Site deactivated.' );
    5150                        break;
    5251                        case 'unspam':
    53                                 _e('Site mark as not spam !');
     52                                _e( 'Site mark as not spam.' );
    5453                        break;
    5554                        case 'spam':
    56                                 _e('Site mark as spam !');
    57                         break;
    58                         case 'umature':
    59                                 _e('Site mark as not mature !');
     55                                _e( 'Site mark as spam.' );
     56                        break;
     57                        case 'unmature':
     58                                _e( 'Site mark as not mature.' );
    6059                        break;
    6160                        case 'mature':
    62                                 _e('Site mark as mature !');
     61                                _e( 'Site mark as mature.' );
    6362                        break;
    6463                        default:
    65                                 _e('Options saved !');
     64                                _e( 'Settings saved.' );
    6665                        break;
    6766                }
    … …  
    7170}
    7271
    73 $action = isset($_GET['action']) ? $_GET['action'] : 'list';
     72$action = isset( $_GET['action'] ) ? $_GET['action'] : 'list';
    7473
    7574switch ( $action ) {
    76         // Edit blog
    77         case "editblog":
     75        // Edit site
     76        case 'editblog':
    7877                $blog_prefix = $wpdb->get_blog_prefix( $id );
    7978                $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" );
    80                 $details = get_blog_details($id);
     79                $details = get_blog_details( $id );
    8180                $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" );
    8281                $is_main_site = is_main_site( $id );
    … …  
    8483                <div class="wrap">
    8584                <?php screen_icon(); ?>
    86                 <h2><?php _e('Edit Site'); ?> - <a href='<?php echo get_home_url($id); ?>'><?php echo get_home_url($id); ?></a></h2>
     85                <h2><?php _e( 'Edit Site' ); ?> - <a href="<?php echo esc_url( get_home_url( $id ) ); ?>"><?php echo esc_url( get_home_url( $id ) ); ?></a></h2>
    8786                <form method="post" action="ms-edit.php?action=updateblog">
    88                         <?php wp_nonce_field('editblog'); ?>
    89                         <input type="hidden" name="id" value="<?php echo esc_attr($id) ?>" />
    90                         <div class='metabox-holder' style='width:49%;float:left;'>
    91                         <div id="blogedit_bloginfo" class="postbox " >
    92                         <h3 class='hndle'><span><?php _e('Site info (wp_blogs)'); ?></span></h3>
    93                         <div class="inside">
    94                                 <table class="form-table">
    95                                                         <tr class="form-field form-required">
    96                                                                 <th scope="row"><?php _e('Domain') ?></th>
    97 <?php if ( $is_main_site ) { ?>
    98                                                                 <td>http://<?php echo esc_attr($details->domain) ?></td>
    99 <?php } else { ?>
    100                                                                 <td>http://<input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr($details->domain) ?>" size="33" /></td>
    101 <?php } ?>
     87                        <?php wp_nonce_field( 'editblog' ); ?>
     88                        <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
     89                        <div class="metabox-holder" style="width:49%;float:left;">
     90                                <div id="blogedit_bloginfo" class="postbox">
     91                                <h3 class="hndle"><span><?php _e( 'Site info (wp_blogs)' ); ?></span></h3>
     92                                <div class="inside">
     93                                        <table class="form-table">
     94                                                <tr class="form-field form-required">
     95                                                        <th scope="row"><?php _e( 'Domain' ) ?></th>
     96                                                        <?php
     97                                                        $protocol = is_ssl() ? 'https://' : 'http://';
     98                                                        if ( $is_main_site ) { ?>
     99                                                        <td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td>
     100                                                        <?php } else { ?>
     101                                                        <td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td>
     102                                                        <?php } ?>
     103                                                </tr>
     104                                                <tr class="form-field form-required">
     105                                                        <th scope="row"><?php _e( 'Path' ) ?></th>
     106                                                        <?php if ( $is_main_site ) { ?>
     107                                                        <td><code><?php echo esc_attr( $details->path ) ?></code></td>
     108                                                        <?php } else { ?>
     109                                                        <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' />
     110                                                        <br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_blog_option( $id, 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_blog_option( $id, 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td>
     111                                                        <?php } ?>
     112                                                </tr>
     113                                                <tr class="form-field">
     114                                                        <th scope="row"><?php _e( 'Registered') ?></th>
     115                                                        <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td>
     116                                                </tr>
     117                                                <tr class="form-field">
     118                                                        <th scope="row"><?php _e('Last Updated') ?></th>
     119                                                        <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td>
     120                                                </tr>
     121                                                <tr class="form-field">
     122                                                        <th scope="row"><?php _e('Public') ?></th>
     123                                                        <td>
     124                                                                <label><input type="radio" style="width:20px;" name="blog[public]" value="1" <?php checked( $details->public, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
     125                                                                <label><input type="radio" style="width:20px;" name="blog[public]" value="0" <?php checked( $details->public, 0 ); ?> /> <?php _e( 'No' ) ?></label>
     126                                                        </td>
     127                                                </tr>
     128                                                <tr class="form-field">
     129                                                        <th scope="row"><?php _e( 'Archived' ); ?></th>
     130                                                        <td>
     131                                                                <label><input type="radio" style="width:20px;" name="blog[archived]" value="1" <?php checked( $details->archived, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
     132                                                                <label><input type="radio" style="width:20px;" name="blog[archived]" value="0" <?php checked( $details->archived, 0 ); ?> /> <?php _e( 'No' ) ?></label>
     133                                                        </td>
     134                                                </tr>
     135                                                <tr class="form-field">
     136                                                        <th scope="row"><?php _e( 'Mature' ); ?></th>
     137                                                        <td>
     138                                                                <label><input type="radio" style="width:20px;" name="blog[mature]" value="1" <?php checked( $details->mature, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
     139                                                                <label><input type="radio" style="width:20px;" name="blog[mature]" value="0" <?php checked( $details->mature, 0); ?> /> <?php _e( 'No' ) ?></label>
     140                                                        </td>
     141                                                </tr>
     142                                                <tr class="form-field">
     143                                                        <th scope="row"><?php _e( 'Spam' ); ?></th>
     144                                                        <td>
     145                                                                <label><input type="radio" style="width:20px;" name="blog[spam]" value="1" <?php checked( $details->spam, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
     146                                                                <label><input type="radio" style="width:20px;" name="blog[spam]" value="0" <?php checked( $details->spam, 0 ); ?> /> <?php _e( 'No' ) ?></label>
     147                                                        </td>
     148                                                </tr>
     149                                                <tr class="form-field">
     150                                                        <th scope="row"><?php _e( 'Deleted' ); ?></th>
     151                                                        <td>
     152                                                                <label><input type="radio" style="width:20px;" name="blog[deleted]" value="1" <?php checked( $details->deleted, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
     153                                                                <label><input type="radio" style="width:20px;" name="blog[deleted]" value="0" <?php checked( $details->deleted, 0 ); ?> /> <?php _e( 'No' ) ?></label>
     154                                                        </td>
     155                                                </tr>
     156                                        </table>
     157                                        <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
     158                                </div>
     159                                </div>
     160
     161                                <div id="blogedit_blogoptions" class="postbox" >
     162                                <h3 class="hndle"><span><?php printf( __( 'Site options (%soptions)' ), $blog_prefix ); ?></span></h3>
     163                                <div class="inside">
     164                                        <table class="form-table">
     165                                                <?php
     166                                                $editblog_default_role = 'subscriber';
     167                                                foreach ( $options as $option ) {
     168                                                        if ( $option->option_name == 'default_role' )
     169                                                                $editblog_default_role = $option->option_value;
     170                                                        $disabled = false;
     171                                                        $class = 'all-options';
     172                                                        if ( is_serialized( $option->option_value ) ) {
     173                                                                if ( is_serialized_string( $option->option_value ) ) {
     174                                                                        $option->option_value = esc_html( maybe_unserialize( $option->option_value ), 'single' );
     175                                                                } else {
     176                                                                        $option->option_value = 'SERIALIZED DATA';
     177                                                                        $disabled = true;
     178                                                                        $class = 'all-options disabled';
     179                                                                }
     180                                                        }
     181                                                        if ( strpos( $option->option_value, "\n" ) !== false ) {
     182                                                        ?>
     183                                                                <tr class="form-field">
     184                                                                        <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
     185                                                                        <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php wp_htmledit_pre( $option->option_value ) ?></textarea></td>
     186                                                                </tr>
     187                                                        <?php
     188                                                        } else {
     189                                                        ?>
     190                                                                <tr class="form-field">
     191                                                                        <th scope="row"><?php esc_html_e( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></th>
     192                                                                        <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
     193                                                                        <td><code><?php esc_html_e( $option->option_value ) ?></code></td>
     194                                                                        <?php } else { ?>
     195                                                                        <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td>
     196                                                                        <?php } ?>
     197                                                                </tr>
     198                                                        <?php
     199                                                        }
     200                                                } // End foreach
     201                                                ?>
     202                                        </table>
     203                                        <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
     204                                </div>
     205                                </div>
     206                        </div>
     207
     208                        <div class="metabox-holder" style="width:49%;float:right;">
     209                                <?php
     210                                // Site Themes
     211                                $themes = get_themes();
     212                                $blog_allowed_themes = wpmu_get_blog_allowedthemes( $id );
     213                                $allowed_themes = get_site_option( 'allowedthemes' );
     214
     215                                if ( ! $allowed_themes )
     216                                        $allowed_themes = array_keys( $themes );
     217
     218                                $out = '';
     219                                foreach ( $themes as $key => $theme ) {
     220                                        $theme_key = esc_html( $theme['Stylesheet'] );
     221                                        if ( ! isset( $allowed_themes[$theme_key] ) ) {
     222                                                $checked = isset( $blog_allowed_themes[ $theme_key ] ) ? 'checked="checked"' : '';
     223                                                $out .= '<tr class="form-field form-required">
     224                                                                <th title="' . esc_attr( $theme["Description"] ).'" scope="row">' . esc_html( $key ) . '</th>
     225                                                                <td><label><input name="theme[' . esc_attr( $theme_key ) . ']" type="checkbox" style="width:20px;" value="on" '.$checked.'/> ' . __( 'Active' ) . '</label></td>
     226                                                        </tr>';
     227                                        }
     228                                }
     229
     230                                if ( $out != '' ) {
     231                                ?>
     232                                <div id="blogedit_blogthemes" class="postbox">
     233                                <h3 class="hndle"><span><?php esc_html_e( 'Site Themes' ); ?></span></h3>
     234                                <div class="inside">
     235                                        <p class="description"><?php _e( 'Activate the themename of an existing theme and hit "Update Options" to allow the theme for this site.' ) ?></p>
     236                                        <table class="form-table">
     237                                                <?php echo $out; ?>
     238                                        </table>
     239                                        <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
     240                                </div></div>
     241                                <?php }
     242
     243                                // Site users
     244                                $blogusers = get_users_of_blog( $id );
     245                                if ( is_array( $blogusers ) ) {
     246                                        echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">';
     247                                        echo '<table class="form-table">';
     248                                        echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>";
     249                                        reset( $blogusers );
     250                                        foreach ( (array) $blogusers as $key => $val ) {
     251                                                if ( isset( $val->meta_value ) && ! $val->meta_value )
     252                                                        continue;
     253                                                $t = @unserialize( $val->meta_value );
     254                                                if ( is_array( $t ) ) {
     255                                                        reset( $t );
     256                                                        $existing_role = key( $t );
     257                                                }
     258                                                echo '<tr><td><a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a></td>';
     259                                                if ( $val->user_id != $current_user->data->ID ) {
     260                                                        ?>
     261                                                        <td>
     262                                                                <select name="role[<?php echo $val->user_id ?>]" id="new_role"><?php
     263                                                                        foreach ( $editblog_roles as $role => $role_assoc ){
     264                                                                                $name = translate_user_role( $role_assoc['name'] );
     265                                                                                echo '<option ' . selected( $role, $existing_role ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
     266                                                                        }
     267                                                                        ?>
     268                                                                </select>
     269                                                        </td>
     270                                                        <td>
     271                                                                <input type="text" name="user_password[<?php echo esc_attr( $val->user_id ) ?>]" />
     272                                                        </td>
     273                                                        <?php
     274                                                        echo '<td><input title="' . __( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr( $val->user_id ) . ']" /></td>';
     275                                                } else {
     276                                                        echo "<td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __( 'N/A' ) . "</strong></td>";
     277                                                }
     278                                                echo '</tr>';
     279                                        }
     280                                        echo "</table>";
     281                                        echo '<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="' . esc_attr__( 'Update Options' ) . '" /></p>';
     282                                        echo "</div></div>";
     283                                }
     284                                ?>
     285
     286                                <div id="blogedit_blogadduser" class="postbox">
     287                                <h3 class="hndle"><span><?php _e( 'Add a new user' ); ?></span></h3>
     288                                <div class="inside">
     289                                        <p class="description"><?php _e( 'Enter the username of an existing user and hit "Update Options" to add the user.' ) ?></p>
     290                                        <table class="form-table">
     291                                                        <tr>
     292                                                                <th scope="row"><?php _e( 'User&nbsp;Login:' ) ?></th>
     293                                                                <td><input type="text" name="newuser" id="newuser" /></td>
    102294                                                        </tr>
    103                                                         <tr class="form-field form-required">
    104                                                                 <th scope="row"><?php _e('Path') ?></th>
    105 <?php if ( $is_main_site ) { ?>
    106                                                                 <td><?php echo esc_attr($details->path) ?></td>
    107 <?php } else { ?>
    108                                                                 <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr($details->path) ?>" size="40" style='margin-bottom:5px;' />
    109                                                                 <br /><input type='checkbox' style='width:20px;' name='update_home_url' value='update' <?php if ( get_blog_option( $id, 'siteurl' ) == untrailingslashit( get_blogaddress_by_id($id) ) || get_blog_option( $id, 'home' ) == untrailingslashit( get_blogaddress_by_id($id) ) ) echo 'checked="checked"'; ?> /> <?php _e( "Update 'siteurl' and 'home' as well." ); ?></td>
    110 <?php } ?>
    111                                                         </tr>
    112                                                         <tr class="form-field">
    113                                                                 <th scope="row"><?php _e('Registered') ?></th>
    114                                                                 <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr($details->registered) ?>" size="40" /></td>
    115                                                         </tr>
    116                                                         <tr class="form-field">
    117                                                                 <th scope="row"><?php _e('Last Updated') ?></th>
    118                                                                 <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr($details->last_updated) ?>" size="40" /></td>
    119                                                         </tr>
    120                                                         <tr class="form-field">
    121                                                                 <th scope="row"><?php _e('Public') ?></th>
     295                                                        <tr>
     296                                                                <th scope="row"><?php _e( 'Role:' ) ?></th>
    122297                                                                <td>
    123                                                                         <input type='radio' style='width:20px;' name='blog[public]' value='1' <?php if ( $details->public == '1' ) echo 'checked="checked"'; ?> /> <?php _e('Yes') ?>
    124                                                                         <input type='radio' style='width:20px;' name='blog[public]' value='0' <?php if ( $details->public == '0' ) echo 'checked="checked"'; ?> /> <?php _e('No') ?>
    125                                                                 </td>
    126                                                         </tr>
    127                                                         <tr class="form-field">
    128                                                                 <th scope="row"><?php _e( 'Archived' ); ?></th>
    129                                                                 <td>
    130                                                                         <input type='radio' style='width:20px;' name='blog[archived]' value='1' <?php if ( $details->archived == '1' ) echo 'checked="checked"'; ?> /> <?php _e('Yes') ?>
    131                                                                         <input type='radio' style='width:20px;' name='blog[archived]' value='0' <?php if ( $details->archived == '0' ) echo 'checked="checked"'; ?> /> <?php _e('No') ?>
    132                                                                 </td>
    133                                                         </tr>
    134                                                         <tr class="form-field">
    135                                                                 <th scope="row"><?php _e( 'Mature' ); ?></th>
    136                                                                 <td>
    137                                                                         <input type='radio' style='width:20px;' name='blog[mature]' value='1' <?php if ( $details->mature == '1' ) echo 'checked="checked"'; ?> /> <?php _e('Yes') ?>
    138                                                                         <input type='radio' style='width:20px;' name='blog[mature]' value='0' <?php if ( $details->mature == '0' ) echo 'checked="checked"'; ?> /> <?php _e('No') ?>
    139                                                                 </td>
    140                                                         </tr>
    141                                                         <tr class="form-field">
    142                                                                 <th scope="row"><?php _e( 'Spam' ); ?></th>
    143                                                                 <td>
    144                                                                         <input type='radio' style='width:20px;' name='blog[spam]' value='1' <?php if ( $details->spam == '1' ) echo 'checked="checked"'; ?> /> <?php _e('Yes') ?>
    145                                                                         <input type='radio' style='width:20px;' name='blog[spam]' value='0' <?php if ( $details->spam == '0' ) echo 'checked="checked"'; ?> /> <?php _e('No') ?>
    146                                                                 </td>
    147                                                         </tr>
    148                                                         <tr class="form-field">
    149                                                                 <th scope="row"><?php _e( 'Deleted' ); ?></th>
    150                                                                 <td>
    151                                                                         <input type='radio' style='width:20px;' name='blog[deleted]' value='1' <?php if ( $details->deleted == '1' ) echo 'checked="checked"'; ?> /> <?php _e('Yes') ?>
    152                                                                         <input type='radio' style='width:20px;' name='blog[deleted]' value='0' <?php if ( $details->deleted == '0' ) echo 'checked="checked"'; ?> /> <?php _e('No') ?>
     298                                                                        <select name="new_role" id="new_role">
     299                                                                        <?php
     300                                                                        reset( $editblog_roles );
     301                                                                        foreach ( $editblog_roles as $role => $role_assoc ){
     302                                                                                $name = translate_user_role( $role_assoc['name'] );
     303                                                                                $selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : '';
     304                                                                                echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
     305                                                                        }
     306                                                                        ?>
     307                                                                        </select>
    153308                                                                </td>
    154309                                                        </tr>
    155310                                                </table>
    156                                                 <p class="submit" style="margin:-15px 0 -5px 230px;"><input type="submit" name="Submit" value="<?php esc_attr_e('Update Options') ?>" /></p>
    157                         </div></div>
    158 
    159                         <div id="blogedit_blogoptions" class="postbox" >
    160                         <h3 class='hndle'><span><?php printf( __('Site options (%soptions)'), $blog_prefix ); ?></span></h3>
    161                         <div class="inside">
    162                                 <table class="form-table">
    163                                                         <?php
    164                                                         $editblog_default_role = 'subscriber';
    165                                                         foreach ( $options as $option ) {
    166                                                                 if ( $option->option_name == 'default_role' )
    167                                                                         $editblog_default_role = $option->option_value;
    168                                                                 $disabled = false;
    169                                                                 if ( is_serialized($option->option_value) ) {
    170                                                                         if ( is_serialized_string($option->option_value) ) {
    171                                                                                 $option->option_value = esc_html(maybe_unserialize($option->option_value), 'single');
    172                                                                         } else {
    173                                                                                 $option->option_value = "SERIALIZED DATA";
    174                                                                                 $disabled = true;
    175                                                                         }
    176                                                                 }
    177                                                                 if ( stristr($option->option_value, "\r") || stristr($option->option_value, "\n") || stristr($option->option_value, "\r\n") ) {
    178                                                                 ?>
    179                                                                         <tr class="form-field">
    180                                                                                 <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
    181                                                                                 <td><textarea rows="5" cols="40" name="option[<?php echo esc_attr($option->option_name) ?>]" id="<?php echo esc_attr($option->option_name) ?>"<?php disabled( $disabled ) ?>><?php echo esc_html( $option->option_value ) ?></textarea></td>
    182                                                                         </tr>
    183                                                                 <?php
    184                                                                 } else {
    185                                                                 ?>
    186                                                                         <tr class="form-field">
    187                                                                                 <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
    188 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
    189                                                                                 <td><?php echo esc_attr( $option->option_value ) ?></td>
    190 <?php } else { ?>
    191                                                                                 <td><input name="option[<?php echo esc_attr($option->option_name) ?>]" type="text" id="<?php echo esc_attr($option->option_name) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td>
    192 <?php } ?>
    193                                                                         </tr>
    194                                                                 <?php
    195                                                                 }
    196                                                         } // End foreach
    197                                                         ?>
    198                                                 </table>
    199                                                 <p class="submit" style="margin:-15px 0 -5px 230px;"><input type="submit" name="Submit" value="<?php esc_attr_e('Update Options') ?>" /></p>
    200                         </div></div>
    201                         </div>
    202 
    203                         <div class='metabox-holder' style='width:49%;float:right;'>
    204                         <?php
    205                                         // Blog Themes
    206                                         $themes = get_themes();
    207                                         $blog_allowed_themes = wpmu_get_blog_allowedthemes( $id );
    208                                         $allowed_themes = get_site_option( "allowedthemes" );
    209                                         if ( ! $allowed_themes )
    210                                                 $allowed_themes = array_keys( $themes );
    211                                         $out = '';
    212                                         foreach ( $themes as $key => $theme ) {
    213                                                 $theme_key = esc_html( $theme['Stylesheet'] );
    214                                                 if ( ! isset($allowed_themes[$theme_key] ) ) {
    215                                                         $checked = ( isset($blog_allowed_themes[ $theme_key ]) ) ? 'checked="checked"' : '';
    216                                                         $out .= '<tr class="form-field form-required">
    217                                                                         <th title="' . esc_attr( $theme["Description"] ).'" scope="row">' . esc_html($key) . '</th>
    218                                                                         <td><input name="theme[' . esc_attr($theme_key) . ']" type="checkbox" style="width:20px;" value="on" '.$checked.'/>' . __( 'Active' ) . '</td>
    219                                                                 </tr>';
    220                                                 }
    221                                         }
    222 
    223                                         if ( $out != '' ) {
    224                         ?>
    225                         <div id="blogedit_blogthemes" class="postbox">
    226                         <h3 class='hndle'><span><?php esc_html_e('Site Themes'); ?></span></h3>
    227                         <div class="inside">
    228                                 <table class="form-table">
    229                                         <tr><th style="font-weight:bold;"><?php esc_html_e('Theme'); ?></th></tr>
    230                                         <?php echo $out; ?>
    231                                 </table>
    232                                 <p class="submit" style="margin:-15px 0 -5px 230px;"><input type="submit" name="Submit" value="<?php esc_attr_e('Update Options') ?>" /></p>
    233                         </div></div>
    234                         <?php } ?>
    235 
    236                         <?php
    237                                         // Blog users
    238                                         $blogusers = get_users_of_blog( $id );
    239                                         if ( is_array( $blogusers ) ) {
    240                                                 echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __('Site Users') . '</span></h3><div class="inside">';
    241                                                 echo '<table class="form-table">';
    242                                                 echo "<tr><th>" . __('User') . "</th><th>" . __('Role') . "</th><th>" . __('Password') . "</th><th>" . __('Remove') . "</th></tr>";
    243                                                 reset($blogusers);
    244                                                 foreach ( (array) $blogusers as $key => $val ) {
    245                                                         if ( isset( $val->meta_value ) && ! $val->meta_value )
    246                                                                 continue;
    247                                                         $t = @unserialize( $val->meta_value );
    248                                                         if ( is_array( $t ) ) {
    249                                                                 reset( $t );
    250                                                                 $existing_role = key( $t );
    251                                                         }
    252                                                         echo '<tr><td><a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a></td>';
    253                                                         if ( $val->user_id != $current_user->data->ID ) {
    254                                                                 ?>
    255                                                                 <td>
    256                                                                         <select name="role[<?php echo $val->user_id ?>]" id="new_role"><?php
    257                                                                                 foreach ( $editblog_roles as $role => $role_assoc ){
    258                                                                                         $name = translate_user_role($role_assoc['name']);
    259                                                                                         $selected = ( $role == $existing_role ) ? 'selected="selected"' : '';
    260                                                                                         echo "<option {$selected} value=\"" . esc_attr($role) . "\">{$name}</option>";
    261                                                                                 }
    262                                                                                 ?>
    263                                                                         </select>
    264                                                                 </td>
    265                                                                 <td>
    266                                                                                 <input type='text' name='user_password[<?php echo esc_attr($val->user_id) ?>]' />
    267                                                                 </td>
    268                                                                 <?php
    269                                                                 echo '<td><input title="' . __('Click to remove user') . '" type="checkbox" name="blogusers[' . esc_attr($val->user_id) . ']" /></td>';
    270                                                         } else {
    271                                                                 echo "<td><strong>" . __ ('N/A') . "</strong></td><td><strong>" . __ ('N/A') . "</strong></td><td><strong>" . __('N/A') . "</strong></td>";
    272                                                         }
    273                                                         echo '</tr>';
    274                                                 }
    275                                                 echo "</table>";
    276                                                 echo '<p class="submit" style="margin:-15px 0 -5px 230px;"><input type="submit" name="Submit" value="' . esc_attr__('Update Options') . '" /></p>';
    277                                                 echo "</div></div>";
    278                                         }
    279                         ?>
    280 
    281                         <div id="blogedit_blogadduser" class="postbox">
    282                         <h3 class='hndle'><span><?php _e('Add a new user'); ?></span></h3>
    283                         <div class="inside">
    284                                 <p style="margin:10px 0 0px;padding:0px 10px 10px;border-bottom:1px solid #DFDFDF;"><?php _e('Enter the username of an existing user and hit <em>Update Options</em> to add the user.') ?></p>
    285                                 <table class="form-table">
    286                                                 <tr>
    287                                                         <th scope="row"><?php _e('User&nbsp;Login:') ?></th>
    288                                                         <td><input type="text" name="newuser" id="newuser" /></td>
    289                                                 </tr>
    290                                                 <tr>
    291                                                         <th scope="row"><?php _e('Role:') ?></th>
    292                                                         <td>
    293                                                                 <select name="new_role" id="new_role">
    294                                                                 <?php
    295                                                                 reset( $editblog_roles );
    296                                                                 foreach ( $editblog_roles as $role => $role_assoc ){
    297                                                                         $name = translate_user_role( $role_assoc['name'] );
    298                                                                         $selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : '';
    299                                                                         echo "<option {$selected} value=\"" . esc_attr($role) . "\">{$name}</option>";
    300                                                                 }
    301                                                                 ?>
    302                                                                 </select>
    303                                                         </td>
    304                                                 </tr>
     311                                        <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
     312                                </div>
     313                                </div>
     314
     315                                <div id="blogedit_miscoptions" class="postbox">
     316                                <h3 class="hndle"><span><?php _e( 'Misc Site Actions' ) ?></span></h3>
     317                                <div class="inside">
     318                                        <table class="form-table">
     319                                                        <?php do_action( 'wpmueditblogaction', $id ); ?>
    305320                                        </table>
    306                                 <p class="submit" style="margin:-15px 0 -5px 230px;"><input type="submit" name="Submit" value="<?php esc_attr_e('Update Options') ?>" /></p>
    307                         </div></div>
    308 
    309                         <div id="blogedit_miscoptions" class="postbox">
    310                         <h3 class='hndle'><span><?php _e('Misc Site Actions') ?></span></h3>
    311                         <div class="inside">
    312                                 <table class="form-table">
    313                                                 <?php do_action( 'wpmueditblogaction', $id ); ?>
    314                                 </table>
    315                                 <p class="submit" style="margin:-15px 0 -5px 230px;"><input type="submit" name="Submit" value="<?php esc_attr_e('Update Options') ?>" /></p>
    316                         </div></div>
    317 
     321                                        <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
     322                                </div>
     323                                </div>
    318324                        </div>
    319325
    … …  
    324330        break;
    325331
    326         // List blogs
     332        // List sites
    327333        case 'list':
    328334        default:
    … …  
    337343                $per_page = apply_filters( 'ms_sites_per_page', $per_page );
    338344
    339                 $s = isset($_GET['s']) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';
     345                $s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';
    340346                $like_s = esc_sql( like_escape( $s ) );
    341347
    342348                $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
    343 
    344                 if ( isset( $_GET['blogstatus'] ) ) {
    345                         if ( 'deleted' == $_GET['blogstatus'] ) {
    346                                 $query .= " AND {$wpdb->blogs}.deleted = '1' ";
    347                         } elseif ( 'archived' == $_GET['blogstatus'] ) {
    348                                 $query .= " AND {$wpdb->blogs}.archived = '1' ";
    349                         } elseif ( 'spam' == $_GET['blogstatus'] ) {
    350                                 $query .= " AND {$wpdb->blogs}.spam = '1' ";
    351                         }
    352                 }
    353349
    354350                if ( isset( $_GET['searchaction'] ) ) {
    … …  
    381377                $query .= $order;
    382378
    383                 $total = $wpdb->get_var( str_replace('SELECT *', 'SELECT COUNT(blog_id)', $query) );
    384 
    385                 $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page );
     379                $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(blog_id)', $query ) );
     380
     381                $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
    386382                $blog_list = $wpdb->get_results( $query, ARRAY_A );
    387383
    … …  
    390386                        'base' => add_query_arg( 'paged', '%#%' ),
    391387                        'format' => '',
    392                         'prev_text' => __('&laquo;'),
    393                         'next_text' => __('&raquo;'),
     388                        'prev_text' => __( '&laquo;' ),
     389                        'next_text' => __( '&raquo;' ),
    394390                        'total' => $num_pages,
    395391                        'current' => $pagenum
    396392                ));
    397393
    398                 if ( empty($_GET['mode']) )
     394                if ( empty( $_GET['mode'] ) )
    399395                        $mode = 'list';
    400396                else
    401397                        $mode = esc_attr( $_GET['mode'] );
    402 
    403                 // for subsubsub and $blog_list
    404                 $status_list = array( 'archived' => array( 'site-archived', __('Archived') ), 'spam' => array( 'site-spammed', __('Spam') ), 'deleted' => array( 'site-deleted', __('Deleted') ) );
    405398                ?>
    406399
    … …  
    408401                <?php screen_icon(); ?>
    409402                <h2><?php _e('Sites') ?>
    410                 <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x('Add New', 'sites'); ?></a>
     403                <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a>
    411404                <?php
    412                 if ( isset($_GET['s']) && $_GET['s'] )
    413                 printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) );
     405                if ( isset( $_GET['s'] ) && $_GET['s'] )
     406                printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
    414407                ?>
    415408                </h2>
    416 
    417                 <ul class="subsubsub">
    418                 <?php
    419                 $status_links = array();
    420                 $status_class = '';
    421                 $count = get_blog_count();
    422 
    423                 if ( empty($_GET['blogstatus']) || $_GET['blogstatus'] == 'all' )
    424                                 $status_class = ' class="current"';
    425 
    426                 $status_links[] = "<li><a href='ms-sites.php?blogstatus=all'$status_class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'sites' ), number_format_i18n( $count ) ) . '</a>';
    427 
    428                 foreach ( $status_list as $status => $col ) {
    429                         $status_class = '';
    430 
    431                         if ( empty( $count->$status ) )
    432                                 continue;
    433 
    434                         if ( isset( $_GET['blogstatus'] ) && ( $_GET['blogstatus'] == $status ) )
    435                                 $status_class = ' class="current"';
    436 
    437                         $status_links[] = "<li><a href='ms-sites.php?blogstatus=$status'$status_class>" . sprintf(  $col[1] . ' <span class="count">(%s)</span>' , number_format_i18n( $count->$status ) ) . '</a>';
    438                 };
    439 
    440                 echo implode( " |</li>\n", $status_links ) . '</li>';
    441                 unset( $status_links );
    442                 ?>
    443                 </ul>
    444409
    445410                <form action="ms-sites.php" method="get" id="ms-search">
    446411                <p class="search-box">
    447412                <input type="hidden" name="action" value="blogs" />
    448                 <input type="text" name="s" value="<?php esc_attr_e( $s ); ?>" />
    449                 <input type="submit" class="button" value="<?php esc_attr_e('Search Site by') ?>" />
     413                <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" />
     414                <input type="submit" class="button" value="<?php esc_attr_e( 'Search Site by' ) ?>" />
    450415                <select name="searchaction">
    451                         <option value="name" selected="selected"><?php _e('Name'); ?></option>
    452                         <option value="id"><?php _e('ID'); ?></option>
    453                         <option value="ip"><?php _e('IP address'); ?></option>
     416                        <option value="name" selected="selected"><?php _e( 'Name' ); ?></option>
     417                        <option value="id"><?php _e( 'ID' ); ?></option>
     418                        <option value="ip"><?php _e( 'IP address' ); ?></option>
    454419                </select>
    455420                </p>
    … …  
    457422
    458423                <form id="form-site-list" action="ms-edit.php?action=allblogs" method="post">
    459                 <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
     424                <input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" />
    460425                <div class="tablenav">
    461426                <div class="alignleft actions">
    462427                        <select name="action">
    463                                 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
    464                                 <option value="delete"><?php _e('Delete'); ?></option>
    465                                 <option value="spam"><?php _e('Mark as Spam'); ?></option>
    466                                 <option value="notspam"><?php _e('Not Spam'); ?></option>
     428                                <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
     429                                <option value="delete"><?php _e( 'Delete' ); ?></option>
     430                                <option value="spam"><?php _e( 'Mark as Spam' ); ?></option>
     431                                <option value="notspam"><?php _e( 'Not Spam' ); ?></option>
    467432                        </select>
    468                         <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
    469                         <?php wp_nonce_field('bulk-sites'); ?>
     433                        <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
     434                        <?php wp_nonce_field( 'bulk-ms-sites' ); ?>
    470435                </div>
    471436
    … …  
    482447
    483448                <div class="view-switch">
    484                         <a href="<?php echo esc_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e('List View') ?>" alt="<?php _e('List View') ?>" /></a>
    485                         <a href="<?php echo esc_url(add_query_arg('mode', 'excerpt', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e('Excerpt View') ?>" alt="<?php _e('Excerpt View') ?>" /></a>
     449                        <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a>
     450                        <a href="<?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a>
    486451                </div>
    487452
    … …  
    492457                <?php
    493458                // define the columns to display, the syntax is 'internal name' => 'display name'
    494                 $blogname_columns = ( is_subdomain_install() ) ? __('Domain') : __('Path');
    495                 $posts_columns = array(
    496                         'id'           => __('ID'),
     459                $blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
     460                $sites_columns = array(
     461                        'id'           => __( 'ID' ),
    497462                        'blogname'     => $blogname_columns,
    498                         'lastupdated'  => __('Last Updated'),
    499                         'registered'   => __('Registered'),
    500                         'users'        => __('Users')
     463                        'lastupdated'  => __( 'Last Updated'),
     464                        'registered'   => __( 'Registered' ),
     465                        'users'        => __( 'Users' )
    501466                );
    502467
    503468                if ( has_filter( 'wpmublogsaction' ) )
    504                         $posts_columns['plugins'] = __('Actions');
    505 
    506                 $posts_columns = apply_filters('wpmu_blogs_columns', $posts_columns);
     469                        $sites_columns['plugins'] = __( 'Actions' );
     470
     471                $sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns );
    507472                ?>
    508473
    … …  
    510475                        <thead>
    511476                                <tr>
    512                                 <th style="" class="manage-column column-cb check-column" id="cb" scope="col">
     477                                <th class="manage-column column-cb check-column" id="cb" scope="col">
    513478                                        <input type="checkbox" />
    514479                                </th>
    515480                                <?php
    516                                 foreach($posts_columns as $column_id => $column_display_name) {
     481                                $col_url = '';
     482                                foreach($sites_columns as $column_id => $column_display_name) {
    517483                                        $column_link = "<a href='";
    518484                                        $order2 = '';
    519485                                        if ( $order_by == $column_id )
    520                                                 $order2 = ($order == 'DESC') ? 'ASC' : 'DESC';
    521 
    522                                         $column_link .= esc_url(add_query_arg( array('order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), $_SERVER['REQUEST_URI'] ) );
     486                                                $order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC';
     487
     488                                        $column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array('action', 'updated'), $_SERVER['REQUEST_URI'] ) ) );
    523489                                        $column_link .= "'>{$column_display_name}</a>";
    524                                         $col_url = ($column_id == 'users' || $column_id == 'plugins') ? $column_display_name : $column_link;
    525                                 ?>
    526                                 <th scope="col">
    527                                         <?php echo $col_url ?>
    528                                 </th>
    529                                 <?php } ?>
     490                                        $col_url .= '<th scope="col">' . ( ( $column_id == 'users' || $column_id == 'plugins' ) ? $column_display_name : $column_link ) . '</th>';
     491                                }
     492                                echo $col_url ?>
    530493                                </tr>
    531494                        </thead>
    532495                        <tfoot>
    533496                                <tr>
    534                                 <th class="manage-column column-cb check-column" id="cb" scope="col">
     497                                <th class="manage-column column-cb check-column" id="cb1" scope="col">
    535498                                        <input type="checkbox" />
    536499                                </th>
    537                                 <?php foreach($posts_columns as $column_id => $column_display_name) {
    538                                         $column_link = "<a href='";
    539                                         $order2 = '';
    540                                         if ( $order_by == $column_id )
    541                                                 $order2 = ($order == 'DESC') ? 'ASC' : 'DESC';
    542 
    543                                         $column_link .= esc_url(add_query_arg( array('order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array('action', 'updated'), $_SERVER['REQUEST_URI'] ) ) );
    544                                         $column_link .= "'>{$column_display_name}</a>";
    545                                         $col_url = ($column_id == 'users' || $column_id == 'plugins') ? $column_display_name : $column_link;
    546                                 ?>
    547                                 <th scope="col">
    548500                                        <?php echo $col_url ?>
    549                                 </th>
    550                                 <?php } ?>
    551501                                </tr>
    552502                        </tfoot>
    553                         <tbody id="the-list">
     503                        <tbody id="the-site-list" class="list:site">
    554504                        <?php
     505                        $status_list = array( 'archived' => array( 'site-archived', __( 'Archived' ) ), 'spam' => array( 'site-spammed', __( 'Spam' ) ), 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), 'mature' => array( 'site-mature', __( 'Mature' ) ) );
    555506                        if ( $blog_list ) {
    556507                                $class = '';
    557508                                foreach ( $blog_list as $blog ) {
    558                                         $class = ('alternate' == $class) ? '' : 'alternate';
     509                                        $class = ( 'alternate' == $class ) ? '' : 'alternate';
    559510                                        reset( $status_list );
    560511
    … …  
    567518                                        }
    568519                                        $blog_state = '';
    569                                         if ( ! empty($blog_states) ) {
    570                                                 $state_count = count($blog_states);
     520                                        if ( ! empty( $blog_states ) ) {
     521                                                $state_count = count( $blog_states );
    571522                                                $i = 0;
    572523                                                $blog_state .= ' - ';
    … …  
    579530                                        echo "<tr class='$class'>";
    580531
    581                                         $blogname = ( is_subdomain_install() ) ? str_replace('.'.$current_site->domain, '', $blog['domain']) : $blog['path'];
    582                                         foreach ( $posts_columns as $column_name=>$column_display_name ) {
     532                                        $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];
     533                                        foreach ( $sites_columns as $column_name=>$column_display_name ) {
    583534                                                switch ( $column_name ) {
    584535                                                        case 'id': ?>
    585536                                                                <th scope="row" class="check-column">
    586                                                                         <input type='checkbox' id='blog_<?php echo $blog['blog_id'] ?>' name='allblogs[]' value='<?php echo esc_attr($blog['blog_id']) ?>' />
     537                                                                        <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
    587538                                                                </th>
    588539                                                                <th valign="top" scope="row">
    … …  
    594545                                                        case 'blogname': ?>
    595546                                                                <td class="column-title">
    596                                                                         <a href="ms-sites.php?action=editblog&amp;id=<?php echo $blog['blog_id'] ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
     547                                                                        <a href="<?php echo esc_url( admin_url( 'ms-sites.php?action=editblog&amp;id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
    597548                                                                        <?php
    598549                                                                        if ( 'list' != $mode )
    … …  
    600551
    601552                                                                        $actions        = array();
    602                                                                         $actions[]      = '<a href="ms-sites.php?action=editblog&amp;id=' . $blog['blog_id'] . '" class="edit">' . __('Edit') . '</a>';
    603                                                                         $actions[]      = "<a href='" . get_admin_url($blog['blog_id']) . "' class='edit'>" . __('Backend') . '</a>';
    604 
    605                                                                         if ( get_blog_status( $blog['blog_id'], "deleted" ) == '1' )
    606                                                                                 $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=activateblog&amp;ref=' . urlencode( $_SERVER['REQUEST_URI'] ) . '&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to activate the site %s" ), $blogname ) ) . '">' . __('Activate') . '</a>';
    607                                                                         else
    608                                                                                 $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=deactivateblog&amp;ref=' . urlencode( $_SERVER['REQUEST_URI'] ) . '&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to deactivate the site %s" ), $blogname ) ) . '">' . __('Deactivate') . '</a>';
    609 
    610                                                                         if ( get_blog_status( $blog['blog_id'], "archived" ) == '1' )
    611                                                                                 $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=' .  $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unarchive the site %s" ), $blogname ) ) . '">' . __('Unarchive') . '</a>';
    612                                                                         else
    613                                                                                 $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to archive the site %s" ), $blogname ) ) . '">' . __('Archive') . '</a>';
    614 
    615                                                                         if ( get_blog_status( $blog['blog_id'], "spam" ) == '1' )
    616                                                                                 $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unspam the site %s" ), $blogname ) ) . '">' . __('Not Spam') . '</a>';
    617                                                                         else
    618                                                                                 $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to mark the site %s as spam" ), $blogname ) ) . '">' . __("Spam") . '</a>';
    619 
    620                                                                         $actions[]      = '<a class="delete" href="ms-edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to delete the site %s" ), $blogname ) ) . '">' . __("Delete") . '</a>';
    621 
    622                                                                         $actions[]      = "<a href='" . get_home_url($blog['blog_id']) . "' rel='permalink'>" . __('Visit') . '</a>';
    623                                                                         ?>
    624 
    625                                                                         <?php if ( count($actions) ) : ?>
     553                                                                        $actions[]      = '<span class="edit"><a href="' . esc_url( admin_url( 'ms-sites.php?action=editblog&amp;id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a><span>';
     554                                                                        $actions[]      = "<span class='backend'><a href='" . esc_url( get_admin_url($blog['blog_id']) ) . "' class='edit'>" . __( 'Backend' ) . '</a></span>';
     555                                                                        if ( $current_site->blog_id != $blog['blog_id'] ) {
     556                                                                                if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
     557                                                                                        $actions[]      = '<span class="activate"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to activate the site %s" ), $blogname ) ) ) ) . '">' . __( 'Activate' ) . '</a></span>';
     558                                                                                else
     559                                                                                        $actions[]      = '<span class="activate"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to deactivate the site %s" ), $blogname ) ) ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
     560       
     561                                                                                if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
     562                                                                                        $actions[]      = '<span class="archive"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=' .  $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unarchive the site %s." ), $blogname ) ) ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
     563                                                                                else
     564                                                                                        $actions[]      = '<span class="archive"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to archive the site %s." ), $blogname ) ) ) ) . '">' . __( 'Archive' ) . '</a></span>';
     565       
     566                                                                                if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
     567                                                                                        $actions[]      = '<span class="spam"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unspam the site %s." ), $blogname ) ) ) ) . '">' . __( 'Not Spam' ) . '</a></span>';
     568                                                                                else
     569                                                                                        $actions[]      = '<span class="spam"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to mark the site %s as spam." ), $blogname ) ) ) ) . '">' . __( 'Spam' ) . '</a></span>';
     570       
     571                                                                                if ( get_blog_status( $blog['blog_id'], 'mature' ) == '1' )
     572                                                                                        $actions[]      = '<span class="mature"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unmatureblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unmature the site %s." ), $blogname ) ) ) ) . '">' . __( 'Not Mature' ) . '</a></span>';
     573                                                                                else
     574                                                                                        $actions[]      = '<span class="mature"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=matureblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to mark the site %s as mature." ), $blogname ) ) ) ) . '">' . __( 'Mature' ) . '</a></span>';
     575       
     576                                                                                $actions[]      = '<span class="delete"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to delete the site %s." ), $blogname ) ) ) ) . '">' . __( 'Delete' ) . '</a></span>';
     577                                                                        }
     578
     579                                                                        $actions[]      = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'] ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a>';
     580
     581                                                                        if ( count( $actions ) ) : ?>
    626582                                                                        <div class="row-actions">
    627                                                                                 <?php echo implode(' | ', $actions); ?>
     583                                                                                <?php echo implode( ' | ', $actions ); ?>
    628584                                                                        </div>
    629585                                                                        <?php endif; ?>
    … …  
    639595                                                                        else
    640596                                                                                $date = 'Y/m/d \<\b\r \/\> g:i:s a';
    641                                                                         echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __("Never") : mysql2date( __( $date ), $blog['last_updated'] ); ?>
     597                                                                        echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( __( $date ), $blog['last_updated'] ); ?>
    642598                                                                </td>
    643599                                                        <?php
    … …  
    645601                                                case 'registered': ?>
    646602                                                                <td valign="top">
    647                                                                 <?php echo mysql2date(__( $date ), $blog['registered'] ); ?>
     603                                                                <?php
     604                                                                if ( $blog['registered'] == '0000-00-00 00:00:00' )
     605                                                                        echo '&#x2014;';
     606                                                                else
     607                                                                        echo mysql2date( __( $date ), $blog['registered'] );
     608                                                                ?>
    648609                                                                </td>
    649610                                                <?php
    … …  
    657618                                                                                if ( count( $blogusers ) > 5 ) {
    658619                                                                                        $blogusers = array_slice( $blogusers, 0, 5 );
    659                                                                                         $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . get_admin_url($blog['blog_id'], 'users.php') . '">' . __( 'More' ) . '</a>';
     620                                                                                        $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( get_admin_url( $blog['blog_id'], 'users.php' ) ) . '">' . __( 'More' ) . '</a>';
    660621                                                                                }
    661622                                                                                foreach ( $blogusers as $key => $val ) {
    662                                                                                         echo '<a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a> ';
     623                                                                                        echo '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $val->user_id ) ) . '">' . esc_html( $val->user_login ) . '</a> ';
    663624                                                                                        if ( 'list' != $mode )
    664625                                                                                                echo '(' . $val->user_email . ')';
    … …  
    676637                                                                <?php if ( has_filter( 'wpmublogsaction' ) ) { ?>
    677638                                                                <td valign="top">
    678                                                                         <?php do_action( "wpmublogsaction", $blog['blog_id'] ); ?>
     639                                                                        <?php do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
    679640                                                                </td>
    680641                                                                <?php } ?>
    … …  
    684645                                                                <?php if ( has_filter( 'manage_blogs_custom_column' ) ) { ?>
    685646                                                                <td valign="top">
    686                                                                         <?php do_action('manage_blogs_custom_column', $column_name, $blog['blog_id']); ?>
     647                                                                        <?php do_action( 'manage_blogs_custom_column', $column_name, $blog['blog_id'] ); ?>
    687648                                                                </td>
    688649                                                                <?php } ?>
    … …  
    696657                        } else { ?>
    697658                                <tr>
    698                                         <td colspan="8"><?php _e('No blogs found.') ?></td>
     659                                        <td colspan="<?php echo (int) count( $sites_columns ); ?>"><?php _e( 'No blogs found.' ) ?></td>
    699660                                </tr>
    700661                        <?php
    … …  
    712673                        <div class="alignleft actions">
    713674                        <select name="action2">
    714                                 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
    715                                 <option value="delete"><?php _e('Delete'); ?></option>
    716                                 <option value="spam"><?php _e('Mark as Spam'); ?></option>
    717                                 <option value="notspam"><?php _e('Not Spam'); ?></option>
     675                                <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
     676                                <option value="delete"><?php _e( 'Delete' ); ?></option>
     677                                <option value="spam"><?php _e( 'Mark as Spam' ); ?></option>
     678                                <option value="notspam"><?php _e( 'Not Spam' ); ?></option>
    718679                        </select>
    719                         <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
     680                        <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
    720681                        </div>
    721682                        <br class="clear" />
    … …  
    727688                <div class="wrap">
    728689                        <a name="form-add-site"></a>
    729                         <h2><?php _e('Add Site') ?></h2>
     690                        <h2><?php _e( 'Add Site' ) ?></h2>
    730691                        <form method="post" action="ms-edit.php?action=addblog">
    731                                 <?php wp_nonce_field('add-blog') ?>
     692                                <?php wp_nonce_field( 'add-blog' ) ?>
    732693                                <table class="form-table">
    733694                                        <tr class="form-field form-required">
    734                                                 <th scope='row'><?php _e('Site Address') ?></th>
     695                                                <th scope="row"><?php _e( 'Site Address' ) ?></th>
    735696                                                <td>
    736697                                                <?php if ( is_subdomain_install() ) { ?>
    737                                                         <input name="blog[domain]" type="text" class="regular-text" title="<?php _e('Domain') ?>"/>.<?php echo $current_site->domain;?>
     698                                                        <input name="blog[domain]" type="text" class="regular-text" title="<?php _e( 'Domain' ) ?>"/>.<?php echo $current_site->domain;?>
    738699                                                <?php } else {
    739                                                         echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php _e('Domain') ?>"/>
     700                                                        echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php _e( 'Domain' ) ?>"/>
    740701                                                <?php }
    741                                                 echo "<p>" . __( 'Only the characters a-z and 0-9 recommended.' ) . "</p>";
     702                                                echo '<p>' . __( 'Only the characters a-z and 0-9 recommended.' ) . '</p>';
    742703                                                ?>
    743704                                                </td>
    744705                                        </tr>
    745706                                        <tr class="form-field form-required">
    746                                                 <th scope='row'><?php _e('Site Title') ?></th>
    747                                                 <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e('Title') ?>"/></td>
     707                                                <th scope="row"><?php _e( 'Site Title' ) ?></th>
     708                                                <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e( 'Title' ) ?>"/></td>
    748709                                        </tr>
    749710                                        <tr class="form-field form-required">
    750                                                 <th scope='row'><?php _e('Admin Email') ?></th>
    751                                                 <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e('Email') ?>"/></td>
     711                                                <th scope="row"><?php _e( 'Admin Email' ) ?></th>
     712                                                <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/></td>
    752713                                        </tr>
    753714                                        <tr class="form-field">
    754                                                 <td colspan='2'><?php _e('A new user will be created if the above email address is not in the database.') ?><br /><?php _e('The username and password will be mailed to this email address.') ?></td>
     715                                                <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td>
    755716                                        </tr>
    756717                                </table>
    757718                                <p class="submit">
    758                                         <input class="button" type="submit" name="go" value="<?php esc_attr_e('Add Site') ?>" /></p>
     719                                        <input class="button" type="submit" name="go" value="<?php esc_attr_e( 'Add Site' ) ?>" /></p>
    759720                        </form>
    760721                </div>
    … …  
    763724} // end switch( $action )
    764725
    765 include('admin-footer.php'); ?>
     726include( './admin-footer.php' ); ?>
  • trunk/wp-admin/ms-themes.php

    r13771 r13918  
    11<?php
    2 require_once('admin.php');
     2require_once( './admin.php' );
    33
    4 $title = __('Network Themes');
     4$title = __( 'Network Themes' );
    55$parent_file = 'ms-admin.php';
    6 require_once('admin-header.php');
     6require_once( './admin-header.php' );
    77
    88if ( ! current_user_can( 'manage_network_themes' ) )
    9         wp_die( __('You do not have permission to access this page.') );
     9        wp_die( __( 'You do not have permission to access this page.' ) );
    1010
    11 if ( isset($_GET['updated']) ) {
     11if ( isset( $_GET['updated'] ) ) {
    1212        ?>
    13         <div id="message" class="updated fade"><p><?php _e('Site themes saved.') ?></p></div>
     13        <div id="message" class="updated fade"><p><?php _e( 'Site themes saved.' ) ?></p></div>
    1414        <?php
    1515}
    … …  
    1919?>
    2020<div class="wrap">
    21         <form action='ms-edit.php?action=updatethemes' method='post'>
     21        <form action="<?php echo esc_url( admin_url( 'ms-edit.php?action=updatethemes' ) ); ?>" method="post">
    2222                <?php screen_icon(); ?>
    23                 <h2><?php _e('Network Themes') ?></h2>
    24                 <p><?php _e('Disable themes network-wide. You can enable themes on a site by site basis.') ?></p>
     23                <h2><?php _e( 'Network Themes' ) ?></h2>
     24                <p><?php _e( 'Disable themes network-wide. You can enable themes on a site by site basis.' ) ?></p>
    2525                <table class="widefat">
    2626                        <thead>
    2727                                <tr>
    28                                         <th style="width:15%;text-align:center;"><?php _e('Active') ?></th>
    29                                         <th style="width:25%;"><?php _e('Theme') ?></th>
    30                                         <th style="width:10%;"><?php _e('Version') ?></th>
    31                                         <th style="width:60%;"><?php _e('Description') ?></th>
     28                                        <th style="width:15%;text-align:center;"><?php _e( 'Active' ) ?></th>
     29                                        <th style="width:25%;"><?php _e( 'Theme' ) ?></th>
     30                                        <th style="width:10%;"><?php _e( 'Version' ) ?></th>
     31                                        <th style="width:60%;"><?php _e( 'Description' ) ?></th>
    3232                                </tr>
    3333                        </thead>
    … …  
    3838                        foreach ( (array) $themes as $key => $theme ) {
    3939                                $total_theme_count++;
    40                                 $theme_key = esc_html($theme['Stylesheet']);
    41                                 $class = ('alt' == $class) ? '' : 'alt';
     40                                $theme_key = esc_html( $theme['Stylesheet'] );
     41                                $class = ( 'alt' == $class ) ? '' : 'alt';
    4242                                $class1 = $enabled = $disabled = '';
     43                                $enabled = $disabled = false;
    4344
    44                                 if ( isset( $allowed_themes[ $theme_key ] ) == true ) {
    45                                         $enabled = 'checked="checked" ';
     45                                if ( isset( $allowed_themes[$theme_key] ) == true ) {
     46                                        $enabled = true;
    4647                                        $activated_themes_count++;
    47                                         $class1 = ' active';
     48                                        $class1 = 'active';
    4849                                } else {
    49                                         $disabled = 'checked="checked" ';
     50                                        $disabled = true;
    5051                                }
    5152                                ?>
    52                                 <tr valign="top" class="<?php echo $class.$class1; ?>">
     53                                <tr valign="top" class="<?php echo $class, $class1; ?>">
    5354                                        <td style="text-align:center;">
    54                                                 <label><input name="theme[<?php echo $theme_key ?>]" type="radio" id="enabled_<?php echo $theme_key ?>" value="enabled" <?php echo $enabled ?> /> <?php _e('Yes') ?></label>
     55                                                <label><input name="theme[<?php echo $theme_key ?>]" type="radio" id="enabled_<?php echo $theme_key ?>" value="enabled" <?php checked( $enabled ) ?> /> <?php _e( 'Yes' ) ?></label>
    5556                                                &nbsp;&nbsp;&nbsp;
    56                                                 <label><input name="theme[<?php echo $theme_key ?>]" type="radio" id="disabled_<?php echo $theme_key ?>" value="disabled" <?php echo $disabled ?> /> <?php _e('No') ?></label>
     57                                                <label><input name="theme[<?php echo $theme_key ?>]" type="radio" id="disabled_<?php echo $theme_key ?>" value="disabled" <?php checked( $disabled ) ?> /> <?php _e( 'No' ) ?></label>
    5758                                        </td>
    5859                                        <th scope="row" style="text-align:left;"><?php echo $key ?></th>
    … …  
    6566
    6667                <p class="submit">
    67                         <input type='submit' value='<?php _e('Update Themes') ?>' /></p>
     68                        <input type="submit" value="<?php _e( 'Update Themes' ) ?>" /></p>
    6869        </form>
    6970
    70         <h3><?php _e('Total')?></h3>
     71        <h3><?php _e( 'Total' )?></h3>
    7172        <p>
    72                 <?php printf(__('Themes Installed: %d'), $total_theme_count); ?>
     73                <?php printf( __( 'Themes Installed: %d' ), $total_theme_count); ?>
    7374                <br />
    74                 <?php printf(__('Themes Activated: %d'), $activated_themes_count); ?>
     75                <?php printf( __( 'Themes Activated: %d' ), $activated_themes_count); ?>
    7576        </p>
    7677</div>
    7778
    78 <?php include('admin-footer.php'); ?>
     79<?php include( './admin-footer.php' ); ?>
  • trunk/wp-admin/ms-users.php

    r13733 r13918  
    11<?php
    2 require_once('admin.php');
     2require_once( './admin.php' );
    33
    44if ( !is_multisite() )
    5         wp_die( __('Multisite support is not enabled.') );
    6 
    7 $title = __('Users');
     5        wp_die( __( 'Multisite support is not enabled.' ) );
     6
     7$title = __( 'Users' );
    88$parent_file = 'ms-admin.php';
    99
    1010wp_enqueue_script( 'admin-forms' );
    1111
    12 require_once('admin-header.php');
     12require_once( './admin-header.php' );
    1313
    1414if ( ! current_user_can( 'manage_network_users' ) )
    15         wp_die( __('You do not have permission to access this page.') );
    16 
    17 if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) {
     15        wp_die( __( 'You do not have permission to access this page.' ) );
     16
     17if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) {
    1818        ?>
    1919        <div id="message" class="updated fade"><p>
    2020                <?php
    21                 switch ($_GET['action']) {
     21                switch ( $_GET['action'] ) {
    2222                        case 'delete':
    23                                 _e('User deleted !');
     23                                _e( 'User deleted.' );
    2424                        break;
    2525                        case 'all_spam':
    26                                 _e('Users marked as spam !');
     26                                _e( 'Users marked as spam.' );
    2727                        break;
    2828                        case 'all_notspam':
    29                                 _e('Users marked as not spam !');
     29                                _e( 'Users marked as not spam.' );
    3030                        break;
    3131                        case 'all_delete':
    32                                 _e('Users deleted !');
     32                                _e( 'Users deleted.' );
    3333                        break;
    3434                        case 'add':
    35                                 _e('User added !');
     35                                _e( 'User added.' );
    3636                        break;
    3737                        case 'add_superadmin':
    38                                 _e('Network admin added !');
     38                                _e( 'Network admin added.' );
    3939                        break;
    4040                        case 'remove_superadmin':
    41                                 _e('Network admin removed !');
     41                                _e( 'Network admin removed.' );
    4242                        break;
    4343                }
    … …  
    4646        <?php
    4747}
    48 ?>
    49 
    50 <div class="wrap" style="position:relative;">
    51         <?php
    52         $apage = isset( $_GET['apage'] ) ? intval( $_GET['apage'] ) : 1;
    53         $num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 15;
    54         $s = isset($_GET[ 's' ]) ? esc_attr( trim( $_GET[ 's' ] ) ) : '';
     48
     49        $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
     50        if ( empty( $pagenum ) )
     51                $pagenum = 1;
     52
     53        $per_page = (int) get_user_option( 'ms_users_per_page' );
     54        if ( empty( $per_page ) || $per_page < 1 )
     55                $per_page = 15;
     56
     57        $per_page = apply_filters( 'ms_users_per_page', $per_page );
     58
     59        $s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';
     60        $like_s = esc_sql( like_escape( $s ) );
    5561
    5662        $query = "SELECT * FROM {$wpdb->users}";
    5763
    58         if ( !empty( $s ) ) {
    59                 $search = '%' . trim( $s ) . '%';
    60                 $query .= " WHERE user_login LIKE '$search' OR user_email LIKE '$search'";
     64        if ( !empty( $like_s ) ) {
     65                $query .= " WHERE user_login LIKE '%$like_s%' OR user_email LIKE '%$like_s%'";
    6166        }
    6267
    6368        $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id';
    64 
    6569        if ( $order_by == 'email' ) {
    6670                $query .= ' ORDER BY user_email ';
    … …  
    7680        }
    7781
    78         $order = isset($_GET['order']) ? $_GET['order'] : 'ASC';
    79         $order = ( 'DESC' == $order ) ? 'DESC' : 'ASC';
     82        $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? 'DESC' : 'ASC';
    8083        $query .= $order;
    8184
    82         if ( !empty( $s ) )
    83                 $total = $wpdb->get_var( str_replace('SELECT *', 'SELECT COUNT(ID)', $query) );
     85        $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(ID)', $query ) );
     86
     87        $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page );
     88
     89        $user_list = $wpdb->get_results( $query, ARRAY_A );
     90
     91        $num_pages = ceil( $total / $per_page );
     92        $page_links = paginate_links( array(
     93                'base' => add_query_arg( 'paged', '%#%' ),
     94                'format' => '',
     95                'prev_text' => __( '&laquo;' ),
     96                'next_text' => __( '&raquo;' ),
     97                'total' => $num_pages,
     98                'current' => $pagenum
     99        ));
     100
     101        if ( empty( $_GET['mode'] ) )
     102                $mode = 'list';
    84103        else
    85                 $total = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users}");
    86 
    87         $query .= " LIMIT " . intval( ( $apage - 1 ) * $num) . ", " . intval( $num );
    88 
    89         $user_list = $wpdb->get_results( $query, ARRAY_A );
    90 
    91         // Pagination
    92         $user_navigation = paginate_links( array(
    93                 'total' => ceil($total / $num),
    94                 'current' => $apage,
    95                 'base' => add_query_arg( 'apage', '%#%' ),
    96                 'format' => ''
    97         ));
    98 
    99         if ( $user_navigation ) {
    100                 $user_navigation = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
    101                         number_format_i18n( ( $apage - 1 ) * $num + 1 ),
    102                         number_format_i18n( min( $apage * $num, $total ) ),
    103                         number_format_i18n( $total ),
    104                         $user_navigation
    105                 );
    106         }
     104                $mode = esc_attr( $_GET['mode'] );
    107105
    108106        ?>
    109107        <div class="wrap">
    110108        <?php screen_icon(); ?>
    111         <h2><?php esc_html_e("Users"); ?></h2>
     109        <h2><?php esc_html_e( 'Users' ); ?>
     110        <a href="#form-add-user" class="button add-new-h2"><?php echo esc_html_x( 'Add New' , 'users'); ?></a>
     111        <?php
     112        if ( isset( $_GET['s'] ) && $_GET['s'] )
     113        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
     114        ?>
     115        </h2>
     116
    112117        <form action="ms-users.php" method="get" class="search-form">
    113118                <p class="search-box">
    114                 <input type="text" name="s" value="<?php if ( isset($_GET['s']) ) esc_attr( stripslashes( $s ) ); ?>" class="search-input" id="user-search-input" />
    115                 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Search Users') ?>" class="button" />
     119                <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" class="search-input" id="user-search-input" />
     120                <input type="submit" id="post-query-submit" value="<?php esc_attr_e( 'Search Users' ) ?>" class="button" />
    116121                </p>
    117122        </form>
    118         </div>
    119123
    120124        <form id="form-user-list" action='ms-edit.php?action=allusers' method='post'>
     125                <input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" />
    121126                <div class="tablenav">
    122                         <?php if ( $user_navigation ) echo "<div class='tablenav-pages'>$user_navigation</div>"; ?>
    123 
    124127                        <div class="alignleft actions">
    125                                 <input type="submit" value="<?php esc_attr_e('Delete') ?>" name="alluser_delete" class="button-secondary delete" />
    126                                 <input type="submit" value="<?php esc_attr_e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
    127                                 <input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
    128                                 <input type="submit" value="<?php esc_attr_e('Add Network Admins') ?>" name="add_superadmin" class="button-secondary" />
    129                                 <input type="submit" value="<?php esc_attr_e('Remove Network Admins') ?>" name="remove_superadmin" class="button-secondary" />
    130                                 <?php wp_nonce_field( 'allusers' ); ?>
    131                                 <br class="clear" />
     128                                <select name="action">
     129                                        <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
     130                                        <option value="delete"><?php _e( 'Delete' ); ?></option>
     131                                        <option value="spam"><?php _e( 'Mark as Spammers' ); ?></option>
     132                                        <option value="notspam"><?php _e( 'Not Spam' ); ?></option>
     133                                        <option value="superadmin"><?php _e( 'Add Super Admins' ); ?></option>
     134                                        <option value="notsuperadmin"><?php _e( 'Remove Super Admins' ); ?></option>
     135                                </select>
     136                                <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
     137                                <?php wp_nonce_field( 'bulk-ms-users' ); ?>
     138                        </div>
     139
     140                        <?php if ( $page_links ) { ?>
     141                        <div class="tablenav-pages">
     142                        <?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
     143                        number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
     144                        number_format_i18n( min( $pagenum * $per_page, $num_pages ) ),
     145                        number_format_i18n( $num_pages ),
     146                        $page_links
     147                        ); echo $page_links_text; ?>
     148                        </div>
     149                        <?php } ?>
     150
     151                        <div class="view-switch">
     152                                <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a>
     153                                <a href="<?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a>
    132154                        </div>
    133155                </div>
    134 
    135                 <?php if ( isset($_GET['s']) && $_GET['s'] != '' ) : ?>
    136                         <p><a href="ms-sites.php?action=blogs&amp;s=<?php echo urlencode( stripslashes( $s ) ); ?>&blog_name=Search+blogs+by+name"><?php _e('Search Sites for') ?> <strong><?php echo stripslashes( $s ) ?></strong></a></p>
    137                 <?php endif; ?>
     156                <div class="clear"></div>
    138157
    139158                <?php
    140159                // define the columns to display, the syntax is 'internal name' => 'display name'
    141                 $posts_columns = array(
    142                         'checkbox'       => '',
    143                         'login'      => __('Username'),
    144                         'name'       => __('Name'),
    145                         'email'      => __('E-mail'),
    146                         'registered' => __('Registered'),
    147                         'blogs'      => ''
     160                $users_columns = array(
     161                        'id'           => __( 'ID' ),
     162                        'login'      => __( 'Username' ),
     163                        'name'       => __( 'Name' ),
     164                        'email'      => __( 'E-mail' ),
     165                        'registered' => __( 'Registered' ),
     166                        'blogs'      => __( 'Sites' )
    148167                );
    149                 $posts_columns = apply_filters('wpmu_users_columns', $posts_columns);
     168                $users_columns = apply_filters( 'wpmu_users_columns', $users_columns );
    150169                ?>
    151                 <table class="widefat" cellspacing="0">
     170                <table class="widefat">
    152171                        <thead>
    153172                        <tr>
    154                                 <?php foreach( (array) $posts_columns as $column_id => $column_display_name) {
    155                                         if ( $column_id == 'blogs' ) {
    156                                                 echo '<th scope="col">'.__('Sites').'</th>';
    157                                         } elseif ( $column_id == 'checkbox') {
    158                                                 echo '<th scope="col" class="check-column"><input type="checkbox" /></th>';
    159                                         } else { ?>
    160                                                 <th scope="col"><a href="ms-users.php?sortby=<?php echo $column_id ?>&amp;<?php if ( $order_by == $column_id ) { if ( $order == 'DESC' ) { echo "order=ASC&amp;" ; } else { echo "order=DESC&amp;"; } } ?>apage=<?php echo $apage ?>"><?php echo $column_display_name; ?></a></th>
    161                                         <?php } ?>
    162                                 <?php } ?>
     173                                <th class="manage-column column-cb check-column" id="cb" scope="col">
     174                                        <input type="checkbox" />
     175                                </th>
     176                                <?php
     177                                $col_url = '';
     178                                foreach($users_columns as $column_id => $column_display_name) {
     179                                        $column_link = "<a href='";
     180                                        $order2 = '';
     181                                        if ( $order_by == $column_id )
     182                                                $order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC';
     183
     184                                        $column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array( 'action', 'updated' ), $_SERVER['REQUEST_URI'] ) ) );
     185                                        $column_link .= "'>{$column_display_name}</a>";
     186                                        $col_url .= '<th scope="col">' . ( $column_id == 'blogs' ? $column_display_name : $column_link ) . '</th>';
     187                                }
     188                                echo $col_url; ?>
    163189                        </tr>
    164190                        </thead>
    165                         <tbody id="users" class="list:user user-list">
    166                         <?php if ($user_list) {
     191                        <tfoot>
     192                        <tr>
     193                                <th class="manage-column column-cb check-column" id="cb" scope="col">
     194                                        <input type="checkbox" />
     195                                </th>
     196                                <?php echo $col_url; ?>
     197                        </tr>
     198                        </tfoot>
     199                        <tbody id="the-user-list" class="list:user">
     200                        <?php if ( $user_list ) {
    167201                                $class = '';
    168202                                $super_admins = get_site_option( 'site_admins' );
    169                                 foreach ( (array) $user_list as $user) {
    170                                         $class = ('alternate' == $class) ? '' : 'alternate';
    171 
    172                                         $status_list = array( "spam" => "site-spammed", "deleted" => "site-deleted" );
     203                                foreach ( (array) $user_list as $user ) {
     204                                        $class = ( 'alternate' == $class ) ? '' : 'alternate';
     205
     206                                        $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
    173207
    174208                                        foreach ( $status_list as $status => $col ) {
    … …  
    178212
    179213                                        ?>
    180 
    181214                                        <tr class="<?php echo $class; ?>">
    182215                                        <?php
    183                                         foreach( (array) $posts_columns as $column_name=>$column_display_name) :
    184                                                 switch($column_name) {
    185                                                         case 'checkbox': ?>
    186                                                                 <th scope="row" class="check-column"><input type='checkbox' id='user_<?php echo $user['ID'] ?>' name='allusers[]' value='<?php echo esc_attr($user['ID']) ?>' /></th>
     216                                        foreach( (array) $users_columns as $column_name=>$column_display_name ) :
     217                                                switch( $column_name ) {
     218                                                        case 'id': ?>
     219                                                                <th scope="row" class="check-column">
     220                                                                        <input type="checkbox" id="blog_<?php echo $user['ID'] ?>" name="allusers[]" value="<?php echo esc_attr( $user['ID'] ) ?>" />
     221                                                                </th>
     222                                                                <th valign="top" scope="row">
     223                                                                        <?php echo $user['ID'] ?>
     224                                                                </th>
    187225                                                        <?php
    188226                                                        break;
    … …  
    190228                                                        case 'login':
    191229                                                                $avatar = get_avatar( $user['user_email'], 32 );
    192                                                                 $edit   = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=".$user['ID'] ) );
    193                                                                 // @todo Make delete link work like delete button with transfering users (in ms-edit.php)
    194                                                                 //$delete       = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), wp_nonce_url( 'ms-edit.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user['ID'] ) );
    195230                                                                ?>
    196231                                                                <td class="username column-username">
    197                                                                         <?php echo $avatar; ?><strong><a href="<?php echo $edit; ?>" class="edit"><?php echo stripslashes($user['user_login']); ?></a><?php
    198                                                                 if ( in_array( $user[ 'user_login' ], $super_admins ) )
    199                                                                         echo ' - ' . __( 'Super admin' );
    200 ?></strong>
     232                                                                        <?php echo $avatar; ?><strong><a href="<?php echo esc_url( admin_url( 'user-edit.php?user_id=' . $user['ID'] ) ); ?>" class="edit"><?php echo stripslashes( $user['user_login'] ); ?></a><?php
     233                                                                        if ( in_array( $user['user_login'], $super_admins ) )
     234                                                                                echo ' - ' . __( 'Super admin' );
     235                                                                        ?></strong>
    201236                                                                        <br/>
    202237                                                                        <div class="row-actions">
    203                                                                                 <span class="edit"><a href="<?php echo $edit; ?>">Edit</a></span>
    204                                                                                 <?php /*<span class="delete"><a href="<?php echo $delete; ?>" class="delete">Delete</a></span> */ ?>
     238                                                                                <span class="edit"><a href="<?php echo esc_url( admin_url( 'user-edit.php?user_id=' . $user['ID'] ) ); ?>"><?php _e( 'Edit'); ?></a></span>
     239                                                                                <?php if ( ! in_array( $user['user_login'], $super_admins ) ) { ?>
     240                                                                                | <span class="delete"><a href="<?php echo $delete      = esc_url( admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'ms-edit.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user['ID'] ) ) ); ?>" class="delete"><?php _e( 'Delete' ); ?></a></span>
     241                                                                                <?php } ?>
    205242                                                                        </div>
    206243                                                                </td>
    … …  
    218255                                                        break;
    219256
    220                                                         case 'registered': ?>
    221                                                                 <td><?php echo mysql2date(__('Y-m-d \<\b\r \/\> g:i a'), $user['user_registered']); ?></td>
     257                                                        case 'registered':
     258                                                                if ( 'list' == $mode )
     259                                                                        $date = 'Y/m/d';
     260                                                                else
     261                                                                        $date = 'Y/m/d \<\b\r \/\> g:i:s a';
     262                                                        ?>
     263                                                                <td><?php echo mysql2date( __( $date ), $user['user_registered'] ); ?></td>
    222264                                                        <?php
    223265                                                        break;
    … …  
    230272                                                                        if ( is_array( $blogs ) ) {
    231273                                                                                foreach ( (array) $blogs as $key => $val ) {
    232                                                                                         $path   = ($val->path == '/') ? '' : $val->path;
    233                                                                                         echo '<a href="ms-sites.php?action=editblog&amp;id=' . $val->userblog_id . '">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
     274                                                                                        $path   = ( $val->path == '/' ) ? '' : $val->path;
     275                                                                                        echo '<a href="'. esc_url( admin_url( 'ms-sites.php?action=editblog&amp;id=' . $val->userblog_id  ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
    234276                                                                                        echo ' <small class="row-actions">';
    235277
    236278                                                                                        // Edit
    237                                                                                         echo '<a href="ms-sites.php?action=editblog&amp;id=' . $val->userblog_id . '">' . __('Edit') . '</a> | ';
     279                                                                                        echo '<a href="'. esc_url( admin_url( 'ms-sites.php?action=editblog&amp;id=' . $val->userblog_id  ) ) .'">' . __( 'Edit' ) . '</a> | ';
    238280
    239281                                                                                        // View
    240282                                                                                        echo '<a ';
    241283                                                                                        if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 )
    242                                                                                                 echo 'style="background-color: #f66" ';
    243                                                                                         echo 'target="_new" href="http://'.$val->domain . $val->path.'">' . __('View') . '</a>';
    244 
     284                                                                                                echo 'style="background-color: #faa" ';
     285                                                                                        echo 'href="' .  esc_url( get_home_url( $val->userblog_id ) )  . '">' . __( 'View' ) . '</a>';
     286                                                                                       
    245287                                                                                        echo '</small><br />';
    246288                                                                                }
    … …  
    252294
    253295                                                        default: ?>
    254                                                                 <td><?php do_action('manage_users_custom_column', $column_name, $user['ID']); ?></td>
     296                                                                <td><?php do_action( 'manage_users_custom_column', $column_name, $user['ID'] ); ?></td>
    255297                                                        <?php
    256298                                                        break;
    … …  
    263305                        } else {
    264306                        ?>
    265                                 <tr style='background-color: <?php echo $bgcolor; ?>'>
    266                                         <td colspan="<?php echo (int) count($posts_columns); ?>"><?php _e('No users found.') ?></td>
     307                                <tr>
     308                                        <td colspan="<?php echo (int) count($users_columns); ?>"><?php _e( 'No users found.' ) ?></td>
    267309                                </tr>
    268310                                <?php
    … …  
    273315
    274316                <div class="tablenav">
    275                         <?php if ( $user_navigation ) echo "<div class='tablenav-pages'>$user_navigation</div>"; ?>
    276 
    277                         <div class="alignleft">
    278                                 <input type="submit" value="<?php esc_attr_e('Delete') ?>" name="alluser_delete" class="button-secondary delete" />
    279                                 <input type="submit" value="<?php esc_attr_e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
    280                                 <input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
    281                                 <input type="submit" value="<?php esc_attr_e('Add Network Admins') ?>" name="add_superadmin" class="button-secondary" />
    282                                 <input type="submit" value="<?php esc_attr_e('Remove Network Admins') ?>" name="remove_superadmin" class="button-secondary" />
    283                                 <?php wp_nonce_field( 'allusers' ); ?>
    284                                 <br class="clear" />
     317                        <?php
     318                        if ( $page_links )
     319                                echo "<div class='tablenav-pages'>$page_links_text</div>";
     320                        ?>
     321
     322                        <div class="alignleft actions">
     323                                <select name="action2">
     324                                        <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
     325                                        <option value="delete"><?php _e( 'Delete' ); ?></option>
     326                                        <option value="spam"><?php _e( 'Mark as Spammers' ); ?></option>
     327                                        <option value="notspam"><?php _e( 'Not Spam' ); ?></option>
     328                                        <option value="superadmin"><?php _e( 'Add Super Admins' ); ?></option>
     329                                        <option value="notsuperadmin"><?php _e( 'Remove Super Admins' ); ?></option>
     330                                </select>
     331                                <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
    285332                        </div>
     333                        <br class="clear" />
    286334                </div>
    287         </form>
    288 </div>
     335
     336                </form>
     337                </div>
    289338
    290339<?php
    291 if ( apply_filters('show_adduser_fields', true) ) :
     340if ( apply_filters( 'show_adduser_fields', true ) ) :
    292341?>
    293342<div class="wrap">
    294         <h2><?php _e('Add user') ?></h2>
    295         <form action="ms-edit.php?action=adduser" method="post">
     343        <h2><?php _e( 'Add user' ) ?></h2>
     344        <form action="ms-edit.php?action=adduser" method="post" id="form-add-user">
    296345        <table class="form-table">
    297346                <tr class="form-field form-required">
    298                         <th scope='row'><?php _e('Username') ?></th>
    299                         <td><input type="text" name="user[username]" /></td>
     347                        <th scope="row"><?php _e( 'Username' ) ?></th>
     348                        <td><input type="text" class="regular-text" name="user[username]" /></td>
    300349                </tr>
    301350                <tr class="form-field form-required">
    302                         <th scope='row'><?php _e('Email') ?></th>
    303                         <td><input type="text" name="user[email]" /></td>
     351                        <th scope="row"><?php _e( 'Email' ) ?></th>
     352                        <td><input type="text" class="regular-text" name="user[email]" /></td>
    304353                </tr>
    305354                <tr class="form-field">
    306                         <td colspan='2'><?php _e('Username and password will be mailed to the above email address.') ?></td>
     355                        <td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
    307356                </tr>
    308357        </table>
    309358        <p class="submit">
    310                 <?php wp_nonce_field('add-user') ?>
    311                 <input class="button" type="submit" name="Add user" value="<?php esc_attr_e('Add user') ?>" /></p>
     359                <?php wp_nonce_field( 'add-user' ) ?>
     360                <input class="button" type="submit" value="<?php esc_attr_e( 'Add user' ) ?>" /></p>
    312361        </form>
    313362</div>
    314363<?php endif; ?>
    315364
    316 <?php include('admin-footer.php'); ?>
     365<?php include( './admin-footer.php' ); ?>
  • trunk/wp-admin/my-sites.php

    r13896 r13918  
    11<?php
    2 
    3 require_once('admin.php');
     2require_once( './admin.php' );
    43
    54if ( !is_multisite() )
    6         wp_die( __('Multisite support is not enabled.') );
     5        wp_die( __( 'Multisite support is not enabled.' ) );
    76
    87if ( ! current_user_can('read') )
    9         wp_die(__('You do not have sufficient permissions to view this page.'));
     8        wp_die( __( 'You do not have sufficient permissions to view this page.' ) );
    109
    11 $action = isset($_POST['action']) ? $_POST['action'] : 'splash';
     10$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
    1211
    1312$blogs = get_blogs_of_user( $current_user->id );
    … …  
    1817$updated = false;
    1918if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) {
    20         check_admin_referer('update-my-sites');
    21         // @todo Validate primary blog.
    22         update_user_option( $current_user->id, 'primary_blog', (int) $_POST['primary_blog'], true );
    23         $updated = true;
     19        check_admin_referer( 'update-my-sites' );
     20
     21        $blog = get_blog_details( (int) $_POST['primary_blog'] );
     22        if ( $blog && isset( $blog->domain ) ) {
     23                update_user_option( $current_user->id, 'primary_blog', (int) $_POST['primary_blog'], true );
     24                $updated = true;
     25        } else {
     26                wp_die( __( "The primary site, which you have choosen, doesn't exists." ) );   
     27        }
    2428}
    2529
    26 $title = __('My Sites');
     30$title = __( 'My Sites' );
    2731$parent_file = 'index.php';
    28 require_once('admin-header.php');
     32require_once( './admin-header.php' );
    2933
    3034if ( $updated ) { ?>
    31                 <div id="message" class="updated fade"><p><strong><?php _e( 'Your site preferences have been updated.' ); ?></strong></p></div>
     35        <div id="message" class="updated fade"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
    3236<?php } ?>
    3337
    3438<div class="wrap">
    3539<?php screen_icon(); ?>
    36 <h2><?php echo esc_html($title); ?></h2>
     40<h2><?php esc_html_e( $title ); ?></h2>
    3741<form id="myblogs" action="" method="post">
    3842        <?php
    3943        choose_primary_blog();
    4044        do_action( 'myblogs_allblogs_options' );
    41         ?><table class='widefat'> <?php
     45        ?>
     46        <br clear="all" />
     47        <table class="widefat fixed">
     48        <?php
    4249        $settings_html = apply_filters( 'myblogs_options', '', 'global' );
    4350        if ( $settings_html != '' ) {
    … …  
    5360        elseif ( $num >= 10 )
    5461                $cols = 2;
    55         $num_rows = ceil($num/$cols);
     62        $num_rows = ceil( $num / $cols );
    5663        $split = 0;
    5764        for ( $i = 1; $i <= $num_rows; $i++ ) {
    … …  
    6269        $c = '';
    6370        foreach ( $rows as $row ) {
    64                 $c = $c == "alternate" ? '' : 'alternate';
     71                $c = $c == 'alternate' ? '' : 'alternate';
    6572                echo "<tr class='$c'>";
    66                 $t = '';
     73                $i = 0;
    6774                foreach ( $row as $user_blog ) {
    68                         $t = $t == 'border-right: 1px solid #ccc;' ? '' : 'border-right: 1px solid #ccc;';
    69                         echo "<td valign='top' style='$t; width:50%'>";
     75                        $s = $i == 3 ? '' : 'border-right: 1px solid #ccc;';
     76                        echo "<td valign='top' style='$s'>";
    7077                        echo "<h3>{$user_blog->blogname}</h3>";
    71                         echo "<p>" . apply_filters( "myblogs_blog_actions", "<a href='" . get_home_url($user_blog->userblog_id) . "'>" . __( 'Visit' ) . "</a> | <a href='" . get_admin_url($user_blog->userblog_id) . "'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";
     78                        echo "<p>" . apply_filters( 'myblogs_blog_actions', "<a href='" . esc_url( get_home_url( $user_blog->userblog_id ) ). "'>" . __( 'Visit' ) . "</a> | <a href='" . esc_url( get_admin_url( $user_blog->userblog_id ) ) . "'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";
    7279                        echo apply_filters( 'myblogs_options', '', $user_blog );
    7380                        echo "</td>";
     81                        $i++;
    7482                }
    7583                echo "</tr>";
    … …  
    7785        </table>
    7886        <input type="hidden" name="action" value="updateblogsettings" />
    79         <?php wp_nonce_field('update-my-sites'); ?>
     87        <?php wp_nonce_field( 'update-my-sites' ); ?>
    8088        <p>
    81          <input type="submit" class="button-primary" value="<?php _e('Update Options') ?>" name="submit" />
     89         <input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" />
    8290        </p>
    8391        </form>
    8492        </div>
    8593<?php
    86 include('admin-footer.php');
    87 
     94include( './admin-footer.php' );
    8895?>
Note: See TracChangeset for help on using the changeset viewer.