On this page
get_core_checksums( string $version, string $locale ): array|false
Gets and caches the checksums for the given version of WordPress.
Parameters
$versionstring Required-
Version string to query.
$localestring Required-
Locale to query.
Return
array|false An array of checksums on success, false on failure.
Source
File: wp-admin/includes/update.php. View all references
function get_core_checksums( $version, $locale ) {
$http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' );
$url = $http_url;
$ssl = wp_http_supports( array( 'ssl' ) );
if ( $ssl ) {
$url = set_url_scheme( $url, 'https' );
}
$options = array(
'timeout' => wp_doing_cron() ? 30 : 3,
);
$response = wp_remote_get( $url, $options );
if ( $ssl && is_wp_error( $response ) ) {
trigger_error(
sprintf(
/* translators: %s: Support forums URL. */
__( 'An unexpected error occurred. 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>.' ),
__( 'https://wordpress.org/support/forums/' )
) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
);
$response = wp_remote_get( $http_url, $options );
}
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
return false;
}
$body = trim( wp_remote_retrieve_body( $response ) );
$body = json_decode( $body, true );
if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) {
return false;
}
return $body['checksums'];
}
Related
Uses
| Uses | Description |
|---|---|
| wp_doing_cron() wp-includes/load.php | Determines whether the current request is a WordPress cron request. |
| set_url_scheme() wp-includes/link-template.php | Sets the scheme for a URL. |
| wp_http_supports() wp-includes/http.php | Determines if there is an HTTP Transport that can process this request. |
| wp_remote_get() wp-includes/http.php | Performs an HTTP request using the GET method and returns its response. |
| wp_remote_retrieve_response_code() wp-includes/http.php | Retrieve only the response code from the raw response. |
| wp_remote_retrieve_body() wp-includes/http.php | Retrieve only the body from the raw response. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Used By
| Used By | Description |
|---|---|
| WP_Site_Health_Auto_Updates::test_all_files_writable() wp-admin/includes/class-wp-site-health-auto-updates.php | Checks if core files are writable by the web user/group. |
| Core_Upgrader::check_files() wp-admin/includes/class-core-upgrader.php | Compare the disk file checksums against the expected checksums. |
| update_core() wp-admin/includes/update-core.php | Upgrades the core of WordPress. |
Changelog
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_core_checksums