Skip to content

Commit 993af05

Browse files
committed
Remove dependency on WooCommerce
Avoid fatals when the WooCommerce plugin is not active
1 parent 561ebd0 commit 993af05

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ Download and install just like any other WordPress plugin. If you want to be rea
4444

4545
## Changelog
4646

47+
### 0.7.0-dev - YYYY.MM.DD
48+
* Tweak - Remove dependency on WooCommerce
49+
4750
### 0.7.0 - 2017.04.12
4851
* Feature - Use the Bogus gateway for Subscriptions automatic renewals
4952
* Fix - Subscriptions integration throwing a warning in WooCommerce 3.0+

includes/class-wc-dev-helper-bogus-gateway.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
defined( 'ABSPATH' ) or exit;
2020

21+
if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
22+
return;
23+
}
24+
2125
/**
2226
* Adds a testing gateway that calls the WooCommerce payment_complete() method.
2327
*

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "woocommerce-dev-helper",
3-
"version": "0.5.0",
3+
"version": "0.7.0-dev",
44
"author": "SkyVerge Team",
55
"homepage": "http://www.skyverge.com",
66
"repository": {

woocommerce-dev-helper.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: A simple plugin for helping develop/debug WooCommerce & extensions
66
* Author: SkyVerge
77
* Author URI: http://www.skyverge.com
8-
* Version: 0.7.0
8+
* Version: 0.7.0-dev
99
* Text Domain: woocommerce-dev-helper
1010
* Domain Path: /i18n/languages/
1111
*
@@ -69,7 +69,9 @@ public function __construct() {
6969

7070
// add some inline JS
7171
add_action( 'wp_footer', array( $this, 'enqueue_scripts' ) );
72-
add_action( 'wp_head', array( $this, 'bogus_gateway_styles' ) );
72+
if ( $this->is_plugin_active( 'woocommerce.php' ) ) {
73+
add_action( 'wp_head', array( $this, 'bogus_gateway_styles' ) );
74+
}
7375

7476
// add the testing gateway
7577
add_filter( 'woocommerce_payment_gateways', array( $this, 'add_bogus_gateway' ) );
@@ -142,8 +144,8 @@ public function includes() {
142144
$this->ajax = new WC_Dev_Helper_Ajax();
143145
}
144146

145-
require_once( $this->get_plugin_path() . '/includes/class-wc-dev-helper-bogus-gateway.php' );
146147
if ( $this->is_plugin_active( 'woocommerce.php' ) ) {
148+
require_once( $this->get_plugin_path() . '/includes/class-wc-dev-helper-bogus-gateway.php' );
147149
$this->gateway = new WC_Bogus_Gateway();
148150
}
149151

0 commit comments

Comments
 (0)