Make WordPress Core

Ticket #19781: 19781.diff

File 19781.diff, 4.6 KB (added by dd32, 11 years ago)
  • wp-admin/includes/class-wp-upgrader.php

     
    11241124                        $this->feedback(implode(' | ', (array)$update_actions));
    11251125        }
    11261126
     1127        function header() {
     1128                // Nothing, This will be displayed within a iframe.
     1129        }
     1130
     1131        function footer() {
     1132                // Nothing, This will be displayed within a iframe.
     1133        }
     1134
    11271135        function before() {
    11281136                if ( $this->upgrader->show_before ) {
    11291137                        echo $this->upgrader->show_before;
     
    14591467                parent::__construct($args);
    14601468        }
    14611469
     1470        function header() {
     1471                // Nothing, This will be displayed within a iframe.
     1472        }
     1473
     1474        function footer() {
     1475                // Nothing, This will be displayed within a iframe.
     1476        }
     1477
    14621478        function after() {
    14631479
    14641480                $update_actions = array();
  • wp-admin/update.php

     
    66 * @subpackage Administration
    77 */
    88
    9 if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) )
    10         define( 'IFRAME_REQUEST', true );
     9if ( ! defined( 'IFRAME_REQUEST' ) ) {
     10        // Requests directly to this page which are assumed to be within iframes
     11        if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) )
     12                define( 'IFRAME_REQUEST', true );
     13        // Requests to this page which we iframe from here
     14        elseif ( ! empty( $_GET['iframe'] ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'upgrade-plugin', 'upgrade-theme' ) ) )
     15                define( 'IFRAME_REQUEST', true );
     16}
    1117
    1218/** WordPress Administration Bootstrap */
    1319require_once('./admin.php');
     
    5460                $title = __('Update Plugin');
    5561                $parent_file = 'plugins.php';
    5662                $submenu_file = 'plugins.php';
    57                 require_once(ABSPATH . 'wp-admin/admin-header.php');
    5863
    5964                $nonce = 'upgrade-plugin_' . $plugin;
    60                 $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin;
     65                $url = 'update.php?action=upgrade-plugin&iframe=1&plugin=' . $plugin;
    6166
    62                 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
    63                 $upgrader->upgrade($plugin);
     67                if ( ! defined( 'IFRAME_REQUEST')  || ! IFRAME_REQUEST ) {
     68                        require_once(ABSPATH . 'wp-admin/admin-header.php');
    6469
    65                 include(ABSPATH . 'wp-admin/admin-footer.php');
     70                        echo '<div class="wrap">';
     71                        screen_icon('plugins');
     72                        echo '<h2>' . $title . '</h2>';
     73                        echo "<iframe src='" . wp_nonce_url( $url, $nonce ) . "' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
     74                        echo '</div>';
    6675
     76                        include(ABSPATH . 'wp-admin/admin-footer.php');
     77
     78                } else {
     79
     80                        iframe_header();
     81
     82                        $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
     83                        $upgrader->upgrade($plugin);
     84
     85                        iframe_footer();
     86
     87                }
     88
    6789        } elseif ('activate-plugin' == $action ) {
    6890                if ( ! current_user_can('update_plugins') )
    6991                        wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
     
    157179                $title = __('Update Theme');
    158180                $parent_file = 'themes.php';
    159181                $submenu_file = 'themes.php';
    160                 require_once(ABSPATH . 'wp-admin/admin-header.php');
    161 
    162182                $nonce = 'upgrade-theme_' . $theme;
    163                 $url = 'update.php?action=upgrade-theme&theme=' . $theme;
     183                $url = 'update.php?action=upgrade-theme&iframe=1&theme=' . $theme;
    164184
    165                 $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) );
    166                 $upgrader->upgrade($theme);
     185                if ( ! defined( 'IFRAME_REQUEST')  || ! IFRAME_REQUEST ) {
     186                        require_once(ABSPATH . 'wp-admin/admin-header.php');
    167187
    168                 include(ABSPATH . 'wp-admin/admin-footer.php');
     188                        echo '<div class="wrap">';
     189                        screen_icon('themes');
     190                        echo '<h2>' . $title . '</h2>';
     191                        echo "<iframe src='" . wp_nonce_url( $url, $nonce ) . "' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
     192                        echo '</div>';
     193
     194                        include(ABSPATH . 'wp-admin/admin-footer.php');
     195
     196                } else {
     197
     198                        iframe_header();
     199
     200                        $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) );
     201                        $upgrader->upgrade($theme);
     202
     203                        iframe_footer();
     204
     205                }
     206
    169207        } elseif ( 'update-selected-themes' == $action ) {
    170208                if ( ! current_user_can( 'update_themes' ) )
    171209                        wp_die( __( 'You do not have sufficient permissions to update themes for this site.' ) );