Ticket #21432: 21432.3.diff
File 21432.3.diff, 19.3 KB (added by , 12 years ago) |
---|
-
wp-includes/class-wp-theme.php
1109 1109 1110 1110 $current = $blog_id == get_current_blog_id(); 1111 1111 1112 if ( $current ) 1112 if ( $current ) { 1113 1113 $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); 1114 else 1115 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowedthemes' ); 1114 } else { 1115 switch_to_blog( $blog_id ); 1116 $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); 1117 restore_current_blog(); 1118 } 1116 1119 1117 1120 // This is all super old MU back compat joy. 1118 1121 // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. 1119 1122 if ( false === $allowed_themes[ $blog_id ] ) { 1120 if ( $current ) 1123 if ( $current ) { 1121 1124 $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); 1122 else 1123 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowed_themes' ); 1125 } else { 1126 switch_to_blog( $blog_id ); 1127 $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); 1128 restore_current_blog(); 1129 } 1124 1130 1125 1131 if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) { 1126 1132 $allowed_themes[ $blog_id ] = array(); … … 1139 1145 update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); 1140 1146 delete_option( 'allowed_themes' ); 1141 1147 } else { 1142 update_blog_option( $blog_id, 'allowedthemes', $allowed_themes[ $blog_id ] ); 1143 delete_blog_option( $blog_id, 'allowed_themes' ); 1148 switch_to_blog( $blog_id ); 1149 update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); 1150 delete_option( 'allowed_themes' ); 1151 restore_current_blog(); 1144 1152 } 1145 1153 } 1146 1154 } -
wp-includes/ms-blogs.php
222 222 return $details; 223 223 } 224 224 225 $details->blogname = get_blog_option( $blog_id, 'blogname' ); 226 $details->siteurl = get_blog_option( $blog_id, 'siteurl' ); 227 $details->post_count = get_blog_option( $blog_id, 'post_count' ); 225 switch_to_blog( $blog_id ); 226 $details->blogname = get_option( 'blogname' ); 227 $details->siteurl = get_option( 'siteurl' ); 228 $details->post_count = get_option( 'post_count' ); 229 restore_current_blog(); 228 230 229 231 $details = apply_filters( 'blog_details', $details ); 230 232 … … 298 300 do_action( "make_ham_blog", $blog_id ); 299 301 } 300 302 301 if ( isset($details[ 'public' ]) ) 302 update_blog_option( $blog_id, 'blog_public', $details[ 'public' ] ); 303 if ( isset($details[ 'public' ]) ) { 304 switch_to_blog( $blog_id ); 305 update_option( 'blog_public', $details[ 'public' ] ); 306 restore_current_blog(); 307 } 303 308 304 309 refresh_blog_details($blog_id); 305 310 … … 307 312 } 308 313 309 314 /** 310 * Retrieve option value for a given blog id based on name of option.311 *312 * If the option does not exist or does not have a value, then the return value313 * will be false. This is useful to check whether you need to install an option314 * and is commonly used during installation of plugin options and to test315 * whether upgrading is required.316 *317 * If the option was serialized then it will be unserialized when it is returned.318 *319 * @since MU320 *321 * @param int $id A blog ID. Can be null to refer to the current blog.322 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.323 * @param mixed $default Optional. Default value to return if the option does not exist.324 * @return mixed Value set for the option.325 */326 function get_blog_option( $id, $option, $default = false ) {327 $id = (int) $id;328 329 if ( empty( $id ) )330 $id = get_current_blog_id();331 332 if ( get_current_blog_id() == $id )333 return get_option( $option, $default );334 335 switch_to_blog( $id );336 $option = get_option( $option, $default );337 restore_current_blog();338 339 return $option;340 }341 342 /**343 * Add a new option for a given blog id.344 *345 * You do not need to serialize values. If the value needs to be serialized, then346 * it will be serialized before it is inserted into the database. Remember,347 * resources can not be serialized or added as an option.348 *349 * You can create options without values and then update the values later.350 * Existing options will not be updated and checks are performed to ensure that you351 * aren't adding a protected WordPress option. Care should be taken to not name352 * options the same as the ones which are protected.353 *354 * @since MU355 *356 * @param int $id A blog ID. Can be null to refer to the current blog.357 * @param string $option Name of option to add. Expected to not be SQL-escaped.358 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped.359 * @return bool False if option was not added and true if option was added.360 */361 function add_blog_option( $id, $option, $value ) {362 $id = (int) $id;363 364 if ( empty( $id ) )365 $id = get_current_blog_id();366 367 if ( get_current_blog_id() == $id )368 return add_option( $option, $value );369 370 switch_to_blog( $id );371 $return = add_option( $option, $value );372 restore_current_blog();373 374 return $return;375 }376 377 /**378 * Removes option by name for a given blog id. Prevents removal of protected WordPress options.379 *380 * @since MU381 *382 * @param int $id A blog ID. Can be null to refer to the current blog.383 * @param string $option Name of option to remove. Expected to not be SQL-escaped.384 * @return bool True, if option is successfully deleted. False on failure.385 */386 function delete_blog_option( $id, $option ) {387 $id = (int) $id;388 389 if ( empty( $id ) )390 $id = get_current_blog_id();391 392 if ( get_current_blog_id() == $id )393 return delete_option( $option );394 395 switch_to_blog( $id );396 $return = delete_option( $option );397 restore_current_blog();398 399 return $return;400 }401 402 /**403 * Update an option for a particular blog.404 *405 * @since MU406 *407 * @param int $id The blog id408 * @param string $option The option key409 * @param mixed $value The option value410 * @return bool True on success, false on failrue.411 */412 function update_blog_option( $id, $option, $value, $deprecated = null ) {413 $id = (int) $id;414 415 if ( null !== $deprecated )416 _deprecated_argument( __FUNCTION__, '3.1' );417 418 if ( get_current_blog_id() == $id )419 return update_option( $option, $value );420 421 switch_to_blog( $id );422 $return = update_option( $option, $value );423 restore_current_blog();424 425 refresh_blog_details( $id );426 427 return $return;428 }429 430 /**431 315 * Switch the current blog. 432 316 * 433 317 * This function is useful if you need to pull posts, or other information, -
wp-includes/class-wp-xmlrpc-server.php
475 475 $blog_id = $blog->userblog_id; 476 476 $is_admin = current_user_can_for_blog( $blog_id, 'manage_options' ); 477 477 478 switch_to_blog( $blog_id ); 478 479 $struct[] = array( 479 480 'isAdmin' => $is_admin, 480 'url' => get_home_url( $blog_id,'/' ),481 'url' => home_url( '/' ), 481 482 'blogid' => (string) $blog_id, 482 'blogName' => get_ blog_option( $blog_id,'blogname' ),483 'xmlrpc' => get_site_url( $blog_id,'xmlrpc.php' )483 'blogName' => get_option( 'blogname' ), 484 'xmlrpc' => site_url( 'xmlrpc.php' ) 484 485 ); 486 restore_current_blog(); 485 487 } 486 488 487 489 return $struct; -
wp-includes/link-template.php
1896 1896 if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) 1897 1897 $scheme = is_ssl() && !is_admin() ? 'https' : 'http'; 1898 1898 1899 if ( empty( $blog_id ) || !is_multisite() ) 1899 if ( empty( $blog_id ) || !is_multisite() ) { 1900 1900 $url = get_option( 'home' ); 1901 else 1902 $url = get_blog_option( $blog_id, 'home' ); 1901 } else { 1902 switch_to_blog( $blog_id ); 1903 $url = get_option( 'home' ); 1904 restore_current_blog(); 1905 } 1903 1906 1904 1907 if ( 'relative' == $scheme ) 1905 1908 $url = preg_replace( '#^.+://[^/]*#', '', $url ); … … 1961 1964 $scheme = ( is_ssl() ? 'https' : 'http' ); 1962 1965 } 1963 1966 1964 if ( empty( $blog_id ) || !is_multisite() ) 1967 if ( empty( $blog_id ) || !is_multisite() ) { 1965 1968 $url = get_option( 'siteurl' ); 1966 else 1967 $url = get_blog_option( $blog_id, 'siteurl' ); 1969 } else { 1970 switch_to_blog( $blog_id ); 1971 $url = get_option( 'siteurl' ); 1972 restore_current_blog(); 1973 } 1968 1974 1969 1975 if ( 'relative' == $scheme ) 1970 1976 $url = preg_replace( '#^.+://[^/]*#', '', $url ); -
wp-includes/ms-deprecated.php
270 270 } 271 271 return $url; 272 272 } 273 274 /** 275 * Retrieve option value for a given blog id based on name of option. 276 * 277 * If the option does not exist or does not have a value, then the return value 278 * will be false. This is useful to check whether you need to install an option 279 * and is commonly used during installation of plugin options and to test 280 * whether upgrading is required. 281 * 282 * If the option was serialized then it will be unserialized when it is returned. 283 * 284 * @since MU 285 * @deprecated 3.5.0 286 * 287 * @param int $id A blog ID. Can be null to refer to the current blog. 288 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. 289 * @param mixed $default Optional. Default value to return if the option does not exist. 290 * @return mixed Value set for the option. 291 */ 292 function get_blog_option( $id, $option, $default = false ) { 293 _deprecated_function( __FUNCTION__, '3.5' ); 294 295 $id = (int) $id; 296 297 if ( empty( $id ) ) 298 $id = get_current_blog_id(); 299 300 if ( get_current_blog_id() == $id ) 301 return get_option( $option, $default ); 302 303 switch_to_blog( $id ); 304 $option = get_option( $option, $default ); 305 restore_current_blog(); 306 307 return $option; 308 } 309 310 /** 311 * Add a new option for a given blog id. 312 * 313 * You do not need to serialize values. If the value needs to be serialized, then 314 * it will be serialized before it is inserted into the database. Remember, 315 * resources can not be serialized or added as an option. 316 * 317 * You can create options without values and then update the values later. 318 * Existing options will not be updated and checks are performed to ensure that you 319 * aren't adding a protected WordPress option. Care should be taken to not name 320 * options the same as the ones which are protected. 321 * 322 * @since MU 323 * @deprecated 3.5.0 324 * 325 * @param int $id A blog ID. Can be null to refer to the current blog. 326 * @param string $option Name of option to add. Expected to not be SQL-escaped. 327 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped. 328 * @return bool False if option was not added and true if option was added. 329 */ 330 function add_blog_option( $id, $option, $value ) { 331 _deprecated_function( __FUNCTION__, '3.5' ); 332 333 $id = (int) $id; 334 335 if ( empty( $id ) ) 336 $id = get_current_blog_id(); 337 338 if ( get_current_blog_id() == $id ) 339 return add_option( $option, $value ); 340 341 switch_to_blog( $id ); 342 $return = add_option( $option, $value ); 343 restore_current_blog(); 344 345 return $return; 346 } 347 348 /** 349 * Removes option by name for a given blog id. Prevents removal of protected WordPress options. 350 * 351 * @since MU 352 * @deprecated 3.5.0 353 * 354 * @param int $id A blog ID. Can be null to refer to the current blog. 355 * @param string $option Name of option to remove. Expected to not be SQL-escaped. 356 * @return bool True, if option is successfully deleted. False on failure. 357 */ 358 function delete_blog_option( $id, $option ) { 359 _deprecated_function( __FUNCTION__, '3.5' ); 360 361 $id = (int) $id; 362 363 if ( empty( $id ) ) 364 $id = get_current_blog_id(); 365 366 if ( get_current_blog_id() == $id ) 367 return delete_option( $option ); 368 369 switch_to_blog( $id ); 370 $return = delete_option( $option ); 371 restore_current_blog(); 372 373 return $return; 374 } 375 376 /** 377 * Update an option for a particular blog. 378 * 379 * @since MU 380 * @deprecated 3.5.0 381 * 382 * @param int $id The blog id 383 * @param string $option The option key 384 * @param mixed $value The option value 385 * @return bool True on success, false on failrue. 386 */ 387 function update_blog_option( $id, $option, $value, $deprecated = null ) { 388 _deprecated_function( __FUNCTION__, '3.5' ); 389 390 $id = (int) $id; 391 392 if ( null !== $deprecated ) 393 _deprecated_argument( __FUNCTION__, '3.1' ); 394 395 if ( get_current_blog_id() == $id ) 396 return update_option( $option, $value ); 397 398 switch_to_blog( $id ); 399 $return = update_option( $option, $value ); 400 restore_current_blog(); 401 402 refresh_blog_details( $id ); 403 404 return $return; 405 } -
wp-admin/includes/class-wp-ms-sites-list-table.php
230 230 echo "<td class='column-$column_name $column_name'$style>"; ?> 231 231 <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> 232 232 <?php 233 if ( 'list' != $mode ) 234 echo '<p>' . sprintf( _x( '%1$s – <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '</p>'; 233 if ( 'list' != $mode ) { 234 switch_to_blog( $blog['blog_id'] ); 235 echo '<p>' . sprintf( _x( '%1$s – <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>'; 236 restore_current_blog(); 237 } 235 238 236 239 // Preordered. 237 240 $actions = array( -
wp-admin/includes/ms.php
411 411 412 412 // Edit blog upload space setting on Edit Blog page 413 413 function upload_space_setting( $id ) { 414 $quota = get_blog_option( $id, 'blog_upload_space' ); 414 switch_to_blog( $id ); 415 $quota = get_option( 'blog_upload_space' ); 416 restore_current_blog(); 417 415 418 if ( !$quota ) 416 419 $quota = ''; 417 420 -
wp-admin/network/site-info.php
135 135 <th scope="row"><?php _e( 'Path' ) ?></th> 136 136 <?php if ( $is_main_site ) { ?> 137 137 <td><code><?php echo esc_attr( $details->path ) ?></code></td> 138 <?php } else { ?> 138 <?php 139 } else { 140 switch_to_blog( $id ); 141 ?> 139 142 <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' /> 140 <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> 141 <?php } ?> 143 <br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_option( 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_option( 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td> 144 <?php 145 restore_current_blog(); 146 } ?> 142 147 </tr> 143 148 <tr class="form-field"> 144 149 <th scope="row"><?php _ex( 'Registered', 'site' ) ?></th> -
wp-admin/network/site-users.php
45 45 wp_die( __('Invalid site ID.') ); 46 46 47 47 $details = get_blog_details( $id ); 48 if ( ! can_edit_network( $details->site_id ) )48 if ( ! can_edit_network( $details->site_id ) ) 49 49 wp_die( __( 'You do not have permission to access this page.' ) ); 50 50 51 51 $is_main_site = is_main_site( $id ); 52 52 53 // get blog prefix 54 $blog_prefix = $wpdb->get_blog_prefix( $id ); 53 switch_to_blog( $id ); 55 54 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' ); 55 $editblog_roles = $wp_roles->roles; 64 56 57 $default_role = get_option( 'default_role' ); 58 65 59 $action = $wp_list_table->current_action(); 66 60 67 61 if ( $action ) { 68 switch_to_blog( $id );69 62 70 63 switch ( $action ) { 71 64 case 'newuser': 72 65 check_admin_referer( 'add-user', '_wpnonce_add-new-user' ); 73 66 $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'] ) ) { 75 68 $update = 'err_new'; 76 69 } else { 77 70 $password = wp_generate_password( 12, false); … … 94 87 $newuser = $_POST['newuser']; 95 88 $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); 96 89 if ( $userid ) { 90 $blog_prefix = $wpdb->get_blog_prefix( $id ); 97 91 $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" ); 98 92 if ( $user == false ) 99 93 add_user_to_blog( $id, $userid, $_POST['new_role'] ); … … 108 102 break; 109 103 110 104 case 'remove': 111 if ( ! current_user_can('remove_users') )105 if ( ! current_user_can( 'remove_users' ) ) 112 106 die(__('You can’t remove users.')); 113 107 check_admin_referer( 'bulk-users' ); 114 108 … … 152 146 break; 153 147 } 154 148 155 restore_current_blog();156 149 wp_safe_redirect( add_query_arg( 'update', $update, $referer ) ); 157 150 exit(); 158 151 } 159 152 153 restore_current_blog(); 154 160 155 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) { 161 156 wp_safe_redirect( $referer ); 162 157 exit(); -
wp-admin/network/upgrade.php
60 60 } 61 61 echo "<ul>"; 62 62 foreach ( (array) $blogs as $details ) { 63 $siteurl = get_blog_option( $details['blog_id'], 'siteurl' ); 63 switch_to_blog( $details['blog_id'] ); 64 $siteurl = site_url(); 65 $upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' ); 66 restore_current_blog(); 64 67 echo "<li>$siteurl</li>"; 65 $response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=upgrade_db", array( 'timeout' => 120, 'httpversion' => '1.1' ) );68 $response = wp_remote_get( $upgrade_url, array( 'timeout' => 120, 'httpversion' => '1.1' ) ); 66 69 if ( is_wp_error( $response ) ) 67 70 wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>' ), $siteurl, $response->get_error_message() ) ); 68 71 do_action( 'after_mu_upgrade', $response );