Skip to content

Commit c3534d1

Browse files
committed
Fix Subs + WC 3.0 support warning
1 parent 1b54009 commit c3534d1

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is a simple and opinionated plugin for helping develop/debug WooCommerce &
55

66
### Use Forwarded URLs
77

8-
Once activated, this plugin will make WordPress use HTTP_X_FORWARDED_HOST for all your links instead of your site URL. No configuration needed.
8+
Once activated, this plugin will make WordPress use `HTTP_X_FORWARDED_HOST` for all your links instead of your site URL. No configuration needed.
99

1010
We like [ForwardHQ](https://fwd.wf) for this, along with a `ForwardFile` in your WordPress root.
1111

@@ -14,11 +14,11 @@ We like [ForwardHQ](https://fwd.wf) for this, along with a `ForwardFile` in your
1414
Adds a "renew" link to each subscription under WooCommerce > Subscriptions for easy renewal processing. This is particularly useful for testing
1515
payment gateways that supports subscriptions.
1616

17-
Allows minutes and hours-long Subscription periods for quicker testing.
17+
Allows for minutes and hours-long Subscription periods for quicker testing.
1818

1919
### Memberships
2020

21-
Allows minutes and hours-long Membership lengths for quicker testing.
21+
Allows for minutes and hours-long Membership lengths for quicker testing.
2222

2323
### Bogus Gateway
2424

@@ -34,7 +34,7 @@ Adds a testing payment gateway that will call the `$order->payment_complete()` m
3434

3535
### Misc
3636

37-
* Removes the WooThemes Updater notice
37+
* Removes the WooCommmerce Updater notice
3838
* Removes the strong password requirement for customer accounts
3939
* Helper for logging actions/filters fired during a page load -- simply add `?wcdh_hooks=actions|filters|all`, reload the page, and your desired hooks will be printed to the error log, along with the fired count
4040

@@ -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 - 2017.04.12
48+
* Fix - Subscriptions integration throwing a warning in WooCommerce 3.0+
49+
4750
### 0.6.0 - 2017.02.18
4851
* Feature - Adds a bogus gateway that calls `$order->payment_complete()` when used
4952

includes/class-wc-dev-helper-subscriptions.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ public function add_renew_action( $actions, $subscription ) {
7676

7777
$renew_url = add_query_arg(
7878
array(
79-
'post' => $subscription->id,
79+
'post' => is_callable( array( $subscription, 'get_id' ) ) ? $subscription->get_id() : $subscription->id,
8080
'action' => 'renew',
8181
'_wpnonce' => wp_create_nonce( 'bulk-posts' ),
8282
)
8383
);
8484

8585
} else {
86+
8687
$renew_url = add_query_arg(
8788
array(
8889
'page' => $_REQUEST['page'],
@@ -199,7 +200,7 @@ public function maybe_render_pre_subs_2_0_renewal_success_message( $args ) {
199200
}
200201

201202
$args['custom_action'] = true;
202-
$args['messages'] = array( __( 'Subscription Renewal Processed', 'woocommerce-dev-helper' ) );
203+
$args['messages'] = array( __( 'Subscription Renewal Processed', 'woocommerce-dev-helper' ) );
203204

204205
return $args;
205206
}
@@ -243,24 +244,25 @@ public function new_subscription_periods( $subscription_periods ) {
243244
* @return array - updated lengths
244245
*/
245246
public function new_subscription_lengths( $lengths ) {
247+
246248
// start range with 0 => all time
247249
$minute_durations = array( 'all time', '1 minute' );
248-
$minute_steps = range( 5, 60, 5 );
250+
$minute_steps = range( 5, 60, 5 );
249251

250252
// add possible steps for subscription duration
251253
foreach( $minute_steps as $number ) {
252254
$minute_durations[ $number ] = $number . ' minutes';
253255
}
254256

255257
$hour_durations = array( 'all time', '1 hour' );
256-
$hour_steps = range( 2, 6 );
258+
$hour_steps = range( 2, 6 );
257259

258260
foreach ( $hour_steps as $number ) {
259261
$hour_durations[ $number ] = $number . ' hours';
260262
}
261263

262264
$lengths['minute'] = $minute_durations;
263-
$lengths['hour'] = $hour_durations;
265+
$lengths['hour'] = $hour_durations;
264266

265267
return $lengths;
266268
}

woocommerce-dev-helper.php

Lines changed: 6 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.6.0
8+
* Version: 0.7.0
99
* Text Domain: woocommerce-dev-helper
1010
* Domain Path: /i18n/languages/
1111
*
@@ -138,9 +138,12 @@ function add_bogus_gateway( $gateways ) {
138138
public function includes() {
139139

140140
require_once( $this->get_plugin_path() . '/includes/class-wc-dev-helper-ajax.php' );
141-
require_once( $this->get_plugin_path() . '/includes/class-wc-dev-helper-bogus-gateway.php' );
142141
if ( $this->is_plugin_active( 'woocommerce.php' ) && is_ajax() ) {
143142
$this->ajax = new WC_Dev_Helper_Ajax();
143+
}
144+
145+
require_once( $this->get_plugin_path() . '/includes/class-wc-dev-helper-bogus-gateway.php' );
146+
if ( $this->is_plugin_active( 'woocommerce.php' ) ) {
144147
$this->gateway = new WC_Bogus_Gateway();
145148
}
146149

@@ -352,7 +355,7 @@ public function __wakeup() {
352355
}
353356

354357

355-
} // end \WC_Dev_Helper class
358+
}
356359

357360

358361
/**

0 commit comments

Comments
 (0)