list_core_update

The WordPress Core list core update function.

Description

list_core_update( (object) $update ); 

Parameters (1)

0. $update (object)
The update.

Usage

  1. if ( !function_exists( 'list_core_update' ) ) { 
  2. require_once ABSPATH . '/wp-admin/update-core.php'; 
  3.  
  4. // The update. 
  5. $update = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = list_core_update($update); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/update-core.php  
  1. function list_core_update( $update ) { 
  2. global $wp_local_package, $wpdb; 
  3. static $first_pass = true; 
  4.  
  5. $wp_version = get_bloginfo( 'version' ); 
  6.  
  7. if ( 'en_US' == $update->locale && 'en_US' == get_locale() ) 
  8. $version_string = $update->current; 
  9. // If the only available update is a partial builds, it doesn't need a language-specific version string. 
  10. elseif ( 'en_US' == $update->locale && $update->packages->partial && $wp_version == $update->partial_version && ( $updates = get_core_updates() ) && 1 == count( $updates ) ) 
  11. $version_string = $update->current; 
  12. else 
  13. $version_string = sprintf( "%s–<strong>%s</strong>", $update->current, $update->locale ); 
  14.  
  15. $current = false; 
  16. if ( !isset($update->response) || 'latest' == $update->response ) 
  17. $current = true; 
  18. $submit = __('Update Now'); 
  19. $form_action = 'update-core.php?action=do-core-upgrade'; 
  20. $php_version = phpversion(); 
  21. $mysql_version = $wpdb->db_version(); 
  22. $show_buttons = true; 
  23. if ( 'development' == $update->response ) { 
  24. $message = __('You are using a development version of WordPress. You can update to the latest nightly build automatically:'); 
  25. } else { 
  26. if ( $current ) { 
  27. $message = sprintf( __( 'If you need to re-install version %s, you can do so here:' ), $version_string ); 
  28. $submit = __('Re-install Now'); 
  29. $form_action = 'update-core.php?action=do-core-reinstall'; 
  30. } else { 
  31. $php_compat = version_compare( $php_version, $update->php_version, '>=' ); 
  32. if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) 
  33. $mysql_compat = true; 
  34. else 
  35. $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ); 
  36.  
  37. if ( !$mysql_compat && !$php_compat ) 
  38. /** translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Minimum required MySQL version number, 4: Current PHP version number, 5: Current MySQL version number */ 
  39. $message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ); 
  40. elseif ( !$php_compat ) 
  41. /** translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Current PHP version number */ 
  42. $message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version ); 
  43. elseif ( !$mysql_compat ) 
  44. /** translators: 1: WordPress version number, 2: Minimum required MySQL version number, 3: Current MySQL version number */ 
  45. $message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version ); 
  46. else 
  47. /** translators: 1: WordPress version number, 2: WordPress version number including locale if necessary */ 
  48. $message = sprintf(__('You can update to <a href="https://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically:'), $update->current, $version_string); 
  49. if ( !$mysql_compat || !$php_compat ) 
  50. $show_buttons = false; 
  51.  
  52. echo '<p>'; 
  53. echo $message; 
  54. echo '</p>'; 
  55. echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">'; 
  56. wp_nonce_field('upgrade-core'); 
  57. echo '<p>'; 
  58. echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>'; 
  59. echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>'; 
  60. if ( $show_buttons ) { 
  61. if ( $first_pass ) { 
  62. submit_button( $submit, $current ? '' : 'primary regular', 'upgrade', false ); 
  63. $first_pass = false; 
  64. } else { 
  65. submit_button( $submit, '', 'upgrade', false ); 
  66. if ( 'en_US' != $update->locale ) 
  67. if ( !isset( $update->dismissed ) || !$update->dismissed ) 
  68. submit_button( __( 'Hide this update' ), '', 'dismiss', false ); 
  69. else 
  70. submit_button( __( 'Bring back this update' ), '', 'undismiss', false ); 
  71. echo '</p>'; 
  72. if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) ) 
  73. echo '<p class="hint">'.__('This localized version contains both the translation and various other localization fixes. You can skip upgrading if you want to keep your current translation.').'</p>'; 
  74. // Partial builds don't need language-specific warnings. 
  75. elseif ( 'en_US' == $update->locale && get_locale() != 'en_US' && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) { 
  76. echo '<p class="hint">'.sprintf( __('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.'), $update->response != 'development' ? $update->current : '' ).'</p>'; 
  77. echo '</form>'; 
  78.