PageRenderTime 57ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-admin/update-core.php

https://github.com/flyingnn/yoTheme
PHP | 541 lines | 445 code | 69 blank | 27 comment | 102 complexity | 9acc3d622977c1fee144592a19c3a08f MD5 | raw file
  1. <?php
  2. /**
  3. * Update Core administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once('./admin.php');
  10. wp_enqueue_style( 'plugin-install' );
  11. wp_enqueue_script( 'plugin-install' );
  12. add_thickbox();
  13. if ( is_multisite() && ! is_network_admin() ) {
  14. wp_redirect( network_admin_url( 'update-core.php' ) );
  15. exit();
  16. }
  17. if ( ! current_user_can( 'update_core' ) )
  18. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  19. function list_core_update( $update ) {
  20. global $wp_local_package, $wpdb;
  21. static $first_pass = true;
  22. $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
  23. $update->current : sprintf("%s&ndash;<strong>%s</strong>", $update->current, $update->locale);
  24. $current = false;
  25. if ( !isset($update->response) || 'latest' == $update->response )
  26. $current = true;
  27. $submit = __('Update Now');
  28. $form_action = 'update-core.php?action=do-core-upgrade';
  29. $php_version = phpversion();
  30. $mysql_version = $wpdb->db_version();
  31. $show_buttons = true;
  32. if ( 'development' == $update->response ) {
  33. $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:');
  34. $download = __('Download nightly build');
  35. } else {
  36. if ( $current ) {
  37. $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);
  38. $submit = __('Re-install Now');
  39. $form_action = 'update-core.php?action=do-core-reinstall';
  40. } else {
  41. $php_compat = version_compare( $php_version, $update->php_version, '>=' );
  42. if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
  43. $mysql_compat = true;
  44. else
  45. $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
  46. if ( !$mysql_compat && !$php_compat )
  47. $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 );
  48. elseif ( !$php_compat )
  49. $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 );
  50. elseif ( !$mysql_compat )
  51. $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 );
  52. else
  53. $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);
  54. if ( !$mysql_compat || !$php_compat )
  55. $show_buttons = false;
  56. }
  57. $download = sprintf(__('Download %s'), $version_string);
  58. }
  59. echo '<p>';
  60. echo $message;
  61. echo '</p>';
  62. echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
  63. wp_nonce_field('upgrade-core');
  64. echo '<p>';
  65. echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
  66. echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
  67. if ( $show_buttons ) {
  68. if ( $first_pass ) {
  69. submit_button( $submit, $current ? 'button' : 'primary', 'upgrade', false );
  70. $first_pass = false;
  71. } else {
  72. submit_button( $submit, 'button', 'upgrade', false );
  73. }
  74. echo '&nbsp;<a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a>&nbsp;';
  75. }
  76. if ( 'en_US' != $update->locale )
  77. if ( !isset( $update->dismissed ) || !$update->dismissed )
  78. submit_button( __('Hide this update'), 'button', 'dismiss', false );
  79. else
  80. submit_button( __('Bring back this update'), 'button', 'undismiss', false );
  81. echo '</p>';
  82. if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
  83. 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>';
  84. else if ( 'en_US' == $update->locale && get_locale() != 'en_US' ) {
  85. 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>';
  86. }
  87. echo '</form>';
  88. }
  89. function dismissed_updates() {
  90. $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
  91. if ( $dismissed ) {
  92. $show_text = esc_js(__('Show hidden updates'));
  93. $hide_text = esc_js(__('Hide hidden updates'));
  94. ?>
  95. <script type="text/javascript">
  96. jQuery(function($) {
  97. $('dismissed-updates').show();
  98. $('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
  99. $('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
  100. });
  101. </script>
  102. <?php
  103. echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
  104. echo '<ul id="dismissed-updates" class="core-updates dismissed">';
  105. foreach( (array) $dismissed as $update) {
  106. echo '<li>';
  107. list_core_update( $update );
  108. echo '</li>';
  109. }
  110. echo '</ul>';
  111. }
  112. }
  113. /**
  114. * Display upgrade WordPress for downloading latest or upgrading automatically form.
  115. *
  116. * @since 2.7
  117. *
  118. * @return null
  119. */
  120. function core_upgrade_preamble() {
  121. global $upgrade_error, $wp_version;
  122. $updates = get_core_updates();
  123. ?>
  124. <div class="wrap">
  125. <?php screen_icon('tools'); ?>
  126. <h2><?php _e('WordPress Updates'); ?></h2>
  127. <?php
  128. if ( $upgrade_error ) {
  129. echo '<div class="error"><p>';
  130. if ( $upgrade_error == 'themes' )
  131. _e('Please select one or more themes to update.');
  132. else
  133. _e('Please select one or more plugins to update.');
  134. echo '</p></div>';
  135. }
  136. echo '<p>';
  137. /* translators: %1 date, %2 time. */
  138. printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
  139. echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
  140. echo '</p>';
  141. if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
  142. echo '<h3>';
  143. _e('You have the latest version of WordPress.');
  144. echo '</h3>';
  145. } else {
  146. echo '<div class="updated inline"><p>';
  147. _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.');
  148. echo '</p></div>';
  149. echo '<h3 class="response">';
  150. _e( 'An updated version of WordPress is available.' );
  151. echo '</h3>';
  152. }
  153. echo '<ul class="core-updates">';
  154. $alternate = true;
  155. foreach( (array) $updates as $update ) {
  156. echo '<li>';
  157. list_core_update( $update );
  158. echo '</li>';
  159. }
  160. echo '</ul>';
  161. if ( $updates ) {
  162. 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>';
  163. } else {
  164. list( $normalized_version ) = explode( '-', $wp_version );
  165. echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>';
  166. }
  167. dismissed_updates();
  168. if ( current_user_can( 'update_plugins' ) )
  169. list_plugin_updates();
  170. if ( current_user_can( 'update_themes' ) )
  171. list_theme_updates();
  172. do_action('core_upgrade_preamble');
  173. echo '</div>';
  174. }
  175. function list_plugin_updates() {
  176. global $wp_version;
  177. $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
  178. require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
  179. $plugins = get_plugin_updates();
  180. if ( empty( $plugins ) ) {
  181. echo '<h3>' . __( 'Plugins' ) . '</h3>';
  182. echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
  183. return;
  184. }
  185. $form_action = 'update-core.php?action=do-plugin-upgrade';
  186. $core_updates = get_core_updates();
  187. 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, '=') )
  188. $core_update_version = false;
  189. else
  190. $core_update_version = $core_updates[0]->current;
  191. ?>
  192. <h3><?php _e( 'Plugins' ); ?></h3>
  193. <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click &#8220;Update Plugins&#8221;.' ); ?></p>
  194. <form method="post" action="<?php echo $form_action; ?>" name="upgrade-plugins" class="upgrade">
  195. <?php wp_nonce_field('upgrade-core'); ?>
  196. <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
  197. <table class="widefat" cellspacing="0" id="update-plugins-table">
  198. <thead>
  199. <tr>
  200. <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
  201. <th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
  202. </tr>
  203. </thead>
  204. <tfoot>
  205. <tr>
  206. <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
  207. <th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></th>
  208. </tr>
  209. </tfoot>
  210. <tbody class="plugins">
  211. <?php
  212. foreach ( (array) $plugins as $plugin_file => $plugin_data) {
  213. $info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
  214. // Get plugin compat for running version of WordPress.
  215. if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
  216. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
  217. } elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
  218. $compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
  219. $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]);
  220. } else {
  221. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
  222. }
  223. // Get plugin compat for updated version of WordPress.
  224. if ( $core_update_version ) {
  225. if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
  226. $update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
  227. $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]);
  228. } else {
  229. $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
  230. }
  231. }
  232. // Get the upgrade notice for the new plugin version.
  233. if ( isset($plugin_data->update->upgrade_notice) ) {
  234. $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice);
  235. } else {
  236. $upgrade_notice = '';
  237. }
  238. $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '&section=changelog&TB_iframe=true&width=640&height=662');
  239. $details_text = sprintf(__('View version %1$s details'), $plugin_data->update->new_version);
  240. $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);
  241. echo "
  242. <tr class='active'>
  243. <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
  244. <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>
  245. </tr>";
  246. }
  247. ?>
  248. </tbody>
  249. </table>
  250. <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
  251. </form>
  252. <?php
  253. }
  254. function list_theme_updates() {
  255. $themes = get_theme_updates();
  256. if ( empty( $themes ) ) {
  257. echo '<h3>' . __( 'Themes' ) . '</h3>';
  258. echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
  259. return;
  260. }
  261. $form_action = 'update-core.php?action=do-theme-upgrade';
  262. ?>
  263. <h3><?php _e( 'Themes' ); ?></h3>
  264. <p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.' ); ?></p>
  265. <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>
  266. <form method="post" action="<?php echo $form_action; ?>" name="upgrade-themes" class="upgrade">
  267. <?php wp_nonce_field('upgrade-core'); ?>
  268. <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
  269. <table class="widefat" cellspacing="0" id="update-themes-table">
  270. <thead>
  271. <tr>
  272. <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
  273. <th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
  274. </tr>
  275. </thead>
  276. <tfoot>
  277. <tr>
  278. <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
  279. <th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></th>
  280. </tr>
  281. </tfoot>
  282. <tbody class="plugins">
  283. <?php
  284. foreach ( $themes as $stylesheet => $theme ) {
  285. echo "
  286. <tr class='active'>
  287. <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' /></th>
  288. <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>
  289. </tr>";
  290. }
  291. ?>
  292. </tbody>
  293. </table>
  294. <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
  295. </form>
  296. <?php
  297. }
  298. /**
  299. * Upgrade WordPress core display.
  300. *
  301. * @since 2.7
  302. *
  303. * @return null
  304. */
  305. function do_core_upgrade( $reinstall = false ) {
  306. global $wp_filesystem;
  307. if ( $reinstall )
  308. $url = 'update-core.php?action=do-core-reinstall';
  309. else
  310. $url = 'update-core.php?action=do-core-upgrade';
  311. $url = wp_nonce_url($url, 'upgrade-core');
  312. if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )
  313. return;
  314. $version = isset( $_POST['version'] )? $_POST['version'] : false;
  315. $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  316. $update = find_core_update( $version, $locale );
  317. if ( !$update )
  318. return;
  319. if ( ! WP_Filesystem($credentials, ABSPATH) ) {
  320. request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again
  321. return;
  322. }
  323. ?>
  324. <div class="wrap">
  325. <?php screen_icon('tools'); ?>
  326. <h2><?php _e('Update WordPress'); ?></h2>
  327. <?php
  328. if ( $wp_filesystem->errors->get_error_code() ) {
  329. foreach ( $wp_filesystem->errors->get_error_messages() as $message )
  330. show_message($message);
  331. echo '</div>';
  332. return;
  333. }
  334. if ( $reinstall )
  335. $update->response = 'reinstall';
  336. $result = wp_update_core($update, 'show_message');
  337. if ( is_wp_error($result) ) {
  338. show_message($result);
  339. if ('up_to_date' != $result->get_error_code() )
  340. show_message( __('Installation Failed') );
  341. echo '</div>';
  342. return;
  343. }
  344. show_message( __('WordPress updated successfully') );
  345. 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>' );
  346. 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>' );
  347. ?>
  348. </div>
  349. <script type="text/javascript">
  350. window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
  351. </script>
  352. <?php
  353. }
  354. function do_dismiss_core_update() {
  355. $version = isset( $_POST['version'] )? $_POST['version'] : false;
  356. $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  357. $update = find_core_update( $version, $locale );
  358. if ( !$update )
  359. return;
  360. dismiss_core_update( $update );
  361. wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
  362. exit;
  363. }
  364. function do_undismiss_core_update() {
  365. $version = isset( $_POST['version'] )? $_POST['version'] : false;
  366. $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  367. $update = find_core_update( $version, $locale );
  368. if ( !$update )
  369. return;
  370. undismiss_core_update( $version, $locale );
  371. wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
  372. exit;
  373. }
  374. function no_update_actions($actions) {
  375. return '';
  376. }
  377. $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
  378. $upgrade_error = false;
  379. if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
  380. && ! isset( $_POST['checked'] ) ) {
  381. $upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
  382. $action = 'upgrade-core';
  383. }
  384. $title = __('WordPress Updates');
  385. $parent_file = 'tools.php';
  386. get_current_screen()->add_help_tab( array(
  387. 'id' => 'overview',
  388. 'title' => __('Overview'),
  389. 'content' =>
  390. '<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>' .
  391. '<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>'
  392. ) );
  393. get_current_screen()->add_help_tab( array(
  394. 'id' => 'how-to-update',
  395. 'title' => __('How to Update'),
  396. 'content' =>
  397. '<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>' .
  398. '<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>'
  399. ) );
  400. get_current_screen()->set_help_sidebar(
  401. '<p><strong>' . __('For more information:') . '</strong></p>' .
  402. '<p>' . __('<a href="http://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>') . '</p>' .
  403. '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
  404. );
  405. if ( 'upgrade-core' == $action ) {
  406. wp_version_check();
  407. require_once(ABSPATH . 'wp-admin/admin-header.php');
  408. core_upgrade_preamble();
  409. include(ABSPATH . 'wp-admin/admin-footer.php');
  410. } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
  411. check_admin_referer('upgrade-core');
  412. // do the (un)dismiss actions before headers,
  413. // so that they can redirect
  414. if ( isset( $_POST['dismiss'] ) )
  415. do_dismiss_core_update();
  416. elseif ( isset( $_POST['undismiss'] ) )
  417. do_undismiss_core_update();
  418. require_once(ABSPATH . 'wp-admin/admin-header.php');
  419. if ( 'do-core-reinstall' == $action )
  420. $reinstall = true;
  421. else
  422. $reinstall = false;
  423. if ( isset( $_POST['upgrade'] ) )
  424. do_core_upgrade($reinstall);
  425. include(ABSPATH . 'wp-admin/admin-footer.php');
  426. } elseif ( 'do-plugin-upgrade' == $action ) {
  427. if ( ! current_user_can( 'update_plugins' ) )
  428. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  429. check_admin_referer('upgrade-core');
  430. if ( isset( $_GET['plugins'] ) ) {
  431. $plugins = explode( ',', $_GET['plugins'] );
  432. } elseif ( isset( $_POST['checked'] ) ) {
  433. $plugins = (array) $_POST['checked'];
  434. } else {
  435. wp_redirect( admin_url('update-core.php') );
  436. exit;
  437. }
  438. $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
  439. $url = wp_nonce_url($url, 'bulk-update-plugins');
  440. $title = __('Update Plugins');
  441. require_once(ABSPATH . 'wp-admin/admin-header.php');
  442. echo '<div class="wrap">';
  443. screen_icon('plugins');
  444. echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
  445. echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
  446. echo '</div>';
  447. include(ABSPATH . 'wp-admin/admin-footer.php');
  448. } elseif ( 'do-theme-upgrade' == $action ) {
  449. if ( ! current_user_can( 'update_themes' ) )
  450. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  451. check_admin_referer('upgrade-core');
  452. if ( isset( $_GET['themes'] ) ) {
  453. $themes = explode( ',', $_GET['themes'] );
  454. } elseif ( isset( $_POST['checked'] ) ) {
  455. $themes = (array) $_POST['checked'];
  456. } else {
  457. wp_redirect( admin_url('update-core.php') );
  458. exit;
  459. }
  460. $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
  461. $url = wp_nonce_url($url, 'bulk-update-themes');
  462. $title = __('Update Themes');
  463. require_once(ABSPATH . 'wp-admin/admin-header.php');
  464. echo '<div class="wrap">';
  465. screen_icon('themes');
  466. echo '<h2>' . esc_html__('Update Themes') . '</h2>';
  467. echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
  468. echo '</div>';
  469. include(ABSPATH . 'wp-admin/admin-footer.php');
  470. } else {
  471. do_action('update-core-custom_' . $action);
  472. }