WC Tracker: Add enabled features, plugin feature compatibility
* Adds a data key with the list of WC features that are currently enabled on the site. * Adds a `feature_compat` key to each plugin that shows its compatibility with each feature (compatibile, incompatible, uncertain) if the plugin is "woocommerce aware", otherwise just an empty array.
This commit is contained in:
parent
9725529e41
commit
71ead43c61
|
@ -12,8 +12,8 @@
|
|||
|
||||
use Automattic\Jetpack\Constants;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
|
||||
use Automattic\WooCommerce\Utilities\{ FeaturesUtil, OrderUtil, PluginUtil };
|
||||
use Automattic\WooCommerce\Internal\Utilities\BlocksUtil;
|
||||
use Automattic\WooCommerce\Utilities\OrderUtil;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
|
@ -153,7 +153,6 @@ class WC_Tracker {
|
|||
$data['inactive_plugins'] = $all_plugins['inactive_plugins'];
|
||||
|
||||
// Jetpack & WooCommerce Connect.
|
||||
|
||||
$data['jetpack_version'] = Constants::is_defined( 'JETPACK__VERSION' ) ? Constants::get_constant( 'JETPACK__VERSION' ) : 'none';
|
||||
$data['jetpack_connected'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_active' ) && Jetpack::is_active() ) ? 'yes' : 'no';
|
||||
$data['jetpack_is_staging'] = self::is_jetpack_staging_site() ? 'yes' : 'no';
|
||||
|
@ -177,6 +176,9 @@ class WC_Tracker {
|
|||
// Shipping method info.
|
||||
$data['shipping_methods'] = self::get_active_shipping_methods();
|
||||
|
||||
// Features
|
||||
$data['enabled_features'] = self::get_enabled_features();
|
||||
|
||||
// Get all WooCommerce options info.
|
||||
$data['settings'] = self::get_all_woocommerce_options_values();
|
||||
|
||||
|
@ -329,6 +331,10 @@ class WC_Tracker {
|
|||
if ( isset( $v['PluginURI'] ) ) {
|
||||
$formatted['plugin_uri'] = wp_strip_all_tags( $v['PluginURI'] );
|
||||
}
|
||||
$formatted['feature_compat'] = array();
|
||||
if ( wc_get_container()->get( PluginUtil::class )->is_woocommerce_aware_plugin( $k ) ) {
|
||||
$formatted['feature_compat'] = array_filter( FeaturesUtil::get_compatible_features_for_plugin( $k ) );
|
||||
}
|
||||
if ( in_array( $k, $active_plugins_keys, true ) ) {
|
||||
// Remove active plugins from list so we can show active and inactive separately.
|
||||
unset( $plugins[ $k ] );
|
||||
|
@ -904,6 +910,23 @@ class WC_Tracker {
|
|||
return $active_methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of slugs for WC features that are enabled on the site.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private static function get_enabled_features() {
|
||||
$all_features = FeaturesUtil::get_features( true, true );
|
||||
$enabled_features = array_filter(
|
||||
$all_features,
|
||||
function( $feature ) {
|
||||
return $feature['is_enabled'];
|
||||
}
|
||||
);
|
||||
|
||||
return array_keys( $enabled_features );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all options starting with woocommerce_ prefix.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue