Skip to content

Commit

Permalink
Refine wc dependency checkk
Browse files Browse the repository at this point in the history
  • Loading branch information
roykho committed Apr 23, 2018
1 parent 489ba36 commit 971a2ab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function _manually_load_plugin() {
require $plugin_dir . 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php';
}

if ( ! function_exists( 'is_woocommerce_active' ) ) {
function is_woocommerce_active() {
if ( ! function_exists( 'wc_stripe_is_wc_active' ) ) {
function wc_stripe_is_wc_active() {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Checks if WooCommerce is enabled
*/
class WC_Dependencies {
class WC_Stripe_Dependencies {

private static $active_plugins;

Expand Down
11 changes: 6 additions & 5 deletions woo-includes/woo-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
/**
* Functions used by plugins
*/
if ( ! class_exists( 'WC_Dependencies' ) )
require_once 'class-wc-dependencies.php';
if ( ! class_exists( 'WC_Stripe_Dependencies' ) ) {
require_once( dirname( __FILE__ ) . '/class-wc-stripe-dependencies.php' );
}

/**
* WC Detection
*/
if ( ! function_exists( 'is_woocommerce_active' ) ) {
function is_woocommerce_active() {
return WC_Dependencies::woocommerce_active_check();
if ( ! function_exists( 'wc_stripe_is_wc_active' ) ) {
function wc_stripe_is_wc_active() {
return WC_Stripe_Dependencies::woocommerce_active_check();
}
}
4 changes: 2 additions & 2 deletions woocommerce-gateway-stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
exit;
}

require_once( 'woo-includes/woo-functions.php' );
require_once( dirname( __FILE__ ) . '/woo-includes/woo-functions.php' );

/**
* WooCommerce fallback notice.
Expand All @@ -31,7 +31,7 @@ function woocommerce_stripe_missing_wc_notice() {
echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
}

if ( ! is_woocommerce_active() ) {
if ( ! wc_stripe_is_wc_active() ) {
add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' );
return;
}
Expand Down

0 comments on commit 971a2ab

Please sign in to comment.