[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> update-core.php (source)

   1  <?php
   2  /**
   3   * Update Core administration panel.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /** WordPress Administration Bootstrap */
  10  require_once  __DIR__ . '/admin.php';
  11  
  12  wp_enqueue_style( 'plugin-install' );
  13  wp_enqueue_script( 'plugin-install' );
  14  wp_enqueue_script( 'updates' );
  15  add_thickbox();
  16  
  17  if ( is_multisite() && ! is_network_admin() ) {
  18      wp_redirect( network_admin_url( 'update-core.php' ) );
  19      exit;
  20  }
  21  
  22  if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) {
  23      wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
  24  }
  25  
  26  /**
  27   * Lists available core updates.
  28   *
  29   * @since 2.7.0
  30   *
  31   * @global string $wp_local_package Locale code of the package.
  32   * @global wpdb   $wpdb             WordPress database abstraction object.
  33   *
  34   * @param object $update
  35   */
  36  function list_core_update( $update ) {
  37      global $wp_local_package, $wpdb;
  38      static $first_pass = true;
  39  
  40      $wp_version     = get_bloginfo( 'version' );
  41      $version_string = sprintf( '%s&ndash;<strong>%s</strong>', $update->current, $update->locale );
  42  
  43      if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) {
  44          $version_string = $update->current;
  45      } elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) {
  46          $updates = get_core_updates();
  47          if ( $updates && 1 === count( $updates ) ) {
  48              // If the only available update is a partial builds, it doesn't need a language-specific version string.
  49              $version_string = $update->current;
  50          }
  51      }
  52  
  53      $current = false;
  54      if ( ! isset( $update->response ) || 'latest' === $update->response ) {
  55          $current = true;
  56      }
  57  
  58      $submit        = __( 'Update Now' );
  59      $form_action   = 'update-core.php?action=do-core-upgrade';
  60      $php_version   = phpversion();
  61      $mysql_version = $wpdb->db_version();
  62      $show_buttons  = true;
  63  
  64      if ( 'development' === $update->response ) {
  65          $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build automatically:' );
  66      } else {
  67          if ( $current ) {
  68              /* translators: %s: WordPress version. */
  69              $message     = sprintf( __( 'If you need to re-install version %s, you can do so here:' ), $version_string );
  70              $submit      = __( 'Re-install Now' );
  71              $form_action = 'update-core.php?action=do-core-reinstall';
  72          } else {
  73              $php_compat = version_compare( $php_version, $update->php_version, '>=' );
  74              if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
  75                  $mysql_compat = true;
  76              } else {
  77                  $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
  78              }
  79  
  80              $version_url = sprintf(
  81                  /* translators: %s: WordPress version. */
  82                  esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
  83                  sanitize_title( $update->current )
  84              );
  85  
  86              $php_update_message = '</p><p>' . sprintf(
  87                  /* translators: %s: URL to Update PHP page. */
  88                  __( '<a href="%s">Learn more about updating PHP</a>.' ),
  89                  esc_url( wp_get_update_php_url() )
  90              );
  91  
  92              $annotation = wp_get_update_php_annotation();
  93  
  94              if ( $annotation ) {
  95                  $php_update_message .= '</p><p><em>' . $annotation . '</em>';
  96              }
  97  
  98              if ( ! $mysql_compat && ! $php_compat ) {
  99                  $message = sprintf(
 100                      /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */
 101                      __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ),
 102                      $version_url,
 103                      $update->current,
 104                      $update->php_version,
 105                      $update->mysql_version,
 106                      $php_version,
 107                      $mysql_version
 108                  ) . $php_update_message;
 109              } elseif ( ! $php_compat ) {
 110                  $message = sprintf(
 111                      /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
 112                      __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ),
 113                      $version_url,
 114                      $update->current,
 115                      $update->php_version,
 116                      $php_version
 117                  ) . $php_update_message;
 118              } elseif ( ! $mysql_compat ) {
 119                  $message = sprintf(
 120                      /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
 121                      __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ),
 122                      $version_url,
 123                      $update->current,
 124                      $update->mysql_version,
 125                      $mysql_version
 126                  );
 127              } else {
 128                  $message = sprintf(
 129                      /* translators: 1: Installed WordPress version number, 2: URL to WordPress release notes, 3: New WordPress version number, including locale if necessary. */
 130                      __( 'You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> automatically:' ),
 131                      $wp_version,
 132                      $version_url,
 133                      $version_string
 134                  );
 135              }
 136  
 137              if ( ! $mysql_compat || ! $php_compat ) {
 138                  $show_buttons = false;
 139              }
 140          }
 141      }
 142  
 143      echo '<p>';
 144      echo $message;
 145      echo '</p>';
 146  
 147      echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
 148      wp_nonce_field( 'upgrade-core' );
 149  
 150      echo '<p>';
 151      echo '<input name="version" value="' . esc_attr( $update->current ) . '" type="hidden"/>';
 152      echo '<input name="locale" value="' . esc_attr( $update->locale ) . '" type="hidden"/>';
 153      if ( $show_buttons ) {
 154          if ( $first_pass ) {
 155              submit_button( $submit, $current ? '' : 'primary regular', 'upgrade', false );
 156              $first_pass = false;
 157          } else {
 158              submit_button( $submit, '', 'upgrade', false );
 159          }
 160      }
 161      if ( 'en_US' !== $update->locale ) {
 162          if ( ! isset( $update->dismissed ) || ! $update->dismissed ) {
 163              submit_button( __( 'Hide this update' ), '', 'dismiss', false );
 164          } else {
 165              submit_button( __( 'Bring back this update' ), '', 'undismiss', false );
 166          }
 167      }
 168      echo '</p>';
 169  
 170      if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package != $update->locale ) ) {
 171          echo '<p class="hint">' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '</p>';
 172      } elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) {
 173          // Partial builds don't need language-specific warnings.
 174          echo '<p class="hint">' . sprintf(
 175              /* translators: %s: WordPress version. */
 176              __( '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.' ),
 177              'development' !== $update->response ? $update->current : ''
 178          ) . '</p>';
 179      }
 180  
 181      echo '</form>';
 182  
 183  }
 184  
 185  /**
 186   * Display dismissed updates.
 187   *
 188   * @since 2.7.0
 189   */
 190  function dismissed_updates() {
 191      $dismissed = get_core_updates(
 192          array(
 193              'dismissed' => true,
 194              'available' => false,
 195          )
 196      );
 197      if ( $dismissed ) {
 198  
 199          $show_text = esc_js( __( 'Show hidden updates' ) );
 200          $hide_text = esc_js( __( 'Hide hidden updates' ) );
 201          ?>
 202      <script type="text/javascript">
 203          jQuery(function( $ ) {
 204              $( 'dismissed-updates' ).show();
 205              $( '#show-dismissed' ).toggle( function() { $( this ).text( '<?php echo $hide_text; ?>' ).attr( 'aria-expanded', 'true' ); }, function() { $( this ).text( '<?php echo $show_text; ?>' ).attr( 'aria-expanded', 'false' ); } );
 206              $( '#show-dismissed' ).click( function() { $( '#dismissed-updates' ).toggle( 'fast' ); } );
 207          });
 208      </script>
 209          <?php
 210          echo '<p class="hide-if-no-js"><button type="button" class="button" id="show-dismissed" aria-expanded="false">' . __( 'Show hidden updates' ) . '</button></p>';
 211          echo '<ul id="dismissed-updates" class="core-updates dismissed">';
 212          foreach ( (array) $dismissed as $update ) {
 213              echo '<li>';
 214              list_core_update( $update );
 215              echo '</li>';
 216          }
 217          echo '</ul>';
 218      }
 219  }
 220  
 221  /**
 222   * Display upgrade WordPress for downloading latest or upgrading automatically form.
 223   *
 224   * @since 2.7.0
 225   *
 226   * @global string $required_php_version   The required PHP version string.
 227   * @global string $required_mysql_version The required MySQL version string.
 228   */
 229  function core_upgrade_preamble() {
 230      global $required_php_version, $required_mysql_version;
 231  
 232      $wp_version = get_bloginfo( 'version' );
 233      $updates    = get_core_updates();
 234  
 235      if ( ! isset( $updates[0]->response ) || 'latest' === $updates[0]->response ) {
 236          echo '<h2>';
 237          _e( 'You have the latest version of WordPress.' );
 238  
 239          if ( wp_http_supports( array( 'ssl' ) ) ) {
 240              require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
 241              $upgrader            = new WP_Automatic_Updater;
 242              $future_minor_update = (object) array(
 243                  'current'       => $wp_version . '.1.next.minor',
 244                  'version'       => $wp_version . '.1.next.minor',
 245                  'php_version'   => $required_php_version,
 246                  'mysql_version' => $required_mysql_version,
 247              );
 248              $should_auto_update  = $upgrader->should_update( 'core', $future_minor_update, ABSPATH );
 249              if ( $should_auto_update ) {
 250                  echo ' ' . __( 'Future security updates will be applied automatically.' );
 251              }
 252          }
 253          echo '</h2>';
 254      }
 255  
 256      if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
 257          echo '<div class="notice notice-warning"><p>';
 258          printf(
 259              /* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
 260              __( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),
 261              __( 'https://wordpress.org/support/article/wordpress-backups/' ),
 262              __( 'https://wordpress.org/support/article/updating-wordpress/' )
 263          );
 264          echo '</p></div>';
 265  
 266          echo '<h2 class="response">';
 267          _e( 'An updated version of WordPress is available.' );
 268          echo '</h2>';
 269      }
 270  
 271      if ( isset( $updates[0] ) && 'development' === $updates[0]->response ) {
 272          require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
 273          $upgrader = new WP_Automatic_Updater;
 274          if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) {
 275              echo '<div class="updated inline"><p>';
 276              echo '<strong>' . __( 'BETA TESTERS:' ) . '</strong> ' . __( 'This site is set up to install updates of future beta versions automatically.' );
 277              echo '</p></div>';
 278          }
 279      }
 280  
 281      echo '<ul class="core-updates">';
 282      foreach ( (array) $updates as $update ) {
 283          echo '<li>';
 284          list_core_update( $update );
 285          echo '</li>';
 286      }
 287      echo '</ul>';
 288      // Don't show the maintenance mode notice when we are only showing a single re-install option.
 289      if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) {
 290          echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>';
 291      } elseif ( ! $updates ) {
 292          list( $normalized_version ) = explode( '-', $wp_version );
 293          echo '<p>' . sprintf(
 294              /* translators: 1: URL to About screen, 2: WordPress version. */
 295              __( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ),
 296              esc_url( self_admin_url( 'about.php' ) ),
 297              $normalized_version
 298          ) . '</p>';
 299      }
 300      dismissed_updates();
 301  }
 302  
 303  /**
 304   * Display WordPress auto-updates settings.
 305   *
 306   * @since 5.6.0
 307   */
 308  function core_auto_updates_settings() {
 309      $upgrade_major_value = '';
 310      if ( isset( $_POST['core-auto-updates-settings'] ) && wp_verify_nonce( $_POST['set_core_auto_updates_settings'], 'core-auto-updates-nonce' ) ) {
 311          if ( isset( $_POST['core-auto-updates-major'] ) && 1 === (int) $_POST['core-auto-updates-major'] ) {
 312              update_site_option( 'auto_update_core_major', 1 );
 313          } else {
 314              update_site_option( 'auto_update_core_major', 0 );
 315          }
 316          echo '<div class="notice notice-info is-dismissible"><p>';
 317          _e( 'WordPress auto-updates settings updated.' );
 318          echo '</p></div>';
 319      }
 320  
 321      $upgrade_dev   = get_site_option( 'auto_update_core_dev', true );
 322      $upgrade_minor = get_site_option( 'auto_update_core_minor', true );
 323      $upgrade_major = get_site_option( 'auto_update_core_major', false );
 324  
 325      if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
 326          if ( false === WP_AUTO_UPDATE_CORE ) {
 327              // Defaults to turned off, unless a filter allows it.
 328              $upgrade_dev   = false;
 329              $upgrade_minor = false;
 330              $upgrade_major = false;
 331          } elseif ( true === WP_AUTO_UPDATE_CORE ) {
 332              // ALL updates for core.
 333              $upgrade_dev   = true;
 334              $upgrade_minor = true;
 335              $upgrade_major = true;
 336          } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
 337              // Only minor updates for core.
 338              $upgrade_dev   = false;
 339              $upgrade_minor = true;
 340              $upgrade_major = false;
 341          }
 342      }
 343  
 344      $upgrade_dev   = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev );
 345      $upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
 346      $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major );
 347  
 348      $auto_update_settings = array(
 349          'dev'   => $upgrade_dev,
 350          'minor' => $upgrade_minor,
 351          'major' => $upgrade_major,
 352      );
 353      ?>
 354      <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" name="core-auto-updates" class="form-core-auto-updates">
 355          <?php wp_nonce_field( 'core-auto-updates-nonce', 'set_core_auto_updates_settings' ); ?>
 356          <h2><?php _e( 'Auto-update settings' ); ?></h2>
 357          <p>
 358              <?php
 359              if ( $auto_update_settings['major'] ) {
 360                  $wp_version = get_bloginfo( 'version' );
 361                  $updates    = get_core_updates();
 362                  if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
 363                      echo wp_get_auto_update_message();
 364                  }
 365              }
 366              ?>
 367          </p>
 368          <p>
 369              <input type="checkbox" name="core-auto-updates-major" id="core-auto-updates-major" value="1" <?php checked( $auto_update_settings['major'], 1 ); ?> />
 370              <label for="core-auto-updates-major">
 371                  <?php _e( 'Keep my site up-to-date with regular feature updates (major versions).' ); ?>
 372              </label>
 373          </p>
 374          <?php
 375          /**
 376           * Fires after the major core auto-update checkbox.
 377           *
 378           * @since 5.6.0
 379           */
 380          do_action( 'after_core_auto_updates_settings_fields', $auto_update_settings );
 381          ?>
 382          <p>
 383              <input id="core-auto-updates-settings" class="button" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" name="core-auto-updates-settings" />
 384          </p>
 385      </form>
 386      <?php
 387  }
 388  
 389  /**
 390   * Display the upgrade plugins form.
 391   *
 392   * @since 2.9.0
 393   */
 394  function list_plugin_updates() {
 395      $wp_version     = get_bloginfo( 'version' );
 396      $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
 397  
 398      require_once  ABSPATH . 'wp-admin/includes/plugin-install.php';
 399      $plugins = get_plugin_updates();
 400      if ( empty( $plugins ) ) {
 401          echo '<h2>' . __( 'Plugins' ) . '</h2>';
 402          echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
 403          return;
 404      }
 405      $form_action = 'update-core.php?action=do-plugin-upgrade';
 406  
 407      $core_updates = get_core_updates();
 408      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, '=' ) ) {
 409          $core_update_version = false;
 410      } else {
 411          $core_update_version = $core_updates[0]->current;
 412      }
 413      ?>
 414  <h2><?php _e( 'Plugins' ); ?></h2>
 415  <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>
 416  <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
 417      <?php wp_nonce_field( 'upgrade-core' ); ?>
 418  <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
 419  <table class="widefat updates-table" id="update-plugins-table">
 420      <thead>
 421      <tr>
 422          <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td>
 423          <td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td>
 424      </tr>
 425      </thead>
 426  
 427      <tbody class="plugins">
 428      <?php
 429  
 430      $auto_updates = array();
 431      if ( wp_is_auto_update_enabled_for_type( 'plugin' ) ) {
 432          $auto_updates       = (array) get_site_option( 'auto_update_plugins', array() );
 433          $auto_update_notice = ' | ' . wp_get_auto_update_message();
 434      }
 435  
 436      foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
 437          $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
 438  
 439          $icon            = '<span class="dashicons dashicons-admin-plugins"></span>';
 440          $preferred_icons = array( 'svg', '2x', '1x', 'default' );
 441          foreach ( $preferred_icons as $preferred_icon ) {
 442              if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) {
 443                  $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />';
 444                  break;
 445              }
 446          }
 447  
 448          // Get plugin compat for running version of WordPress.
 449          if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) {
 450              /* translators: %s: WordPress version. */
 451              $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $cur_wp_version );
 452          } else {
 453              /* translators: %s: WordPress version. */
 454              $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $cur_wp_version );
 455          }
 456          // Get plugin compat for updated version of WordPress.
 457          if ( $core_update_version ) {
 458              if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
 459                  /* translators: %s: WordPress version. */
 460                  $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $core_update_version );
 461              } else {
 462                  /* translators: %s: WordPress version. */
 463                  $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $core_update_version );
 464              }
 465          }
 466  
 467          $requires_php   = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null;
 468          $compatible_php = is_php_version_compatible( $requires_php );
 469  
 470          if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
 471              $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
 472              $compat .= sprintf(
 473                  /* translators: %s: URL to Update PHP page. */
 474                  __( '<a href="%s">Learn more about updating PHP</a>.' ),
 475                  esc_url( wp_get_update_php_url() )
 476              );
 477  
 478              $annotation = wp_get_update_php_annotation();
 479  
 480              if ( $annotation ) {
 481                  $compat .= '</p><p><em>' . $annotation . '</em>';
 482              }
 483          }
 484  
 485          // Get the upgrade notice for the new plugin version.
 486          if ( isset( $plugin_data->update->upgrade_notice ) ) {
 487              $upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice );
 488          } else {
 489              $upgrade_notice = '';
 490          }
 491  
 492          $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' );
 493          $details     = sprintf(
 494              '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
 495              esc_url( $details_url ),
 496              /* translators: 1: Plugin name, 2: Version number. */
 497              esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ),
 498              /* translators: %s: Plugin version. */
 499              sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version )
 500          );
 501  
 502          $checkbox_id = 'checkbox_' . md5( $plugin_data->Name );
 503          ?>
 504      <tr>
 505          <td class="check-column">
 506              <?php if ( $compatible_php ) : ?>
 507                  <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
 508                  <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
 509                      <?php
 510                      /* translators: %s: Plugin name. */
 511                      printf( __( 'Select %s' ), $plugin_data->Name );
 512                      ?>
 513                  </label>
 514              <?php endif; ?>
 515          </td>
 516          <td class="plugin-title"><p>
 517              <?php echo $icon; ?>
 518              <strong><?php echo $plugin_data->Name; ?></strong>
 519              <?php
 520              printf(
 521                  /* translators: 1: Plugin version, 2: New version. */
 522                  __( 'You have version %1$s installed. Update to %2$s.' ),
 523                  $plugin_data->Version,
 524                  $plugin_data->update->new_version
 525              );
 526  
 527              echo ' ' . $details . $compat . $upgrade_notice;
 528  
 529              if ( in_array( $plugin_file, $auto_updates, true ) ) {
 530                  echo $auto_update_notice;
 531              }
 532              ?>
 533          </p></td>
 534      </tr>
 535              <?php
 536      }
 537      ?>
 538      </tbody>
 539  
 540      <tfoot>
 541      <tr>
 542          <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></td>
 543          <td class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></td>
 544      </tr>
 545      </tfoot>
 546  </table>
 547  <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
 548  </form>
 549      <?php
 550  }
 551  
 552  /**
 553   * Display the upgrade themes form.
 554   *
 555   * @since 2.9.0
 556   */
 557  function list_theme_updates() {
 558      $themes = get_theme_updates();
 559      if ( empty( $themes ) ) {
 560          echo '<h2>' . __( 'Themes' ) . '</h2>';
 561          echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
 562          return;
 563      }
 564  
 565      $form_action = 'update-core.php?action=do-theme-upgrade';
 566      ?>
 567  <h2><?php _e( 'Themes' ); ?></h2>
 568  <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>
 569  <p>
 570      <?php
 571      printf(
 572          /* translators: %s: Link to documentation on child themes. */
 573          __( '<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.' ),
 574          __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' )
 575      );
 576      ?>
 577  </p>
 578  <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
 579      <?php wp_nonce_field( 'upgrade-core' ); ?>
 580  <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
 581  <table class="widefat updates-table" id="update-themes-table">
 582      <thead>
 583      <tr>
 584          <td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td>
 585          <td class="manage-column"><label for="themes-select-all"><?php _e( 'Select All' ); ?></label></td>
 586      </tr>
 587      </thead>
 588  
 589      <tbody class="plugins">
 590      <?php
 591      $auto_updates = array();
 592      if ( wp_is_auto_update_enabled_for_type( 'theme' ) ) {
 593          $auto_updates       = (array) get_site_option( 'auto_update_themes', array() );
 594          $auto_update_notice = ' | ' . wp_get_auto_update_message();
 595      }
 596  
 597      foreach ( $themes as $stylesheet => $theme ) {
 598          $requires_wp  = isset( $theme->update['requires'] ) ? $theme->update['requires'] : null;
 599          $requires_php = isset( $theme->update['requires_php'] ) ? $theme->update['requires_php'] : null;
 600  
 601          $compatible_wp  = is_wp_version_compatible( $requires_wp );
 602          $compatible_php = is_php_version_compatible( $requires_php );
 603  
 604          $compat = '';
 605  
 606          if ( ! $compatible_wp && ! $compatible_php ) {
 607              $compat .= '<br>' . __( 'This update doesn&#8217;t work with your versions of WordPress and PHP.' ) . '&nbsp;';
 608              if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 609                  $compat .= sprintf(
 610                      /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 611                      __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 612                      self_admin_url( 'update-core.php' ),
 613                      esc_url( wp_get_update_php_url() )
 614                  );
 615  
 616                  $annotation = wp_get_update_php_annotation();
 617  
 618                  if ( $annotation ) {
 619                      $compat .= '</p><p><em>' . $annotation . '</em>';
 620                  }
 621              } elseif ( current_user_can( 'update_core' ) ) {
 622                  $compat .= sprintf(
 623                      /* translators: %s: URL to WordPress Updates screen. */
 624                      __( '<a href="%s">Please update WordPress</a>.' ),
 625                      self_admin_url( 'update-core.php' )
 626                  );
 627              } elseif ( current_user_can( 'update_php' ) ) {
 628                  $compat .= sprintf(
 629                      /* translators: %s: URL to Update PHP page. */
 630                      __( '<a href="%s">Learn more about updating PHP</a>.' ),
 631                      esc_url( wp_get_update_php_url() )
 632                  );
 633  
 634                  $annotation = wp_get_update_php_annotation();
 635  
 636                  if ( $annotation ) {
 637                      $compat .= '</p><p><em>' . $annotation . '</em>';
 638                  }
 639              }
 640          } elseif ( ! $compatible_wp ) {
 641              $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of WordPress.' ) . '&nbsp;';
 642              if ( current_user_can( 'update_core' ) ) {
 643                  $compat .= sprintf(
 644                      /* translators: %s: URL to WordPress Updates screen. */
 645                      __( '<a href="%s">Please update WordPress</a>.' ),
 646                      self_admin_url( 'update-core.php' )
 647                  );
 648              }
 649          } elseif ( ! $compatible_php ) {
 650              $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
 651              if ( current_user_can( 'update_php' ) ) {
 652                  $compat .= sprintf(
 653                      /* translators: %s: URL to Update PHP page. */
 654                      __( '<a href="%s">Learn more about updating PHP</a>.' ),
 655                      esc_url( wp_get_update_php_url() )
 656                  );
 657  
 658                  $annotation = wp_get_update_php_annotation();
 659  
 660                  if ( $annotation ) {
 661                      $compat .= '</p><p><em>' . $annotation . '</em>';
 662                  }
 663              }
 664          }
 665  
 666          $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
 667          ?>
 668      <tr>
 669          <td class="check-column">
 670              <?php if ( $compatible_wp && $compatible_php ) : ?>
 671                  <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
 672                  <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
 673                      <?php
 674                      /* translators: %s: Theme name. */
 675                      printf( __( 'Select %s' ), $theme->display( 'Name' ) );
 676                      ?>
 677                  </label>
 678              <?php endif; ?>
 679          </td>
 680          <td class="plugin-title"><p>
 681              <img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
 682              <strong><?php echo $theme->display( 'Name' ); ?></strong>
 683              <?php
 684              printf(
 685                  /* translators: 1: Theme version, 2: New version. */
 686                  __( 'You have version %1$s installed. Update to %2$s.' ),
 687                  $theme->display( 'Version' ),
 688                  $theme->update['new_version']
 689              );
 690  
 691              echo ' ' . $compat;
 692  
 693              if ( in_array( $stylesheet, $auto_updates, true ) ) {
 694                  echo $auto_update_notice;
 695              }
 696              ?>
 697          </p></td>
 698      </tr>
 699              <?php
 700      }
 701      ?>
 702      </tbody>
 703  
 704      <tfoot>
 705      <tr>
 706          <td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td>
 707          <td class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></td>
 708      </tr>
 709      </tfoot>
 710  </table>
 711  <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
 712  </form>
 713      <?php
 714  }
 715  
 716  /**
 717   * Display the update translations form.
 718   *
 719   * @since 3.7.0
 720   */
 721  function list_translation_updates() {
 722      $updates = wp_get_translation_updates();
 723      if ( ! $updates ) {
 724          if ( 'en_US' !== get_locale() ) {
 725              echo '<h2>' . __( 'Translations' ) . '</h2>';
 726              echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
 727          }
 728          return;
 729      }
 730  
 731      $form_action = 'update-core.php?action=do-translation-upgrade';
 732      ?>
 733      <h2><?php _e( 'Translations' ); ?></h2>
 734      <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade">
 735          <p><?php _e( 'New translations are available.' ); ?></p>
 736          <?php wp_nonce_field( 'upgrade-translations' ); ?>
 737          <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
 738      </form>
 739      <?php
 740  }
 741  
 742  /**
 743   * Upgrade WordPress core display.
 744   *
 745   * @since 2.7.0
 746   *
 747   * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
 748   *
 749   * @param bool $reinstall
 750   */
 751  function do_core_upgrade( $reinstall = false ) {
 752      global $wp_filesystem;
 753  
 754      require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
 755  
 756      if ( $reinstall ) {
 757          $url = 'update-core.php?action=do-core-reinstall';
 758      } else {
 759          $url = 'update-core.php?action=do-core-upgrade';
 760      }
 761      $url = wp_nonce_url( $url, 'upgrade-core' );
 762  
 763      $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
 764      $locale  = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
 765      $update  = find_core_update( $version, $locale );
 766      if ( ! $update ) {
 767          return;
 768      }
 769  
 770      // Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
 771      // that it's safe to do so. This only happens when there are no new files to create.
 772      $allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
 773  
 774      ?>
 775      <div class="wrap">
 776      <h1><?php _e( 'Update WordPress' ); ?></h1>
 777      <?php
 778  
 779      $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
 780      if ( false === $credentials ) {
 781          echo '</div>';
 782          return;
 783      }
 784  
 785      if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
 786          // Failed to connect. Error and request again.
 787          request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
 788          echo '</div>';
 789          return;
 790      }
 791  
 792      if ( $wp_filesystem->errors->has_errors() ) {
 793          foreach ( $wp_filesystem->errors->get_error_messages() as $message ) {
 794              show_message( $message );
 795          }
 796          echo '</div>';
 797          return;
 798      }
 799  
 800      if ( $reinstall ) {
 801          $update->response = 'reinstall';
 802      }
 803  
 804      add_filter( 'update_feedback', 'show_message' );
 805  
 806      $upgrader = new Core_Upgrader();
 807      $result   = $upgrader->upgrade(
 808          $update,
 809          array(
 810              'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
 811          )
 812      );
 813  
 814      if ( is_wp_error( $result ) ) {
 815          show_message( $result );
 816          if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) {
 817              show_message( __( 'Installation failed.' ) );
 818          }
 819          echo '</div>';
 820          return;
 821      }
 822  
 823      show_message( __( 'WordPress updated successfully.' ) );
 824      show_message(
 825          '<span class="hide-if-no-js">' . sprintf(
 826              /* translators: 1: WordPress version, 2: URL to About screen. */
 827              __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ),
 828              $result,
 829              esc_url( self_admin_url( 'about.php?updated' ) )
 830          ) . '</span>'
 831      );
 832      show_message(
 833          '<span class="hide-if-js">' . sprintf(
 834              /* translators: 1: WordPress version, 2: URL to About screen. */
 835              __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ),
 836              $result,
 837              esc_url( self_admin_url( 'about.php?updated' ) )
 838          ) . '</span>'
 839      );
 840      ?>
 841      </div>
 842      <script type="text/javascript">
 843      window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
 844      </script>
 845      <?php
 846  }
 847  
 848  /**
 849   * Dismiss a core update.
 850   *
 851   * @since 2.7.0
 852   */
 853  function do_dismiss_core_update() {
 854      $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
 855      $locale  = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
 856      $update  = find_core_update( $version, $locale );
 857      if ( ! $update ) {
 858          return;
 859      }
 860      dismiss_core_update( $update );
 861      wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) );
 862      exit;
 863  }
 864  
 865  /**
 866   * Undismiss a core update.
 867   *
 868   * @since 2.7.0
 869   */
 870  function do_undismiss_core_update() {
 871      $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
 872      $locale  = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
 873      $update  = find_core_update( $version, $locale );
 874      if ( ! $update ) {
 875          return;
 876      }
 877      undismiss_core_update( $version, $locale );
 878      wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) );
 879      exit;
 880  }
 881  
 882  $action = isset( $_GET['action'] ) ? $_GET['action'] : 'upgrade-core';
 883  
 884  $upgrade_error = false;
 885  if ( ( 'do-theme-upgrade' === $action || ( 'do-plugin-upgrade' === $action && ! isset( $_GET['plugins'] ) ) )
 886      && ! isset( $_POST['checked'] ) ) {
 887      $upgrade_error = ( 'do-theme-upgrade' === $action ) ? 'themes' : 'plugins';
 888      $action        = 'upgrade-core';
 889  }
 890  
 891  $title       = __( 'WordPress Updates' );
 892  $parent_file = 'index.php';
 893  
 894  $updates_overview  = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes, plugins, and translations from the WordPress.org repositories.' ) . '</p>';
 895  $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>';
 896  
 897  get_current_screen()->add_help_tab(
 898      array(
 899          'id'      => 'overview',
 900          'title'   => __( 'Overview' ),
 901          'content' => $updates_overview,
 902      )
 903  );
 904  
 905  $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>';
 906  $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>';
 907  
 908  if ( 'en_US' !== get_locale() ) {
 909      $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>';
 910  }
 911  
 912  get_current_screen()->add_help_tab(
 913      array(
 914          'id'      => 'how-to-update',
 915          'title'   => __( 'How to Update' ),
 916          'content' => $updates_howto,
 917      )
 918  );
 919  
 920  $help_sidebar_autoupdates = '';
 921  
 922  if ( ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) || ( current_user_can( 'update_plugins' ) && wp_is_auto_update_enabled_for_type( 'plugin' ) ) ) {
 923      $help_tab_autoupdates  = '<p>' . __( 'Auto-updates can be enabled or disabled for each individual theme or plugin. Themes or plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>';
 924      $help_tab_autoupdates .= '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>';
 925  
 926      get_current_screen()->add_help_tab(
 927          array(
 928              'id'      => 'plugins-themes-auto-updates',
 929              'title'   => __( 'Auto-updates' ),
 930              'content' => $help_tab_autoupdates,
 931          )
 932      );
 933  
 934      $help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>';
 935  }
 936  
 937  get_current_screen()->set_help_sidebar(
 938      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 939      '<p>' . __( '<a href="https://wordpress.org/support/article/dashboard-updates-screen/">Documentation on Updating WordPress</a>' ) . '</p>' .
 940      $help_sidebar_autoupdates .
 941      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 942  );
 943  
 944  if ( 'upgrade-core' === $action ) {
 945      // Force a update check when requested.
 946      $force_check = ! empty( $_GET['force-check'] );
 947      wp_version_check( array(), $force_check );
 948  
 949      require_once  ABSPATH . 'wp-admin/admin-header.php';
 950      ?>
 951      <div class="wrap">
 952      <h1><?php _e( 'WordPress Updates' ); ?></h1>
 953      <?php
 954      if ( $upgrade_error ) {
 955          echo '<div class="error"><p>';
 956          if ( 'themes' === $upgrade_error ) {
 957              _e( 'Please select one or more themes to update.' );
 958          } else {
 959              _e( 'Please select one or more plugins to update.' );
 960          }
 961          echo '</p></div>';
 962      }
 963  
 964      $last_update_check = false;
 965      $current           = get_site_transient( 'update_core' );
 966  
 967      if ( $current && isset( $current->last_checked ) ) {
 968          $last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
 969      }
 970  
 971      echo '<p>';
 972      /* translators: 1: Date, 2: Time. */
 973      printf( __( 'Last checked on %1$s at %2$s.' ), date_i18n( __( 'F j, Y' ), $last_update_check ), date_i18n( __( 'g:i a' ), $last_update_check ) );
 974      echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check Again' ) . '</a>';
 975      echo '</p>';
 976  
 977      if ( current_user_can( 'update_core' ) ) {
 978          core_upgrade_preamble();
 979          core_auto_updates_settings();
 980      }
 981      if ( current_user_can( 'update_plugins' ) ) {
 982          list_plugin_updates();
 983      }
 984      if ( current_user_can( 'update_themes' ) ) {
 985          list_theme_updates();
 986      }
 987      if ( current_user_can( 'update_languages' ) ) {
 988          list_translation_updates();
 989      }
 990  
 991      /**
 992       * Fires after the core, plugin, and theme update tables.
 993       *
 994       * @since 2.9.0
 995       */
 996      do_action( 'core_upgrade_preamble' );
 997      echo '</div>';
 998  
 999      wp_localize_script(
1000          'updates',
1001          '_wpUpdatesItemCounts',
1002          array(
1003              'totals' => wp_get_update_data(),
1004          )
1005      );
1006  
1007      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1008  
1009  } elseif ( 'do-core-upgrade' === $action || 'do-core-reinstall' === $action ) {
1010  
1011      if ( ! current_user_can( 'update_core' ) ) {
1012          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1013      }
1014  
1015      check_admin_referer( 'upgrade-core' );
1016  
1017      // Do the (un)dismiss actions before headers, so that they can redirect.
1018      if ( isset( $_POST['dismiss'] ) ) {
1019          do_dismiss_core_update();
1020      } elseif ( isset( $_POST['undismiss'] ) ) {
1021          do_undismiss_core_update();
1022      }
1023  
1024      require_once  ABSPATH . 'wp-admin/admin-header.php';
1025      if ( 'do-core-reinstall' === $action ) {
1026          $reinstall = true;
1027      } else {
1028          $reinstall = false;
1029      }
1030  
1031      if ( isset( $_POST['upgrade'] ) ) {
1032          do_core_upgrade( $reinstall );
1033      }
1034  
1035      wp_localize_script(
1036          'updates',
1037          '_wpUpdatesItemCounts',
1038          array(
1039              'totals' => wp_get_update_data(),
1040          )
1041      );
1042  
1043      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1044  
1045  } elseif ( 'do-plugin-upgrade' === $action ) {
1046  
1047      if ( ! current_user_can( 'update_plugins' ) ) {
1048          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1049      }
1050  
1051      check_admin_referer( 'upgrade-core' );
1052  
1053      if ( isset( $_GET['plugins'] ) ) {
1054          $plugins = explode( ',', $_GET['plugins'] );
1055      } elseif ( isset( $_POST['checked'] ) ) {
1056          $plugins = (array) $_POST['checked'];
1057      } else {
1058          wp_redirect( admin_url( 'update-core.php' ) );
1059          exit;
1060      }
1061  
1062      $url = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) );
1063      $url = wp_nonce_url( $url, 'bulk-update-plugins' );
1064  
1065      $title = __( 'Update Plugins' );
1066  
1067      require_once  ABSPATH . 'wp-admin/admin-header.php';
1068      echo '<div class="wrap">';
1069      echo '<h1>' . __( 'Update Plugins' ) . '</h1>';
1070      echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="' . esc_attr__( 'Update progress' ) . '"></iframe>';
1071      echo '</div>';
1072  
1073      wp_localize_script(
1074          'updates',
1075          '_wpUpdatesItemCounts',
1076          array(
1077              'totals' => wp_get_update_data(),
1078          )
1079      );
1080  
1081      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1082  
1083  } elseif ( 'do-theme-upgrade' === $action ) {
1084  
1085      if ( ! current_user_can( 'update_themes' ) ) {
1086          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1087      }
1088  
1089      check_admin_referer( 'upgrade-core' );
1090  
1091      if ( isset( $_GET['themes'] ) ) {
1092          $themes = explode( ',', $_GET['themes'] );
1093      } elseif ( isset( $_POST['checked'] ) ) {
1094          $themes = (array) $_POST['checked'];
1095      } else {
1096          wp_redirect( admin_url( 'update-core.php' ) );
1097          exit;
1098      }
1099  
1100      $url = 'update.php?action=update-selected-themes&themes=' . urlencode( implode( ',', $themes ) );
1101      $url = wp_nonce_url( $url, 'bulk-update-themes' );
1102  
1103      $title = __( 'Update Themes' );
1104  
1105      require_once  ABSPATH . 'wp-admin/admin-header.php';
1106      ?>
1107      <div class="wrap">
1108          <h1><?php _e( 'Update Themes' ); ?></h1>
1109          <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe>
1110      </div>
1111      <?php
1112  
1113      wp_localize_script(
1114          'updates',
1115          '_wpUpdatesItemCounts',
1116          array(
1117              'totals' => wp_get_update_data(),
1118          )
1119      );
1120  
1121      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1122  
1123  } elseif ( 'do-translation-upgrade' === $action ) {
1124  
1125      if ( ! current_user_can( 'update_languages' ) ) {
1126          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1127      }
1128  
1129      check_admin_referer( 'upgrade-translations' );
1130  
1131      require_once  ABSPATH . 'wp-admin/admin-header.php';
1132      require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1133  
1134      $url     = 'update-core.php?action=do-translation-upgrade';
1135      $nonce   = 'upgrade-translations';
1136      $title   = __( 'Update Translations' );
1137      $context = WP_LANG_DIR;
1138  
1139      $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
1140      $result   = $upgrader->bulk_upgrade();
1141  
1142      wp_localize_script(
1143          'updates',
1144          '_wpUpdatesItemCounts',
1145          array(
1146              'totals' => wp_get_update_data(),
1147          )
1148      );
1149  
1150      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1151  
1152  } else {
1153      /**
1154       * Fires for each custom update action on the WordPress Updates screen.
1155       *
1156       * The dynamic portion of the hook name, `$action`, refers to the
1157       * passed update action. The hook fires in lieu of all available
1158       * default update actions.
1159       *
1160       * @since 3.2.0
1161       */
1162      do_action( "update-core-custom_{$action}" );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
1163  }


Generated : Thu Oct 22 08:20:02 2020 Cross-referenced by PHPXref