get_core_checksums

Gets and caches the checksums for the given version of WordPress.

Description

(bool|array) get_core_checksums( (string) $version, (string) $locale ); 

Returns (bool|array)

False on failure. An array of checksums on success.

Parameters (2)

0. $version (string)
Version string to query.
1. $locale (string)
Locale to query.

Usage

  1. if ( !function_exists( 'get_core_checksums' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/update.php'; 
  3.  
  4. // Version string to query. 
  5. $version = ''; 
  6.  
  7. // Locale to query. 
  8. $locale = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_core_checksums($version, $locale); 
  12.  

Defined (1)

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

/wp-admin/includes/update.php  
  1. function get_core_checksums( $version, $locale ) { 
  2. $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); 
  3.  
  4. if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) 
  5. $url = set_url_scheme( $url, 'https' ); 
  6.  
  7. $options = array( 
  8. 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),  
  9. ); 
  10.  
  11. $response = wp_remote_get( $url, $options ); 
  12. if ( $ssl && is_wp_error( $response ) ) { 
  13. trigger_error( 
  14. sprintf( 
  15. /** translators: %s: support forums URL */ 
  16. __( 'An unexpectederroroccurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),  
  17. __( 'https://wordpress.org/support/' ) 
  18. ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),  
  19. headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE 
  20. ); 
  21. $response = wp_remote_get( $http_url, $options ); 
  22.  
  23. if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) 
  24. return false; 
  25.  
  26. $body = trim( wp_remote_retrieve_body( $response ) ); 
  27. $body = json_decode( $body, true ); 
  28.  
  29. if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) 
  30. return false; 
  31.  
  32. return $body['checksums'];