Make WordPress Core


Ignore:
Timestamp:
08/03/2012 05:51:42 PM (12 years ago)
Author:
ryan
Message:

Deprecate get_blog_option(), add_blog_option(), update_blog_option(), and delete_blog_option().

Use the regular option functions wrapped in switch_to_blog() and restore_current_blog() instead.

Group multiple operations within a single switch where possible.

fixes #21432

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network/site-users.php

    r21413 r21414  
    4646
    4747$details = get_blog_details( $id );
    48 if ( !can_edit_network( $details->site_id ) )
     48if ( ! can_edit_network( $details->site_id ) )
    4949    wp_die( __( 'You do not have permission to access this page.' ) );
    5050
    5151$is_main_site = is_main_site( $id );
    5252
    53 // get blog prefix
    54 $blog_prefix = $wpdb->get_blog_prefix( $id );
    55 
    56 // @todo This is a hack. Eventually, add API to WP_Roles allowing retrieval of roles for a particular blog.
    57 if ( ! empty($wp_roles->use_db) ) {
    58     $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" );
    59 } else {
    60     // Roles are stored in memory, not the DB.
    61     $editblog_roles = $wp_roles->roles;
    62 }
    63 $default_role = get_blog_option( $id, 'default_role' );
     53switch_to_blog( $id );
     54
     55$editblog_roles = $wp_roles->roles;
     56
     57$default_role = get_option( 'default_role' );
    6458
    6559$action = $wp_list_table->current_action();
    6660
    6761if ( $action ) {
    68     switch_to_blog( $id );
    6962
    7063    switch ( $action ) {
     
    7265            check_admin_referer( 'add-user', '_wpnonce_add-new-user' );
    7366            $user = $_POST['user'];
    74             if ( !is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) {
     67            if ( ! is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) {
    7568                $update = 'err_new';
    7669            } else {
     
    9588                $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) );
    9689                if ( $userid ) {
     90                    $blog_prefix = $wpdb->get_blog_prefix( $id );
    9791                    $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" );
    9892                    if ( $user == false )
     
    109103
    110104        case 'remove':
    111             if ( !current_user_can('remove_users')  )
     105            if ( ! current_user_can( 'remove_users' )  )
    112106                die(__('You can’t remove users.'));
    113107            check_admin_referer( 'bulk-users' );
     
    153147    }
    154148
    155     restore_current_blog();
    156149    wp_safe_redirect( add_query_arg( 'update', $update, $referer ) );
    157150    exit();
    158151}
     152
     153restore_current_blog();
    159154
    160155if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
Note: See TracChangeset for help on using the changeset viewer.