Make WordPress Core

Changeset 12736


Ignore:
Timestamp:
01/15/2010 11:49:09 PM (17 years ago)
Author:
ryan
Message:

Coding style

Location:
trunk/wp-admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r12728 r12736  
    911911
    912912        $_POST['post_category'] = explode(",", $_POST['catslist']);
    913         if($_POST['post_type'] == 'page' || empty($_POST['post_category']))
     913        if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
    914914                unset($_POST['post_category']);
    915915
     
    927927
    928928        $id = $revision_id = 0;
    929         if($_POST['post_ID'] < 0) {
     929        if ( $_POST['post_ID'] < 0 ) {
    930930                $_POST['post_status'] = 'draft';
    931931                $_POST['temp_ID'] = $_POST['post_ID'];
  • trunk/wp-admin/admin.php

    r12733 r12736  
    8484
    8585if (isset($plugin_page) ) {
    86         if( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) {
     86        if ( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) {
    8787                $page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
    8888                // backwards compatibility for plugins using add_management_page
  • trunk/wp-admin/edit-link-categories.php

    r12716 r12736  
    9393if ( empty($pagenum) )
    9494        $pagenum = 1;
    95 if( ! isset( $catsperpage ) || $catsperpage < 0 )
     95if ( ! isset( $catsperpage ) || $catsperpage < 0 )
    9696        $catsperpage = 20;
    9797
  • trunk/wp-admin/ms-edit.php

    r12725 r12736  
    1010do_action('wpmuadminedit', '');
    1111
    12 if( isset($_GET[ 'id' ]) ) {
     12if ( isset($_GET[ 'id' ]) )
    1313        $id = intval( $_GET[ 'id' ] );
    14 } elseif( isset($_POST[ 'id' ]) ) {
     14elseif ( isset($_POST[ 'id' ]) )
    1515        $id = intval( $_POST[ 'id' ] );
    16 }
    17 
    18 if( isset( $_POST['ref'] ) == false && !empty($_SERVER['HTTP_REFERER']) ) {
     16
     17if ( isset( $_POST['ref'] ) == false && !empty($_SERVER['HTTP_REFERER']) )
    1918        $_POST['ref'] = $_SERVER['HTTP_REFERER'];
    20 }
    21 
    22 switch( $_GET['action'] ) {
     19
     20switch ( $_GET['action'] ) {
    2321        case "siteoptions":
    2422                check_admin_referer('siteoptions');
    25                 if( empty( $_POST ) )
     23                if ( empty( $_POST ) )
    2624                        wp_die( __("You probably need to go back to the <a href='ms-options.php'>options page</a>") );
    2725
    2826                update_site_option( "WPLANG", $_POST['WPLANG'] );
    2927
    30                 if( is_email( $_POST['admin_email'] ) )
     28                if ( is_email( $_POST['admin_email'] ) )
    3129                        update_site_option( "admin_email", $_POST['admin_email'] );
    3230
    3331                $illegal_names = split( ' ', $_POST['illegal_names'] );
    34                 foreach( (array) $illegal_names as $name ) {
     32                foreach ( (array) $illegal_names as $name ) {
    3533                        $name = trim( $name );
    36                         if( $name != '' )
     34                        if ( $name != '' )
    3735                                $names[] = trim( $name );
    3836                }
    3937                update_site_option( "illegal_names", $names );
    4038
    41                 if( $_POST['limited_email_domains'] != '' ) {
     39                if ( $_POST['limited_email_domains'] != '' ) {
    4240                        $limited_email_domains = str_replace( ' ', "\n", $_POST[ 'limited_email_domains' ] );
    4341                        $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) );
    44                         foreach( (array) $limited_email_domains as $domain ) {
     42                        foreach ( (array) $limited_email_domains as $domain ) {
    4543                                $limited_email[] = trim( $domain );
    4644                        }
     
    5048                }
    5149
    52                 if( $_POST['banned_email_domains'] != '' ) {
     50                if ( $_POST['banned_email_domains'] != '' ) {
    5351                        $banned_email_domains = split( "\n", stripslashes( $_POST[ 'banned_email_domains' ] ) );
    54                         foreach( (array) $banned_email_domains as $domain ) {
     52                        foreach ( (array) $banned_email_domains as $domain ) {
    5553                                $banned[] = trim( $domain );
    5654                        }
     
    6058                }
    6159                update_site_option( 'default_user_role', $_POST[ 'default_user_role' ] );
    62                 if( trim( $_POST[ 'dashboard_blog_orig' ] ) == '' )
     60                if ( trim( $_POST[ 'dashboard_blog_orig' ] ) == '' )
    6361                        $_POST[ 'dashboard_blog_orig' ] = $current_site->blog_id;
    64                 if( trim( $_POST[ 'dashboard_blog' ] ) == '' ) {
     62                if ( trim( $_POST[ 'dashboard_blog' ] ) == '' ) {
    6563                        $_POST[ 'dashboard_blog' ] = $current_site->blog_id;
    6664                        $dashboard_blog_id = $current_site->blog_id;
     
    8583                        }
    8684                }
    87                 if ( is_wp_error( $dashboard_blog_id ) ) {
     85                if ( is_wp_error( $dashboard_blog_id ) )
    8886                        wp_die( __( 'Problem creating dashboard blog: ' ) . $dashboard_blog_id->get_error_message() );
    89                 }
    90                 if( $_POST[ 'dashboard_blog_orig' ] != $_POST[ 'dashboard_blog' ] ) {
     87                if ( $_POST[ 'dashboard_blog_orig' ] != $_POST[ 'dashboard_blog' ] ) {
    9188                        $users = get_users_of_blog( get_site_option( 'dashboard_blog' ) );
    9289                        $move_users = array();
    9390                        foreach ( (array)$users as $user ) {
    94                                 if( array_pop( array_keys( unserialize( $user->meta_value ) ) ) == 'subscriber' )
     91                                if ( array_pop( array_keys( unserialize( $user->meta_value ) ) ) == 'subscriber' )
    9592                                        $move_users[] = $user->user_id;
    9693                        }
     
    105102                update_site_option( "dashboard_blog", $dashboard_blog_id );
    106103                $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' );
    107                 foreach( $options as $option_name ) {
     104                foreach ( $options as $option_name ) {
    108105                        $value = stripslashes_deep( $_POST[ $option_name ] );
    109106                        update_site_option( $option_name, $value );
     
    113110                if ( is_array( $site_admins ) ) {
    114111                        $mainblog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
    115                         if( $mainblog_id ) {
     112                        if ( $mainblog_id ) {
    116113                                reset( $site_admins );
    117                                 foreach( (array) $site_admins as $site_admin ) {
     114                                foreach ( (array) $site_admins as $site_admin ) {
    118115                                        $uid = $wpdb->get_var( "SELECT ID FROM {$wpdb->users} WHERE user_login='{$site_admin}'" );
    119                                         if( $uid )
     116                                        if ( $uid )
    120117                                                add_user_to_blog( $mainblog_id, $uid, 'administrator' );
    121118                                }
     
    133130                check_admin_referer('add-blog');
    134131
    135                 if( is_array( $_POST[ 'blog' ] ) == false ) {
     132                if ( is_array( $_POST[ 'blog' ] ) == false )
    136133                        wp_die( "Can't create an empty blog." );
    137                 }
    138134                $blog = $_POST['blog'];
    139135                $domain = sanitize_user( str_replace( '/', '', $blog[ 'domain' ] ) );
     
    141137                $title = $blog[ 'title' ];
    142138
    143                 if ( empty($domain) || empty($email))
     139                if ( empty($domain) || empty($email) )
    144140                        wp_die( __('Missing blog address or email address.') );
    145                 if( !is_email( $email ) )
     141                if ( !is_email( $email ) )
    146142                        wp_die( __('Invalid email address') );
    147143
    148                 if( is_subdomain_install() ) {
     144                if ( is_subdomain_install() ) {
    149145                        $newdomain = $domain.".".$current_site->domain;
    150146                        $path = $base;
     
    156152                $password = 'N/A';
    157153                $user_id = email_exists($email);
    158                 if( !$user_id ) { // Create a new user with a random password
     154                if ( !$user_id ) { // Create a new user with a random password
    159155                        $password = wp_generate_password();
    160156                        $user_id = wpmu_create_user( $domain, $password, $email );
    161                         if(false == $user_id) {
     157                        if ( false == $user_id )
    162158                                wp_die( __('There was an error creating the user') );
    163                         } else {
     159                        else
    164160                                wp_new_user_notification($user_id, $password);
    165                         }
    166161                }
    167162
     
    169164                $id = wpmu_create_blog($newdomain, $path, $title, $user_id , array( "public" => 1 ), $current_site->id);
    170165                $wpdb->show_errors();
    171                 if( !is_wp_error($id) ) {
     166                if ( !is_wp_error($id) ) {
    172167                        $dashboard_blog = get_dashboard_blog();
    173                         if( get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id )
     168                        if ( get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id )
    174169                                update_user_option( $user_id, 'primary_blog', $id, true );
    175170                        $content_mail = sprintf( __( "New blog created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain.$path, stripslashes( $title ) );
     
    185180        case "updateblog":
    186181                check_admin_referer('editblog');
    187                 if( empty( $_POST ) )
     182                if ( empty( $_POST ) )
    188183                        wp_die( __('You probably need to go back to the <a href="ms-sites.php">sites page</a>') );
    189184
    190185                // themes
    191                 if( is_array( $_POST[ 'theme' ] ) ) {
     186                if ( is_array( $_POST[ 'theme' ] ) )
    192187                        $_POST[ 'option' ][ 'allowedthemes' ] = $_POST[ 'theme' ];
    193                 } else {
     188                else
    194189                        $_POST[ 'option' ][ 'allowedthemes' ] = '';
    195                 }
    196190
    197191                switch_to_blog( $id );
    198                 if( is_array( $_POST[ 'option' ] ) ) {
     192                if ( is_array( $_POST[ 'option' ] ) ) {
    199193                        $c = 1;
    200194                        $count = count( $_POST[ 'option' ] );
    201195                        foreach ( (array) $_POST['option'] as $key => $val ) {
    202                                 if( $key === 0 )
     196                                if ( $key === 0 )
    203197                                        continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
    204                                 if( $c == $count ) {
     198                                if ( $c == $count )
    205199                                        update_option( $key, $val );
    206                                 } else {
     200                                else
    207201                                        update_option( $key, $val, false ); // no need to refresh blog details yet
    208                                 }
    209202                                $c++;
    210203                        }
    211204                }
    212205
    213                 if( $_POST['update_home_url'] == 'update' ) {
     206                if ( $_POST['update_home_url'] == 'update' ) {
    214207                        if( get_option( 'siteurl' ) != 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] )
    215208                                update_option( 'siteurl', 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] );
     
    239232                $blog_prefix = $wpdb->get_blog_prefix( $id );
    240233                // user roles
    241                 if( is_array( $_POST[ 'role' ] ) == true ) {
     234                if ( is_array( $_POST[ 'role' ] ) == true ) {
    242235                        $newroles = $_POST[ 'role' ];
    243236                        reset( $newroles );
     
    245238                                $role_len = strlen( $role );
    246239                                $existing_role = $wpdb->get_var( "SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$userid'  AND meta_key = '" . $blog_prefix. "capabilities'" );
    247                                 if( false == $existing_role ) {
     240                                if ( false == $existing_role )
    248241                                        $wpdb->query( "INSERT INTO " . $wpdb->usermeta . "( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$userid', '" . $blog_prefix . "capabilities', 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}')" );
    249                                 } elseif( $existing_role != "a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}" ) {
     242                                elseif ( $existing_role != "a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}" )
    250243                                        $wpdb->query( "UPDATE $wpdb->usermeta SET meta_value = 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}' WHERE user_id = '$userid'  AND meta_key = '" . $blog_prefix . "capabilities'" );
    251                                 }
    252 
    253244                        }
    254245                }
     
    262253
    263254                // change password
    264                 if( is_array( $_POST[ 'user_password' ] ) ) {
     255                if ( is_array( $_POST[ 'user_password' ] ) ) {
    265256                        reset( $_POST[ 'user_password' ] );
    266257                        $newroles = $_POST[ 'role' ];
     
    268259                                unset( $_POST[ 'role' ] );
    269260                                $_POST[ 'role' ] = $newroles[ $userid ];
    270                                 if( $pass != '' ) {
     261                                if ( $pass != '' ) {
    271262                                        $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:{}'" );
    272263                                        $userdata = get_userdata($userid);
     
    275266                                        $_POST[ 'rich_editing' ] = $userdata->rich_editing;
    276267                                        edit_user( $userid );
    277                                         if( $cap == null )
     268                                        if ( $cap == null )
    278269                                                $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id = '{$userid}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" );
    279270                                }
     
    284275
    285276                // add user?
    286                 if( $_POST[ 'newuser' ] != '' ) {
     277                if ( $_POST[ 'newuser' ] != '' ) {
    287278                        $newuser = $_POST[ 'newuser' ];
    288279                        $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) );
    289                         if( $userid ) {
     280                        if ( $userid ) {
    290281                                $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='wp_" . $id . "_capabilities'" );
    291                                 if( $user == false )
     282                                if ( $user == false )
    292283                                        add_user_to_blog($id, $userid, $_POST[ 'new_role' ]);
    293284                        }
     
    300291        case "deleteblog":
    301292                check_admin_referer('deleteblog');
    302                 if( $id != '0' && $id != $current_site->blog_id )
     293                if ( $id != '0' && $id != $current_site->blog_id )
    303294                        wpmu_delete_blog( $id, true );
    304295
     
    310301                check_admin_referer('allblogs');
    311302                foreach ( (array) $_POST[ 'allblogs' ] as $key => $val ) {
    312                         if( $val != '0' && $val != $current_site->blog_id ) {
     303                        if ( $val != '0' && $val != $current_site->blog_id ) {
    313304                                if ( isset($_POST['allblog_delete']) ) {
    314305                                        $blogfunction = 'all_delete';
     
    393384        // Themes
    394385    case "updatethemes":
    395         if( is_array( $_POST['theme'] ) ) {
     386        if ( is_array( $_POST['theme'] ) ) {
    396387                        $themes = get_themes();
    397388                        reset( $themes );
    398                         foreach( (array) $themes as $key => $theme ) {
    399                                 if( $_POST['theme'][ wp_specialchars( $theme['Stylesheet'] ) ] == 'enabled' )
     389                        foreach ( (array) $themes as $key => $theme ) {
     390                                if ( $_POST['theme'][ wp_specialchars( $theme['Stylesheet'] ) ] == 'enabled' )
    400391                                        $allowed_themes[ wp_specialchars( $theme['Stylesheet'] ) ] = true;
    401392                        }
     
    410401                $referrer = ( isset($_GET['ref']) ) ? stripslashes($_GET['ref']) : $_SERVER['HTTP_REFERER'];
    411402                $referrer = clean_url($referrer);
    412                 if( !headers_sent() ){
     403                if ( !headers_sent() ) {
    413404                        nocache_headers();
    414405                        header( 'Content-Type: text/html; charset=utf-8' );
     
    441432        case "deleteuser":
    442433                check_admin_referer('deleteuser');
    443                 if( $id != '0' && $id != '1' )
     434                if ( $id != '0' && $id != '1' )
    444435                        wpmu_delete_user($id);
    445436
     
    455446                        confirm_delete_users( $_POST['allusers'] );
    456447                        echo '</div>';
    457                 } elseif( isset( $_POST[ 'alluser_transfer_delete' ] ) ) {
    458                         if( is_array( $_POST[ 'blog' ] ) && !empty( $_POST[ 'blog' ] ) ) {
    459                                 foreach( $_POST[ 'blog' ] as $id => $users ) {
    460                                         foreach( $users as $blogid => $user_id ) {
     448                } elseif ( isset( $_POST[ 'alluser_transfer_delete' ] ) ) {
     449                        if ( is_array( $_POST[ 'blog' ] ) && !empty( $_POST[ 'blog' ] ) ) {
     450                                foreach ( $_POST[ 'blog' ] as $id => $users ) {
     451                                        foreach ( $users as $blogid => $user_id ) {
    461452                                                remove_user_from_blog( $id, $blogid, $user_id );
    462453                                        }
    463454                                }
    464455                        }
    465                         if( is_array( $_POST[ 'user' ] ) && !empty( $_POST[ 'user' ] ) )
     456                        if ( is_array( $_POST[ 'user' ] ) && !empty( $_POST[ 'user' ] ) )
    466457                                foreach( $_POST[ 'user' ] as $id )
    467458                                        wpmu_delete_user( $id );
     
    470461                } else {
    471462                        foreach ( (array) $_POST['allusers'] as $key => $val ) {
    472                                 if( $val == '' || $val == '0' ) {
     463                                if ( $val == '' || $val == '0' )
    473464                                        continue;
    474                                 }
    475465                                $user = new WP_User( $val );
    476                                 if ( in_array( $user->user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) ) {
     466                                if ( in_array( $user->user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) )
    477467                                        wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a site admnistrator.' ), $user->user_login ) );
    478                                 }
    479468                                if ( isset($_POST['alluser_spam']) ) {
    480469                                        $userfunction = 'all_spam';
     
    502491                check_admin_referer('add-user');
    503492
    504                 if( is_array( $_POST[ 'user' ] ) == false ) {
     493                if ( is_array( $_POST[ 'user' ] ) == false )
    505494                        wp_die( __( "Cannot create an empty user." ) );
    506                 }
    507495                $user = $_POST['user'];
    508                 if ( empty($user['username']) && empty($user['email']) ) {
     496                if ( empty($user['username']) && empty($user['email']) )
    509497                        wp_die( __('Missing username and email.') );
    510                 } elseif ( empty($user['username']) ) {
     498                elseif ( empty($user['username']) )
    511499                        wp_die( __('Missing username.') );
    512                 } elseif ( empty($user['email']) ) {
     500                elseif ( empty($user['email']) )
    513501                        wp_die( __('Missing email.') );
    514                 }
    515502
    516503                $password = generate_random_password();
    517504                $user_id = wpmu_create_user(wp_specialchars( strtolower( $user['username'] ) ), $password, wp_specialchars( $user['email'] ) );
    518505
    519                 if( false == $user_id ) {
     506                if ( false == $user_id )
    520507                        wp_die( __('Duplicated username or email address.') );
    521                 } else {
     508                else
    522509                        wp_new_user_notification($user_id, $password);
    523                 }
    524                 if ( get_site_option( 'dashboard_blog' ) == false ) {
     510
     511                if ( get_site_option( 'dashboard_blog' ) == false )
    525512                        add_user_to_blog( $current_site->blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    526                 } else {
     513                else
    527514                        add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    528                 }
    529515
    530516                wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add'), $_SERVER['HTTP_REFERER'] ) );
Note: See TracChangeset for help on using the changeset viewer.