Fix compatibility check to handle WP 5; call wp_get_jed_locale_data

This commit is contained in:
Allen Snook 2018-11-04 21:14:26 -05:00
parent 3cc52dab29
commit 1a72cf2e4e
2 changed files with 16 additions and 4 deletions

View File

@ -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.

View File

@ -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;
}
/**