PageRenderTime 70ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-admin/update-core.php

https://gitlab.com/manikapali/narendraphoto
PHP | 661 lines | 520 code | 94 blank | 47 comment | 139 complexity | 75c977ae43d7215f48fa3b44c080ab81 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( 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="https://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="https://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="https://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="https://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="https://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="https://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>';
  160. echo '<strong>' . __( 'BETA TESTERS:' ) . '</strong> ' . __( 'This site is set up to install updates of future beta versions automatically.' );
  161. echo '</p></div>';
  162. }
  163. }
  164. echo '<ul class="core-updates">';
  165. foreach( (array) $updates as $update ) {
  166. echo '<li>';
  167. list_core_update( $update );
  168. echo '</li>';
  169. }
  170. echo '</ul>';
  171. // Don't show the maintenance mode notice when we are only showing a single re-install option.
  172. if ( $updates && ( count( $updates ) > 1 || $updates[0]->response != 'latest' ) ) {
  173. 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>';
  174. } elseif ( ! $updates ) {
  175. list( $normalized_version ) = explode( '-', $wp_version );
  176. echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>';
  177. }
  178. dismissed_updates();
  179. }
  180. function list_plugin_updates() {
  181. global $wp_version;
  182. $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
  183. require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
  184. $plugins = get_plugin_updates();
  185. if ( empty( $plugins ) ) {
  186. echo '<h3>' . __( 'Plugins' ) . '</h3>';
  187. echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
  188. return;
  189. }
  190. $form_action = 'update-core.php?action=do-plugin-upgrade';
  191. $core_updates = get_core_updates();
  192. 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, '=') )
  193. $core_update_version = false;
  194. else
  195. $core_update_version = $core_updates[0]->current;
  196. ?>
  197. <h3><?php _e( 'Plugins' ); ?></h3>
  198. <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>
  199. <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
  200. <?php wp_nonce_field('upgrade-core'); ?>
  201. <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
  202. <table class="widefat" id="update-plugins-table">
  203. <thead>
  204. <tr>
  205. <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
  206. <th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
  207. </tr>
  208. </thead>
  209. <tbody class="plugins">
  210. <?php
  211. foreach ( (array) $plugins as $plugin_file => $plugin_data) {
  212. $info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
  213. if ( is_wp_error( $info ) ) {
  214. $info = false;
  215. }
  216. // Get plugin compat for running version of WordPress.
  217. if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
  218. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
  219. } elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
  220. $compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
  221. $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]);
  222. } else {
  223. $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
  224. }
  225. // Get plugin compat for updated version of WordPress.
  226. if ( $core_update_version ) {
  227. if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
  228. $update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
  229. $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]);
  230. } else {
  231. $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
  232. }
  233. }
  234. // Get the upgrade notice for the new plugin version.
  235. if ( isset($plugin_data->update->upgrade_notice) ) {
  236. $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice);
  237. } else {
  238. $upgrade_notice = '';
  239. }
  240. $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');
  241. $details_text = sprintf(__('View version %1$s details'), $plugin_data->update->new_version);
  242. $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);
  243. echo "
  244. <tr>
  245. <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
  246. <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>
  247. </tr>";
  248. }
  249. ?>
  250. </tbody>
  251. <tfoot>
  252. <tr>
  253. <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
  254. <th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></th>
  255. </tr>
  256. </tfoot>
  257. </table>
  258. <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
  259. </form>
  260. <?php
  261. }
  262. function list_theme_updates() {
  263. $themes = get_theme_updates();
  264. if ( empty( $themes ) ) {
  265. echo '<h3>' . __( 'Themes' ) . '</h3>';
  266. echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
  267. return;
  268. }
  269. $form_action = 'update-core.php?action=do-theme-upgrade';
  270. ?>
  271. <h3><?php _e( 'Themes' ); ?></h3>
  272. <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>
  273. <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.' ), __( 'https://codex.wordpress.org/Child_Themes' ) ); ?></p>
  274. <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
  275. <?php wp_nonce_field('upgrade-core'); ?>
  276. <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
  277. <table class="widefat" id="update-themes-table">
  278. <thead>
  279. <tr>
  280. <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
  281. <th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
  282. </tr>
  283. </thead>
  284. <tbody class="plugins">
  285. <?php
  286. foreach ( $themes as $stylesheet => $theme ) {
  287. echo "
  288. <tr>
  289. <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' /></th>
  290. <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>
  291. </tr>";
  292. }
  293. ?>
  294. </tbody>
  295. <tfoot>
  296. <tr>
  297. <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
  298. <th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></th>
  299. </tr>
  300. </tfoot>
  301. </table>
  302. <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
  303. </form>
  304. <?php
  305. }
  306. function list_translation_updates() {
  307. $updates = wp_get_translation_updates();
  308. if ( ! $updates ) {
  309. if ( 'en_US' != get_locale() ) {
  310. echo '<h3>' . __( 'Translations' ) . '</h3>';
  311. echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
  312. }
  313. return;
  314. }
  315. $form_action = 'update-core.php?action=do-translation-upgrade';
  316. ?>
  317. <h3><?php _e( 'Translations' ); ?></h3>
  318. <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade">
  319. <p><?php _e( 'New translations are available.' ); ?></p>
  320. <?php wp_nonce_field( 'upgrade-translations' ); ?>
  321. <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
  322. </form>
  323. <?php
  324. }
  325. /**
  326. * Upgrade WordPress core display.
  327. *
  328. * @since 2.7.0
  329. *
  330. * @return null
  331. */
  332. function do_core_upgrade( $reinstall = false ) {
  333. global $wp_filesystem;
  334. include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
  335. if ( $reinstall )
  336. $url = 'update-core.php?action=do-core-reinstall';
  337. else
  338. $url = 'update-core.php?action=do-core-upgrade';
  339. $url = wp_nonce_url($url, 'upgrade-core');
  340. $version = isset( $_POST['version'] )? $_POST['version'] : false;
  341. $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  342. $update = find_core_update( $version, $locale );
  343. if ( !$update )
  344. return;
  345. // Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
  346. // that it's safe to do so. This only happens when there are no new files to create.
  347. $allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
  348. ?>
  349. <div class="wrap">
  350. <h2><?php _e('Update WordPress'); ?></h2>
  351. <?php
  352. if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) {
  353. echo '</div>';
  354. return;
  355. }
  356. if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
  357. // Failed to connect, Error and request again
  358. request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
  359. echo '</div>';
  360. return;
  361. }
  362. if ( $wp_filesystem->errors->get_error_code() ) {
  363. foreach ( $wp_filesystem->errors->get_error_messages() as $message )
  364. show_message($message);
  365. echo '</div>';
  366. return;
  367. }
  368. if ( $reinstall )
  369. $update->response = 'reinstall';
  370. add_filter( 'update_feedback', 'show_message' );
  371. $upgrader = new Core_Upgrader();
  372. $result = $upgrader->upgrade( $update, array(
  373. 'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership
  374. ) );
  375. if ( is_wp_error($result) ) {
  376. show_message($result);
  377. if ('up_to_date' != $result->get_error_code() )
  378. show_message( __('Installation Failed') );
  379. echo '</div>';
  380. return;
  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="%2$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
  391. }
  392. function do_dismiss_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. dismiss_core_update( $update );
  399. wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
  400. exit;
  401. }
  402. function do_undismiss_core_update() {
  403. $version = isset( $_POST['version'] )? $_POST['version'] : false;
  404. $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  405. $update = find_core_update( $version, $locale );
  406. if ( !$update )
  407. return;
  408. undismiss_core_update( $version, $locale );
  409. wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
  410. exit;
  411. }
  412. $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
  413. $upgrade_error = false;
  414. if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
  415. && ! isset( $_POST['checked'] ) ) {
  416. $upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
  417. $action = 'upgrade-core';
  418. }
  419. $title = __('WordPress Updates');
  420. $parent_file = 'index.php';
  421. $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>';
  422. $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>';
  423. get_current_screen()->add_help_tab( array(
  424. 'id' => 'overview',
  425. 'title' => __( 'Overview' ),
  426. 'content' => $updates_overview
  427. ) );
  428. $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>';
  429. $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>';
  430. if ( 'en_US' != get_locale() ) {
  431. $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>';
  432. }
  433. get_current_screen()->add_help_tab( array(
  434. 'id' => 'how-to-update',
  435. 'title' => __( 'How to Update' ),
  436. 'content' => $updates_howto
  437. ) );
  438. get_current_screen()->set_help_sidebar(
  439. '<p><strong>' . __('For more information:') . '</strong></p>' .
  440. '<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>' ) . '</p>' .
  441. '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
  442. );
  443. if ( 'upgrade-core' == $action ) {
  444. // Force a update check when requested
  445. $force_check = ! empty( $_GET['force-check'] );
  446. wp_version_check( array(), $force_check );
  447. require_once(ABSPATH . 'wp-admin/admin-header.php');
  448. ?>
  449. <div class="wrap">
  450. <h2><?php _e('WordPress Updates'); ?></h2>
  451. <?php
  452. if ( $upgrade_error ) {
  453. echo '<div class="error"><p>';
  454. if ( $upgrade_error == 'themes' )
  455. _e('Please select one or more themes to update.');
  456. else
  457. _e('Please select one or more plugins to update.');
  458. echo '</p></div>';
  459. }
  460. echo '<p>';
  461. /* translators: %1 date, %2 time. */
  462. printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
  463. echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php?force-check=1') ) . '">' . __( 'Check Again' ) . '</a>';
  464. echo '</p>';
  465. if ( $core = current_user_can( 'update_core' ) )
  466. core_upgrade_preamble();
  467. if ( $plugins = current_user_can( 'update_plugins' ) )
  468. list_plugin_updates();
  469. if ( $themes = current_user_can( 'update_themes' ) )
  470. list_theme_updates();
  471. if ( $core || $plugins || $themes )
  472. list_translation_updates();
  473. unset( $core, $plugins, $themes );
  474. /**
  475. * Fires after the core, plugin, and theme update tables.
  476. *
  477. * @since 2.9.0
  478. */
  479. do_action( 'core_upgrade_preamble' );
  480. echo '</div>';
  481. include(ABSPATH . 'wp-admin/admin-footer.php');
  482. } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
  483. if ( ! current_user_can( 'update_core' ) )
  484. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  485. check_admin_referer('upgrade-core');
  486. // Do the (un)dismiss actions before headers, so that they can redirect.
  487. if ( isset( $_POST['dismiss'] ) )
  488. do_dismiss_core_update();
  489. elseif ( isset( $_POST['undismiss'] ) )
  490. do_undismiss_core_update();
  491. require_once(ABSPATH . 'wp-admin/admin-header.php');
  492. if ( 'do-core-reinstall' == $action )
  493. $reinstall = true;
  494. else
  495. $reinstall = false;
  496. if ( isset( $_POST['upgrade'] ) )
  497. do_core_upgrade($reinstall);
  498. include(ABSPATH . 'wp-admin/admin-footer.php');
  499. } elseif ( 'do-plugin-upgrade' == $action ) {
  500. if ( ! current_user_can( 'update_plugins' ) )
  501. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  502. check_admin_referer('upgrade-core');
  503. if ( isset( $_GET['plugins'] ) ) {
  504. $plugins = explode( ',', $_GET['plugins'] );
  505. } elseif ( isset( $_POST['checked'] ) ) {
  506. $plugins = (array) $_POST['checked'];
  507. } else {
  508. wp_redirect( admin_url('update-core.php') );
  509. exit;
  510. }
  511. $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
  512. $url = wp_nonce_url($url, 'bulk-update-plugins');
  513. $title = __('Update Plugins');
  514. require_once(ABSPATH . 'wp-admin/admin-header.php');
  515. echo '<div class="wrap">';
  516. echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
  517. echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>';
  518. echo '</div>';
  519. include(ABSPATH . 'wp-admin/admin-footer.php');
  520. } elseif ( 'do-theme-upgrade' == $action ) {
  521. if ( ! current_user_can( 'update_themes' ) )
  522. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  523. check_admin_referer('upgrade-core');
  524. if ( isset( $_GET['themes'] ) ) {
  525. $themes = explode( ',', $_GET['themes'] );
  526. } elseif ( isset( $_POST['checked'] ) ) {
  527. $themes = (array) $_POST['checked'];
  528. } else {
  529. wp_redirect( admin_url('update-core.php') );
  530. exit;
  531. }
  532. $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
  533. $url = wp_nonce_url($url, 'bulk-update-themes');
  534. $title = __('Update Themes');
  535. require_once(ABSPATH . 'wp-admin/admin-header.php');
  536. ?>
  537. <div class="wrap">
  538. <h2><?php echo esc_html__('Update Themes') ?></h2>
  539. <iframe src="<?php echo $url ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>
  540. </div>
  541. <?php
  542. include(ABSPATH . 'wp-admin/admin-footer.php');
  543. } elseif ( 'do-translation-upgrade' == $action ) {
  544. if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) )
  545. wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
  546. check_admin_referer( 'upgrade-translations' );
  547. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  548. include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
  549. $url = 'update-core.php?action=do-translation-upgrade';
  550. $nonce = 'upgrade-translations';
  551. $title = __( 'Update Translations' );
  552. $context = WP_LANG_DIR;
  553. $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
  554. $result = $upgrader->bulk_upgrade();
  555. require_once( ABSPATH . 'wp-admin/admin-footer.php' );
  556. } else {
  557. /**
  558. * Fires for each custom update action on the WordPress Updates screen.
  559. *
  560. * The dynamic portion of the hook name, `$action`, refers to the
  561. * passed update action. The hook fires in lieu of all available
  562. * default update actions.
  563. *
  564. * @since 3.2.0
  565. */
  566. do_action( "update-core-custom_{$action}" );
  567. }