PageRenderTime 61ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-admin/update-core.php

https://github.com/jpwannabi/tiendaelfracaso
PHP | 646 lines | 510 code | 90 blank | 46 comment | 136 complexity | 1a5897d963339da8c8f7cd6ae6e6933d MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /**
  3. * Update Core administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once( dirname( __FILE__ ) . '/admin.php' );
  10. wp_enqueue_style( 'plugin-install' );
  11. wp_enqueue_script( 'plugin-install' );
  12. wp_enqueue_script( 'updates' );
  13. add_thickbox();
  14. if ( is_multisite() && ! is_network_admin() ) {
  15. wp_redirect( network_admin_url( 'update-core.php' ) );
  16. exit();
  17. }
  18. if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) )
  19. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  20. function list_core_update( $update ) {
  21. global $wp_local_package, $wpdb, $wp_version;
  22. static $first_pass = true;
  23. if ( 'en_US' == $update->locale && 'en_US' == get_locale() )
  24. $version_string = $update->current;
  25. // If the only available update is a partial builds, it doesn't need a language-specific version string.
  26. elseif ( 'en_US' == $update->locale && $update->packages->partial && $wp_version == $update->partial_version && ( $updates = get_core_updates() ) && 1 == count( $updates ) )
  27. $version_string = $update->current;
  28. else
  29. $version_string = sprintf( "%s&ndash;<strong>%s</strong>", $update->current, $update->locale );
  30. $current = false;
  31. if ( !isset($update->response) || 'latest' == $update->response )
  32. $current = true;
  33. $submit = __('Update Now');
  34. $form_action = 'update-core.php?action=do-core-upgrade';
  35. $php_version = phpversion();
  36. $mysql_version = $wpdb->db_version();
  37. $show_buttons = true;
  38. if ( 'development' == $update->response ) {
  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:');
  40. $download = __('Download nightly build');
  41. } else {
  42. if ( $current ) {
  43. $message = sprintf( __( 'If you need to re-install version %s, you can do so here or download the package and re-install manually:' ), $version_string );
  44. $submit = __('Re-install Now');
  45. $form_action = 'update-core.php?action=do-core-reinstall';
  46. } else {
  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. if ( !$mysql_compat && !$php_compat )
  53. $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 );
  54. elseif ( !$php_compat )
  55. $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 );
  56. elseif ( !$mysql_compat )
  57. $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 );
  58. else
  59. $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);
  60. if ( !$mysql_compat || !$php_compat )
  61. $show_buttons = false;
  62. }
  63. $download = sprintf(__('Download %s'), $version_string);
  64. }
  65. echo '<p>';
  66. echo $message;
  67. echo '</p>';
  68. echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
  69. wp_nonce_field('upgrade-core');
  70. echo '<p>';
  71. echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
  72. echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
  73. if ( $show_buttons ) {
  74. if ( $first_pass ) {
  75. submit_button( $submit, $current ? 'button' : 'primary regular', 'upgrade', false );
  76. $first_pass = false;
  77. } else {
  78. submit_button( $submit, 'button', 'upgrade', false );
  79. }
  80. echo '&nbsp;<a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a>&nbsp;';
  81. }
  82. if ( 'en_US' != $update->locale )
  83. if ( !isset( $update->dismissed ) || !$update->dismissed )
  84. submit_button( __('Hide this update'), 'button', 'dismiss', false );
  85. else
  86. submit_button( __('Bring back this update'), 'button', 'undismiss', false );
  87. echo '</p>';
  88. if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
  89. 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>';
  90. // Partial builds don't need language-specific warnings.
  91. elseif ( 'en_US' == $update->locale && get_locale() != 'en_US' && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) {
  92. 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>';
  93. }
  94. echo '</form>';
  95. }
  96. function dismissed_updates() {
  97. $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
  98. if ( $dismissed ) {
  99. $show_text = esc_js(__('Show hidden updates'));
  100. $hide_text = esc_js(__('Hide hidden updates'));
  101. ?>
  102. <script type="text/javascript">
  103. jQuery(function($) {
  104. $('dismissed-updates').show();
  105. $('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
  106. $('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
  107. });
  108. </script>
  109. <?php
  110. echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
  111. echo '<ul id="dismissed-updates" class="core-updates dismissed">';
  112. foreach( (array) $dismissed as $update) {
  113. echo '<li>';
  114. list_core_update( $update );
  115. echo '</li>';
  116. }
  117. echo '</ul>';
  118. }
  119. }
  120. /**
  121. * Display upgrade WordPress for downloading latest or upgrading automatically form.
  122. *
  123. * @since 2.7.0
  124. *
  125. * @return null
  126. */
  127. function core_upgrade_preamble() {
  128. global $wp_version, $required_php_version, $required_mysql_version;
  129. $updates = get_core_updates();
  130. if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
  131. echo '<h3>';
  132. _e('You have the latest version of WordPress.');
  133. if ( wp_http_supports( array( 'ssl' ) ) ) {
  134. require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
  135. $upgrader = new WP_Automatic_Updater;
  136. $future_minor_update = (object) array(
  137. 'current' => $wp_version . '.1.next.minor',
  138. 'version' => $wp_version . '.1.next.minor',
  139. 'php_version' => $required_php_version,
  140. 'mysql_version' => $required_mysql_version,
  141. );
  142. $should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH );
  143. if ( $should_auto_update )
  144. echo ' ' . __( 'Future security updates will be applied automatically.' );
  145. }
  146. echo '</h3>';
  147. } else {
  148. echo '<div class="updated inline"><p>';
  149. _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.');
  150. echo '</p></div>';
  151. echo '<h3 class="response">';
  152. _e( 'An updated version of WordPress is available.' );
  153. echo '</h3>';
  154. }
  155. if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
  156. require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
  157. $upgrader = new WP_Automatic_Updater;
  158. if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) )
  159. echo '<div class="updated inline"><p><strong>BETA TESTERS:</strong> This site is set up to install updates of future beta versions automatically.</p></div>';
  160. }
  161. echo '<ul class="core-updates">';
  162. $alternate = true;
  163. foreach( (array) $updates as $update ) {
  164. echo '<li>';
  165. list_core_update( $update );
  166. echo '</li>';
  167. }
  168. echo '</ul>';
  169. // Don't show the maintenance mode notice when we are only showing a single re-install option.
  170. if ( $updates && ( count( $updates ) > 1 || $updates[0]->response != 'latest' ) ) {
  171. 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>';
  172. } elseif ( ! $updates ) {
  173. list( $normalized_version ) = explode( '-', $wp_version );
  174. echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>';
  175. }
  176. dismissed_updates();
  177. }
  178. function list_plugin_updates() {
  179. global $wp_version;
  180. $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
  181. require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
  182. $plugins = get_plugin_updates();
  183. if ( empty( $plugins ) ) {
  184. echo '<h3>' . __( 'Plugins' ) . '</h3>';
  185. echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
  186. return;
  187. }
  188. $form_action = 'update-core.php?action=do-plugin-upgrade';
  189. $core_updates = get_core_updates();
  190. 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, '=') )
  191. $core_update_version = false;
  192. else
  193. $core_update_version = $core_updates[0]->current;
  194. ?>
  195. <h3><?php _e( 'Plugins' ); ?></h3>
  196. <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>
  197. <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
  198. <?php wp_nonce_field('upgrade-core'); ?>
  199. <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
  200. <table class="widefat" id="update-plugins-table">
  201. <thead>
  202. <tr>
  203. <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
  204. <th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
  205. </tr>
  206. </thead>
  207. <tfoot>
  208. <tr>
  209. <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
  210. <th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></th>
  211. </tr>
  212. </tfoot>
  213. <tbody class="plugins">
  214. <?php
  215. foreach ( (array) $plugins as $plugin_file => $plugin_data) {
  216. $info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
  217. // Get plugin compat for running version of WordPress.
  218. if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
  219. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
  220. } elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
  221. $compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
  222. $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]);
  223. } else {
  224. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
  225. }
  226. // Get plugin compat for updated version of WordPress.
  227. if ( $core_update_version ) {
  228. if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
  229. $update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
  230. $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]);
  231. } else {
  232. $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
  233. }
  234. }
  235. // Get the upgrade notice for the new plugin version.
  236. if ( isset($plugin_data->update->upgrade_notice) ) {
  237. $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice);
  238. } else {
  239. $upgrade_notice = '';
  240. }
  241. $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');
  242. $details_text = sprintf(__('View version %1$s details'), $plugin_data->update->new_version);
  243. $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);
  244. echo "
  245. <tr>
  246. <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
  247. <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>
  248. </tr>";
  249. }
  250. ?>
  251. </tbody>
  252. </table>
  253. <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
  254. </form>
  255. <?php
  256. }
  257. function list_theme_updates() {
  258. $themes = get_theme_updates();
  259. if ( empty( $themes ) ) {
  260. echo '<h3>' . __( 'Themes' ) . '</h3>';
  261. echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
  262. return;
  263. }
  264. $form_action = 'update-core.php?action=do-theme-upgrade';
  265. ?>
  266. <h3><?php _e( 'Themes' ); ?></h3>
  267. <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>
  268. <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.' ), __( 'http://codex.wordpress.org/Child_Themes' ) ); ?></p>
  269. <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
  270. <?php wp_nonce_field('upgrade-core'); ?>
  271. <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
  272. <table class="widefat" id="update-themes-table">
  273. <thead>
  274. <tr>
  275. <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
  276. <th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
  277. </tr>
  278. </thead>
  279. <tfoot>
  280. <tr>
  281. <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
  282. <th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></th>
  283. </tr>
  284. </tfoot>
  285. <tbody class="plugins">
  286. <?php
  287. foreach ( $themes as $stylesheet => $theme ) {
  288. echo "
  289. <tr>
  290. <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' /></th>
  291. <td class='plugin-title'><img src='" . esc_url( $theme->get_screenshot() ) . "' width='85' 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>
  292. </tr>";
  293. }
  294. ?>
  295. </tbody>
  296. </table>
  297. <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
  298. </form>
  299. <?php
  300. }
  301. function list_translation_updates() {
  302. $updates = wp_get_translation_updates();
  303. if ( ! $updates ) {
  304. if ( 'en_US' != get_locale() ) {
  305. echo '<h3>' . __( 'Translations' ) . '</h3>';
  306. echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
  307. }
  308. return;
  309. }
  310. $form_action = 'update-core.php?action=do-translation-upgrade';
  311. ?>
  312. <h3><?php _e( 'Translations' ); ?></h3>
  313. <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
  314. <p><?php _e( 'Some of your translations are out of date.' ); ?></p>
  315. <?php wp_nonce_field('upgrade-translations'); ?>
  316. <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
  317. </form>
  318. <?php
  319. }
  320. /**
  321. * Upgrade WordPress core display.
  322. *
  323. * @since 2.7.0
  324. *
  325. * @return null
  326. */
  327. function do_core_upgrade( $reinstall = false ) {
  328. global $wp_filesystem;
  329. include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
  330. if ( $reinstall )
  331. $url = 'update-core.php?action=do-core-reinstall';
  332. else
  333. $url = 'update-core.php?action=do-core-upgrade';
  334. $url = wp_nonce_url($url, 'upgrade-core');
  335. $version = isset( $_POST['version'] )? $_POST['version'] : false;
  336. $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  337. $update = find_core_update( $version, $locale );
  338. if ( !$update )
  339. return;
  340. ?>
  341. <div class="wrap">
  342. <h2><?php _e('Update WordPress'); ?></h2>
  343. <?php
  344. if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH ) ) ) {
  345. echo '</div>';
  346. return;
  347. }
  348. if ( ! WP_Filesystem( $credentials, ABSPATH ) ) {
  349. // Failed to connect, Error and request again
  350. request_filesystem_credentials( $url, '', true, ABSPATH );
  351. echo '</div>';
  352. return;
  353. }
  354. if ( $wp_filesystem->errors->get_error_code() ) {
  355. foreach ( $wp_filesystem->errors->get_error_messages() as $message )
  356. show_message($message);
  357. echo '</div>';
  358. return;
  359. }
  360. if ( $reinstall )
  361. $update->response = 'reinstall';
  362. add_filter( 'update_feedback', 'show_message' );
  363. $upgrader = new Core_Upgrader();
  364. $result = $upgrader->upgrade( $update );
  365. if ( is_wp_error($result) ) {
  366. show_message($result);
  367. if ('up_to_date' != $result->get_error_code() )
  368. show_message( __('Installation Failed') );
  369. echo '</div>';
  370. return;
  371. }
  372. show_message( __('WordPress updated successfully') );
  373. 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="%2$s">here</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
  374. 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>' );
  375. ?>
  376. </div>
  377. <script type="text/javascript">
  378. window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
  379. </script>
  380. <?php
  381. }
  382. function do_dismiss_core_update() {
  383. $version = isset( $_POST['version'] )? $_POST['version'] : false;
  384. $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  385. $update = find_core_update( $version, $locale );
  386. if ( !$update )
  387. return;
  388. dismiss_core_update( $update );
  389. wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
  390. exit;
  391. }
  392. function do_undismiss_core_update() {
  393. $version = isset( $_POST['version'] )? $_POST['version'] : false;
  394. $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  395. $update = find_core_update( $version, $locale );
  396. if ( !$update )
  397. return;
  398. undismiss_core_update( $version, $locale );
  399. wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
  400. exit;
  401. }
  402. $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
  403. $upgrade_error = false;
  404. if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
  405. && ! isset( $_POST['checked'] ) ) {
  406. $upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
  407. $action = 'upgrade-core';
  408. }
  409. $title = __('WordPress Updates');
  410. $parent_file = 'index.php';
  411. $updates_overview = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes and plugins from the WordPress.org repositories.' ) . '</p>';
  412. $updates_overview .= '<p>' . __( 'If an update is available, you&#8127;ll see a notification appear in the Toolbar and navigation menu.' ) . ' ' . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' ) . '</p>';
  413. get_current_screen()->add_help_tab( array(
  414. 'id' => 'overview',
  415. 'title' => __( 'Overview' ),
  416. 'content' => $updates_overview
  417. ) );
  418. $updates_howto = '<p>' . __( '<strong>WordPress</strong> &mdash; Updating your WordPress installation is a simple one-click procedure: just <strong>click on the &#8220;Update Now&#8221; button</strong> when you are notified that a new version is available.' ) . ' ' . __( 'In most cases, WordPress will automatically apply maintenance and security updates in the background for you.' ) . '</p>';
  419. $updates_howto .= '<p>' . __( '<strong>Themes and Plugins</strong> &mdash; To update individual themes or plugins from this screen, use the checkboxes to make your selection, then <strong>click on the appropriate &#8220;Update&#8221; button</strong>. To update all of your themes or plugins at once, you can check the box at the top of the section to select all before clicking the update button.' ) . '</p>';
  420. if ( 'en_US' != get_locale() ) {
  421. $updates_howto .= '<p>' . __( '<strong>Translations</strong> &mdash; The files translating WordPress into your language are updated for you whenever any other updates occur. But if these files are out of date, you can <strong>click the &#8220;Update Translations&#8221;</strong> button.' ) . '</p>';
  422. }
  423. get_current_screen()->add_help_tab( array(
  424. 'id' => 'how-to-update',
  425. 'title' => __( 'How to Update' ),
  426. 'content' => $updates_howto
  427. ) );
  428. get_current_screen()->set_help_sidebar(
  429. '<p><strong>' . __('For more information:') . '</strong></p>' .
  430. '<p>' . __( '<a href="http://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>' ) . '</p>' .
  431. '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
  432. );
  433. if ( 'upgrade-core' == $action ) {
  434. // Force a update check when requested
  435. $force_check = ! empty( $_GET['force-check'] );
  436. wp_version_check( array(), $force_check );
  437. require_once(ABSPATH . 'wp-admin/admin-header.php');
  438. ?>
  439. <div class="wrap">
  440. <h2><?php _e('WordPress Updates'); ?></h2>
  441. <?php
  442. if ( $upgrade_error ) {
  443. echo '<div class="error"><p>';
  444. if ( $upgrade_error == 'themes' )
  445. _e('Please select one or more themes to update.');
  446. else
  447. _e('Please select one or more plugins to update.');
  448. echo '</p></div>';
  449. }
  450. echo '<p>';
  451. /* translators: %1 date, %2 time. */
  452. printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
  453. echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php?force-check=1') ) . '">' . __( 'Check Again' ) . '</a>';
  454. echo '</p>';
  455. if ( $core = current_user_can( 'update_core' ) )
  456. core_upgrade_preamble();
  457. if ( $plugins = current_user_can( 'update_plugins' ) )
  458. list_plugin_updates();
  459. if ( $themes = current_user_can( 'update_themes' ) )
  460. list_theme_updates();
  461. if ( $core || $plugins || $themes )
  462. list_translation_updates();
  463. unset( $core, $plugins, $themes );
  464. /**
  465. * Fires after the core, plugin, and theme update tables.
  466. *
  467. * @since 2.9.0
  468. */
  469. do_action( 'core_upgrade_preamble' );
  470. echo '</div>';
  471. include(ABSPATH . 'wp-admin/admin-footer.php');
  472. } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
  473. if ( ! current_user_can( 'update_core' ) )
  474. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  475. check_admin_referer('upgrade-core');
  476. // do the (un)dismiss actions before headers,
  477. // so that they can redirect
  478. if ( isset( $_POST['dismiss'] ) )
  479. do_dismiss_core_update();
  480. elseif ( isset( $_POST['undismiss'] ) )
  481. do_undismiss_core_update();
  482. require_once(ABSPATH . 'wp-admin/admin-header.php');
  483. if ( 'do-core-reinstall' == $action )
  484. $reinstall = true;
  485. else
  486. $reinstall = false;
  487. if ( isset( $_POST['upgrade'] ) )
  488. do_core_upgrade($reinstall);
  489. include(ABSPATH . 'wp-admin/admin-footer.php');
  490. } elseif ( 'do-plugin-upgrade' == $action ) {
  491. if ( ! current_user_can( 'update_plugins' ) )
  492. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  493. check_admin_referer('upgrade-core');
  494. if ( isset( $_GET['plugins'] ) ) {
  495. $plugins = explode( ',', $_GET['plugins'] );
  496. } elseif ( isset( $_POST['checked'] ) ) {
  497. $plugins = (array) $_POST['checked'];
  498. } else {
  499. wp_redirect( admin_url('update-core.php') );
  500. exit;
  501. }
  502. $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
  503. $url = wp_nonce_url($url, 'bulk-update-plugins');
  504. $title = __('Update Plugins');
  505. require_once(ABSPATH . 'wp-admin/admin-header.php');
  506. echo '<div class="wrap">';
  507. echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
  508. echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
  509. echo '</div>';
  510. include(ABSPATH . 'wp-admin/admin-footer.php');
  511. } elseif ( 'do-theme-upgrade' == $action ) {
  512. if ( ! current_user_can( 'update_themes' ) )
  513. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  514. check_admin_referer('upgrade-core');
  515. if ( isset( $_GET['themes'] ) ) {
  516. $themes = explode( ',', $_GET['themes'] );
  517. } elseif ( isset( $_POST['checked'] ) ) {
  518. $themes = (array) $_POST['checked'];
  519. } else {
  520. wp_redirect( admin_url('update-core.php') );
  521. exit;
  522. }
  523. $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
  524. $url = wp_nonce_url($url, 'bulk-update-themes');
  525. $title = __('Update Themes');
  526. require_once(ABSPATH . 'wp-admin/admin-header.php');
  527. echo '<div class="wrap">';
  528. echo '<h2>' . esc_html__('Update Themes') . '</h2>';
  529. echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
  530. echo '</div>';
  531. include(ABSPATH . 'wp-admin/admin-footer.php');
  532. } elseif ( 'do-translation-upgrade' == $action ) {
  533. if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) )
  534. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  535. check_admin_referer( 'upgrade-translations' );
  536. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  537. include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
  538. $url = 'update-core.php?action=do-translation-upgrade';
  539. $nonce = 'upgrade-translations';
  540. $title = __( 'Update Translations' );
  541. $context = WP_LANG_DIR;
  542. $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
  543. $result = $upgrader->bulk_upgrade();
  544. require_once( ABSPATH . 'wp-admin/admin-footer.php' );
  545. } else {
  546. /**
  547. * Fires for each custom update action on the WordPress Updates screen.
  548. *
  549. * The dynamic portion of the hook name, $action, refers to the
  550. * passed update action. The hook fires in lieu of all available
  551. * default update actions.
  552. *
  553. * @since 3.2.0
  554. */
  555. do_action( "update-core-custom_{$action}" );
  556. }