src/Checksum_Plugin_Command.php
private function check_file_checksum( $path, $checksums ) {
		if ( $this->supports_sha256()
			&& array_key_exists( 'sha256', $checksums )
		) {
			$sha256 = $this->get_sha256( $this->get_absolute_path( $path ) );

			return in_array( $sha256, (array) $checksums['sha256'], true );
		}

		if ( ! array_key_exists( 'md5', $checksums ) ) {
			return 'No matching checksum algorithm found';
		}

		$md5 = $this->get_md5( $this->get_absolute_path( $path ) );

		return in_array( $md5, (array) $checksums['md5'], true );
	}
private function check_file_checksum( $path, $checksums ) {
		if ( $this->supports_sha256()
			&& array_key_exists( 'sha256', $checksums )
		) {
			$sha256 = $this->get_sha256( $this->get_absolute_path( $path ) );

			return in_array( $sha256, (array) $checksums['sha256'], true );
		}

		if ( ! array_key_exists( 'md5', $checksums ) ) {
			return 'No matching checksum algorithm found';
		}

		$md5 = $this->get_md5( $this->get_absolute_path( $path ) );

		return in_array( $md5, (array) $checksums['md5'], true );
	}
private function check_file_checksum ( $ path , $ checksums ) { if ( $ this -> supports_sha256 ( ) && array_key_exists ( 'sha256' , $ checksums ) ) { $ sha256 = $ this -> get_sha256 ( $ this -> get_absolute_path ( $ path ) ) ; return in_array ( $ sha256 , ( array ) $ checksums [ 'sha256' ] , true ) ; } if ( ! array_key_exists ( 'md5' , $ checksums ) ) { return 'No matching checksum algorithm found' ; } $ md5 = $ this -> get_md5 ( $ this -> get_absolute_path ( $ path ) ) ; return in_array ( $ md5 , ( array ) $ checksums [ 'md5' ] , true ) ; }
Checks the integrity of a single plugin file by comparing it to the
officially provided checksum.

@param string $path      Relative path to the plugin file to check the
integrity of.
@param array  $checksums Array of provided checksums to compare against.

@return true|string
Checks the integrity of a single plugin file by comparing it to the officially provided checksum .