[ Index ]

PHP Cross Reference of WordPress

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


Generated: Thu Feb 25 01:00:09 2021 Cross-referenced by PHPXref 0.7.1