Ticket #11869: 11869.diff
File 11869.diff, 4.8 KB (added by , 15 years ago) |
---|
-
wp-admin/ms-upgrade-network.php
12 12 if ( !is_multisite() ) 13 13 wp_die( __('Multisite support is not enabled.') ); 14 14 15 require_once( ABSPATH . WPINC . '/http.php' );16 17 $title = __('Update Network');18 $parent_file = 'ms-admin.php';19 require_once('admin-header.php');20 21 15 if ( ! current_user_can( 'manage_network' ) ) 22 16 wp_die( __('You do not have permission to access this page.') ); 23 17 24 echo '<div class="wrap">'; 25 screen_icon(); 26 echo '<h2>'.__('Update Network').'</h2>'; 18 require_once( ABSPATH . WPINC . '/http.php' ); 27 19 28 20 $action = isset($_GET['action']) ? $_GET['action'] : 'show'; 21 $n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0; 29 22 23 $ajax = false; 24 if ( 'upgrade' == $action && $n > 4 ) 25 $ajax = true; 26 27 if ( !$ajax ) { 28 $title = __('Update Network'); 29 $parent_file = 'ms-admin.php'; 30 require_once('admin-header.php'); 31 echo '<div class="wrap">'; 32 screen_icon(); 33 echo '<h2>'.__('Update Network').'</h2>'; 34 } else { 35 @header('Content-Type: text/html; charset=' . get_option('blog_charset')); 36 } 37 30 38 switch ( $action ) { 31 39 case "upgrade": 32 $n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0;40 33 41 34 42 if ( $n < 5 ) { 35 43 global $wp_db_version; … … 37 45 } 38 46 39 47 $blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A ); 40 if ( empty( $blogs ) ) { 41 echo '<p>' . __( 'All done!' ) . '</p>'; 42 break; 43 } 44 echo "<ul>"; 48 if ( empty( $blogs ) ) 49 die( '0' ); 50 51 if ( !$ajax ) 52 echo "<ul id='site_list'>"; 53 45 54 foreach ( (array) $blogs as $details ) { 46 55 if ( $details['spam'] == 0 && $details['deleted'] == 0 && $details['archived'] == 0 ) { 47 56 $siteurl = get_blog_option( $details['blog_id'], 'siteurl' ); 48 echo "<li>$siteurl</li>"; 57 49 58 $response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=1", array( 'timeout' => 120, 'httpversion' => '1.1' ) ); 50 if ( is_wp_error( $response ) ) 51 wp_die( "<strong>Warning!</strong> Problem updating {$siteurl}. Your server may not be able to connect to sites running on it.<br /> Error message: <em>" . $response->get_error_message() ."</em>" ); 59 if ( is_wp_error( $response ) ) { 60 echo '<div class="error inline" style="width:600px;"><p>'; 61 _e( "<strong>Warning!</strong> Problem updating {$siteurl}. Your server may not be able to connect to sites running on it.<br /> Error message: <em>" . $response->get_error_message() ."</em>" ); 62 echo '</p></div>'; 63 } else { 64 echo "<li><div class='updated inline' style='width:600px;'><p><strong>" . __('Successful:') . "</strong> $siteurl</p></div></li>"; 65 } 52 66 do_action( 'after_mu_upgrade', $response ); 53 67 do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] ); 54 68 } 55 69 } 56 echo "</ul>"; 57 ?><p><?php _e("If your browser doesn't start loading the next page automatically click this link:"); ?> <a class="button" href="ms-upgrade-network.php?action=upgrade&n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p> 70 if ( !$ajax ) { 71 echo "</ul>"; 72 ?> 73 58 74 <script type='text/javascript'> 59 <!-- 60 function nextpage() { 61 location.href = "ms-upgrade-network.php?action=upgrade&n=<?php echo ($n + 5) ?>"; 75 jQuery(document).ready(function($){ 76 var admin_url = "<?php echo admin_url(); ?>"; 77 var n = 0; 78 79 function nextsites() { 80 n = n + 5; 81 nexturl = admin_url + 'ms-upgrade-network.php?action=upgrade&n=' + n; 82 jQuery.post(nexturl, function(r) { 83 if ( r == '0' ) { 84 $('ul#site_list').after('<div class="updated inline"><p><strong><?php _e('All Done!'); ?></strong></p></div>'); 85 $('div.wrap h2:first').after('<div id="message" class="updated fade"><p><strong><?php _e( 'All Done!' ); ?></strong></p></div>'); 86 } else { 87 $('ul#site_list').append(r); 88 nextsites(); 89 } 90 }) 91 } 92 nextsites(); 93 }) 94 </script> 95 <?php 62 96 } 63 setTimeout( "nextpage()", 250 );64 //-->65 </script><?php66 97 break; 67 98 case 'show': 68 99 default: 69 100 ?><p><?php _e("You can update all the sites on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update."); ?></p> 70 <p><a class="button" href=" ms-upgrade-network.php?action=upgrade"><?php _e("Update Network"); ?></a></p><?php101 <p><a class="button" href="<?php echo admin_url( 'ms-upgrade-network.php?action=upgrade' ) ?>"><?php _e("Update Network"); ?></a></p><?php 71 102 do_action( 'wpmu_upgrade_page' ); 72 103 break; 73 104 } 105 106 if ( !$ajax ) { 107 include('admin-footer.php'); 108 echo '</div>'; 109 } 74 110 ?> 75 </div>76 77 <?php include('admin-footer.php'); ?>