Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors
PluginVersionRuleProcessor::process
Process the rule.
Method of the class: PluginVersionRuleProcessor{}
Hooks from the method
Returns
true|false. Whether the rule passes or not.
Usage
$PluginVersionRuleProcessor = new PluginVersionRuleProcessor(); $PluginVersionRuleProcessor->process( $rule, $stored_state );
- $rule(object) (required)
- The specific rule being processed by this rule processor.
- $stored_state(object) (required)
- Stored state.
PluginVersionRuleProcessor::process() PluginVersionRuleProcessor::process code WC 10.3.6
public function process( $rule, $stored_state ) {
$active_plugin_slugs = $this->plugins_provider->get_active_plugin_slugs();
/**
* Filters a plugin dependency’s slug before matching to the WordPress.org slug format.
*
* @since 9.0.0
*
* @param string $plugin_name requested plugin name
*/
$plugin_name = apply_filters( 'wp_plugin_dependencies_slug', $rule->plugin );
if ( ! in_array( $plugin_name, $active_plugin_slugs, true ) ) {
return false;
}
$plugin_data = $this->plugins_provider->get_plugin_data( $plugin_name );
if ( ! is_array( $plugin_data ) || ! array_key_exists( 'Version', $plugin_data ) ) {
return false;
}
$plugin_version = $plugin_data['Version'];
return version_compare( $plugin_version, $rule->version, $rule->operator );
}