diff --git a/plugins/woocommerce-blocks/bin/github-deploy.sh b/plugins/woocommerce-blocks/bin/github-deploy.sh index f06d0e7e46f..a72550395bf 100644 --- a/plugins/woocommerce-blocks/bin/github-deploy.sh +++ b/plugins/woocommerce-blocks/bin/github-deploy.sh @@ -107,9 +107,11 @@ if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" != "y" ]; then fi # Version changes -output 2 "Updating version numbers in files (note pre-releases will not have the readme.txt stable tag updated)..." +output 2 "Updating version numbers in files and regenerating php autoload classmap (note pre-releases will not have the readme.txt stable tag updated)..." source $RELEASER_PATH/bin/version-changes.sh +composer dump-autoload + output 2 "Committing version change..." echo diff --git a/plugins/woocommerce-blocks/bin/version-changes.sh b/plugins/woocommerce-blocks/bin/version-changes.sh index 56df7735518..67e8694414d 100755 --- a/plugins/woocommerce-blocks/bin/version-changes.sh +++ b/plugins/woocommerce-blocks/bin/version-changes.sh @@ -17,3 +17,6 @@ perl -i -pe 's/"version":*.+/"version": "'${VERSION}'",/' package.json # Update version in src/Package.php perl -i -pe "s/version \= '*.+';/version = '${VERSION}';/" src/Package.php + +# Add version to composer.json +perl -i -pe 's/"type":*.+/"type":"wordpress-plugin",\n\t"version": "'${VERSION}'",/' composer.json diff --git a/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php b/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php index e4443818408..fe4a348ec0c 100644 --- a/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php +++ b/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php @@ -10,7 +10,7 @@ * Requires at least: 5.2 * Requires PHP: 5.6 * WC requires at least: 4.0 - * WC tested up to: 4.2 + * WC tested up to: 4.4 * * @package WooCommerce\Blocks * @internal This file is only used when running as a feature plugin. @@ -64,6 +64,44 @@ if ( version_compare( $GLOBALS['wp_version'], $minimum_wp_version, '<' ) ) { return; } +/** + * Returns whether the current version is a development version + * Note this relies on composer.json version, not plugin version. + * Development installs of the plugin don't have a version defined in + * composer json. + * + * @return bool True means the current version is a development version. + */ +function woocommerce_blocks_is_development_version() { + $composer_file = __DIR__ . '/composer.json'; + if ( ! is_readable( $composer_file ) ) { + return false; + } + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- including local file + $composer_config = json_decode( file_get_contents( $composer_file ), true ); + return ! isset( $composer_config['version'] ); +} + +/** + * If development version is detected and the Jetpack constant is not defined, show a notice. + */ +if ( woocommerce_blocks_is_development_version() && ! defined( 'JETPACK_AUTOLOAD_DEV' ) ) { + add_action( + 'admin_notices', + function() { + echo '

'; + printf( + /* Translators: %1$s is referring to a php constant name, %2$s is referring to the wp-config.php file. */ + esc_html__( 'WooCommerce Blocks development mode requires the %1$s constant to be defined and true in your %2$s file. Otherwise you are loading the blocks package from WooCommerce core.', 'woo-gutenberg-products-block' ), + 'JETPACK_AUTOLOAD_DEV', + 'wp-config.php' + ); + echo '

'; + } + ); +} + + /** * Autoload packages. *