Automattic\WooCommerce\Internal\Features

FeaturesController::maybe_display_feature_incompatibility_warning()privateWC 1.0

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

Method of the class: FeaturesController{}

No Hooks.

Return

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() code WC 8.6.1

<?php
private function maybe_display_feature_incompatibility_warning(): void {
	if ( ! current_user_can( 'activate_plugins' ) ) {
		return;
	}

	$incompatible_plugins = false;

	foreach ( $this->plugin_util->get_woocommerce_aware_plugins( true ) as $plugin ) {
		$compatibility     = $this->get_compatible_features_for_plugin( $plugin, true );
		$incompatible_with = array_filter(
			array_merge( $compatibility['incompatible'], $compatibility['uncertain'] ),
			function( $feature_id ) {
				return ! $this->is_legacy_feature( $feature_id );
			}
		);

		if ( $incompatible_with ) {
			$incompatible_plugins = true;
			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
}