list_core_update() – Lists available core updates.

You appear to be a bot. Output may be restricted

Description

Lists available core updates.

Usage

list_core_update( $update );

Parameters

$update
( object ) required

Returns

void

Source

File name: wordpress/wp-admin/update-core.php
Lines:

1 to 100 of 159
function list_core_update( $update ) {
  global $wp_local_package, $wpdb;
  static $first_pass = true;

  $wp_version     = get_bloginfo( 'version' );
  $version_string = sprintf( '%s–%s', $update->current, get_locale() );

  if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) {
    $version_string = $update->current;
  } elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) {
    $updates = get_core_updates();
    if ( $updates && 1 === count( $updates ) ) {
      // If the only available update is a partial builds, it doesn't need a language-specific version string.
      $version_string = $update->current;
    }
  } elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() ) {
    $version_string = sprintf( '%s–%s', $update->current, $update->locale );
  }

  $current = false;
  if ( ! isset( $update->response ) || 'latest' === $update->response ) {
    $current = true;
  }

  $message       = '';
  $form_action   = 'update-core.php?action=do-core-upgrade';
  $php_version   = PHP_VERSION;
  $mysql_version = $wpdb->db_version();
  $show_buttons  = true;

  // Nightly build versions have two hyphens and a commit number.
  if ( preg_match( '/-\w+-\d+/', $update->current ) ) {
    // Retrieve the major version number.
    preg_match( '/^\d+.\d+/', $update->current, $update_major );
    /* translators: %s: WordPress version. */
    $submit = sprintf( __( 'Update to latest %s nightly' ), $update_major[0] );
  } else {
    /* translators: %s: WordPress version. */
    $submit = sprintf( __( 'Update to version %s' ), $version_string );
  }

  if ( 'development' === $update->response ) {
    $message = __( 'You can update to the latest nightly build manually:' );
  } else {
    if ( $current ) {
      /* translators: %s: WordPress version. */
      $submit      = sprintf( __( 'Re-install version %s' ), $version_string );
      $form_action = 'update-core.php?action=do-core-reinstall';
    } else {
      $php_compat = version_compare( $php_version, $update->php_version, '>=' );
      if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
        $mysql_compat = true;
      } else {
        $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
      }

      $version_url = sprintf(
        /* translators: %s: WordPress version. */
        esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ),
        sanitize_title( $update->current )
      );

      $php_update_message = '</p><p>' . sprintf(
        /* translators: %s: URL to Update PHP page. */
        __( '<a href="%s">Learn more about updating PHP</a>.' ),
        esc_url( wp_get_update_php_url() )
      );

      $annotation = wp_get_update_php_annotation();

      if ( $annotation ) {
        $php_update_message .= '</p><p><em>' . $annotation . '</em>';
      }

      if ( ! $mysql_compat && ! $php_compat ) {
        $message = sprintf(
          /* 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. */
          __( '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.' ),
          $version_url,
          $update->current,
          $update->php_version,
          $update->mysql_version,
          $php_version,
          $mysql_version
        ) . $php_update_message;
      } elseif ( ! $php_compat ) {
        $message = sprintf(
          /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
          __( '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.' ),
          $version_url,
          $update->current,
          $update->php_version,
          $php_version
        ) . $php_update_message;
      } elseif ( ! $mysql_compat ) {
        $message = sprintf(
          /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
          __( '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.' ),
          $version_url,
          $update->current,
 

 View on GitHub View on Trac