2019-03-25 06:43:26 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Updates PHP versions to match those in package.json before start or build.
|
|
|
|
*
|
|
|
|
* @package WooCommerce Admin
|
|
|
|
*/
|
|
|
|
|
|
|
|
$package_json = file_get_contents( 'package.json' );
|
|
|
|
$package = json_decode( $package_json );
|
|
|
|
|
2019-08-15 02:24:34 +00:00
|
|
|
function replace_version( $filename, $package_json ) {
|
2019-08-15 02:25:18 +00:00
|
|
|
$lines = array();
|
|
|
|
$file = file( $filename );
|
2019-08-15 22:08:29 +00:00
|
|
|
|
2019-08-15 02:24:34 +00:00
|
|
|
foreach ( $file as $line ) {
|
|
|
|
if ( stripos( $line, ' * Version: ' ) !== false ) {
|
|
|
|
$line = " * Version: {$package_json->version}\n";
|
|
|
|
}
|
|
|
|
if ( stripos( $line, ">define( 'WC_ADMIN_VERSION_NUMBER'," ) !== false ) {
|
|
|
|
$line = "\t\t\$this->define( 'WC_ADMIN_VERSION_NUMBER', '{$package_json->version}' );\n";
|
|
|
|
}
|
2019-11-19 23:23:27 +00:00
|
|
|
if ( stripos( $line, "const VERSION =" ) !== false ) {
|
|
|
|
$line = "\tconst VERSION = '{$package_json->version}';\n";
|
|
|
|
}
|
2020-03-17 19:30:33 +00:00
|
|
|
if ( stripos( $line, 'Stable tag: ' ) !== false ) {
|
|
|
|
$line = "Stable tag: {$package_json->version}\n";
|
|
|
|
}
|
2019-08-15 02:24:34 +00:00
|
|
|
$lines[] = $line;
|
2019-03-25 06:43:26 +00:00
|
|
|
}
|
2019-08-15 02:24:34 +00:00
|
|
|
file_put_contents( $filename, $lines );
|
2019-03-25 06:43:26 +00:00
|
|
|
}
|
2019-08-15 02:24:34 +00:00
|
|
|
|
|
|
|
replace_version( 'woocommerce-admin.php', $package );
|
|
|
|
replace_version( 'src/FeaturePlugin.php', $package );
|
2019-11-19 23:23:27 +00:00
|
|
|
replace_version( 'src/Package.php', $package );
|
2020-03-17 19:30:33 +00:00
|
|
|
replace_version( 'readme.txt', $package );
|