Make WordPress Core

Ticket #7519: 7519.2.diff

File 7519.2.diff, 1.7 KB (added by DD32, 16 years ago)
  • wp-admin/update.php

     
    102102                return;
    103103        }
    104104
    105         //TODO: Is theme currently active?
    106         $was_current = false; //is_plugin_active($plugin); //Check now, It'll be deactivated by the next line if it is
     105        //Is the current theme active? If so, Put the blog into maintainence mode before update.
     106        $was_current = strtolower(get_current_theme()) == strtolower($theme);
    107107
     108        if ( $was_current ) {
     109                show_message( __('Blog has been put into maintainence mode for duration of theme update') );
     110                // Create maintenance file to signal that we are upgrading
     111                $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
     112                $maintenance_file = $wp_filesystem->abspath() . '.maintenance';
     113                $wp_filesystem->delete($maintenance_file);
     114                $wp_filesystem->put_contents($maintenance_file, $maintenance_string, 0644);
     115        }
     116
    108117        $result = wp_update_theme($theme, 'show_message');
    109118
     119        if ( $was_current ) {
     120                // Remove maintenance file, we're done.
     121                $wp_filesystem->delete($maintenance_file);
     122        }
     123
    110124        if ( is_wp_error($result) ) {
    111125                show_message($result);
    112126                show_message( __('Installation Failed') );
    113127        } else {
    114                 //Result is the new plugin file relative to WP_PLUGIN_DIR
    115128                show_message( __('Theme upgraded successfully') );
    116                 if( $result && $was_current ){
    117                         show_message(__('Setting theme as Current'));
    118                         //TODO: Actually set it as active again.
    119                         //echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $result, 'activate-plugin_' . $result) .'"></iframe>';
    120                 }
    121129        }
    122130        echo '</div>';
    123131}