~katiekitty/+junk/wordpress-byet

« back to all changes in this revision

Viewing changes to wp-admin/update-core.php

  • Committer: kserver
  • Date: 2010-05-15 01:16:36 UTC
  • Revision ID: kserver@kserver-desktop-20100515011636-mnr1j7t637suptdq
Wordpress 2.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
 * @return null
96
96
 */
97
97
function core_upgrade_preamble() {
 
98
        global $upgrade_error;
 
99
 
98
100
        $updates = get_core_updates();
99
101
?>
100
102
        <div class="wrap">
101
103
        <?php screen_icon(); ?>
102
104
        <h2><?php _e('Upgrade WordPress'); ?></h2>
103
105
<?php
 
106
        if ( $upgrade_error ) {
 
107
                echo '<div class="error"><p>';
 
108
                _e('Please select one or more plugins to upgrade.');
 
109
                echo '</p></div>';
 
110
        }
 
111
 
104
112
        if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
105
113
                echo '<h3>';
106
114
                _e('You have the latest version of WordPress. You do not need to upgrade');
126
134
        }
127
135
        echo '</ul>';
128
136
        dismissed_updates();
 
137
 
 
138
        list_plugin_updates();
 
139
        //list_theme_updates();
 
140
        do_action('core_upgrade_preamble');
129
141
        echo '</div>';
130
142
}
131
143
 
 
144
function list_plugin_updates() {
 
145
        global $wp_version;
 
146
 
 
147
        $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
 
148
 
 
149
        require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
 
150
        $plugins = get_plugin_updates();
 
151
        if ( empty($plugins) )
 
152
                return;
 
153
        $form_action = 'update-core.php?action=do-plugin-upgrade';
 
154
 
 
155
        $core_updates = get_core_updates();
 
156
        if ( !isset($core_updates[0]->response) || 'latest' == $core_updates[0]->response || 'development' == $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=') )
 
157
                $core_update_version = false;
 
158
        else
 
159
                $core_update_version = $core_updates[0]->current;
 
160
        ?>
 
161
<h3><?php _e('Plugins'); ?></h3>
 
162
<p><?php _e('The following plugins have new versions available.  Check the ones you want to upgrade and then click "Upgrade Plugins".'); ?></p>
 
163
<form method="post" action="<?php echo $form_action; ?>" name="upgrade-plugins" class="upgrade">
 
164
<?php wp_nonce_field('upgrade-core'); ?>
 
165
<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Upgrade Plugins'); ?>" name="upgrade" /></p>
 
166
<table class="widefat" cellspacing="0" id="update-plugins-table">
 
167
        <thead>
 
168
        <tr>
 
169
                <th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
 
170
                <th scope="col" class="manage-column"><?php _e('Select All'); ?></th>
 
171
        </tr>
 
172
        </thead>
 
173
 
 
174
        <tfoot>
 
175
        <tr>
 
176
                <th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
 
177
                <th scope="col" class="manage-column"><?php _e('Select All'); ?></th>
 
178
        </tr>
 
179
        </tfoot>
 
180
        <tbody class="plugins">
 
181
<?php
 
182
        foreach ( (array) $plugins as $plugin_file => $plugin_data) {
 
183
                $info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
 
184
                // Get plugin compat for running version of WordPress.
 
185
                if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
 
186
                        $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
 
187
                } elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
 
188
                        $compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
 
189
                        $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat[0], $compat[2], $compat[1]);
 
190
                } else {
 
191
                        $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
 
192
                }
 
193
                // Get plugin compat for updated version of WordPress.
 
194
                if ( $core_update_version ) {
 
195
                        if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
 
196
                                $update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
 
197
                                $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat[0], $update_compat[2], $update_compat[1]);
 
198
                        } else {
 
199
                                $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
 
200
                        }
 
201
                }
 
202
                // Get the upgrade notice for the new plugin version.
 
203
                if ( isset($plugin_data->update->upgrade_notice) ) {
 
204
                        $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice);
 
205
                } else {
 
206
                        $upgrade_notice = '';
 
207
                }
 
208
                echo "
 
209
        <tr class='active'>
 
210
                <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
 
211
                <td class='plugin-title'><strong>{$plugin_data->Name}</strong>" . sprintf(__('You are running version %1$s. Upgrade to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . $compat . $upgrade_notice . "</td>
 
212
        </tr>";
 
213
        }
 
214
?>
 
215
        </tbody>
 
216
</table>
 
217
<p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Upgrade Plugins'); ?>" name="upgrade" /></p>
 
218
</form>
 
219
<?php
 
220
}
 
221
 
 
222
function list_theme_updates() {
 
223
        $themes = get_theme_updates();
 
224
        if ( empty($themes) )
 
225
                return;
 
226
?>
 
227
<h3><?php _e('Themes'); ?></h3>
 
228
<table class="widefat" cellspacing="0" id="update-themes-table">
 
229
        <thead>
 
230
        <tr>
 
231
                <th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
 
232
                <th scope="col" class="manage-column"><?php _e('Name'); ?></th>
 
233
        </tr>
 
234
        </thead>
 
235
 
 
236
        <tfoot>
 
237
        <tr>
 
238
                <th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
 
239
                <th scope="col" class="manage-column"><?php _e('Name'); ?></th>
 
240
        </tr>
 
241
        </tfoot>
 
242
        <tbody class="plugins">
 
243
<?php
 
244
        foreach ( (array) $themes as $stylesheet => $theme_data) {
 
245
                echo "
 
246
        <tr class='active'>
 
247
                <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th>
 
248
                <td class='plugin-title'><strong>{$theme_data->Name}</strong></td>
 
249
        </tr>";
 
250
        }
 
251
?>
 
252
        </tbody>
 
253
</table>
 
254
<?php
 
255
}
132
256
 
133
257
/**
134
258
 * Upgrade WordPress core display.
206
330
        wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
207
331
}
208
332
 
 
333
function no_update_actions($actions) {
 
334
        return '';
 
335
}
 
336
 
 
337
function do_plugin_upgrade() {
 
338
        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
 
339
 
 
340
        if ( isset($_GET['plugins']) ) {
 
341
                $plugins = explode(',', $_GET['plugins']);
 
342
        } elseif ( isset($_POST['checked']) ) {
 
343
                $plugins = (array) $_POST['checked'];
 
344
        } else {
 
345
                // Nothing to do.
 
346
                return;
 
347
        }
 
348
        $url = 'update-core.php?action=do-plugin-upgrade&amp;plugins=' . urlencode(join(',', $plugins));
 
349
        $title = __('Upgrade Plugins');
 
350
        $nonce = 'upgrade-core';
 
351
        $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
 
352
        $upgrader->bulk_upgrade($plugins);
 
353
}
 
354
 
209
355
$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
210
356
 
 
357
$upgrade_error = false;
 
358
if ( 'do-plugin-upgrade' == $action && !isset($_GET['plugins']) && !isset($_POST['checked']) ) {
 
359
        $upgrade_error = true;
 
360
        $action = 'upgrade-core';
 
361
}
 
362
 
 
363
$title = __('Upgrade WordPress');
 
364
$parent_file = 'tools.php';
 
365
 
211
366
if ( 'upgrade-core' == $action ) {
212
367
        wp_version_check();
213
 
        $title = __('Upgrade WordPress');
214
 
        $parent_file = 'tools.php';
215
368
        require_once('admin-header.php');
216
369
        core_upgrade_preamble();
217
 
        include('admin-footer.php');
218
370
} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
219
371
        check_admin_referer('upgrade-core');
220
 
        $title = __('Upgrade WordPress');
221
 
        $parent_file = 'tools.php';
222
372
        // do the (un)dismiss actions before headers,
223
373
        // so that they can redirect
224
374
        if ( isset( $_POST['dismiss'] ) )
232
382
                $reinstall = false;
233
383
        if ( isset( $_POST['upgrade'] ) )
234
384
                do_core_upgrade($reinstall);
235
 
        include('admin-footer.php');
 
385
} elseif ( 'do-plugin-upgrade' == $action ) {
 
386
        check_admin_referer('upgrade-core');
 
387
        require_once('admin-header.php');
 
388
        do_plugin_upgrade();
 
389
}
236
390
 
237
 
}?>
 
391
include('admin-footer.php');