Automattic\WooCommerce\Internal\Features

FeaturesController::filter_plugins_list()privateWC 1.0

Handler for the all_plugins filter.

Returns the list of plugins incompatible with a given plugin 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. Ничего.

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

// private - только в коде основоного (родительского) класса
$result = $this->filter_plugins_list( $list ): array;
$list(массив) (обязательный)
The original list of plugins.

Код FeaturesController::filter_plugins_list() WC 7.1.0

private function filter_plugins_list( $list ): array {
	if ( ! $this->verify_did_woocommerce_init() ) {
		return $list;
	}

	// phpcs:disable WordPress.Security.NonceVerification
	if ( ! function_exists( 'get_current_screen' ) || get_current_screen() && 'plugins' !== get_current_screen()->id || 'incompatible_with_feature' !== ArrayUtil::get_value_or_default( $_GET, 'plugin_status' ) ) {
		return $list;
	}

	$feature_id = ArrayUtil::get_value_or_default( $_GET, 'feature_id', 'all' );
	if ( 'all' !== $feature_id && ! $this->feature_exists( $feature_id ) ) {
		return $list;
	}

	$incompatibles = array();

	// phpcs:enable WordPress.Security.NonceVerification
	foreach ( array_keys( $list ) as $plugin_name ) {
		if ( ! $this->plugin_util->is_woocommerce_aware_plugin( $plugin_name ) || ! $this->proxy->call_function( 'is_plugin_active', $plugin_name ) ) {
			continue;
		}

		$compatibility     = $this->get_compatible_features_for_plugin( $plugin_name );
		$incompatible_with = array_diff(
			array_merge( $compatibility['incompatible'], $compatibility['uncertain'] ),
			$this->legacy_feature_ids
		);

		if ( ( 'all' === $feature_id && ! empty( $incompatible_with ) ) || in_array( $feature_id, $incompatible_with, true ) ) {
			$incompatibles[] = $plugin_name;
		}
	}

	return array_intersect_key( $list, array_flip( $incompatibles ) );
}