From a5b1b617c253ff6b253e016527e514e27722dd31 Mon Sep 17 00:00:00 2001 From: Allen Snook Date: Wed, 7 Nov 2018 14:53:05 -0500 Subject: [PATCH] Prompt user to set SCRIPT_DEBUG on WP 5 for now. --- plugins/woocommerce-admin/README.md | 4 ++++ plugins/woocommerce-admin/wc-admin.php | 31 ++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/plugins/woocommerce-admin/README.md b/plugins/woocommerce-admin/README.md index 564d2710960..3fa68c2f49f 100644 --- a/plugins/woocommerce-admin/README.md +++ b/plugins/woocommerce-admin/README.md @@ -14,6 +14,10 @@ This is a feature plugin for a modern, javascript-driven WooCommerce Admin exper For better debugging, it's also recommended you add `define( 'SCRIPT_DEBUG', true );` to your wp-config. This will load the unminified version of all libraries, and specifically the development build of React. +### WordPress 5 + +There is an unresolved bug ( https://github.com/woocommerce/wc-admin/issues/796 ) that prevents us from running with minified script. Until this is resolved, include `define( 'SCRIPT_DEBUG', true );` in your wp-config. + ## Development After cloning the repo, install dependencies with `npm install`. Now you can build the files using one of these commands: diff --git a/plugins/woocommerce-admin/wc-admin.php b/plugins/woocommerce-admin/wc-admin.php index 33a53715b32..9b535f6d891 100755 --- a/plugins/woocommerce-admin/wc-admin.php +++ b/plugins/woocommerce-admin/wc-admin.php @@ -28,12 +28,25 @@ if ( ! defined( 'WC_ADMIN_PLUGIN_FILE' ) ) { * Notify users of the plugin requirements */ function wc_admin_plugins_notice() { - $message = sprintf( - /* translators: 1: URL of Gutenberg plugin, 2: URL of WooCommerce plugin */ - __( 'The WooCommerce Admin feature plugin requires both Gutenberg and WooCommerce (>3.5) to be installed and active.', 'wc-admin' ), - 'https://wordpress.org/plugins/gutenberg/', - 'https://wordpress.org/plugins/woocommerce/' - ); + // The notice varies by WordPress version. + $wordpress_version = get_bloginfo( 'version' ); + $wordpress_includes_gutenberg = version_compare( $wordpress_version, '4.9.9', '>' ); + + if ( $wordpress_includes_gutenberg ) { + $message = sprintf( + // TODO: Remove the "and SCRIPT_DEBUG enabled" when https://github.com/woocommerce/wc-admin/issues/796 is fixed. + /* translators: URL of WooCommerce plugin */ + __( 'The WooCommerce Admin feature plugin requires WooCommerce (>3.5) to be installed and active and SCRIPT_DEBUG enabled.', 'wc-admin' ), + 'https://wordpress.org/plugins/woocommerce/' + ); + } else { + $message = sprintf( + /* translators: 1: URL of Gutenberg plugin, 2: URL of WooCommerce plugin */ + __( 'The WooCommerce Admin feature plugin requires both Gutenberg and WooCommerce (>3.5) to be installed and active.', 'wc-admin' ), + 'https://wordpress.org/plugins/gutenberg/', + 'https://wordpress.org/plugins/woocommerce/' + ); + } printf( '

%s

', $message ); /* WPCS: xss ok. */ } @@ -52,7 +65,11 @@ function dependencies_satisfied() { $wordpress_includes_gutenberg = version_compare( $wordpress_version, '4.9.9', '>' ); $gutenberg_plugin_active = defined( 'GUTENBERG_DEVELOPMENT_MODE' ) || defined( 'GUTENBERG_VERSION' ); - return $wordpress_includes_gutenberg || $gutenberg_plugin_active; + // Right now, there is a bug preventing us from running with WP5 with minified script. + // See https://github.com/woocommerce/wc-admin/issues/796 for details. + $script_debug_enabled = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; + + return ( $script_debug_enabled && $wordpress_includes_gutenberg ) || $gutenberg_plugin_active; } /**