Skip to content

Commit 66420eb

Browse files
committed
Refactor to use namespaces
1 parent 72d92a1 commit 66420eb

8 files changed

Lines changed: 75 additions & 48 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+
### 1.0.0 - 2018-11-06
48+
* Refactor - Use namespaces and rename classes
49+
4750
### 0.8.1 - 2017.12.13
4851
* Fix - Remove WC 3.3+ "Connect to WooCommerce" notice when official plugins are active
4952

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
*
1313
* @package WC-Dev-Helper/Classes
1414
* @author SkyVerge
15-
* @copyright Copyright (c) 2015-2017, SkyVerge, Inc.
15+
* @copyright Copyright (c) 2015-2018, SkyVerge, Inc.
1616
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
1717
*/
1818

19+
namespace SkyVerge\WooCommerce\DevHelper;
20+
1921
defined( 'ABSPATH' ) or exit;
2022

21-
class WC_Dev_Helper_Ajax {
23+
class Ajax {
2224

2325

2426
/**

includes/class-wc-dev-helper-bogus-gateway.php renamed to includes/Bogus_Gateway.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
*
1313
* @package WC-Dev-Helper/Classes
1414
* @author SkyVerge
15-
* @copyright Copyright (c) 2015-2017, SkyVerge, Inc.
15+
* @copyright Copyright (c) 2015-2018, SkyVerge, Inc.
1616
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
1717
*/
1818

19+
namespace SkyVerge\WooCommerce\DevHelper;
20+
1921
defined( 'ABSPATH' ) or exit;
2022

21-
if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
23+
if ( ! class_exists( '\\WC_Payment_Gateway' ) ) {
2224
return;
2325
}
2426

@@ -27,7 +29,12 @@
2729
*
2830
* @since 0.6.0
2931
*/
30-
class WC_Bogus_Gateway extends WC_Payment_Gateway {
32+
class Bogus_Gateway extends \WC_Payment_Gateway {
33+
34+
35+
/** @var string subscriptions setting */
36+
private $subscriptions;
37+
3138

3239
/**
3340
* Constructor for the gateway.
@@ -37,7 +44,7 @@ class WC_Bogus_Gateway extends WC_Payment_Gateway {
3744
public function __construct() {
3845

3946
$this->id = 'bogus_gateway';
40-
$this->icon = apply_filters('woocommerce_bogus_icon', '');
47+
$this->icon = apply_filters( 'woocommerce_bogus_icon', '' );
4148
$this->has_fields = false;
4249
$this->method_title = __( 'Bogus', 'woocommerce-dev-helper' );
4350
$this->method_description = __( 'A testing gateway that calls "payment complete" to simulate credit card transactions.', 'woocommerce-dev-helper' );
@@ -154,8 +161,8 @@ public function process_payment( $order_id ) {
154161

155162
// Return thank you redirect
156163
return array(
157-
'result' => 'success',
158-
'redirect' => $this->get_return_url( $order )
164+
'result' => 'success',
165+
'redirect' => $this->get_return_url( $order ),
159166
);
160167
}
161168

@@ -167,7 +174,7 @@ public function process_payment( $order_id ) {
167174
* @param float $amount_to_charge subscription amount to charge, could include
168175
* multiple renewals if they've previously failed and the admin
169176
* has enabled it
170-
* @param WC_Order $order original order containing the subscription
177+
* @param \WC_Order $order original order containing the subscription
171178
*/
172179
public function process_renewal_payment( $amount_to_charge, $order ) {
173180

includes/class-wc-dev-helper-use-forwarded-urls.php renamed to includes/Forwarded_URLs.php

File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @package WC-Dev-Helper/Classes
1414
* @author SkyVerge
15-
* @copyright Copyright (c) 2015-2017, SkyVerge, Inc.
15+
* @copyright Copyright (c) 2015-2018, SkyVerge, Inc.
1616
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
1717
*/
1818

includes/class-wc-dev-helper-memberships.php renamed to includes/Integrations/Memberships.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
*
1313
* @package WC-Dev-Helper/Classes
1414
* @author SkyVerge
15-
* @copyright Copyright (c) 2015-2017, SkyVerge, Inc.
15+
* @copyright Copyright (c) 2015-2018, SkyVerge, Inc.
1616
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
1717
*/
1818

19+
namespace SkyVerge\WooCommerce\DevHelper\Integrations;
20+
1921
defined( 'ABSPATH' ) or exit;
2022

2123
/**
@@ -25,7 +27,7 @@
2527
*
2628
* @since 0.4.0
2729
*/
28-
class WC_Dev_Helper_Memberships {
30+
class Memberships {
2931

3032

3133
/**
@@ -37,6 +39,7 @@ public function __construct() {
3739

3840
// add support for minutes and hours-long membership plans
3941
add_filter( 'wc_memberships_plan_access_period_options', array( $this, 'add_membership_plan_access_period_options' ) );
42+
4043
// filter the human access length information so it can work with minutes and hours
4144
add_filter( 'wc_memberships_membership_plan_human_access_length', array( $this, 'filter_membership_human_access_length' ), 10, 2 );
4245
}

includes/class-wc-dev-helper-subscriptions.php renamed to includes/Integrations/Subscriptions.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
*
1313
* @package WC-Dev-Helper/Classes
1414
* @author SkyVerge
15-
* @copyright Copyright (c) 2015-2017, SkyVerge, Inc.
15+
* @copyright Copyright (c) 2015-2018, SkyVerge, Inc.
1616
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
1717
*/
1818

19+
namespace SkyVerge\WooCommerce\DevHelper\Integrations;
20+
1921
defined( 'ABSPATH' ) or exit;
2022

2123
/**
@@ -26,7 +28,7 @@
2628
*
2729
* @since 0.1.0
2830
*/
29-
class WC_Dev_Helper_Subscriptions {
31+
class Subscriptions {
3032

3133

3234
/**
@@ -147,7 +149,7 @@ public function maybe_render_renewal_success_message() {
147149

148150
$subscription = wcs_get_subscription( absint( $_REQUEST['id'] ) );
149151

150-
if ( $subscription instanceof WC_Subscription ) {
152+
if ( $subscription instanceof \WC_Subscription ) {
151153
echo '<div class="updated"><p>' . sprintf( esc_html__( 'Subscription renewal processed. %sView Renewal Order%s', 'woocommerce-dev-helper' ), '<a href="' . wcs_get_edit_post_link( $subscription->get_last_order() ) . '">', ' &#8594;</a>' ) . '</p></div>';
152154
}
153155
}
@@ -178,7 +180,7 @@ public function process_pre_subs_2_0_renew_action() {
178180
WC()->payment_gateways();
179181

180182
// trigger the renewal payment
181-
WC_Subscriptions_Payment_Gateways::gateway_scheduled_subscription_payment( absint( $_GET['user'] ), $_GET['subscription'] );
183+
\WC_Subscriptions_Payment_Gateways::gateway_scheduled_subscription_payment( absint( $_GET['user'] ), $_GET['subscription'] );
182184

183185
// success message
184186
add_filter( 'woocommerce_subscriptions_list_table_pre_process_actions', array( $this, 'maybe_render_pre_subs_2_0_renewal_success_message' ) );
@@ -214,7 +216,7 @@ public function maybe_render_pre_subs_2_0_renewal_success_message( $args ) {
214216
*/
215217
protected function is_subs_gte_2_0() {
216218

217-
return version_compare( WC_Subscriptions::$version, '1.6.0', '>' );
219+
return version_compare( \WC_Subscriptions::$version, '2.0.0', '>=' );
218220
}
219221

220222

@@ -229,7 +231,7 @@ public function new_subscription_periods( $subscription_periods ) {
229231

230232
$new_periods = array(
231233
'minute' => 'minute',
232-
'hour' => 'hour',
234+
'hour' => 'hour',
233235
);
234236

235237
return array_merge( $new_periods, $subscription_periods);

0 commit comments

Comments
 (0)