Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors

PluginsActivatedRuleProcessor::process()publicWC 1.0

Process the rule.

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

Хуков нет.

Возвращает

true|false. Whether the rule passes or not.

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

$PluginsActivatedRuleProcessor = new PluginsActivatedRuleProcessor();
$PluginsActivatedRuleProcessor->process( $rule, $stored_state );
$rule(объект) (обязательный)
The specific rule being processed by this rule processor.
$stored_state(объект) (обязательный)
Stored state.

Код PluginsActivatedRuleProcessor::process() WC 8.9.0

public function process( $rule, $stored_state ) {
	if ( ! is_countable( $rule->plugins ) || 0 === count( $rule->plugins ) ) {
		return false;
	}

	$active_plugin_slugs = $this->plugins_provider->get_active_plugin_slugs();

	foreach ( $rule->plugins as $plugin_slug ) {
		if ( ! is_string( $plugin_slug ) ) {
			$logger = wc_get_logger();
			$logger->warning(
				__( 'Invalid plugin slug provided in the plugins activated rule.', 'woocommerce' )
			);
			return false;
		}

		if ( ! in_array( $plugin_slug, $active_plugin_slugs, true ) ) {
			return false;
		}
	}

	return true;
}