core_upgrade_preamble

Display upgrade WordPress for downloading latest or upgrading automatically form.

Description

core_upgrade_preamble(); 

Usage

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

Defined (1)

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

/wp-admin/update-core.php  
  1. function core_upgrade_preamble() { 
  2. global $required_php_version, $required_mysql_version; 
  3.  
  4. $wp_version = get_bloginfo( 'version' ); 
  5. $updates = get_core_updates(); 
  6.  
  7. if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) { 
  8. echo '<h2>'; 
  9. _e('You have the latest version of WordPress.'); 
  10.  
  11. if ( wp_http_supports( array( 'ssl' ) ) ) { 
  12. require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 
  13. $upgrader = new WP_Automatic_Updater; 
  14. $future_minor_update = (object) array( 
  15. 'current' => $wp_version . '.1.next.minor',  
  16. 'version' => $wp_version . '.1.next.minor',  
  17. 'php_version' => $required_php_version,  
  18. 'mysql_version' => $required_mysql_version,  
  19. ); 
  20. $should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH ); 
  21. if ( $should_auto_update ) 
  22. echo ' ' . __( 'Future security updates will be applied automatically.' ); 
  23. echo '</h2>'; 
  24. } else { 
  25. echo '<div class="notice notice-warning"><p>'; 
  26. _e('<strong>Important:</strong> before updating, please <a href="https://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="https://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.'); 
  27. echo '</p></div>'; 
  28.  
  29. echo '<h2 class="response">'; 
  30. _e( 'An updated version of WordPress is available.' ); 
  31. echo '</h2>'; 
  32.  
  33. if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) { 
  34. require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 
  35. $upgrader = new WP_Automatic_Updater; 
  36. if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) { 
  37. echo '<div class="updated inline"><p>'; 
  38. echo '<strong>' . __( 'BETA TESTERS:' ) . '</strong> ' . __( 'This site is set up to install updates of future beta versions automatically.' ); 
  39. echo '</p></div>'; 
  40.  
  41. echo '<ul class="core-updates">'; 
  42. foreach ( (array) $updates as $update ) { 
  43. echo '<li>'; 
  44. list_core_update( $update ); 
  45. echo '</li>'; 
  46. echo '</ul>'; 
  47. // Don't show the maintenance mode notice when we are only showing a single re-install option. 
  48. if ( $updates && ( count( $updates ) > 1 || $updates[0]->response != 'latest' ) ) { 
  49. echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.' ) . '</p>'; 
  50. } elseif ( ! $updates ) { 
  51. list( $normalized_version ) = explode( '-', $wp_version ); 
  52. echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>';