Skip to content

Commit

Permalink
Remove disable on lower plans for woocommerce-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
dz0ny committed Apr 15, 2021
1 parent 37b08ff commit 3f69c9c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := 3.29.3
VERSION := 3.29.4
PLUGINSLUG := woocart-defaults
SRCPATH := $(shell pwd)/src

Expand Down
22 changes: 1 addition & 21 deletions src/classes/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,10 @@
*/
class WooCommerce {

/**
* @var array
*/
private const SMALLER_PLANS = array(
'cart',
'shop',
'dev',
'cartv2',
);


public function __construct() {
add_filter( 'woocommerce_general_settings', array( &$this, 'general_settings' ) );

// Disable WooCommerce admin plugin on lower plans
add_filter( 'woocommerce_admin_disabled', array( $this, 'maybe_disable_wc_admin' ) );
}

/**
Expand Down Expand Up @@ -55,15 +44,6 @@ public function general_settings( $settings ) {
return $updated_settings;
}

/**
* Checks for store plan and disables WC admin only for smaller plans.
*
* @return @bool
*/
public function maybe_disable_wc_admin() : bool {
return in_array( $_SERVER['STORE_PLAN'], self::SMALLER_PLANS );
}

}

}
28 changes: 0 additions & 28 deletions tests/WooCommerceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ function tearDown() : void {
public function testConstructor() {
$woocommerce = new WooCommerce();
\WP_Mock::expectFilterAdded( 'woocommerce_general_settings', array( $woocommerce, 'general_settings' ) );
\WP_Mock::expectFilterAdded( 'woocommerce_admin_disabled', array( $woocommerce, 'maybe_disable_wc_admin' ) );

$woocommerce->__construct();
\WP_Mock::assertHooksAdded();
}
Expand Down Expand Up @@ -65,30 +63,4 @@ public function testGeneralSettings() {
);
}

/**
* @covers ::__construct
* @covers ::maybe_disable_wc_admin
*/
public function testDisableWCAdminTrue() {
$woocommerce = new WooCommerce();

// Set to cart plan
$_SERVER['STORE_PLAN'] = 'cart';

$this->assertTrue( $woocommerce->maybe_disable_wc_admin() );
}

/**
* @covers ::__construct
* @covers ::maybe_disable_wc_admin
*/
public function testDisableWCAdminFalse() {
$woocommerce = new WooCommerce();

// Set to market plan
$_SERVER['STORE_PLAN'] = 'market';

$this->assertFalse( $woocommerce->maybe_disable_wc_admin() );
}

}

0 comments on commit 3f69c9c

Please sign in to comment.