Core_Upgrader::check_files()publicWP 3.7.0

Compares the disk file checksums against the expected checksums.

Method of the class: Core_Upgrader{}

No Hooks.

Return

true|false. True if the checksums match, otherwise false.

Usage

$Core_Upgrader = new Core_Upgrader();
$Core_Upgrader->check_files();

Notes

  • Global. String. $wp_version The WordPress version string.
  • Global. String. $wp_local_package Locale code of the package.

Changelog

Since 3.7.0 Introduced.

Core_Upgrader::check_files() code WP 6.5.2

public function check_files() {
	global $wp_version, $wp_local_package;

	$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );

	if ( ! is_array( $checksums ) ) {
		return false;
	}

	foreach ( $checksums as $file => $checksum ) {
		// Skip files which get updated.
		if ( str_starts_with( $file, 'wp-content' ) ) {
			continue;
		}
		if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) {
			return false;
		}
	}

	return true;
}