The get_core_checksums() WordPress PHP function retrieves and caches the checksums for a specified version of WordPress.
Usage
get_core_checksums( $version, $locale );
Example:
Input:
get_core_checksums('5.8', 'en_US');
Output: An array of the checksums for WordPress version 5.8 with locale ‘en_US’.
Parameters
$version
(string) (Required): The version string of WordPress to query.$locale
(string) (Required): The locale string to query.
More information
See WordPress Developer Resources: get_core_checksums()
Examples
Verify WordPress Core Files
This code will compare the current WordPress core files with the original checksums to identify any file changes.
function verify_core_files() { $wp_version = get_bloginfo('version'); $wp_locale = get_locale(); $checksums = get_core_checksums($wp_version, $wp_locale); if (!$checksums) { echo "Could not retrieve checksums."; return; } $changed_files = array(); foreach ($checksums as $file => $checksum) { $file_path = ABSPATH . $file; if (!file_exists($file_path)) { $changed_files[] = $file; continue; } $file_content = file_get_contents($file_path); if (md5($file_content) !== $checksum) { $changed_files[] = $file; } } if (empty($changed_files)) { echo "All core files are unchanged."; } else { echo "Changed core files:"; echo implode(', ', $changed_files); } } verify_core_files();
Display WordPress Core Checksums
This code will display the checksums for the current WordPress version and locale.
function display_core_checksums() { $wp_version = get_bloginfo('version'); $wp_locale = get_locale(); $checksums = get_core_checksums($wp_version, $wp_locale); if (!$checksums) { echo "Could not retrieve checksums."; return; } foreach ($checksums as $file => $checksum) { echo "File: " . $file . " - Checksum: " . $checksum . "<br>"; } } display_core_checksums();