find_core_auto_update

Gets the best available (and enabled) Auto-Update for WordPress Core.

Description

(array|false) find_core_auto_update(); 

If there's 1.2.3 and 1.3 on offer, it'll choose 1.3 if the install allows it, else, 1.2.3

Returns (array|false)

False on failure, otherwise the core update offering.


Usage

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

Defined (1)

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

/wp-admin/includes/update.php  
  1. function find_core_auto_update() { 
  2. $updates = get_site_transient( 'update_core' ); 
  3. if ( ! $updates || empty( $updates->updates ) ) 
  4. return false; 
  5.  
  6. include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 
  7.  
  8. $auto_update = false; 
  9. $upgrader = new WP_Automatic_Updater; 
  10. foreach ( $updates->updates as $update ) { 
  11. if ( 'autoupdate' != $update->response ) 
  12. continue; 
  13.  
  14. if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) 
  15. continue; 
  16.  
  17. if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) 
  18. $auto_update = $update; 
  19. return $auto_update;