[ 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     = wp_get_wp_version();
  41      $version_string = sprintf( '%s&ndash;%s', $update->current, get_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      } elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() ) {
  52          $version_string = sprintf( '%s&ndash;%s', $update->current, $update->locale );
  53      }
  54  
  55      $current = false;
  56      if ( ! isset( $update->response ) || 'latest' === $update->response ) {
  57          $current = true;
  58      }
  59  
  60      $message       = '';
  61      $form_action   = 'update-core.php?action=do-core-upgrade';
  62      $php_version   = PHP_VERSION;
  63      $mysql_version = $wpdb->db_version();
  64      $show_buttons  = true;
  65  
  66      // Nightly build versions have two hyphens and a commit number.
  67      if ( preg_match( '/-\w+-\d+/', $update->current ) ) {
  68          // Retrieve the major version number.
  69          preg_match( '/^\d+.\d+/', $update->current, $update_major );
  70          /* translators: %s: WordPress version. */
  71          $submit = sprintf( __( 'Update to latest %s nightly' ), $update_major[0] );
  72      } else {
  73          /* translators: %s: WordPress version. */
  74          $submit = sprintf( __( 'Update to version %s' ), $version_string );
  75      }
  76  
  77      if ( 'development' === $update->response ) {
  78          $message = __( 'You can update to the latest nightly build manually:' );
  79      } else {
  80          if ( $current ) {
  81              /* translators: %s: WordPress version. */
  82              $submit      = sprintf( __( 'Re-install version %s' ), $version_string );
  83              $form_action = 'update-core.php?action=do-core-reinstall';
  84          } else {
  85              $php_compat = version_compare( $php_version, $update->php_version, '>=' );
  86              if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
  87                  $mysql_compat = true;
  88              } else {
  89                  $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
  90              }
  91  
  92              $version_url = sprintf(
  93                  /* translators: %s: WordPress version. */
  94                  esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ),
  95                  sanitize_title( $update->current )
  96              );
  97  
  98              $php_update_message = '</p><p>' . sprintf(
  99                  /* translators: %s: URL to Update PHP page. */
 100                  __( '<a href="%s">Learn more about updating PHP</a>.' ),
 101                  esc_url( wp_get_update_php_url() )
 102              );
 103  
 104              $annotation = wp_get_update_php_annotation();
 105  
 106              if ( $annotation ) {
 107                  $php_update_message .= '</p><p><em>' . $annotation . '</em>';
 108              }
 109  
 110              if ( ! $mysql_compat && ! $php_compat ) {
 111                  $message = sprintf(
 112                      /* 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. */
 113                      __( '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.' ),
 114                      $version_url,
 115                      $update->current,
 116                      $update->php_version,
 117                      $update->mysql_version,
 118                      $php_version,
 119                      $mysql_version
 120                  ) . $php_update_message;
 121              } elseif ( ! $php_compat ) {
 122                  $message = sprintf(
 123                      /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
 124                      __( '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.' ),
 125                      $version_url,
 126                      $update->current,
 127                      $update->php_version,
 128                      $php_version
 129                  ) . $php_update_message;
 130              } elseif ( ! $mysql_compat ) {
 131                  $message = sprintf(
 132                      /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
 133                      __( '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.' ),
 134                      $version_url,
 135                      $update->current,
 136                      $update->mysql_version,
 137                      $mysql_version
 138                  );
 139              } else {
 140                  $message = sprintf(
 141                      /* translators: 1: Installed WordPress version number, 2: URL to WordPress release notes, 3: New WordPress version number, including locale if necessary. */
 142                      __( 'You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> manually:' ),
 143                      $wp_version,
 144                      $version_url,
 145                      $version_string
 146                  );
 147              }
 148  
 149              if ( ! $mysql_compat || ! $php_compat ) {
 150                  $show_buttons = false;
 151              }
 152          }
 153      }
 154  
 155      echo '<p>';
 156      echo $message;
 157      echo '</p>';
 158  
 159      echo '<form method="post" action="' . esc_url( $form_action ) . '" name="upgrade" class="upgrade">';
 160      wp_nonce_field( 'upgrade-core' );
 161  
 162      echo '<p>';
 163      echo '<input name="version" value="' . esc_attr( $update->current ) . '" type="hidden" />';
 164      echo '<input name="locale" value="' . esc_attr( $update->locale ) . '" type="hidden" />';
 165      if ( $show_buttons ) {
 166          if ( $first_pass ) {
 167              submit_button( $submit, $current ? '' : 'primary regular', 'upgrade', false );
 168              $first_pass = false;
 169          } else {
 170              submit_button( $submit, '', 'upgrade', false );
 171          }
 172      }
 173      if ( 'en_US' !== $update->locale ) {
 174          if ( ! isset( $update->dismissed ) || ! $update->dismissed ) {
 175              submit_button( __( 'Hide this update' ), '', 'dismiss', false );
 176          } else {
 177              submit_button( __( 'Bring back this update' ), '', 'undismiss', false );
 178          }
 179      }
 180      echo '</p>';
 181  
 182      if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package !== $update->locale ) ) {
 183          echo '<p class="hint">' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '</p>';
 184      } elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version === $update->partial_version ) ) {
 185          // Partial builds don't need language-specific warnings.
 186          echo '<p class="hint">' . sprintf(
 187              /* translators: %s: WordPress version. */
 188              __( '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.' ),
 189              'development' !== $update->response ? $update->current : ''
 190          ) . '</p>';
 191      }
 192  
 193      echo '</form>';
 194  }
 195  
 196  /**
 197   * Display dismissed updates.
 198   *
 199   * @since 2.7.0
 200   */
 201  function dismissed_updates() {
 202      $dismissed = get_core_updates(
 203          array(
 204              'dismissed' => true,
 205              'available' => false,
 206          )
 207      );
 208  
 209      if ( $dismissed ) {
 210          $show_text = esc_js( __( 'Show hidden updates' ) );
 211          $hide_text = esc_js( __( 'Hide hidden updates' ) );
 212          ?>
 213          <script>
 214              jQuery( function( $ ) {
 215                  $( '#show-dismissed' ).on( 'click', function() {
 216                      var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) );
 217  
 218                      if ( isExpanded ) {
 219                          $( this ).text( '<?php echo $show_text; ?>' ).attr( 'aria-expanded', 'false' );
 220                      } else {
 221                          $( this ).text( '<?php echo $hide_text; ?>' ).attr( 'aria-expanded', 'true' );
 222                      }
 223  
 224                      $( '#dismissed-updates' ).toggle( 'fast' );
 225                  });
 226              });
 227          </script>
 228          <?php
 229          echo '<p class="hide-if-no-js"><button type="button" class="button" id="show-dismissed" aria-expanded="false">' . __( 'Show hidden updates' ) . '</button></p>';
 230          echo '<ul id="dismissed-updates" class="core-updates dismissed">';
 231          foreach ( (array) $dismissed as $update ) {
 232              echo '<li>';
 233              list_core_update( $update );
 234              echo '</li>';
 235          }
 236          echo '</ul>';
 237      }
 238  }
 239  
 240  /**
 241   * Display upgrade WordPress for downloading latest or upgrading automatically form.
 242   *
 243   * @since 2.7.0
 244   */
 245  function core_upgrade_preamble() {
 246      $updates = get_core_updates();
 247  
 248      // Include an unmodified $wp_version.
 249      require  ABSPATH . WPINC . '/version.php';
 250  
 251      $is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );
 252  
 253      if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
 254          echo '<h2 class="response">';
 255          _e( 'An updated version of WordPress is available.' );
 256          echo '</h2>';
 257  
 258          $message = sprintf(
 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://developer.wordpress.org/advanced-administration/security/backup/' ),
 262              __( 'https://wordpress.org/documentation/article/updating-wordpress/' )
 263          );
 264          wp_admin_notice(
 265              $message,
 266              array(
 267                  'type'               => 'warning',
 268                  'additional_classes' => array( 'inline' ),
 269              )
 270          );
 271      } elseif ( $is_development_version ) {
 272          echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';
 273      } else {
 274          echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>';
 275      }
 276  
 277      echo '<ul class="core-updates">';
 278      foreach ( (array) $updates as $update ) {
 279          echo '<li>';
 280          list_core_update( $update );
 281          echo '</li>';
 282      }
 283      echo '</ul>';
 284  
 285      // Don't show the maintenance mode notice when we are only showing a single re-install option.
 286      if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) {
 287          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>';
 288      } elseif ( ! $updates ) {
 289          list( $normalized_version ) = explode( '-', $wp_version );
 290          echo '<p>' . sprintf(
 291              /* translators: 1: URL to About screen, 2: WordPress version. */
 292              __( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ),
 293              esc_url( self_admin_url( 'about.php' ) ),
 294              $normalized_version
 295          ) . '</p>';
 296      }
 297  
 298      dismissed_updates();
 299  }
 300  
 301  /**
 302   * Display WordPress auto-updates settings.
 303   *
 304   * @since 5.6.0
 305   */
 306  function core_auto_updates_settings() {
 307      if ( isset( $_GET['core-major-auto-updates-saved'] ) ) {
 308          if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) {
 309              $notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' );
 310              wp_admin_notice(
 311                  $notice_text,
 312                  array(
 313                      'type'        => 'success',
 314                      'dismissible' => true,
 315                  )
 316              );
 317          } elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) {
 318              $notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' );
 319              wp_admin_notice(
 320                  $notice_text,
 321                  array(
 322                      'type'        => 'success',
 323                      'dismissible' => true,
 324                  )
 325              );
 326          }
 327      }
 328  
 329      require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
 330      $updater = new WP_Automatic_Updater();
 331  
 332      // Defaults:
 333      $upgrade_dev   = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled';
 334      $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled';
 335      $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled';
 336  
 337      $can_set_update_option = true;
 338      // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'development', 'branch-development', 'minor', false.
 339      if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
 340          if ( false === WP_AUTO_UPDATE_CORE ) {
 341              // Defaults to turned off, unless a filter allows it.
 342              $upgrade_dev   = false;
 343              $upgrade_minor = false;
 344              $upgrade_major = false;
 345          } elseif ( true === WP_AUTO_UPDATE_CORE
 346              || in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true )
 347          ) {
 348              // ALL updates for core.
 349              $upgrade_dev   = true;
 350              $upgrade_minor = true;
 351              $upgrade_major = true;
 352          } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
 353              // Only minor updates for core.
 354              $upgrade_dev   = false;
 355              $upgrade_minor = true;
 356              $upgrade_major = false;
 357          }
 358  
 359          // The UI is overridden by the `WP_AUTO_UPDATE_CORE` constant.
 360          $can_set_update_option = false;
 361      }
 362  
 363      if ( $updater->is_disabled() ) {
 364          $upgrade_dev   = false;
 365          $upgrade_minor = false;
 366          $upgrade_major = false;
 367  
 368          /*
 369           * The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant
 370           * or the `automatic_updater_disabled` filter,
 371           * or by `wp_is_file_mod_allowed( 'automatic_updater' )`.
 372           * See `WP_Automatic_Updater::is_disabled()`.
 373           */
 374          $can_set_update_option = false;
 375      }
 376  
 377      // Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter?
 378      if ( has_filter( 'allow_major_auto_core_updates' ) ) {
 379          $can_set_update_option = false;
 380      }
 381  
 382      /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
 383      $upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev );
 384      /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
 385      $upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
 386      /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
 387      $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major );
 388  
 389      $auto_update_settings = array(
 390          'dev'   => $upgrade_dev,
 391          'minor' => $upgrade_minor,
 392          'major' => $upgrade_major,
 393      );
 394  
 395      if ( $upgrade_major ) {
 396          $wp_version = wp_get_wp_version();
 397          $updates    = get_core_updates();
 398  
 399          if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
 400              echo '<p>' . wp_get_auto_update_message() . '</p>';
 401          }
 402      }
 403  
 404      $action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' );
 405      ?>
 406  
 407      <p class="auto-update-status">
 408          <?php
 409  
 410          if ( $updater->is_vcs_checkout( ABSPATH ) ) {
 411              _e( 'This site appears to be under version control. Automatic updates are disabled.' );
 412          } elseif ( $upgrade_major ) {
 413              _e( 'This site is automatically kept up to date with each new version of WordPress.' );
 414  
 415              if ( $can_set_update_option ) {
 416                  echo '<br />';
 417                  printf(
 418                      '<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-disable">%s</a>',
 419                      wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ),
 420                      __( 'Switch to automatic updates for maintenance and security releases only.' )
 421                  );
 422              }
 423          } elseif ( $upgrade_minor ) {
 424              _e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' );
 425  
 426              if ( $can_set_update_option ) {
 427                  echo '<br />';
 428                  printf(
 429                      '<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-enable">%s</a>',
 430                      wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ),
 431                      __( 'Enable automatic updates for all new versions of WordPress.' )
 432                  );
 433              }
 434          } else {
 435              _e( 'This site will not receive automatic updates for new versions of WordPress.' );
 436          }
 437          ?>
 438      </p>
 439  
 440      <?php
 441      /**
 442       * Fires after the major core auto-update settings.
 443       *
 444       * @since 5.6.0
 445       *
 446       * @param array $auto_update_settings {
 447       *     Array of core auto-update settings.
 448       *
 449       *     @type bool $dev   Whether to enable automatic updates for development versions.
 450       *     @type bool $minor Whether to enable minor automatic core updates.
 451       *     @type bool $major Whether to enable major automatic core updates.
 452       * }
 453       */
 454      do_action( 'after_core_auto_updates_settings', $auto_update_settings );
 455  }
 456  
 457  /**
 458   * Display the upgrade plugins form.
 459   *
 460   * @since 2.9.0
 461   */
 462  function list_plugin_updates() {
 463      $wp_version     = wp_get_wp_version();
 464      $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
 465  
 466      require_once  ABSPATH . 'wp-admin/includes/plugin-install.php';
 467      $plugins = get_plugin_updates();
 468      if ( empty( $plugins ) ) {
 469          echo '<h2>' . __( 'Plugins' ) . '</h2>';
 470          echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
 471          return;
 472      }
 473      $form_action = 'update-core.php?action=do-plugin-upgrade';
 474  
 475      $core_updates = get_core_updates();
 476      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, '=' ) ) {
 477          $core_update_version = false;
 478      } else {
 479          $core_update_version = $core_updates[0]->current;
 480      }
 481  
 482      $plugins_count = count( $plugins );
 483      ?>
 484  <h2>
 485      <?php
 486      printf(
 487          '%s <span class="count">(%d)</span>',
 488          __( 'Plugins' ),
 489          number_format_i18n( $plugins_count )
 490      );
 491      ?>
 492  </h2>
 493  <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>
 494  <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
 495      <?php wp_nonce_field( 'upgrade-core' ); ?>
 496  <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
 497  <table class="widefat updates-table" id="update-plugins-table">
 498      <thead>
 499      <tr>
 500          <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td>
 501          <td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td>
 502      </tr>
 503      </thead>
 504  
 505      <tbody class="plugins">
 506      <?php
 507  
 508      $auto_updates = array();
 509      if ( wp_is_auto_update_enabled_for_type( 'plugin' ) ) {
 510          $auto_updates       = (array) get_site_option( 'auto_update_plugins', array() );
 511          $auto_update_notice = ' | ' . wp_get_auto_update_message();
 512      }
 513  
 514      foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
 515          $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
 516  
 517          $icon            = '<span class="dashicons dashicons-admin-plugins"></span>';
 518          $preferred_icons = array( 'svg', '2x', '1x', 'default' );
 519          foreach ( $preferred_icons as $preferred_icon ) {
 520              if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) {
 521                  $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" class="plugin-icon" />';
 522                  break;
 523              }
 524          }
 525  
 526          // Get plugin compat for running version of WordPress.
 527          if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) {
 528              /* translators: %s: WordPress version. */
 529              $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: Yes (according to its author)' ), $cur_wp_version );
 530          } else {
 531              /* translators: %s: WordPress version. */
 532              $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: Not tested' ), $cur_wp_version );
 533          }
 534          // Get plugin compat for updated version of WordPress.
 535          if ( $core_update_version ) {
 536              if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
 537                  /* translators: %s: WordPress version. */
 538                  $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Yes (according to its author)' ), $core_update_version );
 539              } else {
 540                  /* translators: %s: WordPress version. */
 541                  $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Not tested' ), $core_update_version );
 542              }
 543          }
 544  
 545          $requires_php   = $plugin_data->update->requires_php ?? null;
 546          $compatible_php = is_php_version_compatible( $requires_php );
 547  
 548          if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
 549              $compat .= '<br />' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
 550              $compat .= sprintf(
 551                  /* translators: %s: URL to Update PHP page. */
 552                  __( '<a href="%s">Learn more about updating PHP</a>.' ),
 553                  esc_url( wp_get_update_php_url() )
 554              );
 555  
 556              $annotation = wp_get_update_php_annotation();
 557  
 558              if ( $annotation ) {
 559                  $compat .= '</p><p><em>' . $annotation . '</em>';
 560              }
 561          }
 562  
 563          // Get the upgrade notice for the new plugin version.
 564          if ( isset( $plugin_data->update->upgrade_notice ) ) {
 565              $upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice );
 566          } else {
 567              $upgrade_notice = '';
 568          }
 569  
 570          $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' );
 571          $details     = sprintf(
 572              '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
 573              esc_url( $details_url ),
 574              /* translators: 1: Plugin name, 2: Version number. */
 575              esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ),
 576              /* translators: %s: Plugin version. */
 577              sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version )
 578          );
 579  
 580          $checkbox_id = 'checkbox_' . md5( $plugin_file );
 581          ?>
 582      <tr>
 583          <td class="check-column">
 584              <?php if ( $compatible_php ) : ?>
 585                  <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
 586                  <label for="<?php echo $checkbox_id; ?>">
 587                      <span class="screen-reader-text">
 588                      <?php
 589                      /* translators: Hidden accessibility text. %s: Plugin name. */
 590                      printf( __( 'Select %s' ), $plugin_data->Name );
 591                      ?>
 592                      </span>
 593                  </label>
 594              <?php endif; ?>
 595          </td>
 596          <td class="plugin-title"><p>
 597              <?php echo $icon; ?>
 598              <strong><?php echo $plugin_data->Name; ?></strong>
 599              <?php
 600              printf(
 601                  /* translators: 1: Plugin version, 2: New version. */
 602                  __( 'You have version %1$s installed. Update to %2$s.' ),
 603                  $plugin_data->Version,
 604                  $plugin_data->update->new_version
 605              );
 606  
 607              echo ' ' . $details . $compat;
 608  
 609              if ( in_array( $plugin_file, $auto_updates, true ) ) {
 610                  echo $auto_update_notice;
 611              }
 612  
 613              echo $upgrade_notice;
 614              ?>
 615          </p></td>
 616      </tr>
 617              <?php
 618      }
 619      ?>
 620      </tbody>
 621  
 622      <tfoot>
 623      <tr>
 624          <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></td>
 625          <td class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></td>
 626      </tr>
 627      </tfoot>
 628  </table>
 629  <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
 630  </form>
 631      <?php
 632  }
 633  
 634  /**
 635   * Display the upgrade themes form.
 636   *
 637   * @since 2.9.0
 638   */
 639  function list_theme_updates() {
 640      $themes = get_theme_updates();
 641      if ( empty( $themes ) ) {
 642          echo '<h2>' . __( 'Themes' ) . '</h2>';
 643          echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
 644          return;
 645      }
 646  
 647      $form_action = 'update-core.php?action=do-theme-upgrade';
 648  
 649      $themes_count = count( $themes );
 650      ?>
 651  <h2>
 652      <?php
 653      printf(
 654          '%s <span class="count">(%d)</span>',
 655          __( 'Themes' ),
 656          number_format_i18n( $themes_count )
 657      );
 658      ?>
 659  </h2>
 660  <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>
 661  <p>
 662      <?php
 663      printf(
 664          /* translators: %s: Link to documentation on child themes. */
 665          __( '<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.' ),
 666          __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' )
 667      );
 668      ?>
 669  </p>
 670  <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
 671      <?php wp_nonce_field( 'upgrade-core' ); ?>
 672  <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
 673  <table class="widefat updates-table" id="update-themes-table">
 674      <thead>
 675      <tr>
 676          <td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td>
 677          <td class="manage-column"><label for="themes-select-all"><?php _e( 'Select All' ); ?></label></td>
 678      </tr>
 679      </thead>
 680  
 681      <tbody class="plugins">
 682      <?php
 683      $auto_updates = array();
 684      if ( wp_is_auto_update_enabled_for_type( 'theme' ) ) {
 685          $auto_updates       = (array) get_site_option( 'auto_update_themes', array() );
 686          $auto_update_notice = ' | ' . wp_get_auto_update_message();
 687      }
 688  
 689      foreach ( $themes as $stylesheet => $theme ) {
 690          $requires_wp  = $theme->update['requires'] ?? null;
 691          $requires_php = $theme->update['requires_php'] ?? null;
 692  
 693          $compatible_wp  = is_wp_version_compatible( $requires_wp );
 694          $compatible_php = is_php_version_compatible( $requires_php );
 695  
 696          $compat = '';
 697  
 698          if ( ! $compatible_wp && ! $compatible_php ) {
 699              $compat .= '<br />' . __( 'This update does not work with your versions of WordPress and PHP.' ) . '&nbsp;';
 700              if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 701                  $compat .= sprintf(
 702                      /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 703                      __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 704                      esc_url( self_admin_url( 'update-core.php' ) ),
 705                      esc_url( wp_get_update_php_url() )
 706                  );
 707  
 708                  $annotation = wp_get_update_php_annotation();
 709  
 710                  if ( $annotation ) {
 711                      $compat .= '</p><p><em>' . $annotation . '</em>';
 712                  }
 713              } elseif ( current_user_can( 'update_core' ) ) {
 714                  $compat .= sprintf(
 715                      /* translators: %s: URL to WordPress Updates screen. */
 716                      __( '<a href="%s">Please update WordPress</a>.' ),
 717                      esc_url( self_admin_url( 'update-core.php' ) )
 718                  );
 719              } elseif ( current_user_can( 'update_php' ) ) {
 720                  $compat .= sprintf(
 721                      /* translators: %s: URL to Update PHP page. */
 722                      __( '<a href="%s">Learn more about updating PHP</a>.' ),
 723                      esc_url( wp_get_update_php_url() )
 724                  );
 725  
 726                  $annotation = wp_get_update_php_annotation();
 727  
 728                  if ( $annotation ) {
 729                      $compat .= '</p><p><em>' . $annotation . '</em>';
 730                  }
 731              }
 732          } elseif ( ! $compatible_wp ) {
 733              $compat .= '<br />' . __( 'This update does not work with your version of WordPress.' ) . '&nbsp;';
 734              if ( current_user_can( 'update_core' ) ) {
 735                  $compat .= sprintf(
 736                      /* translators: %s: URL to WordPress Updates screen. */
 737                      __( '<a href="%s">Please update WordPress</a>.' ),
 738                      esc_url( self_admin_url( 'update-core.php' ) )
 739                  );
 740              }
 741          } elseif ( ! $compatible_php ) {
 742              $compat .= '<br />' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
 743              if ( current_user_can( 'update_php' ) ) {
 744                  $compat .= sprintf(
 745                      /* translators: %s: URL to Update PHP page. */
 746                      __( '<a href="%s">Learn more about updating PHP</a>.' ),
 747                      esc_url( wp_get_update_php_url() )
 748                  );
 749  
 750                  $annotation = wp_get_update_php_annotation();
 751  
 752                  if ( $annotation ) {
 753                      $compat .= '</p><p><em>' . $annotation . '</em>';
 754                  }
 755              }
 756          }
 757  
 758          $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
 759          ?>
 760      <tr>
 761          <td class="check-column">
 762              <?php if ( $compatible_wp && $compatible_php ) : ?>
 763                  <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
 764                  <label for="<?php echo $checkbox_id; ?>">
 765                      <span class="screen-reader-text">
 766                      <?php
 767                      /* translators: Hidden accessibility text. %s: Theme name. */
 768                      printf( __( 'Select %s' ), $theme->display( 'Name' ) );
 769                      ?>
 770                      </span>
 771                  </label>
 772              <?php endif; ?>
 773          </td>
 774          <td class="plugin-title"><p>
 775              <img src="<?php echo esc_url( $theme->get_screenshot() . '?ver=' . $theme->version ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
 776              <strong><?php echo $theme->display( 'Name' ); ?></strong>
 777              <?php
 778              printf(
 779                  /* translators: 1: Theme version, 2: New version. */
 780                  __( 'You have version %1$s installed. Update to %2$s.' ),
 781                  $theme->display( 'Version' ),
 782                  $theme->update['new_version']
 783              );
 784  
 785              echo ' ' . $compat;
 786  
 787              if ( in_array( $stylesheet, $auto_updates, true ) ) {
 788                  echo $auto_update_notice;
 789              }
 790              ?>
 791          </p></td>
 792      </tr>
 793              <?php
 794      }
 795      ?>
 796      </tbody>
 797  
 798      <tfoot>
 799      <tr>
 800          <td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td>
 801          <td class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></td>
 802      </tr>
 803      </tfoot>
 804  </table>
 805  <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
 806  </form>
 807      <?php
 808  }
 809  
 810  /**
 811   * Display the update translations form.
 812   *
 813   * @since 3.7.0
 814   */
 815  function list_translation_updates() {
 816      $translation_updates = wp_get_translation_update_data();
 817      if ( ! $translation_updates ) {
 818          if ( 'en_US' !== get_locale() ) {
 819              echo '<h2>' . __( 'Translations' ) . '</h2>';
 820              echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
 821          }
 822          return;
 823      }
 824  
 825      $form_action   = 'update-core.php?action=do-translation-upgrade';
 826      $updates_count = count( $translation_updates );
 827      ?>
 828      <h2>
 829      <?php
 830      printf(
 831          '%s <span class="count">(%s)</span>',
 832          __( 'Translations' ),
 833          number_format_i18n( $updates_count )
 834      );
 835      ?>
 836      </h2>
 837      <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade">
 838          <p><?php _e( 'The following translation updates are available. Leave any translation updates unchecked if you want to install them later, then click &#8220;Update Translations&#8221;.' ); ?></p>
 839          <p><?php _e( 'Translation updates you leave unchecked will remain available until you select them.' ); ?></p>
 840          <?php wp_nonce_field( 'upgrade-translations' ); ?>
 841          <p><input id="upgrade-translations" class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
 842          <table class="widefat updates-table" id="update-translations-table">
 843              <thead>
 844              <tr>
 845                  <td class="manage-column check-column"><input type="checkbox" id="translations-select-all" /></td>
 846                  <td class="manage-column"><label for="translations-select-all"><?php _e( 'Select All' ); ?></label></td>
 847              </tr>
 848              </thead>
 849  
 850              <tbody class="plugins">
 851              <?php foreach ( $translation_updates as $translation_update ) : ?>
 852                  <?php $checkbox_id = 'checkbox_' . md5( $translation_update['id'] ); ?>
 853                  <tr>
 854                      <td class="check-column">
 855                          <input type="hidden" name="translations[]" value="<?php echo esc_attr( $translation_update['id'] ); ?>" />
 856                          <input type="checkbox" name="checked[]" id="<?php echo esc_attr( $checkbox_id ); ?>" value="<?php echo esc_attr( $translation_update['id'] ); ?>" <?php checked( $translation_update['checked'] ); ?> />
 857                          <label for="<?php echo esc_attr( $checkbox_id ); ?>">
 858                              <span class="screen-reader-text">
 859                              <?php
 860                              printf(
 861                                  /* translators: 1: Project name, 2: Language name or locale. */
 862                                  esc_html__( 'Select the translation update for %1$s in %2$s' ),
 863                                  esc_html( $translation_update['name'] ),
 864                                  esc_html( $translation_update['language'] )
 865                              );
 866                              ?>
 867                              </span>
 868                          </label>
 869                      </td>
 870                      <td class="plugin-title"><p>
 871                          <strong><?php echo esc_html( $translation_update['name'] ); ?></strong>
 872                          <?php
 873                          printf(
 874                              /* translators: 1: Language name or locale, 2: Version number. */
 875                              esc_html__( '%1$s translation is available for version %2$s.' ),
 876                              esc_html( $translation_update['language'] ),
 877                              esc_html( $translation_update['version'] )
 878                          );
 879  
 880                          if ( $translation_update['deferred'] ) {
 881                              echo ' ';
 882                              esc_html_e( 'This translation update will remain available until you select it.' );
 883                          }
 884                          ?>
 885                      </p></td>
 886                  </tr>
 887              <?php endforeach; ?>
 888              </tbody>
 889  
 890              <tfoot>
 891              <tr>
 892                  <td class="manage-column check-column"><input type="checkbox" id="translations-select-all-2" /></td>
 893                  <td class="manage-column"><label for="translations-select-all-2"><?php _e( 'Select All' ); ?></label></td>
 894              </tr>
 895              </tfoot>
 896          </table>
 897          <p><input id="upgrade-translations-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
 898      </form>
 899      <?php
 900  }
 901  
 902  /**
 903   * Upgrades WordPress core display.
 904   *
 905   * @since 2.7.0
 906   *
 907   * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
 908   *
 909   * @param bool $reinstall Optional. Whether to reinstall WordPress. Default false.
 910   */
 911  function do_core_upgrade( $reinstall = false ) {
 912      global $wp_filesystem;
 913  
 914      require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
 915  
 916      if ( $reinstall ) {
 917          $url = 'update-core.php?action=do-core-reinstall';
 918      } else {
 919          $url = 'update-core.php?action=do-core-upgrade';
 920      }
 921      $url = wp_nonce_url( $url, 'upgrade-core' );
 922  
 923      $version = $_POST['version'] ?? false;
 924      $locale  = $_POST['locale'] ?? 'en_US';
 925      $update  = find_core_update( $version, $locale );
 926      if ( ! $update ) {
 927          return;
 928      }
 929  
 930      /*
 931       * Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
 932       * that it's safe to do so. This only happens when there are no new files to create.
 933       */
 934      $allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
 935  
 936      ?>
 937      <div class="wrap">
 938      <h1><?php _e( 'Update WordPress' ); ?></h1>
 939      <?php
 940  
 941      $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
 942      if ( false === $credentials ) {
 943          echo '</div>';
 944          return;
 945      }
 946  
 947      if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
 948          // Failed to connect. Error and request again.
 949          request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
 950          echo '</div>';
 951          return;
 952      }
 953  
 954      if ( $wp_filesystem->errors->has_errors() ) {
 955          foreach ( $wp_filesystem->errors->get_error_messages() as $message ) {
 956              show_message( $message );
 957          }
 958          echo '</div>';
 959          return;
 960      }
 961  
 962      if ( $reinstall ) {
 963          $update->response = 'reinstall';
 964      }
 965  
 966      add_filter( 'update_feedback', 'show_message' );
 967  
 968      $upgrader = new Core_Upgrader();
 969      $result   = $upgrader->upgrade(
 970          $update,
 971          array(
 972              'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
 973          )
 974      );
 975  
 976      if ( is_wp_error( $result ) ) {
 977          show_message( $result );
 978          if ( 'up_to_date' !== $result->get_error_code() && 'locked' !== $result->get_error_code() ) {
 979              show_message( __( 'Installation failed.' ) );
 980          }
 981          echo '</div>';
 982          return;
 983      }
 984  
 985      show_message( __( 'WordPress updated successfully.' ) );
 986      show_message(
 987          '<span class="hide-if-no-js">' . sprintf(
 988              /* translators: 1: WordPress version, 2: URL to About screen. */
 989              __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ),
 990              $result,
 991              esc_url( self_admin_url( 'about.php?updated' ) )
 992          ) . '</span>'
 993      );
 994      show_message(
 995          '<span class="hide-if-js">' . sprintf(
 996              /* translators: 1: WordPress version, 2: URL to About screen. */
 997              __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ),
 998              $result,
 999              esc_url( self_admin_url( 'about.php?updated' ) )
1000          ) . '</span>'
1001      );
1002      ?>
1003      </div>
1004      <script>
1005      window.location = '<?php echo esc_url( self_admin_url( 'about.php?updated' ) ); ?>';
1006      </script>
1007      <?php
1008  }
1009  
1010  /**
1011   * Dismiss a core update.
1012   *
1013   * @since 2.7.0
1014   */
1015  function do_dismiss_core_update() {
1016      $version = $_POST['version'] ?? false;
1017      $locale  = $_POST['locale'] ?? 'en_US';
1018      $update  = find_core_update( $version, $locale );
1019      if ( ! $update ) {
1020          return;
1021      }
1022      dismiss_core_update( $update );
1023      wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) );
1024      exit;
1025  }
1026  
1027  /**
1028   * Undismiss a core update.
1029   *
1030   * @since 2.7.0
1031   */
1032  function do_undismiss_core_update() {
1033      $version = $_POST['version'] ?? false;
1034      $locale  = $_POST['locale'] ?? 'en_US';
1035      $update  = find_core_update( $version, $locale );
1036      if ( ! $update ) {
1037          return;
1038      }
1039      undismiss_core_update( $version, $locale );
1040      wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) );
1041      exit;
1042  }
1043  
1044  $action = $_GET['action'] ?? 'upgrade-core';
1045  
1046  $upgrade_error = false;
1047  if ( ( 'do-theme-upgrade' === $action || ( 'do-plugin-upgrade' === $action && ! isset( $_GET['plugins'] ) ) )
1048      && ! isset( $_POST['checked'] ) ) {
1049      $upgrade_error = ( 'do-theme-upgrade' === $action ) ? 'themes' : 'plugins';
1050      $action        = 'upgrade-core';
1051  }
1052  
1053  $title       = __( 'WordPress Updates' );
1054  $parent_file = 'index.php';
1055  
1056  $updates_overview  = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes, plugins, and translations.' ) . '</p>';
1057  $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>';
1058  
1059  get_current_screen()->add_help_tab(
1060      array(
1061          'id'      => 'overview',
1062          'title'   => __( 'Overview' ),
1063          'content' => $updates_overview,
1064      )
1065  );
1066  
1067  $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>';
1068  $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>';
1069  
1070  if ( 'en_US' !== get_locale() ) {
1071      $updates_howto .= '<p>' . __( '<strong>Translations</strong> &mdash; Translation updates are selected for installation by default. Leave any translation updates unchecked if you want to install them later, then <strong>click the &#8220;Update Translations&#8221;</strong> button. Translation updates you leave unchecked will remain available until you select them.' ) . '</p>';
1072  }
1073  
1074  get_current_screen()->add_help_tab(
1075      array(
1076          'id'      => 'how-to-update',
1077          'title'   => __( 'How to Update' ),
1078          'content' => $updates_howto,
1079      )
1080  );
1081  
1082  $help_sidebar_autoupdates = '';
1083  
1084  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' ) ) ) {
1085      $help_tab_autoupdates  = '<p>' . __( 'Auto-updates can be enabled or disabled for WordPress major versions and 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>';
1086      $help_tab_autoupdates .= '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>';
1087  
1088      get_current_screen()->add_help_tab(
1089          array(
1090              'id'      => 'plugins-themes-auto-updates',
1091              'title'   => __( 'Auto-updates' ),
1092              'content' => $help_tab_autoupdates,
1093          )
1094      );
1095  
1096      $help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/documentation/article/plugins-themes-auto-updates/">Documentation on Auto-updates</a>' ) . '</p>';
1097  }
1098  
1099  $help_sidebar_rollback = '';
1100  
1101  if ( current_user_can( 'update_themes' ) || current_user_can( 'update_plugins' ) ) {
1102      $rollback_help = '<p>' . __( 'This feature will create a temporary backup of a plugin or theme before it is upgraded. This backup is used to restore the plugin or theme back to its previous state if there is an error during the update process.' ) . '</p>';
1103  
1104      $rollback_help .= '<p>' . __( 'On systems with fewer resources, this may lead to server timeouts or resource limits being reached. If you encounter an issue during the update process, please create a support forum topic and reference <strong>Rollback</strong> in the issue title.' ) . '</p>';
1105  
1106      get_current_screen()->add_help_tab(
1107          array(
1108              'id'      => 'rollback-plugins-themes',
1109              'title'   => __( 'Restore Plugin or Theme' ),
1110              'content' => $rollback_help,
1111          )
1112      );
1113  
1114      $help_sidebar_rollback = '<p>' . __( '<a href="https://developer.wordpress.org/advanced-administration/wordpress/common-errors/">Common Errors</a>' ) . '</p>';
1115  }
1116  
1117  get_current_screen()->set_help_sidebar(
1118      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
1119      '<p>' . __( '<a href="https://wordpress.org/documentation/article/dashboard-updates-screen/">Documentation on Updating WordPress</a>' ) . '</p>' .
1120      $help_sidebar_autoupdates .
1121      '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' .
1122      $help_sidebar_rollback
1123  );
1124  
1125  if ( 'upgrade-core' === $action ) {
1126      // Force an update check when requested.
1127      $force_check = ! empty( $_GET['force-check'] );
1128      wp_version_check( array(), $force_check );
1129  
1130      require_once  ABSPATH . 'wp-admin/admin-header.php';
1131      ?>
1132      <div class="wrap">
1133      <h1><?php _e( 'WordPress Updates' ); ?></h1>
1134      <p><?php _e( 'Updates may take several minutes to complete. If there is no feedback after 5 minutes, or if there are errors please refer to the Help section above.' ); ?></p>
1135  
1136      <?php
1137      if ( $upgrade_error ) {
1138          if ( 'themes' === $upgrade_error ) {
1139              $theme_updates = get_theme_updates();
1140              if ( ! empty( $theme_updates ) ) {
1141                  wp_admin_notice(
1142                      __( 'Please select one or more themes to update.' ),
1143                      array(
1144                          'additional_classes' => array( 'error' ),
1145                      )
1146                  );
1147              }
1148          } else {
1149              $plugin_updates = get_plugin_updates();
1150              if ( ! empty( $plugin_updates ) ) {
1151                  wp_admin_notice(
1152                      __( 'Please select one or more plugins to update.' ),
1153                      array(
1154                          'additional_classes' => array( 'error' ),
1155                      )
1156                  );
1157              }
1158          }
1159      }
1160  
1161      $translation_updates_status = isset( $_GET['translation_updates'] ) ? wp_unslash( $_GET['translation_updates'] ) : '';
1162      if ( is_string( $translation_updates_status ) ) {
1163          $translation_updates_status = sanitize_key( $translation_updates_status );
1164      } else {
1165          $translation_updates_status = '';
1166      }
1167  
1168      if ( 'deferred' === $translation_updates_status ) {
1169          wp_admin_notice(
1170              __( 'The unchecked translation updates will remain available until you select them.' ),
1171              array(
1172                  'type' => 'success',
1173              )
1174          );
1175      }
1176  
1177      $last_update_check = false;
1178      $current           = get_site_transient( 'update_core' );
1179  
1180      if ( $current && isset( $current->last_checked ) ) {
1181          $last_update_check = $current->last_checked + (int) ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
1182      }
1183  
1184      echo '<h2 class="wp-current-version">';
1185      /* translators: Current version of WordPress. */
1186      printf( __( 'Current version: %s' ), esc_html( wp_get_wp_version() ) );
1187      echo '</h2>';
1188  
1189      echo '<p class="update-last-checked">';
1190  
1191      printf(
1192          /* translators: 1: Date, 2: Time. */
1193          __( 'Last checked on %1$s at %2$s.' ),
1194          /* translators: Last update date format. See https://www.php.net/manual/datetime.format.php */
1195          date_i18n( __( 'F j, Y' ), $last_update_check ),
1196          /* translators: Last update time format. See https://www.php.net/manual/datetime.format.php */
1197          date_i18n( __( 'g:i a T' ), $last_update_check )
1198      );
1199      echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check again.' ) . '</a>';
1200      echo '</p>';
1201  
1202      if ( current_user_can( 'update_core' ) ) {
1203          core_auto_updates_settings();
1204          core_upgrade_preamble();
1205      }
1206      if ( current_user_can( 'update_plugins' ) ) {
1207          list_plugin_updates();
1208      }
1209      if ( current_user_can( 'update_themes' ) ) {
1210          list_theme_updates();
1211      }
1212      if ( current_user_can( 'update_languages' ) ) {
1213          list_translation_updates();
1214      }
1215  
1216      /**
1217       * Fires after the core, plugin, and theme update tables.
1218       *
1219       * @since 2.9.0
1220       */
1221      do_action( 'core_upgrade_preamble' );
1222      echo '</div>';
1223  
1224      wp_localize_script(
1225          'updates',
1226          '_wpUpdatesItemCounts',
1227          array(
1228              'totals' => wp_get_update_data(),
1229          )
1230      );
1231  
1232      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1233  
1234  } elseif ( 'do-core-upgrade' === $action || 'do-core-reinstall' === $action ) {
1235  
1236      if ( ! current_user_can( 'update_core' ) ) {
1237          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1238      }
1239  
1240      check_admin_referer( 'upgrade-core' );
1241  
1242      // Do the (un)dismiss actions before headers, so that they can redirect.
1243      if ( isset( $_POST['dismiss'] ) ) {
1244          do_dismiss_core_update();
1245      } elseif ( isset( $_POST['undismiss'] ) ) {
1246          do_undismiss_core_update();
1247      }
1248  
1249      require_once  ABSPATH . 'wp-admin/admin-header.php';
1250      if ( 'do-core-reinstall' === $action ) {
1251          $reinstall = true;
1252      } else {
1253          $reinstall = false;
1254      }
1255  
1256      if ( isset( $_POST['upgrade'] ) ) {
1257          do_core_upgrade( $reinstall );
1258      }
1259  
1260      wp_localize_script(
1261          'updates',
1262          '_wpUpdatesItemCounts',
1263          array(
1264              'totals' => wp_get_update_data(),
1265          )
1266      );
1267  
1268      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1269  
1270  } elseif ( 'do-plugin-upgrade' === $action ) {
1271  
1272      if ( ! current_user_can( 'update_plugins' ) ) {
1273          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1274      }
1275  
1276      check_admin_referer( 'upgrade-core' );
1277  
1278      if ( isset( $_GET['plugins'] ) ) {
1279          $plugins = explode( ',', $_GET['plugins'] );
1280      } elseif ( isset( $_POST['checked'] ) ) {
1281          $plugins = (array) $_POST['checked'];
1282      } else {
1283          wp_redirect( admin_url( 'update-core.php' ) );
1284          exit;
1285      }
1286  
1287      $url = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) );
1288      $url = wp_nonce_url( $url, 'bulk-update-plugins' );
1289  
1290      // Used in the HTML title tag.
1291      $title = __( 'Update Plugins' );
1292  
1293      require_once  ABSPATH . 'wp-admin/admin-header.php';
1294      ?>
1295      <div class="wrap">
1296          <h1><?php _e( 'Update Plugins' ); ?></h1>
1297          <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe>
1298      </div>
1299      <?php
1300  
1301      wp_localize_script(
1302          'updates',
1303          '_wpUpdatesItemCounts',
1304          array(
1305              'totals' => wp_get_update_data(),
1306          )
1307      );
1308  
1309      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1310  
1311  } elseif ( 'do-theme-upgrade' === $action ) {
1312  
1313      if ( ! current_user_can( 'update_themes' ) ) {
1314          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1315      }
1316  
1317      check_admin_referer( 'upgrade-core' );
1318  
1319      if ( isset( $_GET['themes'] ) ) {
1320          $themes = explode( ',', $_GET['themes'] );
1321      } elseif ( isset( $_POST['checked'] ) ) {
1322          $themes = (array) $_POST['checked'];
1323      } else {
1324          wp_redirect( admin_url( 'update-core.php' ) );
1325          exit;
1326      }
1327  
1328      $url = 'update.php?action=update-selected-themes&themes=' . urlencode( implode( ',', $themes ) );
1329      $url = wp_nonce_url( $url, 'bulk-update-themes' );
1330  
1331      // Used in the HTML title tag.
1332      $title = __( 'Update Themes' );
1333  
1334      require_once  ABSPATH . 'wp-admin/admin-header.php';
1335      ?>
1336      <div class="wrap">
1337          <h1><?php _e( 'Update Themes' ); ?></h1>
1338          <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe>
1339      </div>
1340      <?php
1341  
1342      wp_localize_script(
1343          'updates',
1344          '_wpUpdatesItemCounts',
1345          array(
1346              'totals' => wp_get_update_data(),
1347          )
1348      );
1349  
1350      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1351  
1352  } elseif ( 'do-translation-upgrade' === $action ) {
1353  
1354      if ( ! current_user_can( 'update_languages' ) ) {
1355          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1356      }
1357  
1358      check_admin_referer( 'upgrade-translations' );
1359  
1360      // Requests without the form's update identifiers must not install all translations.
1361      $translation_update_ids          = array_unique(
1362          array_map(
1363              'sanitize_text_field',
1364              wp_unslash( (array) ( $_POST['translations'] ?? array() ) )
1365          )
1366      );
1367      $selected_translation_update_ids = array_unique(
1368          array_map(
1369              'sanitize_text_field',
1370              wp_unslash( (array) ( $_POST['checked'] ?? array() ) )
1371          )
1372      );
1373  
1374      $selected_translation_updates = wp_process_translation_update_selection( $translation_update_ids, $selected_translation_update_ids );
1375  
1376      if ( false === $selected_translation_updates ) {
1377          wp_redirect( self_admin_url( 'update-core.php' ) );
1378          exit;
1379      }
1380  
1381      if ( empty( $selected_translation_updates ) ) {
1382          wp_redirect( add_query_arg( 'translation_updates', 'deferred', self_admin_url( 'update-core.php' ) ) );
1383          exit;
1384      }
1385  
1386      require_once  ABSPATH . 'wp-admin/admin-header.php';
1387      require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1388  
1389      $url     = 'update-core.php?action=do-translation-upgrade';
1390      $nonce   = 'upgrade-translations';
1391      $title   = __( 'Update Translations' );
1392      $context = WP_LANG_DIR;
1393  
1394      $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
1395      $result   = $upgrader->bulk_upgrade( array_values( $selected_translation_updates ) );
1396  
1397      wp_localize_script(
1398          'updates',
1399          '_wpUpdatesItemCounts',
1400          array(
1401              'totals' => wp_get_update_data(),
1402          )
1403      );
1404  
1405      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1406  
1407  } elseif ( 'core-major-auto-updates-settings' === $action ) {
1408  
1409      if ( ! current_user_can( 'update_core' ) ) {
1410          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1411      }
1412  
1413      $redirect_url = self_admin_url( 'update-core.php' );
1414  
1415      if ( isset( $_GET['value'] ) ) {
1416          check_admin_referer( 'core-major-auto-updates-nonce' );
1417  
1418          if ( 'enable' === $_GET['value'] ) {
1419              update_site_option( 'auto_update_core_major', 'enabled' );
1420              $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'enabled', $redirect_url );
1421          } elseif ( 'disable' === $_GET['value'] ) {
1422              update_site_option( 'auto_update_core_major', 'disabled' );
1423              $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'disabled', $redirect_url );
1424          }
1425      }
1426  
1427      wp_redirect( $redirect_url );
1428      exit;
1429  } else {
1430      /**
1431       * Fires for each custom update action on the WordPress Updates screen.
1432       *
1433       * The dynamic portion of the hook name, `$action`, refers to the
1434       * passed update action. The hook fires in lieu of all available
1435       * default update actions.
1436       *
1437       * @since 3.2.0
1438       */
1439      do_action( "update-core-custom_{$action}" );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
1440  }


Generated : Sat Nov 21 08:20:02 2026 Cross-referenced by PHPXref