Make WordPress Core


Ignore:
Timestamp:
09/26/2008 06:43:53 AM (18 years ago)
Author:
westi
Message:

Theme update UI first pass. See #7519 props DD32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/update.php

    r8885 r8989  
    5757                        show_message(__('Attempting reactivation of the plugin'));
    5858                        echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $result, 'activate-plugin_' . $result) .'"></iframe>';
     59                }
     60        }
     61        echo '</div>';
     62}
     63
     64/**
     65 * Theme upgrade display.
     66 *
     67 * @since 2.5
     68 *
     69 * @param string $plugin Plugin
     70 */
     71function do_theme_upgrade($theme) {
     72        global $wp_filesystem;
     73
     74        $url = wp_nonce_url('update.php?action=upgrade-theme&theme=' . urlencode($theme), 'upgrade-plugin_' . urlencode($theme));
     75        if ( false === ($credentials = request_filesystem_credentials($url)) )
     76                return;
     77
     78        if ( ! WP_Filesystem($credentials) ) {
     79                $error = true;
     80                if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
     81                        $error = $wp_filesystem->errors;
     82                request_filesystem_credentials($url, '', $error); //Failed to connect, Error and request again
     83                return;
     84        }
     85
     86        echo '<div class="wrap">';
     87        echo '<h2>' . __('Upgrade Theme') . '</h2>';
     88        if ( $wp_filesystem->errors->get_error_code() ) {
     89                foreach ( $wp_filesystem->errors->get_error_messages() as $message )
     90                        show_message($message);
     91                echo '</div>';
     92                return;
     93        }
     94
     95        //TODO: Is theme currently active?
     96        $was_current = false; //is_plugin_active($plugin); //Check now, It'll be deactivated by the next line if it is
     97
     98        $result = wp_update_theme($theme, 'show_message');
     99
     100        if ( is_wp_error($result) ) {
     101                show_message($result);
     102                show_message( __('Installation Failed') );
     103        } else {
     104                //Result is the new plugin file relative to WP_PLUGIN_DIR
     105                show_message( __('Theme upgraded successfully') );
     106                if( $result && $was_current ){
     107                        show_message(__('Setting theme as Current'));
     108                        //TODO: Actually set it as active again.
     109                        //echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $result, 'activate-plugin_' . $result) .'"></iframe>';
    59110                }
    60111        }
     
    145196if ( isset($_GET['action']) ) {
    146197        $plugin = isset($_GET['plugin']) ? trim($_GET['plugin']) : '';
    147 
    148         if ( 'upgrade-plugin' == $_GET['action'] ) {
     198        $theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
     199        $action = isset($_GET['action']) ? $_GET['action'] : '';
     200       
     201        if ( 'upgrade-plugin' == $action ) {
    149202                check_admin_referer('upgrade-plugin_' . $plugin);
    150203                $title = __('Upgrade Plugin');
     
    153206                do_plugin_upgrade($plugin);
    154207                include('admin-footer.php');
    155         } elseif ('activate-plugin' == $_GET['action'] ) {
     208        } elseif ('activate-plugin' == $action ) {
    156209                check_admin_referer('activate-plugin_' . $plugin);
    157210                if( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
     
    183236                }
    184237                echo "</body></html>";
    185         } elseif ( 'upgrade-core' == $_GET['action'] ) {
     238        } elseif ( 'upgrade-core' == $action ) {
    186239                $title = __('Upgrade WordPress');
    187240                $parent_file = 'index.php';
     
    189242                core_upgrade_preamble();
    190243                include('admin-footer.php');
    191         } elseif ( 'do-core-upgrade' ) {
     244        } elseif ( 'do-core-upgrade' == $action ) {
    192245                check_admin_referer('upgrade-core');
    193246                $title = __('Upgrade WordPress');
     
    196249                do_core_upgrade();
    197250                include('admin-footer.php');
     251        } elseif ( 'upgrade-theme' == $action ) {       
     252                check_admin_referer('upgrade-theme_' . $theme);
     253                $title = __('Upgrade Theme');
     254                $parent_file = 'themes.php';
     255                require_once('admin-header.php');
     256                do_theme_upgrade($theme);
     257                include('admin-footer.php');
    198258        }
    199259}
Note: See TracChangeset for help on using the changeset viewer.