mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 21:00:21 +00:00
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: https://develop.svn.wordpress.org/trunk@21414 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -135,10 +135,15 @@ if ( ! empty( $messages ) ) {
|
||||
<th scope="row"><?php _e( 'Path' ) ?></th>
|
||||
<?php if ( $is_main_site ) { ?>
|
||||
<td><code><?php echo esc_attr( $details->path ) ?></code></td>
|
||||
<?php } else { ?>
|
||||
<?php
|
||||
} else {
|
||||
switch_to_blog( $id );
|
||||
?>
|
||||
<td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' />
|
||||
<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>
|
||||
<?php } ?>
|
||||
<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>
|
||||
<?php
|
||||
restore_current_blog();
|
||||
} ?>
|
||||
</tr>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><?php _ex( 'Registered', 'site' ) ?></th>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -60,9 +60,12 @@ switch ( $action ) {
|
||||
}
|
||||
echo "<ul>";
|
||||
foreach ( (array) $blogs as $details ) {
|
||||
$siteurl = get_blog_option( $details['blog_id'], 'siteurl' );
|
||||
switch_to_blog( $details['blog_id'] );
|
||||
$siteurl = site_url();
|
||||
$upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
|
||||
restore_current_blog();
|
||||
echo "<li>$siteurl</li>";
|
||||
$response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=upgrade_db", array( 'timeout' => 120, 'httpversion' => '1.1' ) );
|
||||
$response = wp_remote_get( $upgrade_url, array( 'timeout' => 120, 'httpversion' => '1.1' ) );
|
||||
if ( is_wp_error( $response ) )
|
||||
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() ) );
|
||||
do_action( 'after_mu_upgrade', $response );
|
||||
|
||||
Reference in New Issue
Block a user