plugin updates
This commit is contained in:
@@ -196,8 +196,8 @@ final class OrderUtil {
|
||||
public static function get_count_for_type( $order_type ) {
|
||||
global $wpdb;
|
||||
|
||||
$cache_key = 'order-count-' . $order_type;
|
||||
$count_per_status = wp_cache_get( $cache_key, 'orders' );
|
||||
$cache_key = \WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'order-count-' . $order_type;
|
||||
$count_per_status = wp_cache_get( $cache_key, 'counts' );
|
||||
|
||||
if ( false === $count_per_status ) {
|
||||
if ( self::custom_orders_table_usage_is_enabled() ) {
|
||||
@@ -222,7 +222,7 @@ final class OrderUtil {
|
||||
$count_per_status
|
||||
);
|
||||
|
||||
wp_cache_set( $cache_key, $count_per_status, 'orders' );
|
||||
wp_cache_set( $cache_key, $count_per_status, 'counts' );
|
||||
}
|
||||
|
||||
return $count_per_status;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
namespace Automattic\WooCommerce\Utilities;
|
||||
|
||||
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
|
||||
use Automattic\WooCommerce\Internal\Utilities\PluginInstaller;
|
||||
use Automattic\WooCommerce\Proxies\LegacyProxy;
|
||||
|
||||
/**
|
||||
@@ -182,7 +183,10 @@ class PluginUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Util function to generate warning string for incompatible features based on active plugins.
|
||||
* Utility method to generate warning string for incompatible features based on active plugins.
|
||||
*
|
||||
* Additionally, this method will manually print a warning message on the HPOS feature if both
|
||||
* the Legacy REST API and HPOS are active.
|
||||
*
|
||||
* @param string $feature_id Feature id.
|
||||
* @param array $plugin_feature_info Array of plugin feature info. See FeaturesControllers->get_compatible_plugins_for_feature() for details.
|
||||
@@ -195,20 +199,55 @@ class PluginUtil {
|
||||
$incompatibles = array_filter( $incompatibles, 'is_plugin_active' );
|
||||
$incompatibles = array_values( array_diff( $incompatibles, $this->get_plugins_excluded_from_compatibility_ui() ) );
|
||||
$incompatible_count = count( $incompatibles );
|
||||
|
||||
$feature_warnings = array();
|
||||
if ( 'custom_order_tables' === $feature_id && 'yes' === get_option( 'woocommerce_api_enabled' ) ) {
|
||||
if ( is_plugin_active( 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php' ) ) {
|
||||
$legacy_api_and_hpos_incompatibility_warning_text =
|
||||
sprintf(
|
||||
// translators: %s is a URL.
|
||||
__( '⚠ <b><a target="_blank" href="%s">The Legacy REST API plugin</a> is installed and active on this site.</b> Please be aware that the WooCommerce Legacy REST API is <b>not</b> compatible with HPOS.', 'woocommerce' ),
|
||||
'https://wordpress.org/plugins/woocommerce-legacy-rest-api/'
|
||||
);
|
||||
} else {
|
||||
$legacy_api_and_hpos_incompatibility_warning_text =
|
||||
sprintf(
|
||||
// translators: %s is a URL.
|
||||
__( '⚠ <b><a target="_blank" href="%s">The Legacy REST API</a> is active on this site.</b> Please be aware that the WooCommerce Legacy REST API is <b>not</b> compatible with HPOS.', 'woocommerce' ),
|
||||
admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=legacy_api' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter to modify the warning text that appears in the HPOS section of the features settings page
|
||||
* when both the Legacy REST API is active (via WooCommerce core or via the Legacy REST API plugin)
|
||||
* and the orders table is in use as the primary data store for orders.
|
||||
*
|
||||
* @param string $legacy_api_and_hpos_incompatibility_warning_text Original warning text.
|
||||
* @returns string|null Actual warning text to use, or null to suppress the warning.
|
||||
*
|
||||
* @since 8.9.0
|
||||
*/
|
||||
$legacy_api_and_hpos_incompatibility_warning_text = apply_filters( 'woocommerce_legacy_api_and_hpos_incompatibility_warning_text', $legacy_api_and_hpos_incompatibility_warning_text );
|
||||
|
||||
if ( ! is_null( $legacy_api_and_hpos_incompatibility_warning_text ) ) {
|
||||
$feature_warnings[] = $legacy_api_and_hpos_incompatibility_warning_text . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $incompatible_count > 0 ) {
|
||||
if ( 1 === $incompatible_count ) {
|
||||
/* translators: %s = printable plugin name */
|
||||
$feature_warning = sprintf( __( '⚠ 1 Incompatible plugin detected (%s).', 'woocommerce' ), $this->get_plugin_name( $incompatibles[0] ) );
|
||||
$feature_warnings[] = sprintf( __( '⚠ 1 Incompatible plugin detected (%s).', 'woocommerce' ), $this->get_plugin_name( $incompatibles[0] ) );
|
||||
} elseif ( 2 === $incompatible_count ) {
|
||||
$feature_warning = sprintf(
|
||||
$feature_warnings[] = sprintf(
|
||||
/* translators: %1\$s, %2\$s = printable plugin names */
|
||||
__( '⚠ 2 Incompatible plugins detected (%1$s and %2$s).', 'woocommerce' ),
|
||||
$this->get_plugin_name( $incompatibles[0] ),
|
||||
$this->get_plugin_name( $incompatibles[1] )
|
||||
);
|
||||
} else {
|
||||
|
||||
$feature_warning = sprintf(
|
||||
$feature_warnings[] = sprintf(
|
||||
/* translators: %1\$s, %2\$s = printable plugin names, %3\$d = plugins count */
|
||||
_n(
|
||||
'⚠ Incompatible plugins detected (%1$s, %2$s and %3$d other).',
|
||||
@@ -229,18 +268,15 @@ class PluginUtil {
|
||||
),
|
||||
admin_url( 'plugins.php' )
|
||||
);
|
||||
$extra_desc_tip = '<br>' . sprintf(
|
||||
$feature_warnings[] = sprintf(
|
||||
/* translators: %1$s opening link tag %2$s closing link tag. */
|
||||
__( '%1$sView and manage%2$s', 'woocommerce' ),
|
||||
'<a href="' . esc_url( $incompatible_plugins_url ) . '">',
|
||||
'</a>'
|
||||
);
|
||||
|
||||
$feature_warning .= $extra_desc_tip;
|
||||
|
||||
}
|
||||
|
||||
return $feature_warning;
|
||||
return str_replace( "\n", '<br>', implode( "\n", $feature_warnings ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user