<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12736] trunk/wp-admin: Coding style</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12736">12736</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-01-15 23:49:09 +0000 (Fri, 15 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Coding style</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminajaxphp">trunk/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunkwpadminadminphp">trunk/wp-admin/admin.php</a></li>
<li><a href="#trunkwpadmineditlinkcategoriesphp">trunk/wp-admin/edit-link-categories.php</a></li>
<li><a href="#trunkwpadminmseditphp">trunk/wp-admin/ms-edit.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-ajax.php (12735 => 12736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-ajax.php        2010-01-15 23:40:29 UTC (rev 12735)
+++ trunk/wp-admin/admin-ajax.php        2010-01-15 23:49:09 UTC (rev 12736)
</span><span class="lines">@@ -910,7 +910,7 @@
</span><span class="cx">         global $current_user;
</span><span class="cx"> 
</span><span class="cx">         $_POST['post_category'] = explode(&quot;,&quot;, $_POST['catslist']);
</span><del>-        if($_POST['post_type'] == 'page' || empty($_POST['post_category']))
</del><ins>+        if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
</ins><span class="cx">                 unset($_POST['post_category']);
</span><span class="cx"> 
</span><span class="cx">         $do_autosave = (bool) $_POST['autosave'];
</span><span class="lines">@@ -926,7 +926,7 @@
</span><span class="cx">                 $supplemental['session_expired'] = add_query_arg( 'interim-login', 1, wp_login_url() );
</span><span class="cx"> 
</span><span class="cx">         $id = $revision_id = 0;
</span><del>-        if($_POST['post_ID'] &lt; 0) {
</del><ins>+        if ( $_POST['post_ID'] &lt; 0 ) {
</ins><span class="cx">                 $_POST['post_status'] = 'draft';
</span><span class="cx">                 $_POST['temp_ID'] = $_POST['post_ID'];
</span><span class="cx">                 if ( $do_autosave ) {
</span></span></pre></div>
<a id="trunkwpadminadminphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin.php (12735 => 12736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin.php        2010-01-15 23:40:29 UTC (rev 12735)
+++ trunk/wp-admin/admin.php        2010-01-15 23:49:09 UTC (rev 12736)
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx"> do_action('admin_init');
</span><span class="cx"> 
</span><span class="cx"> if (isset($plugin_page) ) {
</span><del>-        if( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) {
</del><ins>+        if ( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) {
</ins><span class="cx">                 $page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
</span><span class="cx">                 // backwards compatibility for plugins using add_management_page
</span><span class="cx">                 if ( empty( $page_hook ) &amp;&amp; 'edit.php' == $pagenow &amp;&amp; '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
</span></span></pre></div>
<a id="trunkwpadmineditlinkcategoriesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-link-categories.php (12735 => 12736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-link-categories.php        2010-01-15 23:40:29 UTC (rev 12735)
+++ trunk/wp-admin/edit-link-categories.php        2010-01-15 23:49:09 UTC (rev 12736)
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
</span><span class="cx"> if ( empty($pagenum) )
</span><span class="cx">         $pagenum = 1;
</span><del>-if( ! isset( $catsperpage ) || $catsperpage &lt; 0 )
</del><ins>+if ( ! isset( $catsperpage ) || $catsperpage &lt; 0 )
</ins><span class="cx">         $catsperpage = 20;
</span><span class="cx"> 
</span><span class="cx"> $page_links = paginate_links( array(
</span></span></pre></div>
<a id="trunkwpadminmseditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/ms-edit.php (12735 => 12736)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/ms-edit.php        2010-01-15 23:40:29 UTC (rev 12735)
+++ trunk/wp-admin/ms-edit.php        2010-01-15 23:49:09 UTC (rev 12736)
</span><span class="lines">@@ -9,39 +9,37 @@
</span><span class="cx"> 
</span><span class="cx"> do_action('wpmuadminedit', '');
</span><span class="cx"> 
</span><del>-if( isset($_GET[ 'id' ]) ) {
</del><ins>+if ( isset($_GET[ 'id' ]) )
</ins><span class="cx">         $id = intval( $_GET[ 'id' ] );
</span><del>-} elseif( isset($_POST[ 'id' ]) ) {
</del><ins>+elseif ( isset($_POST[ 'id' ]) )
</ins><span class="cx">         $id = intval( $_POST[ 'id' ] );
</span><del>-}
</del><span class="cx"> 
</span><del>-if( isset( $_POST['ref'] ) == false &amp;&amp; !empty($_SERVER['HTTP_REFERER']) ) {
</del><ins>+if ( isset( $_POST['ref'] ) == false &amp;&amp; !empty($_SERVER['HTTP_REFERER']) )
</ins><span class="cx">         $_POST['ref'] = $_SERVER['HTTP_REFERER'];
</span><del>-}
</del><span class="cx"> 
</span><del>-switch( $_GET['action'] ) {
</del><ins>+switch ( $_GET['action'] ) {
</ins><span class="cx">         case &quot;siteoptions&quot;:
</span><span class="cx">                 check_admin_referer('siteoptions');
</span><del>-                if( empty( $_POST ) )
</del><ins>+                if ( empty( $_POST ) )
</ins><span class="cx">                         wp_die( __(&quot;You probably need to go back to the &lt;a href='ms-options.php'&gt;options page&lt;/a&gt;&quot;) );
</span><span class="cx"> 
</span><span class="cx">                 update_site_option( &quot;WPLANG&quot;, $_POST['WPLANG'] );
</span><span class="cx"> 
</span><del>-                if( is_email( $_POST['admin_email'] ) )
</del><ins>+                if ( is_email( $_POST['admin_email'] ) )
</ins><span class="cx">                         update_site_option( &quot;admin_email&quot;, $_POST['admin_email'] );
</span><span class="cx"> 
</span><span class="cx">                 $illegal_names = split( ' ', $_POST['illegal_names'] );
</span><del>-                foreach( (array) $illegal_names as $name ) {
</del><ins>+                foreach ( (array) $illegal_names as $name ) {
</ins><span class="cx">                         $name = trim( $name );
</span><del>-                        if( $name != '' )
</del><ins>+                        if ( $name != '' )
</ins><span class="cx">                                 $names[] = trim( $name );
</span><span class="cx">                 }
</span><span class="cx">                 update_site_option( &quot;illegal_names&quot;, $names );
</span><span class="cx"> 
</span><del>-                if( $_POST['limited_email_domains'] != '' ) {
</del><ins>+                if ( $_POST['limited_email_domains'] != '' ) {
</ins><span class="cx">                         $limited_email_domains = str_replace( ' ', &quot;\n&quot;, $_POST[ 'limited_email_domains' ] );
</span><span class="cx">                         $limited_email_domains = split( &quot;\n&quot;, stripslashes( $limited_email_domains ) );
</span><del>-                        foreach( (array) $limited_email_domains as $domain ) {
</del><ins>+                        foreach ( (array) $limited_email_domains as $domain ) {
</ins><span class="cx">                                 $limited_email[] = trim( $domain );
</span><span class="cx">                         }
</span><span class="cx">                         update_site_option( &quot;limited_email_domains&quot;, $limited_email );
</span><span class="lines">@@ -49,9 +47,9 @@
</span><span class="cx">                         update_site_option( &quot;limited_email_domains&quot;, '' );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if( $_POST['banned_email_domains'] != '' ) {
</del><ins>+                if ( $_POST['banned_email_domains'] != '' ) {
</ins><span class="cx">                         $banned_email_domains = split( &quot;\n&quot;, stripslashes( $_POST[ 'banned_email_domains' ] ) );
</span><del>-                        foreach( (array) $banned_email_domains as $domain ) {
</del><ins>+                        foreach ( (array) $banned_email_domains as $domain ) {
</ins><span class="cx">                                 $banned[] = trim( $domain );
</span><span class="cx">                         }
</span><span class="cx">                         update_site_option( &quot;banned_email_domains&quot;, $banned );
</span><span class="lines">@@ -59,9 +57,9 @@
</span><span class="cx">                         update_site_option( &quot;banned_email_domains&quot;, '' );
</span><span class="cx">                 }
</span><span class="cx">                 update_site_option( 'default_user_role', $_POST[ 'default_user_role' ] );
</span><del>-                if( trim( $_POST[ 'dashboard_blog_orig' ] ) == '' )
</del><ins>+                if ( trim( $_POST[ 'dashboard_blog_orig' ] ) == '' )
</ins><span class="cx">                         $_POST[ 'dashboard_blog_orig' ] = $current_site-&gt;blog_id;
</span><del>-                if( trim( $_POST[ 'dashboard_blog' ] ) == '' ) {
</del><ins>+                if ( trim( $_POST[ 'dashboard_blog' ] ) == '' ) {
</ins><span class="cx">                         $_POST[ 'dashboard_blog' ] = $current_site-&gt;blog_id;
</span><span class="cx">                         $dashboard_blog_id = $current_site-&gt;blog_id;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -84,14 +82,13 @@
</span><span class="cx">                                 $dashboard_blog_id = $blog_details-&gt;blog_id;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                if ( is_wp_error( $dashboard_blog_id ) ) {
</del><ins>+                if ( is_wp_error( $dashboard_blog_id ) )
</ins><span class="cx">                         wp_die( __( 'Problem creating dashboard blog: ' ) . $dashboard_blog_id-&gt;get_error_message() );
</span><del>-                }
-                if( $_POST[ 'dashboard_blog_orig' ] != $_POST[ 'dashboard_blog' ] ) {
</del><ins>+                if ( $_POST[ 'dashboard_blog_orig' ] != $_POST[ 'dashboard_blog' ] ) {
</ins><span class="cx">                         $users = get_users_of_blog( get_site_option( 'dashboard_blog' ) );
</span><span class="cx">                         $move_users = array();
</span><span class="cx">                         foreach ( (array)$users as $user ) {
</span><del>-                                if( array_pop( array_keys( unserialize( $user-&gt;meta_value ) ) ) == 'subscriber' )
</del><ins>+                                if ( array_pop( array_keys( unserialize( $user-&gt;meta_value ) ) ) == 'subscriber' )
</ins><span class="cx">                                         $move_users[] = $user-&gt;user_id;
</span><span class="cx">                         }
</span><span class="cx">                         if ( false == empty( $move_users ) ) {
</span><span class="lines">@@ -104,7 +101,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 update_site_option( &quot;dashboard_blog&quot;, $dashboard_blog_id );
</span><span class="cx">                 $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' );
</span><del>-                foreach( $options as $option_name ) {
</del><ins>+                foreach ( $options as $option_name ) {
</ins><span class="cx">                         $value = stripslashes_deep( $_POST[ $option_name ] );
</span><span class="cx">                         update_site_option( $option_name, $value );
</span><span class="cx">                 }
</span><span class="lines">@@ -112,11 +109,11 @@
</span><span class="cx">                 $site_admins = explode( ' ', str_replace( &quot;,&quot;, &quot; &quot;, $_POST['site_admins'] ) );
</span><span class="cx">                 if ( is_array( $site_admins ) ) {
</span><span class="cx">                         $mainblog_id = $wpdb-&gt;get_var( &quot;SELECT blog_id FROM {$wpdb-&gt;blogs} WHERE domain='{$current_site-&gt;domain}' AND path='{$current_site-&gt;path}'&quot; );
</span><del>-                        if( $mainblog_id ) {
</del><ins>+                        if ( $mainblog_id ) {
</ins><span class="cx">                                 reset( $site_admins );
</span><del>-                                foreach( (array) $site_admins as $site_admin ) {
</del><ins>+                                foreach ( (array) $site_admins as $site_admin ) {
</ins><span class="cx">                                         $uid = $wpdb-&gt;get_var( &quot;SELECT ID FROM {$wpdb-&gt;users} WHERE user_login='{$site_admin}'&quot; );
</span><del>-                                        if( $uid )
</del><ins>+                                        if ( $uid )
</ins><span class="cx">                                                 add_user_to_blog( $mainblog_id, $uid, 'administrator' );
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -132,20 +129,19 @@
</span><span class="cx">         case &quot;addblog&quot;:
</span><span class="cx">                 check_admin_referer('add-blog');
</span><span class="cx"> 
</span><del>-                if( is_array( $_POST[ 'blog' ] ) == false ) {
</del><ins>+                if ( is_array( $_POST[ 'blog' ] ) == false )
</ins><span class="cx">                         wp_die( &quot;Can't create an empty blog.&quot; );
</span><del>-                }
</del><span class="cx">                 $blog = $_POST['blog'];
</span><span class="cx">                 $domain = sanitize_user( str_replace( '/', '', $blog[ 'domain' ] ) );
</span><span class="cx">                 $email = sanitize_email( $blog[ 'email' ] );
</span><span class="cx">                 $title = $blog[ 'title' ];
</span><span class="cx"> 
</span><del>-                if ( empty($domain) || empty($email))
</del><ins>+                if ( empty($domain) || empty($email) )
</ins><span class="cx">                         wp_die( __('Missing blog address or email address.') );
</span><del>-                if( !is_email( $email ) )
</del><ins>+                if ( !is_email( $email ) )
</ins><span class="cx">                         wp_die( __('Invalid email address') );
</span><span class="cx"> 
</span><del>-                if( is_subdomain_install() ) {
</del><ins>+                if ( is_subdomain_install() ) {
</ins><span class="cx">                         $newdomain = $domain.&quot;.&quot;.$current_site-&gt;domain;
</span><span class="cx">                         $path = $base;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -155,22 +151,21 @@
</span><span class="cx"> 
</span><span class="cx">                 $password = 'N/A';
</span><span class="cx">                 $user_id = email_exists($email);
</span><del>-                if( !$user_id ) { // Create a new user with a random password
</del><ins>+                if ( !$user_id ) { // Create a new user with a random password
</ins><span class="cx">                         $password = wp_generate_password();
</span><span class="cx">                         $user_id = wpmu_create_user( $domain, $password, $email );
</span><del>-                        if(false == $user_id) {
</del><ins>+                        if ( false == $user_id )
</ins><span class="cx">                                 wp_die( __('There was an error creating the user') );
</span><del>-                        } else {
</del><ins>+                        else
</ins><span class="cx">                                 wp_new_user_notification($user_id, $password);
</span><del>-                        }
</del><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $wpdb-&gt;hide_errors();
</span><span class="cx">                 $id = wpmu_create_blog($newdomain, $path, $title, $user_id , array( &quot;public&quot; =&gt; 1 ), $current_site-&gt;id);
</span><span class="cx">                 $wpdb-&gt;show_errors();
</span><del>-                if( !is_wp_error($id) ) {
</del><ins>+                if ( !is_wp_error($id) ) {
</ins><span class="cx">                         $dashboard_blog = get_dashboard_blog();
</span><del>-                        if( get_user_option( 'primary_blog', $user_id ) == $dashboard_blog-&gt;blog_id )
</del><ins>+                        if ( get_user_option( 'primary_blog', $user_id ) == $dashboard_blog-&gt;blog_id )
</ins><span class="cx">                                 update_user_option( $user_id, 'primary_blog', $id, true );
</span><span class="cx">                         $content_mail = sprintf( __( &quot;New blog created by %1s\n\nAddress: http://%2s\nName: %3s&quot;), $current_user-&gt;user_login , $newdomain.$path, stripslashes( $title ) );
</span><span class="cx">                         wp_mail( get_site_option('admin_email'),  sprintf(__('[%s] New Blog Created'), $current_site-&gt;site_name), $content_mail, 'From: &quot;Site Admin&quot; &lt;' . get_site_option( 'admin_email' ) . '&gt;' );
</span><span class="lines">@@ -184,33 +179,31 @@
</span><span class="cx"> 
</span><span class="cx">         case &quot;updateblog&quot;:
</span><span class="cx">                 check_admin_referer('editblog');
</span><del>-                if( empty( $_POST ) )
</del><ins>+                if ( empty( $_POST ) )
</ins><span class="cx">                         wp_die( __('You probably need to go back to the &lt;a href=&quot;ms-sites.php&quot;&gt;sites page&lt;/a&gt;') );
</span><span class="cx"> 
</span><span class="cx">                 // themes
</span><del>-                if( is_array( $_POST[ 'theme' ] ) ) {
</del><ins>+                if ( is_array( $_POST[ 'theme' ] ) )
</ins><span class="cx">                         $_POST[ 'option' ][ 'allowedthemes' ] = $_POST[ 'theme' ];
</span><del>-                } else {
</del><ins>+                else
</ins><span class="cx">                         $_POST[ 'option' ][ 'allowedthemes' ] = '';
</span><del>-                }
</del><span class="cx"> 
</span><span class="cx">                 switch_to_blog( $id );
</span><del>-                if( is_array( $_POST[ 'option' ] ) ) {
</del><ins>+                if ( is_array( $_POST[ 'option' ] ) ) {
</ins><span class="cx">                         $c = 1;
</span><span class="cx">                         $count = count( $_POST[ 'option' ] );
</span><span class="cx">                         foreach ( (array) $_POST['option'] as $key =&gt; $val ) {
</span><del>-                                if( $key === 0 )
</del><ins>+                                if ( $key === 0 )
</ins><span class="cx">                                         continue; // Avoids &quot;0 is a protected WP option and may not be modified&quot; error when edit blog options
</span><del>-                                if( $c == $count ) {
</del><ins>+                                if ( $c == $count )
</ins><span class="cx">                                         update_option( $key, $val );
</span><del>-                                } else {
</del><ins>+                                else
</ins><span class="cx">                                         update_option( $key, $val, false ); // no need to refresh blog details yet
</span><del>-                                }
</del><span class="cx">                                 $c++;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if( $_POST['update_home_url'] == 'update' ) {
</del><ins>+                if ( $_POST['update_home_url'] == 'update' ) {
</ins><span class="cx">                         if( get_option( 'siteurl' ) != 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] )
</span><span class="cx">                                 update_option( 'siteurl', 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] );
</span><span class="cx"> 
</span><span class="lines">@@ -238,18 +231,16 @@
</span><span class="cx">                 // get blog prefix
</span><span class="cx">                 $blog_prefix = $wpdb-&gt;get_blog_prefix( $id );
</span><span class="cx">                 // user roles
</span><del>-                if( is_array( $_POST[ 'role' ] ) == true ) {
</del><ins>+                if ( is_array( $_POST[ 'role' ] ) == true ) {
</ins><span class="cx">                         $newroles = $_POST[ 'role' ];
</span><span class="cx">                         reset( $newroles );
</span><span class="cx">                         foreach ( (array) $newroles as $userid =&gt; $role ) {
</span><span class="cx">                                 $role_len = strlen( $role );
</span><span class="cx">                                 $existing_role = $wpdb-&gt;get_var( &quot;SELECT meta_value FROM $wpdb-&gt;usermeta WHERE user_id = '$userid'  AND meta_key = '&quot; . $blog_prefix. &quot;capabilities'&quot; );
</span><del>-                                if( false == $existing_role ) {
</del><ins>+                                if ( false == $existing_role )
</ins><span class="cx">                                         $wpdb-&gt;query( &quot;INSERT INTO &quot; . $wpdb-&gt;usermeta . &quot;( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$userid', '&quot; . $blog_prefix . &quot;capabilities', 'a:1:{s:&quot; . strlen( $role ) . &quot;:\&quot;&quot; . $role . &quot;\&quot;;b:1;}')&quot; );
</span><del>-                                } elseif( $existing_role != &quot;a:1:{s:&quot; . strlen( $role ) . &quot;:\&quot;&quot; . $role . &quot;\&quot;;b:1;}&quot; ) {
</del><ins>+                                elseif ( $existing_role != &quot;a:1:{s:&quot; . strlen( $role ) . &quot;:\&quot;&quot; . $role . &quot;\&quot;;b:1;}&quot; )
</ins><span class="cx">                                         $wpdb-&gt;query( &quot;UPDATE $wpdb-&gt;usermeta SET meta_value = 'a:1:{s:&quot; . strlen( $role ) . &quot;:\&quot;&quot; . $role . &quot;\&quot;;b:1;}' WHERE user_id = '$userid'  AND meta_key = '&quot; . $blog_prefix . &quot;capabilities'&quot; );
</span><del>-                                }
-
</del><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -261,20 +252,20 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // change password
</span><del>-                if( is_array( $_POST[ 'user_password' ] ) ) {
</del><ins>+                if ( is_array( $_POST[ 'user_password' ] ) ) {
</ins><span class="cx">                         reset( $_POST[ 'user_password' ] );
</span><span class="cx">                         $newroles = $_POST[ 'role' ];
</span><span class="cx">                         foreach ( (array) $_POST[ 'user_password' ] as $userid =&gt; $pass ) {
</span><span class="cx">                                 unset( $_POST[ 'role' ] );
</span><span class="cx">                                 $_POST[ 'role' ] = $newroles[ $userid ];
</span><del>-                                if( $pass != '' ) {
</del><ins>+                                if ( $pass != '' ) {
</ins><span class="cx">                                         $cap = $wpdb-&gt;get_var( &quot;SELECT meta_value FROM {$wpdb-&gt;usermeta} WHERE user_id = '{$userid}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'&quot; );
</span><span class="cx">                                         $userdata = get_userdata($userid);
</span><span class="cx">                                         $_POST[ 'pass1' ] = $_POST[ 'pass2' ] = $pass;
</span><span class="cx">                                         $_POST[ 'email' ] = $userdata-&gt;user_email;
</span><span class="cx">                                         $_POST[ 'rich_editing' ] = $userdata-&gt;rich_editing;
</span><span class="cx">                                         edit_user( $userid );
</span><del>-                                        if( $cap == null )
</del><ins>+                                        if ( $cap == null )
</ins><span class="cx">                                                 $wpdb-&gt;query( &quot;DELETE FROM {$wpdb-&gt;usermeta} WHERE user_id = '{$userid}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'&quot; );
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -283,12 +274,12 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // add user?
</span><del>-                if( $_POST[ 'newuser' ] != '' ) {
</del><ins>+                if ( $_POST[ 'newuser' ] != '' ) {
</ins><span class="cx">                         $newuser = $_POST[ 'newuser' ];
</span><span class="cx">                         $userid = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT ID FROM &quot; . $wpdb-&gt;users . &quot; WHERE user_login = %s&quot;, $newuser ) );
</span><del>-                        if( $userid ) {
</del><ins>+                        if ( $userid ) {
</ins><span class="cx">                                 $user = $wpdb-&gt;get_var( &quot;SELECT user_id FROM &quot; . $wpdb-&gt;usermeta . &quot; WHERE user_id='$userid' AND meta_key='wp_&quot; . $id . &quot;_capabilities'&quot; );
</span><del>-                                if( $user == false )
</del><ins>+                                if ( $user == false )
</ins><span class="cx">                                         add_user_to_blog($id, $userid, $_POST[ 'new_role' ]);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -299,7 +290,7 @@
</span><span class="cx"> 
</span><span class="cx">         case &quot;deleteblog&quot;:
</span><span class="cx">                 check_admin_referer('deleteblog');
</span><del>-                if( $id != '0' &amp;&amp; $id != $current_site-&gt;blog_id )
</del><ins>+                if ( $id != '0' &amp;&amp; $id != $current_site-&gt;blog_id )
</ins><span class="cx">                         wpmu_delete_blog( $id, true );
</span><span class="cx"> 
</span><span class="cx">                 wp_redirect( add_query_arg( array('updated' =&gt; 'true', 'action' =&gt; 'delete'), $_POST[ 'ref' ] ) );
</span><span class="lines">@@ -309,7 +300,7 @@
</span><span class="cx">         case &quot;allblogs&quot;:
</span><span class="cx">                 check_admin_referer('allblogs');
</span><span class="cx">                 foreach ( (array) $_POST[ 'allblogs' ] as $key =&gt; $val ) {
</span><del>-                        if( $val != '0' &amp;&amp; $val != $current_site-&gt;blog_id ) {
</del><ins>+                        if ( $val != '0' &amp;&amp; $val != $current_site-&gt;blog_id ) {
</ins><span class="cx">                                 if ( isset($_POST['allblog_delete']) ) {
</span><span class="cx">                                         $blogfunction = 'all_delete';
</span><span class="cx">                                         wpmu_delete_blog( $val, true );
</span><span class="lines">@@ -392,11 +383,11 @@
</span><span class="cx"> 
</span><span class="cx">         // Themes
</span><span class="cx">     case &quot;updatethemes&quot;:
</span><del>-            if( is_array( $_POST['theme'] ) ) {
</del><ins>+            if ( is_array( $_POST['theme'] ) ) {
</ins><span class="cx">                         $themes = get_themes();
</span><span class="cx">                         reset( $themes );
</span><del>-                        foreach( (array) $themes as $key =&gt; $theme ) {
-                                if( $_POST['theme'][ wp_specialchars( $theme['Stylesheet'] ) ] == 'enabled' )
</del><ins>+                        foreach ( (array) $themes as $key =&gt; $theme ) {
+                                if ( $_POST['theme'][ wp_specialchars( $theme['Stylesheet'] ) ] == 'enabled' )
</ins><span class="cx">                                         $allowed_themes[ wp_specialchars( $theme['Stylesheet'] ) ] = true;
</span><span class="cx">                         }
</span><span class="cx">                         update_site_option( 'allowedthemes', $allowed_themes );
</span><span class="lines">@@ -409,7 +400,7 @@
</span><span class="cx">         case &quot;confirm&quot;:
</span><span class="cx">                 $referrer = ( isset($_GET['ref']) ) ? stripslashes($_GET['ref']) : $_SERVER['HTTP_REFERER'];
</span><span class="cx">                 $referrer = clean_url($referrer);
</span><del>-                if( !headers_sent() ){
</del><ins>+                if ( !headers_sent() ) {
</ins><span class="cx">                         nocache_headers();
</span><span class="cx">                         header( 'Content-Type: text/html; charset=utf-8' );
</span><span class="cx">                 }
</span><span class="lines">@@ -440,7 +431,7 @@
</span><span class="cx">         // Users (not used any more)
</span><span class="cx">         case &quot;deleteuser&quot;:
</span><span class="cx">                 check_admin_referer('deleteuser');
</span><del>-                if( $id != '0' &amp;&amp; $id != '1' )
</del><ins>+                if ( $id != '0' &amp;&amp; $id != '1' )
</ins><span class="cx">                         wpmu_delete_user($id);
</span><span class="cx"> 
</span><span class="cx">                 wp_redirect( add_query_arg( array('updated' =&gt; 'true', 'action' =&gt; 'delete'), $_POST['ref'] ) );
</span><span class="lines">@@ -454,28 +445,26 @@
</span><span class="cx">                         echo '&lt;div class=&quot;wrap&quot; style=&quot;position:relative;&quot;&gt;';
</span><span class="cx">                         confirm_delete_users( $_POST['allusers'] );
</span><span class="cx">                         echo '&lt;/div&gt;';
</span><del>-                } elseif( isset( $_POST[ 'alluser_transfer_delete' ] ) ) {
-                        if( is_array( $_POST[ 'blog' ] ) &amp;&amp; !empty( $_POST[ 'blog' ] ) ) {
-                                foreach( $_POST[ 'blog' ] as $id =&gt; $users ) {
-                                        foreach( $users as $blogid =&gt; $user_id ) {
</del><ins>+                } elseif ( isset( $_POST[ 'alluser_transfer_delete' ] ) ) {
+                        if ( is_array( $_POST[ 'blog' ] ) &amp;&amp; !empty( $_POST[ 'blog' ] ) ) {
+                                foreach ( $_POST[ 'blog' ] as $id =&gt; $users ) {
+                                        foreach ( $users as $blogid =&gt; $user_id ) {
</ins><span class="cx">                                                 remove_user_from_blog( $id, $blogid, $user_id );
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        if( is_array( $_POST[ 'user' ] ) &amp;&amp; !empty( $_POST[ 'user' ] ) )
</del><ins>+                        if ( is_array( $_POST[ 'user' ] ) &amp;&amp; !empty( $_POST[ 'user' ] ) )
</ins><span class="cx">                                 foreach( $_POST[ 'user' ] as $id )
</span><span class="cx">                                         wpmu_delete_user( $id );
</span><span class="cx"> 
</span><span class="cx">                         wp_redirect( add_query_arg( array('updated' =&gt; 'true', 'action' =&gt; 'all_delete'), 'ms-users.php' ) );
</span><span class="cx">                 } else {
</span><span class="cx">                         foreach ( (array) $_POST['allusers'] as $key =&gt; $val ) {
</span><del>-                                if( $val == '' || $val == '0' ) {
</del><ins>+                                if ( $val == '' || $val == '0' )
</ins><span class="cx">                                         continue;
</span><del>-                                }
</del><span class="cx">                                 $user = new WP_User( $val );
</span><del>-                                if ( in_array( $user-&gt;user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) ) {
</del><ins>+                                if ( in_array( $user-&gt;user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) )
</ins><span class="cx">                                         wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a site admnistrator.' ), $user-&gt;user_login ) );
</span><del>-                                }
</del><span class="cx">                                 if ( isset($_POST['alluser_spam']) ) {
</span><span class="cx">                                         $userfunction = 'all_spam';
</span><span class="cx">                                         $blogs = get_blogs_of_user( $val, true );
</span><span class="lines">@@ -501,31 +490,28 @@
</span><span class="cx">         case &quot;adduser&quot;:
</span><span class="cx">                 check_admin_referer('add-user');
</span><span class="cx"> 
</span><del>-                if( is_array( $_POST[ 'user' ] ) == false ) {
</del><ins>+                if ( is_array( $_POST[ 'user' ] ) == false )
</ins><span class="cx">                         wp_die( __( &quot;Cannot create an empty user.&quot; ) );
</span><del>-                }
</del><span class="cx">                 $user = $_POST['user'];
</span><del>-                if ( empty($user['username']) &amp;&amp; empty($user['email']) ) {
</del><ins>+                if ( empty($user['username']) &amp;&amp; empty($user['email']) )
</ins><span class="cx">                         wp_die( __('Missing username and email.') );
</span><del>-                } elseif ( empty($user['username']) ) {
</del><ins>+                elseif ( empty($user['username']) )
</ins><span class="cx">                         wp_die( __('Missing username.') );
</span><del>-                } elseif ( empty($user['email']) ) {
</del><ins>+                elseif ( empty($user['email']) )
</ins><span class="cx">                         wp_die( __('Missing email.') );
</span><del>-                }
</del><span class="cx"> 
</span><span class="cx">                 $password = generate_random_password();
</span><span class="cx">                 $user_id = wpmu_create_user(wp_specialchars( strtolower( $user['username'] ) ), $password, wp_specialchars( $user['email'] ) );
</span><span class="cx"> 
</span><del>-                if( false == $user_id ) {
</del><ins>+                if ( false == $user_id )
</ins><span class="cx">                          wp_die( __('Duplicated username or email address.') );
</span><del>-                } else {
</del><ins>+                else
</ins><span class="cx">                         wp_new_user_notification($user_id, $password);
</span><del>-                }
-                if ( get_site_option( 'dashboard_blog' ) == false ) {
</del><ins>+
+                if ( get_site_option( 'dashboard_blog' ) == false )
</ins><span class="cx">                         add_user_to_blog( $current_site-&gt;blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
</span><del>-                } else {
</del><ins>+                else
</ins><span class="cx">                         add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
</span><del>-                }
</del><span class="cx"> 
</span><span class="cx">                 wp_redirect( add_query_arg( array('updated' =&gt; 'true', 'action' =&gt; 'add'), $_SERVER['HTTP_REFERER'] ) );
</span><span class="cx">                 exit();
</span></span></pre>
</div>
</div>

</body>
</html>