Merge pull request #25260 from woocommerce/add/wc-admin-version-check

Add WP version check before recommending WooCommerce Admin
This commit is contained in:
Claudio Sanches 2019-12-18 12:16:29 -03:00 committed by GitHub
commit c2e7f0a35d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -48,6 +48,13 @@ class WC_Admin_Setup_Wizard {
'Someone give me high five, I just set up a new store with #WordPress and @WooCommerce!',
);
/**
* The version of WordPress required to run the WooCommerce Admin plugin
*
* @var string
*/
private $wc_admin_plugin_minimum_wordpress_version = '5.3';
/**
* Hook in tabs.
*/
@ -126,12 +133,15 @@ class WC_Admin_Setup_Wizard {
/**
* Should we show the WooCommerce Admin install option?
* True only if the user can install plugins,
* and up until the end date of the recommendation.
* and is running the correct version of WordPress.
*
* @see WC_Admin_Setup_Wizard::$wc_admin_plugin_minimum_wordpress_version
*
* @return boolean
*/
protected function should_show_wc_admin() {
return current_user_can( 'install_plugins' );
$wordpress_minimum_met = version_compare( get_bloginfo( 'version' ), $this->wc_admin_plugin_minimum_wordpress_version, '>=' );
return current_user_can( 'install_plugins' ) && $wordpress_minimum_met;
}
/**
@ -140,7 +150,7 @@ class WC_Admin_Setup_Wizard {
* @return boolean
*/
protected function should_show_wc_admin_onboarding() {
if ( ! current_user_can( 'install_plugins' ) ) {
if ( ! $this->should_show_wc_admin() ) {
return false;
}