5 * @package WordPress |
5 * @package WordPress |
6 * @subpackage Administration |
6 * @subpackage Administration |
7 */ |
7 */ |
8 |
8 |
9 /** WordPress Administration Bootstrap */ |
9 /** WordPress Administration Bootstrap */ |
10 require_once('admin.php'); |
10 require_once('./admin.php'); |
11 |
11 |
12 if ( ! current_user_can('update_plugins') ) |
12 wp_enqueue_style( 'plugin-install' ); |
13 wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); |
13 wp_enqueue_script( 'plugin-install' ); |
|
14 add_thickbox(); |
|
15 |
|
16 if ( is_multisite() && ! is_network_admin() ) { |
|
17 wp_redirect( network_admin_url( 'update-core.php' ) ); |
|
18 exit(); |
|
19 } |
|
20 |
|
21 if ( ! current_user_can( 'update_core' ) ) |
|
22 wp_die( __( 'You do not have sufficient permissions to update this site.' ) ); |
14 |
23 |
15 function list_core_update( $update ) { |
24 function list_core_update( $update ) { |
16 global $wp_local_package; |
25 global $wp_local_package, $wpdb; |
|
26 static $first_pass = true; |
|
27 |
17 $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ? |
28 $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ? |
18 $update->current : sprintf("%s–<strong>%s</strong>", $update->current, $update->locale); |
29 $update->current : sprintf("%s–<strong>%s</strong>", $update->current, $update->locale); |
19 $current = false; |
30 $current = false; |
20 if ( !isset($update->response) || 'latest' == $update->response ) |
31 if ( !isset($update->response) || 'latest' == $update->response ) |
21 $current = true; |
32 $current = true; |
22 $submit = __('Upgrade Automatically'); |
33 $submit = __('Update Now'); |
23 $form_action = 'update-core.php?action=do-core-upgrade'; |
34 $form_action = 'update-core.php?action=do-core-upgrade'; |
|
35 $php_version = phpversion(); |
|
36 $mysql_version = $wpdb->db_version(); |
|
37 $show_buttons = true; |
24 if ( 'development' == $update->response ) { |
38 if ( 'development' == $update->response ) { |
25 $message = __('You are using a development version of WordPress. You can upgrade to the latest nightly build automatically or download the nightly build and install it manually:'); |
39 $message = __('You are using a development version of WordPress. You can update to the latest nightly build automatically or download the nightly build and install it manually:'); |
26 $download = __('Download nightly build'); |
40 $download = __('Download nightly build'); |
27 } else { |
41 } else { |
28 if ( $current ) { |
42 if ( $current ) { |
29 $message = sprintf(__('You have the latest version of WordPress. You do not need to upgrade. However, if you want to re-install version %s, you can do so automatically or download the package and re-install manually:'), $version_string); |
43 $message = sprintf(__('You have the latest version of WordPress. You do not need to update. However, if you want to re-install version %s, you can do so automatically or download the package and re-install manually:'), $version_string); |
30 $submit = __('Re-install Automatically'); |
44 $submit = __('Re-install Now'); |
31 $form_action = 'update-core.php?action=do-core-reinstall'; |
45 $form_action = 'update-core.php?action=do-core-reinstall'; |
32 } else { |
46 } else { |
33 $message = sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string); |
47 $php_compat = version_compare( $php_version, $update->php_version, '>=' ); |
|
48 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) |
|
49 $mysql_compat = true; |
|
50 else |
|
51 $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ); |
|
52 |
|
53 if ( !$mysql_compat && !$php_compat ) |
|
54 $message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ); |
|
55 elseif ( !$php_compat ) |
|
56 $message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version ); |
|
57 elseif ( !$mysql_compat ) |
|
58 $message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version ); |
|
59 else |
|
60 $message = sprintf(__('You can update to <a href="http://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically or download the package and install it manually:'), $update->current, $version_string); |
|
61 if ( !$mysql_compat || !$php_compat ) |
|
62 $show_buttons = false; |
34 } |
63 } |
35 $download = sprintf(__('Download %s'), $version_string); |
64 $download = sprintf(__('Download %s'), $version_string); |
36 } |
65 } |
37 |
66 |
38 echo '<p>'; |
67 echo '<p>'; |
39 echo $message; |
68 echo $message; |
40 echo '</p>'; |
69 echo '</p>'; |
41 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">'; |
70 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">'; |
42 wp_nonce_field('upgrade-core'); |
71 wp_nonce_field('upgrade-core'); |
43 echo '<p>'; |
72 echo '<p>'; |
44 echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" /> '; |
|
45 echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>'; |
73 echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>'; |
46 echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>'; |
74 echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>'; |
47 echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a> '; |
75 if ( $show_buttons ) { |
|
76 if ( $first_pass ) { |
|
77 submit_button( $submit, $current ? 'button' : 'primary', 'upgrade', false ); |
|
78 $first_pass = false; |
|
79 } else { |
|
80 submit_button( $submit, 'button', 'upgrade', false ); |
|
81 } |
|
82 echo ' <a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a> '; |
|
83 } |
48 if ( 'en_US' != $update->locale ) |
84 if ( 'en_US' != $update->locale ) |
49 if ( !isset( $update->dismissed ) || !$update->dismissed ) |
85 if ( !isset( $update->dismissed ) || !$update->dismissed ) |
50 echo '<input id="dismiss" class="button" type="submit" value="' . esc_attr__('Hide this update') . '" name="dismiss" />'; |
86 submit_button( __('Hide this update'), 'button', 'dismiss', false ); |
51 else |
87 else |
52 echo '<input id="undismiss" class="button" type="submit" value="' . esc_attr__('Bring back this update') . '" name="undismiss" />'; |
88 submit_button( __('Bring back this update'), 'button', 'undismiss', false ); |
53 echo '</p>'; |
89 echo '</p>'; |
54 if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) ) |
90 if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) ) |
55 echo '<p class="hint">'.__('This localized version contains both the translation and various other localization fixes. You can skip upgrading if you want to keep your current translation.').'</p>'; |
91 echo '<p class="hint">'.__('This localized version contains both the translation and various other localization fixes. You can skip upgrading if you want to keep your current translation.').'</p>'; |
56 else if ( 'en_US' == $update->locale && get_locale() != 'en_US' ) { |
92 else if ( 'en_US' == $update->locale && get_locale() != 'en_US' ) { |
57 echo '<p class="hint">'.sprintf( __('You are about to install WordPress %s <strong>in English.</strong> There is a chance this upgrade will break your translation. You may prefer to wait for the localized version to be released.'), $update->current ).'</p>'; |
93 echo '<p class="hint">'.sprintf( __('You are about to install WordPress %s <strong>in English (US).</strong> There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.'), $update->response != 'development' ? $update->current : '' ).'</p>'; |
58 } |
94 } |
59 echo '</form>'; |
95 echo '</form>'; |
60 |
96 |
61 } |
97 } |
62 |
98 |
93 * @since 2.7 |
129 * @since 2.7 |
94 * |
130 * |
95 * @return null |
131 * @return null |
96 */ |
132 */ |
97 function core_upgrade_preamble() { |
133 function core_upgrade_preamble() { |
98 global $upgrade_error; |
134 global $upgrade_error, $wp_version; |
99 |
135 |
100 $updates = get_core_updates(); |
136 $updates = get_core_updates(); |
101 ?> |
137 ?> |
102 <div class="wrap"> |
138 <div class="wrap"> |
103 <?php screen_icon(); ?> |
139 <?php screen_icon('tools'); ?> |
104 <h2><?php _e('Upgrade WordPress'); ?></h2> |
140 <h2><?php _e('WordPress Updates'); ?></h2> |
105 <?php |
141 <?php |
106 if ( $upgrade_error ) { |
142 if ( $upgrade_error ) { |
107 echo '<div class="error"><p>'; |
143 echo '<div class="error"><p>'; |
108 _e('Please select one or more plugins to upgrade.'); |
144 if ( $upgrade_error == 'themes' ) |
|
145 _e('Please select one or more themes to update.'); |
|
146 else |
|
147 _e('Please select one or more plugins to update.'); |
109 echo '</p></div>'; |
148 echo '</p></div>'; |
110 } |
149 } |
|
150 |
|
151 echo '<p>'; |
|
152 /* translators: %1 date, %2 time. */ |
|
153 printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) ); |
|
154 echo ' <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>'; |
|
155 echo '</p>'; |
111 |
156 |
112 if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) { |
157 if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) { |
113 echo '<h3>'; |
158 echo '<h3>'; |
114 _e('You have the latest version of WordPress. You do not need to upgrade'); |
159 _e('You have the latest version of WordPress.'); |
115 echo '</h3>'; |
160 echo '</h3>'; |
116 } else { |
161 } else { |
117 echo '<div class="updated fade"><p>'; |
162 echo '<div class="updated inline"><p>'; |
118 _e('<strong>Important:</strong> before upgrading, please <a href="http://codex.wordpress.org/WordPress_Backups">backup your database and files</a>.'); |
163 _e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.'); |
119 echo '</p></div>'; |
164 echo '</p></div>'; |
120 |
165 |
121 echo '<h3 class="response">'; |
166 echo '<h3 class="response">'; |
122 _e( 'There is a new version of WordPress available for upgrade' ); |
167 _e( 'An updated version of WordPress is available.' ); |
123 echo '</h3>'; |
168 echo '</h3>'; |
124 } |
169 } |
125 |
170 |
126 echo '<ul class="core-updates">'; |
171 echo '<ul class="core-updates">'; |
127 $alternate = true; |
172 $alternate = true; |
128 foreach( (array) $updates as $update ) { |
173 foreach( (array) $updates as $update ) { |
129 $class = $alternate? ' class="alternate"' : ''; |
174 echo '<li>'; |
130 $alternate = !$alternate; |
|
131 echo "<li $class>"; |
|
132 list_core_update( $update ); |
175 list_core_update( $update ); |
133 echo '</li>'; |
176 echo '</li>'; |
134 } |
177 } |
135 echo '</ul>'; |
178 echo '</ul>'; |
|
179 if ( $updates ) { |
|
180 echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.' ) . '</p>'; |
|
181 } else { |
|
182 list( $normalized_version ) = explode( '-', $wp_version ); |
|
183 echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>'; |
|
184 } |
136 dismissed_updates(); |
185 dismissed_updates(); |
137 |
186 |
138 list_plugin_updates(); |
187 if ( current_user_can( 'update_plugins' ) ) |
139 //list_theme_updates(); |
188 list_plugin_updates(); |
|
189 if ( current_user_can( 'update_themes' ) ) |
|
190 list_theme_updates(); |
140 do_action('core_upgrade_preamble'); |
191 do_action('core_upgrade_preamble'); |
141 echo '</div>'; |
192 echo '</div>'; |
142 } |
193 } |
143 |
194 |
144 function list_plugin_updates() { |
195 function list_plugin_updates() { |
146 |
197 |
147 $cur_wp_version = preg_replace('/-.*$/', '', $wp_version); |
198 $cur_wp_version = preg_replace('/-.*$/', '', $wp_version); |
148 |
199 |
149 require_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); |
200 require_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); |
150 $plugins = get_plugin_updates(); |
201 $plugins = get_plugin_updates(); |
151 if ( empty($plugins) ) |
202 if ( empty( $plugins ) ) { |
152 return; |
203 echo '<h3>' . __( 'Plugins' ) . '</h3>'; |
|
204 echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>'; |
|
205 return; |
|
206 } |
153 $form_action = 'update-core.php?action=do-plugin-upgrade'; |
207 $form_action = 'update-core.php?action=do-plugin-upgrade'; |
154 |
208 |
155 $core_updates = get_core_updates(); |
209 $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, '=') ) |
210 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; |
211 $core_update_version = false; |
158 else |
212 else |
159 $core_update_version = $core_updates[0]->current; |
213 $core_update_version = $core_updates[0]->current; |
160 ?> |
214 ?> |
161 <h3><?php _e('Plugins'); ?></h3> |
215 <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> |
216 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p> |
163 <form method="post" action="<?php echo $form_action; ?>" name="upgrade-plugins" class="upgrade"> |
217 <form method="post" action="<?php echo $form_action; ?>" name="upgrade-plugins" class="upgrade"> |
164 <?php wp_nonce_field('upgrade-core'); ?> |
218 <?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> |
219 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> |
166 <table class="widefat" cellspacing="0" id="update-plugins-table"> |
220 <table class="widefat" cellspacing="0" id="update-plugins-table"> |
167 <thead> |
221 <thead> |
168 <tr> |
222 <tr> |
169 <th scope="col" class="manage-column check-column"><input type="checkbox" /></th> |
223 <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th> |
170 <th scope="col" class="manage-column"><?php _e('Select All'); ?></th> |
224 <th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th> |
171 </tr> |
225 </tr> |
172 </thead> |
226 </thead> |
173 |
227 |
174 <tfoot> |
228 <tfoot> |
175 <tr> |
229 <tr> |
176 <th scope="col" class="manage-column check-column"><input type="checkbox" /></th> |
230 <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th> |
177 <th scope="col" class="manage-column"><?php _e('Select All'); ?></th> |
231 <th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></th> |
178 </tr> |
232 </tr> |
179 </tfoot> |
233 </tfoot> |
180 <tbody class="plugins"> |
234 <tbody class="plugins"> |
181 <?php |
235 <?php |
182 foreach ( (array) $plugins as $plugin_file => $plugin_data) { |
236 foreach ( (array) $plugins as $plugin_file => $plugin_data) { |
203 if ( isset($plugin_data->update->upgrade_notice) ) { |
257 if ( isset($plugin_data->update->upgrade_notice) ) { |
204 $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice); |
258 $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice); |
205 } else { |
259 } else { |
206 $upgrade_notice = ''; |
260 $upgrade_notice = ''; |
207 } |
261 } |
|
262 |
|
263 $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '§ion=changelog&TB_iframe=true&width=640&height=662'); |
|
264 $details_text = sprintf(__('View version %1$s details'), $plugin_data->update->new_version); |
|
265 $details = sprintf('<a href="%1$s" class="thickbox" title="%2$s">%3$s</a>.', esc_url($details_url), esc_attr($plugin_data->Name), $details_text); |
|
266 |
208 echo " |
267 echo " |
209 <tr class='active'> |
268 <tr class='active'> |
210 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th> |
269 <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> |
270 <td><p><strong>{$plugin_data->Name}</strong><br />" . sprintf(__('You have version %1$s installed. Update to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . ' ' . $details . $compat . $upgrade_notice . "</p></td> |
212 </tr>"; |
271 </tr>"; |
213 } |
272 } |
214 ?> |
273 ?> |
215 </tbody> |
274 </tbody> |
216 </table> |
275 </table> |
217 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Upgrade Plugins'); ?>" name="upgrade" /></p> |
276 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> |
218 </form> |
277 </form> |
219 <?php |
278 <?php |
220 } |
279 } |
221 |
280 |
222 function list_theme_updates() { |
281 function list_theme_updates() { |
223 $themes = get_theme_updates(); |
282 $themes = get_theme_updates(); |
224 if ( empty($themes) ) |
283 if ( empty( $themes ) ) { |
225 return; |
284 echo '<h3>' . __( 'Themes' ) . '</h3>'; |
|
285 echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>'; |
|
286 return; |
|
287 } |
|
288 |
|
289 $form_action = 'update-core.php?action=do-theme-upgrade'; |
|
290 |
226 ?> |
291 ?> |
227 <h3><?php _e('Themes'); ?></h3> |
292 <h3><?php _e( 'Themes' ); ?></h3> |
|
293 <p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click “Update Themes”.' ); ?></p> |
|
294 <p><?php printf( __('<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), _x('http://codex.wordpress.org/Child_Themes', 'Link used in suggestion to use child themes in GUU') ); ?></p> |
|
295 <form method="post" action="<?php echo $form_action; ?>" name="upgrade-themes" class="upgrade"> |
|
296 <?php wp_nonce_field('upgrade-core'); ?> |
|
297 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p> |
228 <table class="widefat" cellspacing="0" id="update-themes-table"> |
298 <table class="widefat" cellspacing="0" id="update-themes-table"> |
229 <thead> |
299 <thead> |
230 <tr> |
300 <tr> |
231 <th scope="col" class="manage-column check-column"><input type="checkbox" /></th> |
301 <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th> |
232 <th scope="col" class="manage-column"><?php _e('Name'); ?></th> |
302 <th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th> |
233 </tr> |
303 </tr> |
234 </thead> |
304 </thead> |
235 |
305 |
236 <tfoot> |
306 <tfoot> |
237 <tr> |
307 <tr> |
238 <th scope="col" class="manage-column check-column"><input type="checkbox" /></th> |
308 <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th> |
239 <th scope="col" class="manage-column"><?php _e('Name'); ?></th> |
309 <th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></th> |
240 </tr> |
310 </tr> |
241 </tfoot> |
311 </tfoot> |
242 <tbody class="plugins"> |
312 <tbody class="plugins"> |
243 <?php |
313 <?php |
244 foreach ( (array) $themes as $stylesheet => $theme_data) { |
314 foreach ( $themes as $stylesheet => $theme ) { |
245 echo " |
315 echo " |
246 <tr class='active'> |
316 <tr class='active'> |
247 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th> |
317 <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> |
318 <td class='plugin-title'><img src='" . esc_url( $theme->get_screenshot() ) . "' width='64' height='64' style='float:left; padding: 0 5px 5px' /><strong>" . $theme->display('Name') . '</strong> ' . sprintf( __( 'You have version %1$s installed. Update to %2$s.' ), $theme->display('Version'), $theme->update['new_version'] ) . "</td> |
249 </tr>"; |
319 </tr>"; |
250 } |
320 } |
251 ?> |
321 ?> |
252 </tbody> |
322 </tbody> |
253 </table> |
323 </table> |
|
324 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p> |
|
325 </form> |
254 <?php |
326 <?php |
255 } |
327 } |
256 |
328 |
257 /** |
329 /** |
258 * Upgrade WordPress core display. |
330 * Upgrade WordPress core display. |
302 |
373 |
303 if ( is_wp_error($result) ) { |
374 if ( is_wp_error($result) ) { |
304 show_message($result); |
375 show_message($result); |
305 if ('up_to_date' != $result->get_error_code() ) |
376 if ('up_to_date' != $result->get_error_code() ) |
306 show_message( __('Installation Failed') ); |
377 show_message( __('Installation Failed') ); |
307 } else { |
378 echo '</div>'; |
308 show_message( __('WordPress upgraded successfully') ); |
379 return; |
309 } |
380 } |
310 echo '</div>'; |
381 |
|
382 show_message( __('WordPress updated successfully') ); |
|
383 show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%s">here</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' ); |
|
384 show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' ); |
|
385 ?> |
|
386 </div> |
|
387 <script type="text/javascript"> |
|
388 window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>'; |
|
389 </script> |
|
390 <?php |
311 } |
391 } |
312 |
392 |
313 function do_dismiss_core_update() { |
393 function do_dismiss_core_update() { |
314 $version = isset( $_POST['version'] )? $_POST['version'] : false; |
394 $version = isset( $_POST['version'] )? $_POST['version'] : false; |
315 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; |
395 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; |
316 $update = find_core_update( $version, $locale ); |
396 $update = find_core_update( $version, $locale ); |
317 if ( !$update ) |
397 if ( !$update ) |
318 return; |
398 return; |
319 dismiss_core_update( $update ); |
399 dismiss_core_update( $update ); |
320 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') ); |
400 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') ); |
|
401 exit; |
321 } |
402 } |
322 |
403 |
323 function do_undismiss_core_update() { |
404 function do_undismiss_core_update() { |
324 $version = isset( $_POST['version'] )? $_POST['version'] : false; |
405 $version = isset( $_POST['version'] )? $_POST['version'] : false; |
325 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; |
406 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; |
326 $update = find_core_update( $version, $locale ); |
407 $update = find_core_update( $version, $locale ); |
327 if ( !$update ) |
408 if ( !$update ) |
328 return; |
409 return; |
329 undismiss_core_update( $version, $locale ); |
410 undismiss_core_update( $version, $locale ); |
330 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') ); |
411 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') ); |
|
412 exit; |
331 } |
413 } |
332 |
414 |
333 function no_update_actions($actions) { |
415 function no_update_actions($actions) { |
334 return ''; |
416 return ''; |
335 } |
417 } |
336 |
418 |
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&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 |
|
355 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core'; |
419 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core'; |
356 |
420 |
357 $upgrade_error = false; |
421 $upgrade_error = false; |
358 if ( 'do-plugin-upgrade' == $action && !isset($_GET['plugins']) && !isset($_POST['checked']) ) { |
422 if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) ) |
359 $upgrade_error = true; |
423 && ! isset( $_POST['checked'] ) ) { |
|
424 $upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins'; |
360 $action = 'upgrade-core'; |
425 $action = 'upgrade-core'; |
361 } |
426 } |
362 |
427 |
363 $title = __('Upgrade WordPress'); |
428 $title = __('WordPress Updates'); |
364 $parent_file = 'tools.php'; |
429 $parent_file = 'tools.php'; |
365 |
430 |
|
431 get_current_screen()->add_help_tab( array( |
|
432 'id' => 'overview', |
|
433 'title' => __('Overview'), |
|
434 'content' => |
|
435 '<p>' . __('This screen lets you update to the latest version of WordPress as well as update your themes and plugins from the WordPress.org repository. When updates are available, the number of available updates will appear in a bubble on the left hand menu as a notification.') . '</p>' . |
|
436 '<p>' . __('It is very important to keep your WordPress installation up to date for security reasons, so when you see a number appear, make sure you take the time to update, which is an easy process.') . '</p>' |
|
437 ) ); |
|
438 |
|
439 get_current_screen()->add_help_tab( array( |
|
440 'id' => 'how-to-update', |
|
441 'title' => __('How to Update'), |
|
442 'content' => |
|
443 '<p>' . __('Updating your WordPress installation is a simple one-click procedure; just click on the Update button when it says a new version is available.') . '</p>' . |
|
444 '<p>' . __('To update themes or plugins from this screen, use the checkboxes to make your selection and click on the appropriate Update button. Check the box at the top of the Themes or Plugins section to select all and update them all at once.') . '</p>' |
|
445 ) ); |
|
446 |
|
447 get_current_screen()->set_help_sidebar( |
|
448 '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
449 '<p>' . __('<a href="http://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>') . '</p>' . |
|
450 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
451 ); |
|
452 |
366 if ( 'upgrade-core' == $action ) { |
453 if ( 'upgrade-core' == $action ) { |
|
454 |
367 wp_version_check(); |
455 wp_version_check(); |
368 require_once('admin-header.php'); |
456 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
369 core_upgrade_preamble(); |
457 core_upgrade_preamble(); |
|
458 include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
459 |
370 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) { |
460 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) { |
371 check_admin_referer('upgrade-core'); |
461 check_admin_referer('upgrade-core'); |
|
462 |
372 // do the (un)dismiss actions before headers, |
463 // do the (un)dismiss actions before headers, |
373 // so that they can redirect |
464 // so that they can redirect |
374 if ( isset( $_POST['dismiss'] ) ) |
465 if ( isset( $_POST['dismiss'] ) ) |
375 do_dismiss_core_update(); |
466 do_dismiss_core_update(); |
376 elseif ( isset( $_POST['undismiss'] ) ) |
467 elseif ( isset( $_POST['undismiss'] ) ) |
377 do_undismiss_core_update(); |
468 do_undismiss_core_update(); |
378 require_once('admin-header.php'); |
469 |
|
470 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
379 if ( 'do-core-reinstall' == $action ) |
471 if ( 'do-core-reinstall' == $action ) |
380 $reinstall = true; |
472 $reinstall = true; |
381 else |
473 else |
382 $reinstall = false; |
474 $reinstall = false; |
|
475 |
383 if ( isset( $_POST['upgrade'] ) ) |
476 if ( isset( $_POST['upgrade'] ) ) |
384 do_core_upgrade($reinstall); |
477 do_core_upgrade($reinstall); |
|
478 |
|
479 include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
480 |
385 } elseif ( 'do-plugin-upgrade' == $action ) { |
481 } elseif ( 'do-plugin-upgrade' == $action ) { |
|
482 |
|
483 if ( ! current_user_can( 'update_plugins' ) ) |
|
484 wp_die( __( 'You do not have sufficient permissions to update this site.' ) ); |
|
485 |
386 check_admin_referer('upgrade-core'); |
486 check_admin_referer('upgrade-core'); |
387 require_once('admin-header.php'); |
487 |
388 do_plugin_upgrade(); |
488 if ( isset( $_GET['plugins'] ) ) { |
389 } |
489 $plugins = explode( ',', $_GET['plugins'] ); |
390 |
490 } elseif ( isset( $_POST['checked'] ) ) { |
391 include('admin-footer.php'); |
491 $plugins = (array) $_POST['checked']; |
|
492 } else { |
|
493 wp_redirect( admin_url('update-core.php') ); |
|
494 exit; |
|
495 } |
|
496 |
|
497 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); |
|
498 $url = wp_nonce_url($url, 'bulk-update-plugins'); |
|
499 |
|
500 $title = __('Update Plugins'); |
|
501 |
|
502 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
503 echo '<div class="wrap">'; |
|
504 screen_icon('plugins'); |
|
505 echo '<h2>' . esc_html__('Update Plugins') . '</h2>'; |
|
506 echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>"; |
|
507 echo '</div>'; |
|
508 include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
509 |
|
510 } elseif ( 'do-theme-upgrade' == $action ) { |
|
511 |
|
512 if ( ! current_user_can( 'update_themes' ) ) |
|
513 wp_die( __( 'You do not have sufficient permissions to update this site.' ) ); |
|
514 |
|
515 check_admin_referer('upgrade-core'); |
|
516 |
|
517 if ( isset( $_GET['themes'] ) ) { |
|
518 $themes = explode( ',', $_GET['themes'] ); |
|
519 } elseif ( isset( $_POST['checked'] ) ) { |
|
520 $themes = (array) $_POST['checked']; |
|
521 } else { |
|
522 wp_redirect( admin_url('update-core.php') ); |
|
523 exit; |
|
524 } |
|
525 |
|
526 $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes)); |
|
527 $url = wp_nonce_url($url, 'bulk-update-themes'); |
|
528 |
|
529 $title = __('Update Themes'); |
|
530 |
|
531 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
532 echo '<div class="wrap">'; |
|
533 screen_icon('themes'); |
|
534 echo '<h2>' . esc_html__('Update Themes') . '</h2>'; |
|
535 echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>"; |
|
536 echo '</div>'; |
|
537 include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
538 |
|
539 } else { |
|
540 do_action('update-core-custom_' . $action); |
|
541 } |