Automattic\WooCommerce\Internal\Features

FeaturesController::maybe_display_current_feature_filter_description()privateWC 1.0

Shows a "You are viewing the plugins that are incompatible with the X feature" if we are in the plugins page and the query string of the current request looks like '?plugin_status=incompatible_with_feature&feature_id=<feature id>'.

Метод класса: FeaturesController{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->maybe_display_current_feature_filter_description(): bool;

Код FeaturesController::maybe_display_current_feature_filter_description() WC 8.7.0

<?php
private function maybe_display_current_feature_filter_description(): bool {
	if ( 'plugins' !== get_current_screen()->id ) {
		return false;
	}

	// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
	$plugin_status = $_GET['plugin_status'] ?? '';
	$feature_id    = $_GET['feature_id'] ?? '';
	// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput

	if ( 'incompatible_with_feature' !== $plugin_status ) {
		return false;
	}

	$feature_id = ( '' === $feature_id ) ? 'all' : $feature_id;

	if ( 'all' !== $feature_id && ! $this->feature_exists( $feature_id ) ) {
		return false;
	}

	$features          = $this->get_feature_definitions();
	$plugins_page_url  = admin_url( 'plugins.php' );
	$features_page_url = $this->get_features_page_url();

	$message =
		'all' === $feature_id
		? __( 'You are viewing active plugins that are incompatible with currently enabled WooCommerce features.', 'woocommerce' )
		: sprintf(
			/* translators: %s is a feature name. */
			__( "You are viewing the active plugins that are incompatible with the '%s' feature.", 'woocommerce' ),
			$features[ $feature_id ]['name']
		);

	$message .= '<br />';
	$message .= sprintf(
		__( "<a href='%1\$s'>View all plugins</a> - <a href='%2\$s'>Manage WooCommerce features</a>", 'woocommerce' ),
		$plugins_page_url,
		$features_page_url
	);

	// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
	?>
	<div class="notice notice-info">
		<p><?php echo $message; ?></p>
	</div>
	<?php
	// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped

	return true;
}