Skip to content
Snippets Groups Projects
Commit 39683e1f authored by dyszczo's avatar dyszczo
Browse files

can check WC version

parent e127733d
No related branches found
No related tags found
1 merge request!3testy jednostkowe + trochę fixów + wsparcie dla openssl
...@@ -17,6 +17,9 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translable { ...@@ -17,6 +17,9 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translable {
/** @var string */ /** @var string */
private $min_wp_version; private $min_wp_version;
/** @var string */
private $min_wc_version;
/** @var array */ /** @var array */
private $plugin_require; private $plugin_require;
...@@ -156,6 +159,9 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translable { ...@@ -156,6 +159,9 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translable {
$notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin cannot run on WordPress versions older than %s. Please update WordPress.', $notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin cannot run on WordPress versions older than %s. Please update WordPress.',
$this->get_text_domain() ), esc_html( $this->plugin_name ), $this->min_wp_version ) ); $this->get_text_domain() ), esc_html( $this->plugin_name ), $this->min_wp_version ) );
} }
if ( ! is_null( $this->min_wc_version ) && $this->can_check_plugin_version() && ! $this->is_wc_at_least( $this->min_wc_version ) ) {
$notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin cannot run on WooCommerce versions older than %s. Please update WooCommerce.', $this->get_text_domain() ), esc_html( $this->plugin_name ), $this->min_wc_version ) );
}
$notices = $this->append_plugin_require_notices( $notices ); $notices = $this->append_plugin_require_notices( $notices );
$notices = $this->append_module_require_notices( $notices ); $notices = $this->append_module_require_notices( $notices );
$notices = $this->append_settings_require_notices( $notices ); $notices = $this->append_settings_require_notices( $notices );
...@@ -163,6 +169,27 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translable { ...@@ -163,6 +169,27 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translable {
return $notices; return $notices;
} }
/**
* Are plugins loaded so we can check the version
*
* @return bool
*/
private function can_check_plugin_version() {
return did_action('plugins_loaded') > 0;
}
/**
* Checks if plugin is active and have designated version. Needs to be enabled in deferred way.
*
* @param string $min_version
*
* @return bool
*/
public static function is_wc_at_least( $min_version ) {
return defined('WC_VERSION') &&
version_compare( WC_VERSION, $min_version, '>=' );
}
/** /**
* @param array $notices * @param array $notices
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment