diff --git a/api-hashes-generator.php b/api-hashes-generator.php index 91ef868..06fc3ab 100644 --- a/api-hashes-generator.php +++ b/api-hashes-generator.php @@ -6,16 +6,24 @@ */ $version_url = 'https://api.wordpress.org/core/version-check/1.7/'; -$checksum_url = 'https://api.wordpress.org/core/checksums/1.0/?version='; -$locale = '&locale=en_US'; $versions = file_get_contents( $version_url ); $versions = json_decode( $versions ); foreach( $versions->offers as $wp_version ) { - $filename = dirname( __FILE__ ) . '/' . 'hashes-' . $wp_version->version . '.php'; + create_hashes( $wp_version->version ); +} + +if ( isset( $_GET['version'] ) ) { + create_hashes( $_GET['version'] ); +} + +function create_hashes( $wp_version ) { + $checksum_url = 'https://api.wordpress.org/core/checksums/1.0/?version='; + $locale = '&locale=en_US'; + $filename = dirname( __FILE__ ) . '/' . 'hashes-' . $wp_version . '.php'; if ( ! file_exists( $filename ) ) { - $checksums = file_get_contents( $checksum_url . $wp_version->version . $locale ); + $checksums = file_get_contents( $checksum_url . $wp_version . $locale ); $checksums = json_decode( $checksums, true ); $hashes = " $checksum ) { @@ -25,6 +33,6 @@ } $hashes .= ");\n"; file_put_contents( $filename, $hashes ); - echo 'Hash file created for ' . $wp_version->version . "\n"; + echo 'Hash file created for ' . $wp_version . "\n"; } }