[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Update Core administration panel.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /** WordPress Administration Bootstrap */
  10  require_once  __DIR__ . '/admin.php';
  11  
  12  wp_enqueue_style( 'plugin-install' );
  13  wp_enqueue_script( 'plugin-install' );
  14  wp_enqueue_script( 'updates' );
  15  add_thickbox();
  16  
  17  if ( is_multisite() && ! is_network_admin() ) {
  18      wp_redirect( network_admin_url( 'update-core.php' ) );
  19      exit;
  20  }
  21  
  22  if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) {
  23      wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
  24  }
  25  
  26  /**
  27   * Lists available core updates.
  28   *
  29   * @since 2.7.0
  30   *
  31   * @global string $wp_local_package Locale code of the package.
  32   * @global wpdb   $wpdb             WordPress database abstraction object.
  33   *
  34   * @param object $update
  35   */
  36  function list_core_update( $update ) {
  37      global $wp_local_package, $wpdb;
  38      static $first_pass = true;
  39  
  40      $wp_version     = get_bloginfo( 'version' );
  41      $version_string = sprintf( '%s&ndash;%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', '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              || 'beta' === WP_AUTO_UPDATE_CORE
 318              || 'rc' === WP_AUTO_UPDATE_CORE
 319          ) {
 320              // ALL updates for core.
 321              $upgrade_dev   = true;
 322              $upgrade_minor = true;
 323              $upgrade_major = true;
 324          } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
 325              // Only minor updates for core.
 326              $upgrade_dev   = false;
 327              $upgrade_minor = true;
 328              $upgrade_major = false;
 329          }
 330  
 331          // The UI is overridden by the `WP_AUTO_UPDATE_CORE` constant.
 332          $can_set_update_option = false;
 333      }
 334  
 335      if ( $updater->is_disabled() ) {
 336          $upgrade_dev   = false;
 337          $upgrade_minor = false;
 338          $upgrade_major = false;
 339  
 340          /*
 341           * The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant
 342           * or the `automatic_updater_disabled` filter,
 343           * or by `wp_is_file_mod_allowed( 'automatic_updater' )`.
 344           * See `WP_Automatic_Updater::is_disabled()`.
 345           */
 346          $can_set_update_option = false;
 347      }
 348  
 349      // Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter?
 350      if ( has_filter( 'allow_major_auto_core_updates' ) ) {
 351          $can_set_update_option = false;
 352      }
 353  
 354      /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
 355      $upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev );
 356      /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
 357      $upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
 358      /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
 359      $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major );
 360  
 361      $auto_update_settings = array(
 362          'dev'   => $upgrade_dev,
 363          'minor' => $upgrade_minor,
 364          'major' => $upgrade_major,
 365      );
 366  
 367      if ( $upgrade_major ) {
 368          $wp_version = get_bloginfo( 'version' );
 369          $updates    = get_core_updates();
 370  
 371          if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
 372              echo '<p>' . wp_get_auto_update_message() . '</p>';
 373          }
 374      }
 375  
 376      $action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' );
 377      ?>
 378  
 379      <p class="auto-update-status">
 380          <?php
 381  
 382          if ( $updater->is_vcs_checkout( ABSPATH ) ) {
 383              _e( 'This site appears to be under version control. Automatic updates are disabled.' );
 384          } elseif ( $upgrade_major ) {
 385              _e( 'This site is automatically kept up to date with each new version of WordPress.' );
 386  
 387              if ( $can_set_update_option ) {
 388                  echo '<br>';
 389                  printf(
 390                      '<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-disable">%s</a>',
 391                      wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ),
 392                      __( 'Switch to automatic updates for maintenance and security releases only.' )
 393                  );
 394              }
 395          } elseif ( $upgrade_minor ) {
 396              _e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' );
 397  
 398              if ( $can_set_update_option ) {
 399                  echo '<br>';
 400                  printf(
 401                      '<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-enable">%s</a>',
 402                      wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ),
 403                      __( 'Enable automatic updates for all new versions of WordPress.' )
 404                  );
 405              }
 406          } else {
 407              _e( 'This site will not receive automatic updates for new versions of WordPress.' );
 408          }
 409          ?>
 410      </p>
 411  
 412      <?php
 413      /**
 414       * Fires after the major core auto-update settings.
 415       *
 416       * @since 5.6.0
 417       */
 418      do_action( 'after_core_auto_updates_settings', $auto_update_settings );
 419  }
 420  
 421  /**
 422   * Display the upgrade plugins form.
 423   *
 424   * @since 2.9.0
 425   */
 426  function list_plugin_updates() {
 427      $wp_version     = get_bloginfo( 'version' );
 428      $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
 429  
 430      require_once  ABSPATH . 'wp-admin/includes/plugin-install.php';
 431      $plugins = get_plugin_updates();
 432      if ( empty( $plugins ) ) {
 433          echo '<h2>' . __( 'Plugins' ) . '</h2>';
 434          echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
 435          return;
 436      }
 437      $form_action = 'update-core.php?action=do-plugin-upgrade';
 438  
 439      $core_updates = get_core_updates();
 440      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, '=' ) ) {
 441          $core_update_version = false;
 442      } else {
 443          $core_update_version = $core_updates[0]->current;
 444      }
 445      ?>
 446  <h2><?php _e( 'Plugins' ); ?></h2>
 447  <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>
 448  <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
 449      <?php wp_nonce_field( 'upgrade-core' ); ?>
 450  <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
 451  <table class="widefat updates-table" id="update-plugins-table">
 452      <thead>
 453      <tr>
 454          <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td>
 455          <td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td>
 456      </tr>
 457      </thead>
 458  
 459      <tbody class="plugins">
 460      <?php
 461  
 462      $auto_updates = array();
 463      if ( wp_is_auto_update_enabled_for_type( 'plugin' ) ) {
 464          $auto_updates       = (array) get_site_option( 'auto_update_plugins', array() );
 465          $auto_update_notice = ' | ' . wp_get_auto_update_message();
 466      }
 467  
 468      foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
 469          $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
 470  
 471          $icon            = '<span class="dashicons dashicons-admin-plugins"></span>';
 472          $preferred_icons = array( 'svg', '2x', '1x', 'default' );
 473          foreach ( $preferred_icons as $preferred_icon ) {
 474              if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) {
 475                  $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />';
 476                  break;
 477              }
 478          }
 479  
 480          // Get plugin compat for running version of WordPress.
 481          if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) {
 482              /* translators: %s: WordPress version. */
 483              $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $cur_wp_version );
 484          } else {
 485              /* translators: %s: WordPress version. */
 486              $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $cur_wp_version );
 487          }
 488          // Get plugin compat for updated version of WordPress.
 489          if ( $core_update_version ) {
 490              if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
 491                  /* translators: %s: WordPress version. */
 492                  $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $core_update_version );
 493              } else {
 494                  /* translators: %s: WordPress version. */
 495                  $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $core_update_version );
 496              }
 497          }
 498  
 499          $requires_php   = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null;
 500          $compatible_php = is_php_version_compatible( $requires_php );
 501  
 502          if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
 503              $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
 504              $compat .= sprintf(
 505                  /* translators: %s: URL to Update PHP page. */
 506                  __( '<a href="%s">Learn more about updating PHP</a>.' ),
 507                  esc_url( wp_get_update_php_url() )
 508              );
 509  
 510              $annotation = wp_get_update_php_annotation();
 511  
 512              if ( $annotation ) {
 513                  $compat .= '</p><p><em>' . $annotation . '</em>';
 514              }
 515          }
 516  
 517          // Get the upgrade notice for the new plugin version.
 518          if ( isset( $plugin_data->update->upgrade_notice ) ) {
 519              $upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice );
 520          } else {
 521              $upgrade_notice = '';
 522          }
 523  
 524          $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' );
 525          $details     = sprintf(
 526              '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
 527              esc_url( $details_url ),
 528              /* translators: 1: Plugin name, 2: Version number. */
 529              esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ),
 530              /* translators: %s: Plugin version. */
 531              sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version )
 532          );
 533  
 534          $checkbox_id = 'checkbox_' . md5( $plugin_file );
 535          ?>
 536      <tr>
 537          <td class="check-column">
 538              <?php if ( $compatible_php ) : ?>
 539                  <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
 540                  <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
 541                      <?php
 542                      /* translators: %s: Plugin name. */
 543                      printf( __( 'Select %s' ), $plugin_data->Name );
 544                      ?>
 545                  </label>
 546              <?php endif; ?>
 547          </td>
 548          <td class="plugin-title"><p>
 549              <?php echo $icon; ?>
 550              <strong><?php echo $plugin_data->Name; ?></strong>
 551              <?php
 552              printf(
 553                  /* translators: 1: Plugin version, 2: New version. */
 554                  __( 'You have version %1$s installed. Update to %2$s.' ),
 555                  $plugin_data->Version,
 556                  $plugin_data->update->new_version
 557              );
 558  
 559              echo ' ' . $details . $compat . $upgrade_notice;
 560  
 561              if ( in_array( $plugin_file, $auto_updates, true ) ) {
 562                  echo $auto_update_notice;
 563              }
 564              ?>
 565          </p></td>
 566      </tr>
 567              <?php
 568      }
 569      ?>
 570      </tbody>
 571  
 572      <tfoot>
 573      <tr>
 574          <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></td>
 575          <td class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></td>
 576      </tr>
 577      </tfoot>
 578  </table>
 579  <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
 580  </form>
 581      <?php
 582  }
 583  
 584  /**
 585   * Display the upgrade themes form.
 586   *
 587   * @since 2.9.0
 588   */
 589  function list_theme_updates() {
 590      $themes = get_theme_updates();
 591      if ( empty( $themes ) ) {
 592          echo '<h2>' . __( 'Themes' ) . '</h2>';
 593          echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
 594          return;
 595      }
 596  
 597      $form_action = 'update-core.php?action=do-theme-upgrade';
 598      ?>
 599  <h2><?php _e( 'Themes' ); ?></h2>
 600  <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>
 601  <p>
 602      <?php
 603      printf(
 604          /* translators: %s: Link to documentation on child themes. */
 605          __( '<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.' ),
 606          __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' )
 607      );
 608      ?>
 609  </p>
 610  <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
 611      <?php wp_nonce_field( 'upgrade-core' ); ?>
 612  <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
 613  <table class="widefat updates-table" id="update-themes-table">
 614      <thead>
 615      <tr>
 616          <td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td>
 617          <td class="manage-column"><label for="themes-select-all"><?php _e( 'Select All' ); ?></label></td>
 618      </tr>
 619      </thead>
 620  
 621      <tbody class="plugins">
 622      <?php
 623      $auto_updates = array();
 624      if ( wp_is_auto_update_enabled_for_type( 'theme' ) ) {
 625          $auto_updates       = (array) get_site_option( 'auto_update_themes', array() );
 626          $auto_update_notice = ' | ' . wp_get_auto_update_message();
 627      }
 628  
 629      foreach ( $themes as $stylesheet => $theme ) {
 630          $requires_wp  = isset( $theme->update['requires'] ) ? $theme->update['requires'] : null;
 631          $requires_php = isset( $theme->update['requires_php'] ) ? $theme->update['requires_php'] : null;
 632  
 633          $compatible_wp  = is_wp_version_compatible( $requires_wp );
 634          $compatible_php = is_php_version_compatible( $requires_php );
 635  
 636          $compat = '';
 637  
 638          if ( ! $compatible_wp && ! $compatible_php ) {
 639              $compat .= '<br>' . __( 'This update doesn&#8217;t work with your versions of WordPress and PHP.' ) . '&nbsp;';
 640              if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 641                  $compat .= sprintf(
 642                      /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 643                      __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 644                      self_admin_url( 'update-core.php' ),
 645                      esc_url( wp_get_update_php_url() )
 646                  );
 647  
 648                  $annotation = wp_get_update_php_annotation();
 649  
 650                  if ( $annotation ) {
 651                      $compat .= '</p><p><em>' . $annotation . '</em>';
 652                  }
 653              } elseif ( current_user_can( 'update_core' ) ) {
 654                  $compat .= sprintf(
 655                      /* translators: %s: URL to WordPress Updates screen. */
 656                      __( '<a href="%s">Please update WordPress</a>.' ),
 657                      self_admin_url( 'update-core.php' )
 658                  );
 659              } elseif ( current_user_can( 'update_php' ) ) {
 660                  $compat .= sprintf(
 661                      /* translators: %s: URL to Update PHP page. */
 662                      __( '<a href="%s">Learn more about updating PHP</a>.' ),
 663                      esc_url( wp_get_update_php_url() )
 664                  );
 665  
 666                  $annotation = wp_get_update_php_annotation();
 667  
 668                  if ( $annotation ) {
 669                      $compat .= '</p><p><em>' . $annotation . '</em>';
 670                  }
 671              }
 672          } elseif ( ! $compatible_wp ) {
 673              $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of WordPress.' ) . '&nbsp;';
 674              if ( current_user_can( 'update_core' ) ) {
 675                  $compat .= sprintf(
 676                      /* translators: %s: URL to WordPress Updates screen. */
 677                      __( '<a href="%s">Please update WordPress</a>.' ),
 678                      self_admin_url( 'update-core.php' )
 679                  );
 680              }
 681          } elseif ( ! $compatible_php ) {
 682              $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
 683              if ( current_user_can( 'update_php' ) ) {
 684                  $compat .= sprintf(
 685                      /* translators: %s: URL to Update PHP page. */
 686                      __( '<a href="%s">Learn more about updating PHP</a>.' ),
 687                      esc_url( wp_get_update_php_url() )
 688                  );
 689  
 690                  $annotation = wp_get_update_php_annotation();
 691  
 692                  if ( $annotation ) {
 693                      $compat .= '</p><p><em>' . $annotation . '</em>';
 694                  }
 695              }
 696          }
 697  
 698          $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
 699          ?>
 700      <tr>
 701          <td class="check-column">
 702              <?php if ( $compatible_wp && $compatible_php ) : ?>
 703                  <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
 704                  <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
 705                      <?php
 706                      /* translators: %s: Theme name. */
 707                      printf( __( 'Select %s' ), $theme->display( 'Name' ) );
 708                      ?>
 709                  </label>
 710              <?php endif; ?>
 711          </td>
 712          <td class="plugin-title"><p>
 713              <img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
 714              <strong><?php echo $theme->display( 'Name' ); ?></strong>
 715              <?php
 716              printf(
 717                  /* translators: 1: Theme version, 2: New version. */
 718                  __( 'You have version %1$s installed. Update to %2$s.' ),
 719                  $theme->display( 'Version' ),
 720                  $theme->update['new_version']
 721              );
 722  
 723              echo ' ' . $compat;
 724  
 725              if ( in_array( $stylesheet, $auto_updates, true ) ) {
 726                  echo $auto_update_notice;
 727              }
 728              ?>
 729          </p></td>
 730      </tr>
 731              <?php
 732      }
 733      ?>
 734      </tbody>
 735  
 736      <tfoot>
 737      <tr>
 738          <td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td>
 739          <td class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></td>
 740      </tr>
 741      </tfoot>
 742  </table>
 743  <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
 744  </form>
 745      <?php
 746  }
 747  
 748  /**
 749   * Display the update translations form.
 750   *
 751   * @since 3.7.0
 752   */
 753  function list_translation_updates() {
 754      $updates = wp_get_translation_updates();
 755      if ( ! $updates ) {
 756          if ( 'en_US' !== get_locale() ) {
 757              echo '<h2>' . __( 'Translations' ) . '</h2>';
 758              echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
 759          }
 760          return;
 761      }
 762  
 763      $form_action = 'update-core.php?action=do-translation-upgrade';
 764      ?>
 765      <h2><?php _e( 'Translations' ); ?></h2>
 766      <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade">
 767          <p><?php _e( 'New translations are available.' ); ?></p>
 768          <?php wp_nonce_field( 'upgrade-translations' ); ?>
 769          <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
 770      </form>
 771      <?php
 772  }
 773  
 774  /**
 775   * Upgrade WordPress core display.
 776   *
 777   * @since 2.7.0
 778   *
 779   * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
 780   *
 781   * @param bool $reinstall
 782   */
 783  function do_core_upgrade( $reinstall = false ) {
 784      global $wp_filesystem;
 785  
 786      require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
 787  
 788      if ( $reinstall ) {
 789          $url = 'update-core.php?action=do-core-reinstall';
 790      } else {
 791          $url = 'update-core.php?action=do-core-upgrade';
 792      }
 793      $url = wp_nonce_url( $url, 'upgrade-core' );
 794  
 795      $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
 796      $locale  = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
 797      $update  = find_core_update( $version, $locale );
 798      if ( ! $update ) {
 799          return;
 800      }
 801  
 802      // Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
 803      // that it's safe to do so. This only happens when there are no new files to create.
 804      $allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
 805  
 806      ?>
 807      <div class="wrap">
 808      <h1><?php _e( 'Update WordPress' ); ?></h1>
 809      <?php
 810  
 811      $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
 812      if ( false === $credentials ) {
 813          echo '</div>';
 814          return;
 815      }
 816  
 817      if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
 818          // Failed to connect. Error and request again.
 819          request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
 820          echo '</div>';
 821          return;
 822      }
 823  
 824      if ( $wp_filesystem->errors->has_errors() ) {
 825          foreach ( $wp_filesystem->errors->get_error_messages() as $message ) {
 826              show_message( $message );
 827          }
 828          echo '</div>';
 829          return;
 830      }
 831  
 832      if ( $reinstall ) {
 833          $update->response = 'reinstall';
 834      }
 835  
 836      add_filter( 'update_feedback', 'show_message' );
 837  
 838      $upgrader = new Core_Upgrader();
 839      $result   = $upgrader->upgrade(
 840          $update,
 841          array(
 842              'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
 843          )
 844      );
 845  
 846      if ( is_wp_error( $result ) ) {
 847          show_message( $result );
 848          if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) {
 849              show_message( __( 'Installation failed.' ) );
 850          }
 851          echo '</div>';
 852          return;
 853      }
 854  
 855      show_message( __( 'WordPress updated successfully.' ) );
 856      show_message(
 857          '<span class="hide-if-no-js">' . sprintf(
 858              /* translators: 1: WordPress version, 2: URL to About screen. */
 859              __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ),
 860              $result,
 861              esc_url( self_admin_url( 'about.php?updated' ) )
 862          ) . '</span>'
 863      );
 864      show_message(
 865          '<span class="hide-if-js">' . sprintf(
 866              /* translators: 1: WordPress version, 2: URL to About screen. */
 867              __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ),
 868              $result,
 869              esc_url( self_admin_url( 'about.php?updated' ) )
 870          ) . '</span>'
 871      );
 872      ?>
 873      </div>
 874      <script type="text/javascript">
 875      window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
 876      </script>
 877      <?php
 878  }
 879  
 880  /**
 881   * Dismiss a core update.
 882   *
 883   * @since 2.7.0
 884   */
 885  function do_dismiss_core_update() {
 886      $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
 887      $locale  = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
 888      $update  = find_core_update( $version, $locale );
 889      if ( ! $update ) {
 890          return;
 891      }
 892      dismiss_core_update( $update );
 893      wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) );
 894      exit;
 895  }
 896  
 897  /**
 898   * Undismiss a core update.
 899   *
 900   * @since 2.7.0
 901   */
 902  function do_undismiss_core_update() {
 903      $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
 904      $locale  = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
 905      $update  = find_core_update( $version, $locale );
 906      if ( ! $update ) {
 907          return;
 908      }
 909      undismiss_core_update( $version, $locale );
 910      wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) );
 911      exit;
 912  }
 913  
 914  $action = isset( $_GET['action'] ) ? $_GET['action'] : 'upgrade-core';
 915  
 916  $upgrade_error = false;
 917  if ( ( 'do-theme-upgrade' === $action || ( 'do-plugin-upgrade' === $action && ! isset( $_GET['plugins'] ) ) )
 918      && ! isset( $_POST['checked'] ) ) {
 919      $upgrade_error = ( 'do-theme-upgrade' === $action ) ? 'themes' : 'plugins';
 920      $action        = 'upgrade-core';
 921  }
 922  
 923  $title       = __( 'WordPress Updates' );
 924  $parent_file = 'index.php';
 925  
 926  $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>';
 927  $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>';
 928  
 929  get_current_screen()->add_help_tab(
 930      array(
 931          'id'      => 'overview',
 932          'title'   => __( 'Overview' ),
 933          'content' => $updates_overview,
 934      )
 935  );
 936  
 937  $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>';
 938  $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>';
 939  
 940  if ( 'en_US' !== get_locale() ) {
 941      $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>';
 942  }
 943  
 944  get_current_screen()->add_help_tab(
 945      array(
 946          'id'      => 'how-to-update',
 947          'title'   => __( 'How to Update' ),
 948          'content' => $updates_howto,
 949      )
 950  );
 951  
 952  $help_sidebar_autoupdates = '';
 953  
 954  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' ) ) ) {
 955      $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>';
 956      $help_tab_autoupdates .= '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>';
 957  
 958      get_current_screen()->add_help_tab(
 959          array(
 960              'id'      => 'plugins-themes-auto-updates',
 961              'title'   => __( 'Auto-updates' ),
 962              'content' => $help_tab_autoupdates,
 963          )
 964      );
 965  
 966      $help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>';
 967  }
 968  
 969  get_current_screen()->set_help_sidebar(
 970      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 971      '<p>' . __( '<a href="https://wordpress.org/support/article/dashboard-updates-screen/">Documentation on Updating WordPress</a>' ) . '</p>' .
 972      $help_sidebar_autoupdates .
 973      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 974  );
 975  
 976  if ( 'upgrade-core' === $action ) {
 977      // Force a update check when requested.
 978      $force_check = ! empty( $_GET['force-check'] );
 979      wp_version_check( array(), $force_check );
 980  
 981      require_once  ABSPATH . 'wp-admin/admin-header.php';
 982      ?>
 983      <div class="wrap">
 984      <h1><?php _e( 'WordPress Updates' ); ?></h1>
 985      <p><?php _e( 'Here you can find information about updates, set auto-updates and see what plugins or themes need updating.' ); ?></p>
 986  
 987      <?php
 988      if ( $upgrade_error ) {
 989          echo '<div class="error"><p>';
 990          if ( 'themes' === $upgrade_error ) {
 991              _e( 'Please select one or more themes to update.' );
 992          } else {
 993              _e( 'Please select one or more plugins to update.' );
 994          }
 995          echo '</p></div>';
 996      }
 997  
 998      $last_update_check = false;
 999      $current           = get_site_transient( 'update_core' );
1000  
1001      if ( $current && isset( $current->last_checked ) ) {
1002          $last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
1003      }
1004  
1005      echo '<h2 class="wp-current-version">';
1006      /* translators: Current version of WordPress. */
1007      printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) );
1008      echo '</h2>';
1009  
1010      echo '<p class="update-last-checked">';
1011      /* translators: 1: Date, 2: Time. */
1012      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 ) );
1013      echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check again.' ) . '</a>';
1014      echo '</p>';
1015  
1016      if ( current_user_can( 'update_core' ) ) {
1017          core_auto_updates_settings();
1018          core_upgrade_preamble();
1019      }
1020      if ( current_user_can( 'update_plugins' ) ) {
1021          list_plugin_updates();
1022      }
1023      if ( current_user_can( 'update_themes' ) ) {
1024          list_theme_updates();
1025      }
1026      if ( current_user_can( 'update_languages' ) ) {
1027          list_translation_updates();
1028      }
1029  
1030      /**
1031       * Fires after the core, plugin, and theme update tables.
1032       *
1033       * @since 2.9.0
1034       */
1035      do_action( 'core_upgrade_preamble' );
1036      echo '</div>';
1037  
1038      wp_localize_script(
1039          'updates',
1040          '_wpUpdatesItemCounts',
1041          array(
1042              'totals' => wp_get_update_data(),
1043          )
1044      );
1045  
1046      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1047  
1048  } elseif ( 'do-core-upgrade' === $action || 'do-core-reinstall' === $action ) {
1049  
1050      if ( ! current_user_can( 'update_core' ) ) {
1051          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1052      }
1053  
1054      check_admin_referer( 'upgrade-core' );
1055  
1056      // Do the (un)dismiss actions before headers, so that they can redirect.
1057      if ( isset( $_POST['dismiss'] ) ) {
1058          do_dismiss_core_update();
1059      } elseif ( isset( $_POST['undismiss'] ) ) {
1060          do_undismiss_core_update();
1061      }
1062  
1063      require_once  ABSPATH . 'wp-admin/admin-header.php';
1064      if ( 'do-core-reinstall' === $action ) {
1065          $reinstall = true;
1066      } else {
1067          $reinstall = false;
1068      }
1069  
1070      if ( isset( $_POST['upgrade'] ) ) {
1071          do_core_upgrade( $reinstall );
1072      }
1073  
1074      wp_localize_script(
1075          'updates',
1076          '_wpUpdatesItemCounts',
1077          array(
1078              'totals' => wp_get_update_data(),
1079          )
1080      );
1081  
1082      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1083  
1084  } elseif ( 'do-plugin-upgrade' === $action ) {
1085  
1086      if ( ! current_user_can( 'update_plugins' ) ) {
1087          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1088      }
1089  
1090      check_admin_referer( 'upgrade-core' );
1091  
1092      if ( isset( $_GET['plugins'] ) ) {
1093          $plugins = explode( ',', $_GET['plugins'] );
1094      } elseif ( isset( $_POST['checked'] ) ) {
1095          $plugins = (array) $_POST['checked'];
1096      } else {
1097          wp_redirect( admin_url( 'update-core.php' ) );
1098          exit;
1099      }
1100  
1101      $url = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) );
1102      $url = wp_nonce_url( $url, 'bulk-update-plugins' );
1103  
1104      $title = __( 'Update Plugins' );
1105  
1106      require_once  ABSPATH . 'wp-admin/admin-header.php';
1107      ?>
1108      <div class="wrap">
1109          <h1><?php _e( 'Update Plugins' ); ?></h1>
1110          <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe>
1111      </div>
1112      <?php
1113  
1114      wp_localize_script(
1115          'updates',
1116          '_wpUpdatesItemCounts',
1117          array(
1118              'totals' => wp_get_update_data(),
1119          )
1120      );
1121  
1122      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1123  
1124  } elseif ( 'do-theme-upgrade' === $action ) {
1125  
1126      if ( ! current_user_can( 'update_themes' ) ) {
1127          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1128      }
1129  
1130      check_admin_referer( 'upgrade-core' );
1131  
1132      if ( isset( $_GET['themes'] ) ) {
1133          $themes = explode( ',', $_GET['themes'] );
1134      } elseif ( isset( $_POST['checked'] ) ) {
1135          $themes = (array) $_POST['checked'];
1136      } else {
1137          wp_redirect( admin_url( 'update-core.php' ) );
1138          exit;
1139      }
1140  
1141      $url = 'update.php?action=update-selected-themes&themes=' . urlencode( implode( ',', $themes ) );
1142      $url = wp_nonce_url( $url, 'bulk-update-themes' );
1143  
1144      $title = __( 'Update Themes' );
1145  
1146      require_once  ABSPATH . 'wp-admin/admin-header.php';
1147      ?>
1148      <div class="wrap">
1149          <h1><?php _e( 'Update Themes' ); ?></h1>
1150          <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe>
1151      </div>
1152      <?php
1153  
1154      wp_localize_script(
1155          'updates',
1156          '_wpUpdatesItemCounts',
1157          array(
1158              'totals' => wp_get_update_data(),
1159          )
1160      );
1161  
1162      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1163  
1164  } elseif ( 'do-translation-upgrade' === $action ) {
1165  
1166      if ( ! current_user_can( 'update_languages' ) ) {
1167          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1168      }
1169  
1170      check_admin_referer( 'upgrade-translations' );
1171  
1172      require_once  ABSPATH . 'wp-admin/admin-header.php';
1173      require_once  ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1174  
1175      $url     = 'update-core.php?action=do-translation-upgrade';
1176      $nonce   = 'upgrade-translations';
1177      $title   = __( 'Update Translations' );
1178      $context = WP_LANG_DIR;
1179  
1180      $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
1181      $result   = $upgrader->bulk_upgrade();
1182  
1183      wp_localize_script(
1184          'updates',
1185          '_wpUpdatesItemCounts',
1186          array(
1187              'totals' => wp_get_update_data(),
1188          )
1189      );
1190  
1191      require_once  ABSPATH . 'wp-admin/admin-footer.php';
1192  
1193  } elseif ( 'core-major-auto-updates-settings' === $action ) {
1194  
1195      if ( ! current_user_can( 'update_core' ) ) {
1196          wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
1197      }
1198  
1199      $redirect_url = self_admin_url( 'update-core.php' );
1200  
1201      if ( isset( $_GET['value'] ) ) {
1202          check_admin_referer( 'core-major-auto-updates-nonce' );
1203  
1204          if ( 'enable' === $_GET['value'] ) {
1205              update_site_option( 'auto_update_core_major', 'enabled' );
1206              $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'enabled', $redirect_url );
1207          } elseif ( 'disable' === $_GET['value'] ) {
1208              update_site_option( 'auto_update_core_major', 'disabled' );
1209              $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'disabled', $redirect_url );
1210          }
1211      }
1212  
1213      wp_redirect( $redirect_url );
1214      exit;
1215  } else {
1216      /**
1217       * Fires for each custom update action on the WordPress Updates screen.
1218       *
1219       * The dynamic portion of the hook name, `$action`, refers to the
1220       * passed update action. The hook fires in lieu of all available
1221       * default update actions.
1222       *
1223       * @since 3.2.0
1224       */
1225      do_action( "update-core-custom_{$action}" );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
1226  }


Generated : Thu Jan 28 08:20:02 2021 Cross-referenced by PHPXref