From 5ca54e7d2fdaeda302da4cca02378e23d2dc860b Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 3 Aug 2012 17:51:42 +0000 Subject: [PATCH] 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 git-svn-id: http://core.svn.wordpress.org/trunk@21414 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-ms-sites-list-table.php | 7 +- wp-admin/includes/ms.php | 5 +- wp-admin/network/site-info.php | 11 +- wp-admin/network/site-users.php | 25 ++-- wp-admin/network/upgrade.php | 7 +- wp-includes/class-wp-theme.php | 24 ++-- wp-includes/class-wp-xmlrpc-server.php | 8 +- wp-includes/link-template.php | 18 ++- wp-includes/ms-blogs.php | 136 ++---------------- wp-includes/ms-deprecated.php | 133 +++++++++++++++++ 10 files changed, 208 insertions(+), 166 deletions(-) diff --git a/wp-admin/includes/class-wp-ms-sites-list-table.php b/wp-admin/includes/class-wp-ms-sites-list-table.php index d0b36a2cc6..1bdc758573 100644 --- a/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -230,8 +230,11 @@ class WP_MS_Sites_List_Table extends WP_List_Table { echo ""; ?> ' . sprintf( _x( '%1$s – %2$s', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '

'; + if ( 'list' != $mode ) { + switch_to_blog( $blog['blog_id'] ); + echo '

' . sprintf( _x( '%1$s – %2$s', '%1$s: site name. %2$s: site tagline.' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '

'; + restore_current_blog(); + } // Preordered. $actions = array( diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index fcdfad8e85..5abb7f90a7 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -411,7 +411,10 @@ function fix_import_form_size( $size ) { // Edit blog upload space setting on Edit Blog page function upload_space_setting( $id ) { - $quota = get_blog_option( $id, 'blog_upload_space' ); + switch_to_blog( $id ); + $quota = get_option( 'blog_upload_space' ); + restore_current_blog(); + if ( !$quota ) $quota = ''; diff --git a/wp-admin/network/site-info.php b/wp-admin/network/site-info.php index ff78e83bb3..bcc71f9f18 100644 --- a/wp-admin/network/site-info.php +++ b/wp-admin/network/site-info.php @@ -135,10 +135,15 @@ if ( ! empty( $messages ) ) { path ) ?> - + -
/> siteurl and home as well.' ); ?> - +
/> siteurl and home as well.' ); ?> + diff --git a/wp-admin/network/site-users.php b/wp-admin/network/site-users.php index 177af4b44b..a7bd37662c 100644 --- a/wp-admin/network/site-users.php +++ b/wp-admin/network/site-users.php @@ -45,33 +45,26 @@ if ( ! $id ) wp_die( __('Invalid site ID.') ); $details = get_blog_details( $id ); -if ( !can_edit_network( $details->site_id ) ) +if ( ! can_edit_network( $details->site_id ) ) wp_die( __( 'You do not have permission to access this page.' ) ); $is_main_site = is_main_site( $id ); -// get blog prefix -$blog_prefix = $wpdb->get_blog_prefix( $id ); +switch_to_blog( $id ); -// @todo This is a hack. Eventually, add API to WP_Roles allowing retrieval of roles for a particular blog. -if ( ! empty($wp_roles->use_db) ) { - $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" ); -} else { - // Roles are stored in memory, not the DB. - $editblog_roles = $wp_roles->roles; -} -$default_role = get_blog_option( $id, 'default_role' ); +$editblog_roles = $wp_roles->roles; + +$default_role = get_option( 'default_role' ); $action = $wp_list_table->current_action(); if ( $action ) { - switch_to_blog( $id ); switch ( $action ) { case 'newuser': check_admin_referer( 'add-user', '_wpnonce_add-new-user' ); $user = $_POST['user']; - if ( !is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) { + if ( ! is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) { $update = 'err_new'; } else { $password = wp_generate_password( 12, false); @@ -94,6 +87,7 @@ if ( $action ) { $newuser = $_POST['newuser']; $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); if ( $userid ) { + $blog_prefix = $wpdb->get_blog_prefix( $id ); $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" ); if ( $user == false ) add_user_to_blog( $id, $userid, $_POST['new_role'] ); @@ -108,7 +102,7 @@ if ( $action ) { break; case 'remove': - if ( !current_user_can('remove_users') ) + if ( ! current_user_can( 'remove_users' ) ) die(__('You can’t remove users.')); check_admin_referer( 'bulk-users' ); @@ -152,11 +146,12 @@ if ( $action ) { break; } - restore_current_blog(); wp_safe_redirect( add_query_arg( 'update', $update, $referer ) ); exit(); } +restore_current_blog(); + if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) { wp_safe_redirect( $referer ); exit(); diff --git a/wp-admin/network/upgrade.php b/wp-admin/network/upgrade.php index d556e13cda..cfbf4002ac 100644 --- a/wp-admin/network/upgrade.php +++ b/wp-admin/network/upgrade.php @@ -60,9 +60,12 @@ switch ( $action ) { } echo "