From 1a72cf2e4e4995dd69c14b3fa0b02225bb599ff7 Mon Sep 17 00:00:00 2001 From: Allen Snook Date: Sun, 4 Nov 2018 21:14:26 -0500 Subject: [PATCH] Fix compatibility check to handle WP 5; call wp_get_jed_locale_data --- plugins/woocommerce-admin/lib/client-assets.php | 8 ++++++-- plugins/woocommerce-admin/wc-admin.php | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/woocommerce-admin/lib/client-assets.php b/plugins/woocommerce-admin/lib/client-assets.php index 7bdddb9ffd7..a6ff969275f 100644 --- a/plugins/woocommerce-admin/lib/client-assets.php +++ b/plugins/woocommerce-admin/lib/client-assets.php @@ -78,8 +78,12 @@ function wc_admin_register_script() { ); // Set up the text domain and translations. - $locale_data = gutenberg_get_jed_locale_data( 'wc-admin' ); - $content = 'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ', "wc-admin" );'; + if ( function_exists( 'wp_get_jed_locale_data' ) ) { + $locale_data = wp_get_jed_locale_data( 'wc-admin' ); + } else { + $locale_data = gutenberg_get_jed_locale_data( 'wc-admin' ); + } + $content = 'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ', "wc-admin" );'; wp_add_inline_script( 'wp-i18n', $content, 'after' ); // Resets lodash to wp-admin's version of lodash. diff --git a/plugins/woocommerce-admin/wc-admin.php b/plugins/woocommerce-admin/wc-admin.php index 71a65a743ee..d62d44b53e4 100755 --- a/plugins/woocommerce-admin/wc-admin.php +++ b/plugins/woocommerce-admin/wc-admin.php @@ -43,8 +43,16 @@ function wc_admin_plugins_notice() { * @return bool */ function dependencies_satisfied() { - return ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) || defined( 'GUTENBERG_VERSION' ) ) - && class_exists( 'WooCommerce' ) && version_compare( WC_VERSION, '3.5', '>' ); + $woocommerce_minimum_met = class_exists( 'WooCommerce' ) && version_compare( WC_VERSION, '3.5', '>' ); + if ( ! $woocommerce_minimum_met ) { + return false; + } + + $wordpress_version = get_bloginfo( 'version' ); + $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; } /**