Core_Upgrader::check_files() WordPress Method

The Core_Upgrader::check_files() method is used to check if any of the WordPress core files have been modified. If any of the files have been modified, the method will return an error.

Core_Upgrader::check_files() #

Compare the disk file checksums against the expected checksums.


Return

(bool) True if the checksums match, otherwise false.


Top ↑

Source

File: wp-admin/includes/class-core-upgrader.php

	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 ( 'wp-content' === substr( $file, 0, 10 ) ) {
				continue;
			}
			if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) {
				return false;
			}
		}

		return true;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.