diff --git a/plugins/woocommerce-blocks/bin/version-changes.sh b/plugins/woocommerce-blocks/bin/version-changes.sh index d1320da616d..c8e30d22306 100755 --- a/plugins/woocommerce-blocks/bin/version-changes.sh +++ b/plugins/woocommerce-blocks/bin/version-changes.sh @@ -4,7 +4,7 @@ IS_PRE_RELEASE=${IS_PRE_RELEASE:=false} # replace all instances of $VID:$ with the release version but only when not pre-release. if [ $IS_PRE_RELEASE = false ]; then - find ./src -name "*.php" -print0 | xargs -0 perl -i -pe 's/\$VID:\$/'${VERSION}'/g' + find ./src woocommerce-gutenberg-products-block.php -name "*.php" -print0 | xargs -0 perl -i -pe 's/\$VID:\$/'${VERSION}'/g' fi # Update version number in readme.txt diff --git a/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php b/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php index 167af20af9e..4b00cf6b282 100644 --- a/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php +++ b/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php @@ -18,7 +18,68 @@ defined( 'ABSPATH' ) || exit; -if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) { +$minimum_wp_version = '5.0'; +$minimum_php_version = '5.6'; + +/** + * Whether notices must be displayed in the current page (plugins and WooCommerce pages). + * + * @since $VID:$ + */ +function should_display_compatibility_notices() { + $current_screen = get_current_screen(); + + if ( ! isset( $current_screen ) ) { + return false; + } + + $is_plugins_page = + property_exists( $current_screen, 'id' ) && + 'plugins' === $current_screen->id; + $is_woocommerce_page = + property_exists( $current_screen, 'parent_base' ) && + 'woocommerce' === $current_screen->parent_base; + + return $is_plugins_page || $is_woocommerce_page; +} + +if ( version_compare( $GLOBALS['wp_version'], $minimum_wp_version, '<' ) ) { + /** + * Outputs for an admin notice about running WooCommerce Blocks on outdated WordPress. + * + * @since $VID:$ + */ + function woocommerce_blocks_admin_unsupported_wp_notice() { + if ( should_display_compatibility_notices() ) { + ?> +
+

+
+ +
+

+
+