@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * |
16 | 16 | */ |
17 | 17 | |
18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
18 | +if ( ! defined('ABSPATH')) { |
|
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | |
22 | -require_once( dirname( __FILE__ ) . '/woo-includes/woo-functions.php' ); |
|
22 | +require_once(dirname(__FILE__) . '/woo-includes/woo-functions.php'); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * WooCommerce fallback notice. |
@@ -28,24 +28,24 @@ discard block |
||
28 | 28 | * @return string |
29 | 29 | */ |
30 | 30 | function woocommerce_stripe_missing_wc_notice() { |
31 | - 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>'; |
|
31 | + 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>'; |
|
32 | 32 | } |
33 | 33 | |
34 | -if ( ! wc_stripe_is_wc_active() ) { |
|
35 | - add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' ); |
|
34 | +if ( ! wc_stripe_is_wc_active()) { |
|
35 | + add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice'); |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | -if ( ! class_exists( 'WC_Stripe' ) ) : |
|
39 | +if ( ! class_exists('WC_Stripe')) : |
|
40 | 40 | /** |
41 | 41 | * Required minimums and constants |
42 | 42 | */ |
43 | - define( 'WC_STRIPE_VERSION', '4.1.3' ); |
|
44 | - define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' ); |
|
45 | - define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' ); |
|
46 | - define( 'WC_STRIPE_MAIN_FILE', __FILE__ ); |
|
47 | - define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
|
48 | - define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
43 | + define('WC_STRIPE_VERSION', '4.1.3'); |
|
44 | + define('WC_STRIPE_MIN_PHP_VER', '5.6.0'); |
|
45 | + define('WC_STRIPE_MIN_WC_VER', '2.6.0'); |
|
46 | + define('WC_STRIPE_MAIN_FILE', __FILE__); |
|
47 | + define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
|
48 | + define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
49 | 49 | |
50 | 50 | class WC_Stripe { |
51 | 51 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @return Singleton The *Singleton* instance. |
66 | 66 | */ |
67 | 67 | public static function get_instance() { |
68 | - if ( null === self::$instance ) { |
|
68 | + if (null === self::$instance) { |
|
69 | 69 | self::$instance = new self(); |
70 | 70 | } |
71 | 71 | return self::$instance; |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * *Singleton* via the `new` operator from outside of this class. |
93 | 93 | */ |
94 | 94 | private function __construct() { |
95 | - add_action( 'admin_init', array( $this, 'install' ) ); |
|
96 | - add_action( 'plugins_loaded', array( $this, 'init' ) ); |
|
95 | + add_action('admin_init', array($this, 'install')); |
|
96 | + add_action('plugins_loaded', array($this, 'init')); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,51 +103,51 @@ discard block |
||
103 | 103 | * @version 4.0.0 |
104 | 104 | */ |
105 | 105 | public function init() { |
106 | - if ( is_admin() ) { |
|
107 | - require_once( dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php' ); |
|
106 | + if (is_admin()) { |
|
107 | + require_once(dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php'); |
|
108 | 108 | } |
109 | 109 | |
110 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php' ); |
|
111 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php' ); |
|
112 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php' ); |
|
113 | - include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' ); |
|
114 | - |
|
115 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
116 | - |
|
117 | - require_once( dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php' ); |
|
118 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php' ); |
|
119 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php' ); |
|
120 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php' ); |
|
121 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php' ); |
|
122 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php' ); |
|
123 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php' ); |
|
124 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php' ); |
|
125 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php' ); |
|
126 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php' ); |
|
127 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php' ); |
|
128 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php' ); |
|
129 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php' ); |
|
130 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php' ); |
|
131 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php' ); |
|
132 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php' ); |
|
133 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php' ); |
|
134 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php' ); |
|
135 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php' ); |
|
136 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php' ); |
|
137 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php' ); |
|
138 | - |
|
139 | - if ( is_admin() ) { |
|
140 | - require_once( dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php' ); |
|
110 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-exception.php'); |
|
111 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'); |
|
112 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'); |
|
113 | + include_once(dirname(__FILE__) . '/includes/class-wc-stripe-api.php'); |
|
114 | + |
|
115 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
116 | + |
|
117 | + require_once(dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'); |
|
118 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'); |
|
119 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'); |
|
120 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php'); |
|
121 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'); |
|
122 | + require_once(dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'); |
|
123 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'); |
|
124 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'); |
|
125 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'); |
|
126 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'); |
|
127 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'); |
|
128 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'); |
|
129 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'); |
|
130 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'); |
|
131 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'); |
|
132 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'); |
|
133 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php'); |
|
134 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'); |
|
135 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'); |
|
136 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'); |
|
137 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'); |
|
138 | + |
|
139 | + if (is_admin()) { |
|
140 | + require_once(dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | // REMOVE IN THE FUTURE. |
144 | - require_once( dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php' ); |
|
144 | + require_once(dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php'); |
|
145 | 145 | |
146 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
147 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
146 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
147 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
148 | 148 | |
149 | - if ( version_compare( WC_VERSION, '3.4', '<' ) ) { |
|
150 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
149 | + if (version_compare(WC_VERSION, '3.4', '<')) { |
|
150 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @version 4.0.0 |
159 | 159 | */ |
160 | 160 | public function update_plugin_version() { |
161 | - delete_option( 'wc_stripe_version' ); |
|
162 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
161 | + delete_option('wc_stripe_version'); |
|
162 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | * @version 3.1.0 |
170 | 170 | */ |
171 | 171 | public function install() { |
172 | - if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
172 | + if ( ! is_plugin_active(plugin_basename(__FILE__))) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
176 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
177 | - do_action( 'woocommerce_stripe_updated' ); |
|
176 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
177 | + do_action('woocommerce_stripe_updated'); |
|
178 | 178 | |
179 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
180 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
179 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
180 | + define('WC_STRIPE_INSTALLING', true); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $this->update_plugin_version(); |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | * @since 1.0.0 |
191 | 191 | * @version 4.0.0 |
192 | 192 | */ |
193 | - public function plugin_action_links( $links ) { |
|
193 | + public function plugin_action_links($links) { |
|
194 | 194 | $plugin_links = array( |
195 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
196 | - '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>', |
|
197 | - '<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>', |
|
195 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
196 | + '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>', |
|
197 | + '<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>', |
|
198 | 198 | ); |
199 | - return array_merge( $plugin_links, $links ); |
|
199 | + return array_merge($plugin_links, $links); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * @since 1.0.0 |
206 | 206 | * @version 4.0.0 |
207 | 207 | */ |
208 | - public function add_gateways( $methods ) { |
|
209 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) { |
|
208 | + public function add_gateways($methods) { |
|
209 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) { |
|
210 | 210 | $methods[] = 'WC_Stripe_Subs_Compat'; |
211 | 211 | $methods[] = 'WC_Stripe_Sepa_Subs_Compat'; |
212 | 212 | } else { |
@@ -232,28 +232,28 @@ discard block |
||
232 | 232 | * @since 4.0.0 |
233 | 233 | * @version 4.0.0 |
234 | 234 | */ |
235 | - public function filter_gateway_order_admin( $sections ) { |
|
236 | - unset( $sections['stripe'] ); |
|
237 | - unset( $sections['stripe_bancontact'] ); |
|
238 | - unset( $sections['stripe_sofort'] ); |
|
239 | - unset( $sections['stripe_giropay'] ); |
|
240 | - unset( $sections['stripe_eps'] ); |
|
241 | - unset( $sections['stripe_ideal'] ); |
|
242 | - unset( $sections['stripe_p24'] ); |
|
243 | - unset( $sections['stripe_alipay'] ); |
|
244 | - unset( $sections['stripe_sepa'] ); |
|
245 | - unset( $sections['stripe_multibanco'] ); |
|
235 | + public function filter_gateway_order_admin($sections) { |
|
236 | + unset($sections['stripe']); |
|
237 | + unset($sections['stripe_bancontact']); |
|
238 | + unset($sections['stripe_sofort']); |
|
239 | + unset($sections['stripe_giropay']); |
|
240 | + unset($sections['stripe_eps']); |
|
241 | + unset($sections['stripe_ideal']); |
|
242 | + unset($sections['stripe_p24']); |
|
243 | + unset($sections['stripe_alipay']); |
|
244 | + unset($sections['stripe_sepa']); |
|
245 | + unset($sections['stripe_multibanco']); |
|
246 | 246 | |
247 | 247 | $sections['stripe'] = 'Stripe'; |
248 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
249 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
250 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
251 | - $sections['stripe_eps'] = __( 'Stripe EPS', 'woocommerce-gateway-stripe' ); |
|
252 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
253 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
254 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
255 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
256 | - $sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' ); |
|
248 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
249 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
250 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
251 | + $sections['stripe_eps'] = __('Stripe EPS', 'woocommerce-gateway-stripe'); |
|
252 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
253 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
254 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
255 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
256 | + $sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe'); |
|
257 | 257 | |
258 | 258 | return $sections; |
259 | 259 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! class_exists( 'WC_Abstract_Privacy' ) ) { |
|
2 | +if ( ! class_exists('WC_Abstract_Privacy')) { |
|
3 | 3 | return; |
4 | 4 | } |
5 | 5 | |
@@ -9,18 +9,18 @@ discard block |
||
9 | 9 | * |
10 | 10 | */ |
11 | 11 | public function __construct() { |
12 | - parent::__construct( __( 'Stripe', 'woocommerce-gateway-stripe' ) ); |
|
12 | + parent::__construct(__('Stripe', 'woocommerce-gateway-stripe')); |
|
13 | 13 | |
14 | - $this->add_exporter( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_exporter' ) ); |
|
14 | + $this->add_exporter('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_exporter')); |
|
15 | 15 | |
16 | - if ( function_exists( 'wcs_get_subscriptions' ) ) { |
|
17 | - $this->add_exporter( 'woocommerce-gateway-stripe-subscriptions-data', __( 'WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe' ), array( $this, 'subscriptions_data_exporter' ) ); |
|
16 | + if (function_exists('wcs_get_subscriptions')) { |
|
17 | + $this->add_exporter('woocommerce-gateway-stripe-subscriptions-data', __('WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe'), array($this, 'subscriptions_data_exporter')); |
|
18 | 18 | } |
19 | 19 | |
20 | - $this->add_exporter( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_exporter' ) ); |
|
20 | + $this->add_exporter('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_exporter')); |
|
21 | 21 | |
22 | - $this->add_eraser( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_eraser' ) ); |
|
23 | - $this->add_eraser( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_eraser' ) ); |
|
22 | + $this->add_eraser('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_eraser')); |
|
23 | + $this->add_eraser('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_eraser')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return array WP_Post |
33 | 33 | */ |
34 | - protected function get_stripe_orders( $email_address, $page ) { |
|
35 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
34 | + protected function get_stripe_orders($email_address, $page) { |
|
35 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
36 | 36 | |
37 | - $order_query = array( |
|
38 | - 'payment_method' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ), |
|
37 | + $order_query = array( |
|
38 | + 'payment_method' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'), |
|
39 | 39 | 'limit' => 10, |
40 | 40 | 'page' => $page, |
41 | 41 | ); |
42 | 42 | |
43 | - if ( $user instanceof WP_User ) { |
|
43 | + if ($user instanceof WP_User) { |
|
44 | 44 | $order_query['customer_id'] = (int) $user->ID; |
45 | 45 | } else { |
46 | 46 | $order_query['billing_email'] = $email_address; |
47 | 47 | } |
48 | 48 | |
49 | - return wc_get_orders( $order_query ); |
|
49 | + return wc_get_orders($order_query); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | */ |
56 | 56 | public function get_privacy_message() { |
57 | - return wpautop( sprintf( __( 'By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe' ), 'https://docs.woocommerce.com/privacy/?woocommerce-gateway-stripe' ) ); |
|
57 | + return wpautop(sprintf(__('By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe'), 'https://docs.woocommerce.com/privacy/?woocommerce-gateway-stripe')); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -65,34 +65,34 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - public function order_data_exporter( $email_address, $page = 1 ) { |
|
68 | + public function order_data_exporter($email_address, $page = 1) { |
|
69 | 69 | $done = false; |
70 | 70 | $data_to_export = array(); |
71 | 71 | |
72 | - $orders = $this->get_stripe_orders( $email_address, (int) $page ); |
|
72 | + $orders = $this->get_stripe_orders($email_address, (int) $page); |
|
73 | 73 | |
74 | 74 | $done = true; |
75 | 75 | |
76 | - if ( 0 < count( $orders ) ) { |
|
77 | - foreach ( $orders as $order ) { |
|
76 | + if (0 < count($orders)) { |
|
77 | + foreach ($orders as $order) { |
|
78 | 78 | $data_to_export[] = array( |
79 | 79 | 'group_id' => 'woocommerce_orders', |
80 | - 'group_label' => __( 'Orders', 'woocommerce-gateway-stripe' ), |
|
80 | + 'group_label' => __('Orders', 'woocommerce-gateway-stripe'), |
|
81 | 81 | 'item_id' => 'order-' . $order->get_id(), |
82 | 82 | 'data' => array( |
83 | 83 | array( |
84 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
85 | - 'value' => get_post_meta( $order->get_id(), '_stripe_source_id', true ), |
|
84 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
85 | + 'value' => get_post_meta($order->get_id(), '_stripe_source_id', true), |
|
86 | 86 | ), |
87 | 87 | array( |
88 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
89 | - 'value' => get_post_meta( $order->get_id(), '_stripe_customer_id', true ), |
|
88 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
89 | + 'value' => get_post_meta($order->get_id(), '_stripe_customer_id', true), |
|
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
93 | 93 | } |
94 | 94 | |
95 | - $done = 10 > count( $orders ); |
|
95 | + $done = 10 > count($orders); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return array( |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return array |
111 | 111 | */ |
112 | - public function subscriptions_data_exporter( $email_address, $page = 1 ) { |
|
112 | + public function subscriptions_data_exporter($email_address, $page = 1) { |
|
113 | 113 | $done = false; |
114 | 114 | $page = (int) $page; |
115 | 115 | $data_to_export = array(); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'relation' => 'AND', |
119 | 119 | array( |
120 | 120 | 'key' => '_payment_method', |
121 | - 'value' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ), |
|
121 | + 'value' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'), |
|
122 | 122 | 'compare' => 'IN', |
123 | 123 | ), |
124 | 124 | array( |
@@ -128,36 +128,36 @@ discard block |
||
128 | 128 | ), |
129 | 129 | ); |
130 | 130 | |
131 | - $subscription_query = array( |
|
131 | + $subscription_query = array( |
|
132 | 132 | 'posts_per_page' => 10, |
133 | 133 | 'page' => $page, |
134 | 134 | 'meta_query' => $meta_query, |
135 | 135 | ); |
136 | 136 | |
137 | - $subscriptions = wcs_get_subscriptions( $subscription_query ); |
|
137 | + $subscriptions = wcs_get_subscriptions($subscription_query); |
|
138 | 138 | |
139 | 139 | $done = true; |
140 | 140 | |
141 | - if ( 0 < count( $subscriptions ) ) { |
|
142 | - foreach ( $subscriptions as $subscription ) { |
|
141 | + if (0 < count($subscriptions)) { |
|
142 | + foreach ($subscriptions as $subscription) { |
|
143 | 143 | $data_to_export[] = array( |
144 | 144 | 'group_id' => 'woocommerce_subscriptions', |
145 | - 'group_label' => __( 'Subscriptions', 'woocommerce-gateway-stripe' ), |
|
145 | + 'group_label' => __('Subscriptions', 'woocommerce-gateway-stripe'), |
|
146 | 146 | 'item_id' => 'subscription-' . $subscription->get_id(), |
147 | 147 | 'data' => array( |
148 | 148 | array( |
149 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
150 | - 'value' => get_post_meta( $subscription->get_id(), '_stripe_source_id', true ), |
|
149 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
150 | + 'value' => get_post_meta($subscription->get_id(), '_stripe_source_id', true), |
|
151 | 151 | ), |
152 | 152 | array( |
153 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
154 | - 'value' => get_post_meta( $subscription->get_id(), '_stripe_customer_id', true ), |
|
153 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
154 | + 'value' => get_post_meta($subscription->get_id(), '_stripe_customer_id', true), |
|
155 | 155 | ), |
156 | 156 | ), |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
160 | - $done = 10 > count( $subscriptions ); |
|
160 | + $done = 10 > count($subscriptions); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return array( |
@@ -173,24 +173,24 @@ discard block |
||
173 | 173 | * @param int $page Page. |
174 | 174 | * @return array An array of personal data in name value pairs |
175 | 175 | */ |
176 | - public function customer_data_exporter( $email_address, $page ) { |
|
177 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
176 | + public function customer_data_exporter($email_address, $page) { |
|
177 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
178 | 178 | $data_to_export = array(); |
179 | 179 | |
180 | - if ( $user instanceof WP_User ) { |
|
181 | - $stripe_user = new WC_Stripe_Customer( $user->ID ); |
|
180 | + if ($user instanceof WP_User) { |
|
181 | + $stripe_user = new WC_Stripe_Customer($user->ID); |
|
182 | 182 | |
183 | 183 | $data_to_export[] = array( |
184 | 184 | 'group_id' => 'woocommerce_customer', |
185 | - 'group_label' => __( 'Customer Data', 'woocommerce-gateway-stripe' ), |
|
185 | + 'group_label' => __('Customer Data', 'woocommerce-gateway-stripe'), |
|
186 | 186 | 'item_id' => 'user', |
187 | 187 | 'data' => array( |
188 | 188 | array( |
189 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
190 | - 'value' => get_user_meta( $user->ID, '_stripe_source_id', true ), |
|
189 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
190 | + 'value' => get_user_meta($user->ID, '_stripe_source_id', true), |
|
191 | 191 | ), |
192 | 192 | array( |
193 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
193 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
194 | 194 | 'value' => $stripe_user->get_id(), |
195 | 195 | ), |
196 | 196 | ), |
@@ -210,21 +210,21 @@ discard block |
||
210 | 210 | * @param int $page Page. |
211 | 211 | * @return array An array of personal data in name value pairs |
212 | 212 | */ |
213 | - public function customer_data_eraser( $email_address, $page ) { |
|
213 | + public function customer_data_eraser($email_address, $page) { |
|
214 | 214 | $page = (int) $page; |
215 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
215 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
216 | 216 | |
217 | - $stripe_customer_id = get_user_meta( $user->ID, '_stripe_customer_id', true ); |
|
218 | - $stripe_source_id = get_user_meta( $user->ID, '_stripe_source_id', true ); |
|
217 | + $stripe_customer_id = get_user_meta($user->ID, '_stripe_customer_id', true); |
|
218 | + $stripe_source_id = get_user_meta($user->ID, '_stripe_source_id', true); |
|
219 | 219 | |
220 | 220 | $items_removed = false; |
221 | 221 | $messages = array(); |
222 | 222 | |
223 | - if ( ! empty( $stripe_customer_id ) || ! empty( $stripe_source_id ) ) { |
|
223 | + if ( ! empty($stripe_customer_id) || ! empty($stripe_source_id)) { |
|
224 | 224 | $items_removed = true; |
225 | - delete_user_meta( $user->ID, '_stripe_customer_id' ); |
|
226 | - delete_user_meta( $user->ID, '_stripe_source_id' ); |
|
227 | - $messages[] = __( 'Stripe User Data Erased.', 'woocommerce-gateway-stripe' ); |
|
225 | + delete_user_meta($user->ID, '_stripe_customer_id'); |
|
226 | + delete_user_meta($user->ID, '_stripe_source_id'); |
|
227 | + $messages[] = __('Stripe User Data Erased.', 'woocommerce-gateway-stripe'); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | return array( |
@@ -242,29 +242,29 @@ discard block |
||
242 | 242 | * @param int $page Page. |
243 | 243 | * @return array An array of personal data in name value pairs |
244 | 244 | */ |
245 | - public function order_data_eraser( $email_address, $page ) { |
|
246 | - $orders = $this->get_stripe_orders( $email_address, (int) $page ); |
|
245 | + public function order_data_eraser($email_address, $page) { |
|
246 | + $orders = $this->get_stripe_orders($email_address, (int) $page); |
|
247 | 247 | |
248 | 248 | $items_removed = false; |
249 | 249 | $items_retained = false; |
250 | 250 | $messages = array(); |
251 | 251 | |
252 | - foreach ( (array) $orders as $order ) { |
|
253 | - $order = wc_get_order( $order->get_id() ); |
|
252 | + foreach ((array) $orders as $order) { |
|
253 | + $order = wc_get_order($order->get_id()); |
|
254 | 254 | |
255 | - list( $removed, $retained, $msgs ) = $this->maybe_handle_order( $order ); |
|
255 | + list($removed, $retained, $msgs) = $this->maybe_handle_order($order); |
|
256 | 256 | $items_removed |= $removed; |
257 | 257 | $items_retained |= $retained; |
258 | - $messages = array_merge( $messages, $msgs ); |
|
258 | + $messages = array_merge($messages, $msgs); |
|
259 | 259 | |
260 | - list( $removed, $retained, $msgs ) = $this->maybe_handle_subscription( $order ); |
|
260 | + list($removed, $retained, $msgs) = $this->maybe_handle_subscription($order); |
|
261 | 261 | $items_removed |= $removed; |
262 | 262 | $items_retained |= $retained; |
263 | - $messages = array_merge( $messages, $msgs ); |
|
263 | + $messages = array_merge($messages, $msgs); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | // Tell core if we have more orders to work on still |
267 | - $done = count( $orders ) < 10; |
|
267 | + $done = count($orders) < 10; |
|
268 | 268 | |
269 | 269 | return array( |
270 | 270 | 'items_removed' => $items_removed, |
@@ -280,49 +280,49 @@ discard block |
||
280 | 280 | * @param WC_Order $order |
281 | 281 | * @return array |
282 | 282 | */ |
283 | - protected function maybe_handle_subscription( $order ) { |
|
284 | - if ( ! class_exists( 'WC_Subscriptions' ) ) { |
|
285 | - return array( false, false, array() ); |
|
283 | + protected function maybe_handle_subscription($order) { |
|
284 | + if ( ! class_exists('WC_Subscriptions')) { |
|
285 | + return array(false, false, array()); |
|
286 | 286 | } |
287 | 287 | |
288 | - if ( ! wcs_order_contains_subscription( $order ) ) { |
|
289 | - return array( false, false, array() ); |
|
288 | + if ( ! wcs_order_contains_subscription($order)) { |
|
289 | + return array(false, false, array()); |
|
290 | 290 | } |
291 | 291 | |
292 | - $subscription = current( wcs_get_subscriptions_for_order( $order->get_id() ) ); |
|
292 | + $subscription = current(wcs_get_subscriptions_for_order($order->get_id())); |
|
293 | 293 | $subscription_id = $subscription->get_id(); |
294 | 294 | |
295 | - $stripe_source_id = get_post_meta( $subscription_id, '_stripe_source_id', true ); |
|
295 | + $stripe_source_id = get_post_meta($subscription_id, '_stripe_source_id', true); |
|
296 | 296 | |
297 | - if ( empty( $stripe_source_id ) ) { |
|
298 | - return array( false, false, array() ); |
|
297 | + if (empty($stripe_source_id)) { |
|
298 | + return array(false, false, array()); |
|
299 | 299 | } |
300 | 300 | |
301 | - $order_age = strtotime( 'now' ) - $order->get_date_created()->getTimestamp(); |
|
301 | + $order_age = strtotime('now') - $order->get_date_created()->getTimestamp(); |
|
302 | 302 | |
303 | 303 | // If order age is longer than specified days, don't do anything to it |
304 | 304 | // TODO: Figure out if 180 is the real number |
305 | - if ( $order_age < DAY_IN_SECONDS * 180 ) { |
|
306 | - return array( false, true, array( sprintf( __( 'Order ID %d is less than 180 days (Stripe)' ), $order->get_id() ) ) ); |
|
305 | + if ($order_age < DAY_IN_SECONDS * 180) { |
|
306 | + return array(false, true, array(sprintf(__('Order ID %d is less than 180 days (Stripe)'), $order->get_id()))); |
|
307 | 307 | } |
308 | 308 | |
309 | - if ( $subscription->has_status( apply_filters( 'wc_stripe_privacy_eraser_subs_statuses', array( 'on-hold', 'active' ) ) ) ) { |
|
310 | - return array( false, true, array( sprintf( __( 'Order ID %d contains an active Subscription' ), $order->get_id() ) ) ); |
|
309 | + if ($subscription->has_status(apply_filters('wc_stripe_privacy_eraser_subs_statuses', array('on-hold', 'active')))) { |
|
310 | + return array(false, true, array(sprintf(__('Order ID %d contains an active Subscription'), $order->get_id()))); |
|
311 | 311 | } |
312 | 312 | |
313 | - $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders( $order->get_id() ); |
|
313 | + $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders($order->get_id()); |
|
314 | 314 | |
315 | - foreach ( $renewal_orders as $renewal_order_id ) { |
|
316 | - delete_post_meta( $renewal_order_id, '_stripe_source_id' ); |
|
317 | - delete_post_meta( $renewal_order_id, '_stripe_refund_id' ); |
|
318 | - delete_post_meta( $renewal_order_id, '_stripe_customer_id' ); |
|
315 | + foreach ($renewal_orders as $renewal_order_id) { |
|
316 | + delete_post_meta($renewal_order_id, '_stripe_source_id'); |
|
317 | + delete_post_meta($renewal_order_id, '_stripe_refund_id'); |
|
318 | + delete_post_meta($renewal_order_id, '_stripe_customer_id'); |
|
319 | 319 | } |
320 | 320 | |
321 | - delete_post_meta( $subscription_id, '_stripe_source_id' ); |
|
322 | - delete_post_meta( $subscription_id, '_stripe_refund_id' ); |
|
323 | - delete_post_meta( $subscription_id, '_stripe_customer_id' ); |
|
321 | + delete_post_meta($subscription_id, '_stripe_source_id'); |
|
322 | + delete_post_meta($subscription_id, '_stripe_refund_id'); |
|
323 | + delete_post_meta($subscription_id, '_stripe_customer_id'); |
|
324 | 324 | |
325 | - return array( true, false, array( __( 'Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe' ) ) ); |
|
325 | + return array(true, false, array(__('Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe'))); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -331,21 +331,21 @@ discard block |
||
331 | 331 | * @param WC_Order $order |
332 | 332 | * @return array |
333 | 333 | */ |
334 | - protected function maybe_handle_order( $order ) { |
|
334 | + protected function maybe_handle_order($order) { |
|
335 | 335 | $order_id = $order->get_id(); |
336 | - $stripe_source_id = get_post_meta( $order_id, '_stripe_source_id', true ); |
|
337 | - $stripe_refund_id = get_post_meta( $order_id, '_stripe_refund_id', true ); |
|
338 | - $stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true ); |
|
336 | + $stripe_source_id = get_post_meta($order_id, '_stripe_source_id', true); |
|
337 | + $stripe_refund_id = get_post_meta($order_id, '_stripe_refund_id', true); |
|
338 | + $stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true); |
|
339 | 339 | |
340 | - if ( empty( $stripe_source_id ) && empty( $stripe_refund_id ) && empty( $stripe_customer_id ) ) { |
|
341 | - return array( false, false, array() ); |
|
340 | + if (empty($stripe_source_id) && empty($stripe_refund_id) && empty($stripe_customer_id)) { |
|
341 | + return array(false, false, array()); |
|
342 | 342 | } |
343 | 343 | |
344 | - delete_post_meta( $order_id, '_stripe_source_id' ); |
|
345 | - delete_post_meta( $order_id, '_stripe_refund_id' ); |
|
346 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
344 | + delete_post_meta($order_id, '_stripe_source_id'); |
|
345 | + delete_post_meta($order_id, '_stripe_refund_id'); |
|
346 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
347 | 347 | |
348 | - return array( true, false, array( __( 'Stripe personal data erased.', 'woocommerce-gateway-stripe' ) ) ); |
|
348 | + return array(true, false, array(__('Stripe personal data erased.', 'woocommerce-gateway-stripe'))); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 |