Automattic\WooCommerce\Internal\Features
FeaturesController::maybe_display_feature_incompatibility_warning
Shows a warning when there are any incompatibility between active plugins and enabled features. The warning is shown in on any admin screen except the plugins screen itself, since there's already a "You are viewing plugins that are incompatible" notice.
Method of the class: FeaturesController{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->maybe_display_feature_incompatibility_warning(): void;
FeaturesController::maybe_display_feature_incompatibility_warning() FeaturesController::maybe display feature incompatibility warning code WC 10.8.1
<?php
private function maybe_display_feature_incompatibility_warning(): void {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
$incompatible_plugins = false;
$relevant_plugins = array_diff( $this->plugin_util->get_woocommerce_aware_plugins( true ), $this->plugins_excluded_from_compatibility_ui );
foreach ( $relevant_plugins as $plugin ) {
$compatibility_info = $this->get_compatible_features_for_plugin( $plugin, true );
$incompatibles = array_filter( $compatibility_info[ FeaturePluginCompatibility::INCOMPATIBLE ], fn( $id ) => ! $this->should_skip_compatibility_checks( $id ) );
if ( ! empty( $incompatibles ) ) {
$incompatible_plugins = true;
break;
}
$uncertains = array_filter( $compatibility_info[ FeaturePluginCompatibility::UNCERTAIN ], fn( $id ) => ! $this->should_skip_compatibility_checks( $id ) );
foreach ( $uncertains as $feature_id ) {
if ( FeaturePluginCompatibility::COMPATIBLE !== $this->get_default_plugin_compatibility( $feature_id ) ) {
$incompatible_plugins = true;
break;
}
}
if ( $incompatible_plugins ) {
break;
}
}
if ( ! $incompatible_plugins ) {
return;
}
$message = str_replace(
'<a>',
'<a href="' . esc_url( add_query_arg( array( 'plugin_status' => 'incompatible_with_feature' ), admin_url( 'plugins.php' ) ) ) . '">',
__( 'WooCommerce has detected that some of your active plugins are incompatible with currently enabled WooCommerce features. Please <a>review the details</a>.', 'woocommerce' )
);
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
?>
<div class="notice notice-error">
<p><?php echo $message; ?></p>
</div>
<?php
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
}