get_core_updates

Get available core updates.

Description

(array|false) get_core_updates( (array) $options = array() ); 

Returns (array|false)

Array of the update objects on success, false on failure.

Parameters (1)

0. $options — Optional. (array) => array()
Set $options['dismissed'] to true to show dismissed upgrades too, set $options['available'] to false to skip not-dismissed updates.

Usage

  1. if ( !function_exists( 'get_core_updates' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/update.php'; 
  3.  
  4. // Set $options['dismissed'] to true to show dismissed upgrades too, 
  5. // set $options['available'] to false to skip not-dismissed updates. 
  6. $options = array(); 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = get_core_updates($options); 
  10.  

Defined (1)

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

/wp-admin/includes/update.php  
  1. function get_core_updates( $options = array() ) { 
  2. $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); 
  3. $dismissed = get_site_option( 'dismissed_update_core' ); 
  4.  
  5. if ( ! is_array( $dismissed ) ) 
  6. $dismissed = array(); 
  7.  
  8. $from_api = get_site_transient( 'update_core' ); 
  9.  
  10. if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) 
  11. return false; 
  12.  
  13. $updates = $from_api->updates; 
  14. $result = array(); 
  15. foreach ( $updates as $update ) { 
  16. if ( $update->response == 'autoupdate' ) 
  17. continue; 
  18.  
  19. if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { 
  20. if ( $options['dismissed'] ) { 
  21. $update->dismissed = true; 
  22. $result[] = $update; 
  23. } else { 
  24. if ( $options['available'] ) { 
  25. $update->dismissed = false; 
  26. $result[] = $update; 
  27. return $result;