@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Whether the gateway and Payment Request Button (prerequisites for Apple Pay) are enabled. |
70 | 70 | * |
71 | 71 | * @since 4.5.4 |
72 | - * @return string Whether Apple Pay required settings are enabled. |
|
72 | + * @return boolean Whether Apple Pay required settings are enabled. |
|
73 | 73 | */ |
74 | 74 | private function is_enabled() { |
75 | 75 | $stripe_enabled = 'yes' === $this->get_option( 'enabled', 'no' ); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * Add to the list of publicly allowed query variables. |
104 | 104 | * |
105 | 105 | * @param array $query_vars - provided public query vars. |
106 | - * @return array Updated public query vars. |
|
106 | + * @return string[] Updated public query vars. |
|
107 | 107 | */ |
108 | 108 | public function whitelist_domain_association_query_param( $query_vars ) { |
109 | 109 | $query_vars[] = 'apple-developer-merchantid-domain-association'; |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @since 4.0.6 |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if ( ! defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | public $apple_pay_verify_notice; |
33 | 33 | |
34 | 34 | public function __construct() { |
35 | - add_action( 'init', array( $this, 'add_domain_association_rewrite_rule' ) ); |
|
36 | - add_filter( 'query_vars', array( $this, 'whitelist_domain_association_query_param' ), 10, 1 ); |
|
37 | - add_action( 'parse_request', array( $this, 'parse_domain_association_request' ), 10, 1 ); |
|
35 | + add_action('init', array($this, 'add_domain_association_rewrite_rule')); |
|
36 | + add_filter('query_vars', array($this, 'whitelist_domain_association_query_param'), 10, 1); |
|
37 | + add_action('parse_request', array($this, 'parse_domain_association_request'), 10, 1); |
|
38 | 38 | |
39 | - add_action( 'woocommerce_stripe_updated', array( $this, 'verify_domain_if_configured' ) ); |
|
40 | - add_action( 'add_option_woocommerce_stripe_settings', array( $this, 'verify_domain_on_new_settings' ), 10, 2 ); |
|
41 | - add_action( 'update_option_woocommerce_stripe_settings', array( $this, 'verify_domain_on_updated_settings' ), 10, 2 ); |
|
42 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
39 | + add_action('woocommerce_stripe_updated', array($this, 'verify_domain_if_configured')); |
|
40 | + add_action('add_option_woocommerce_stripe_settings', array($this, 'verify_domain_on_new_settings'), 10, 2); |
|
41 | + add_action('update_option_woocommerce_stripe_settings', array($this, 'verify_domain_on_updated_settings'), 10, 2); |
|
42 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
43 | 43 | |
44 | - $this->stripe_settings = get_option( 'woocommerce_stripe_settings', array() ); |
|
45 | - $this->apple_pay_domain_set = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' ); |
|
44 | + $this->stripe_settings = get_option('woocommerce_stripe_settings', array()); |
|
45 | + $this->apple_pay_domain_set = 'yes' === $this->get_option('apple_pay_domain_set', 'no'); |
|
46 | 46 | $this->apple_pay_verify_notice = ''; |
47 | 47 | } |
48 | 48 | |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | * @param string default |
55 | 55 | * @return string $setting_value |
56 | 56 | */ |
57 | - public function get_option( $setting = '', $default = '' ) { |
|
58 | - if ( empty( $this->stripe_settings ) ) { |
|
57 | + public function get_option($setting = '', $default = '') { |
|
58 | + if (empty($this->stripe_settings)) { |
|
59 | 59 | return $default; |
60 | 60 | } |
61 | 61 | |
62 | - if ( ! empty( $this->stripe_settings[ $setting ] ) ) { |
|
63 | - return $this->stripe_settings[ $setting ]; |
|
62 | + if ( ! empty($this->stripe_settings[$setting])) { |
|
63 | + return $this->stripe_settings[$setting]; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $default; |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @return string Whether Apple Pay required settings are enabled. |
74 | 74 | */ |
75 | 75 | private function is_enabled() { |
76 | - $stripe_enabled = 'yes' === $this->get_option( 'enabled', 'no' ); |
|
77 | - $payment_request_button_enabled = 'yes' === $this->get_option( 'payment_request', 'yes' ); |
|
76 | + $stripe_enabled = 'yes' === $this->get_option('enabled', 'no'); |
|
77 | + $payment_request_button_enabled = 'yes' === $this->get_option('payment_request', 'yes'); |
|
78 | 78 | |
79 | 79 | return $stripe_enabled && $payment_request_button_enabled; |
80 | 80 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @return string Secret key. |
87 | 87 | */ |
88 | 88 | private function get_secret_key() { |
89 | - $testmode = 'yes' === $this->get_option( 'testmode', 'no' ); |
|
90 | - return $testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' ); |
|
89 | + $testmode = 'yes' === $this->get_option('testmode', 'no'); |
|
90 | + return $testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $regex = '^\.well-known\/apple-developer-merchantid-domain-association$'; |
98 | 98 | $redirect = 'index.php?apple-developer-merchantid-domain-association=1'; |
99 | 99 | |
100 | - add_rewrite_rule( $regex, $redirect, 'top' ); |
|
100 | + add_rewrite_rule($regex, $redirect, 'top'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param array $query_vars - provided public query vars. |
107 | 107 | * @return array Updated public query vars. |
108 | 108 | */ |
109 | - public function whitelist_domain_association_query_param( $query_vars ) { |
|
109 | + public function whitelist_domain_association_query_param($query_vars) { |
|
110 | 110 | $query_vars[] = 'apple-developer-merchantid-domain-association'; |
111 | 111 | return $query_vars; |
112 | 112 | } |
@@ -116,17 +116,17 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @param WP WordPress environment object. |
118 | 118 | */ |
119 | - public function parse_domain_association_request( $wp ) { |
|
119 | + public function parse_domain_association_request($wp) { |
|
120 | 120 | if ( |
121 | - ! isset( $wp->query_vars['apple-developer-merchantid-domain-association'] ) || |
|
121 | + ! isset($wp->query_vars['apple-developer-merchantid-domain-association']) || |
|
122 | 122 | '1' !== $wp->query_vars['apple-developer-merchantid-domain-association'] |
123 | 123 | ) { |
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | $path = WC_STRIPE_PLUGIN_PATH . '/apple-developer-merchantid-domain-association'; |
128 | - header( 'Content-Type: application/octet-stream' ); |
|
129 | - echo esc_html( file_get_contents( $path ) ); |
|
128 | + header('Content-Type: application/octet-stream'); |
|
129 | + echo esc_html(file_get_contents($path)); |
|
130 | 130 | exit; |
131 | 131 | } |
132 | 132 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @version 4.5.4 |
138 | 138 | * @param string $secret_key |
139 | 139 | */ |
140 | - private function make_domain_registration_request( $secret_key ) { |
|
141 | - if ( empty( $secret_key ) ) { |
|
142 | - throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) ); |
|
140 | + private function make_domain_registration_request($secret_key) { |
|
141 | + if (empty($secret_key)) { |
|
142 | + throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe')); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $endpoint = 'https://api.stripe.com/v1/apple_pay/domains'; |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | $endpoint, |
158 | 158 | array( |
159 | 159 | 'headers' => $headers, |
160 | - 'body' => http_build_query( $data ), |
|
160 | + 'body' => http_build_query($data), |
|
161 | 161 | ) |
162 | 162 | ); |
163 | 163 | |
164 | - if ( is_wp_error( $response ) ) { |
|
164 | + if (is_wp_error($response)) { |
|
165 | 165 | /* translators: error message */ |
166 | - throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) ); |
|
166 | + throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message())); |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( 200 !== $response['response']['code'] ) { |
|
170 | - $parsed_response = json_decode( $response['body'] ); |
|
169 | + if (200 !== $response['response']['code']) { |
|
170 | + $parsed_response = json_decode($response['body']); |
|
171 | 171 | |
172 | 172 | $this->apple_pay_verify_notice = $parsed_response->error->message; |
173 | 173 | |
174 | 174 | /* translators: error message */ |
175 | - throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) ); |
|
175 | + throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message)); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -184,25 +184,25 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @param string $secret_key |
186 | 186 | */ |
187 | - public function register_domain_with_apple( $secret_key ) { |
|
187 | + public function register_domain_with_apple($secret_key) { |
|
188 | 188 | try { |
189 | - $this->make_domain_registration_request( $secret_key ); |
|
189 | + $this->make_domain_registration_request($secret_key); |
|
190 | 190 | |
191 | 191 | // No errors to this point, verification success! |
192 | 192 | $this->stripe_settings['apple_pay_domain_set'] = 'yes'; |
193 | 193 | $this->apple_pay_domain_set = true; |
194 | 194 | |
195 | - update_option( 'woocommerce_stripe_settings', $this->stripe_settings ); |
|
195 | + update_option('woocommerce_stripe_settings', $this->stripe_settings); |
|
196 | 196 | |
197 | - WC_Stripe_Logger::log( 'Your domain has been verified with Apple Pay!' ); |
|
197 | + WC_Stripe_Logger::log('Your domain has been verified with Apple Pay!'); |
|
198 | 198 | |
199 | - } catch ( Exception $e ) { |
|
199 | + } catch (Exception $e) { |
|
200 | 200 | $this->stripe_settings['apple_pay_domain_set'] = 'no'; |
201 | 201 | $this->apple_pay_domain_set = false; |
202 | 202 | |
203 | - update_option( 'woocommerce_stripe_settings', $this->stripe_settings ); |
|
203 | + update_option('woocommerce_stripe_settings', $this->stripe_settings); |
|
204 | 204 | |
205 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
205 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function verify_domain_if_configured() { |
217 | 217 | $secret_key = $this->get_secret_key(); |
218 | 218 | |
219 | - if ( ! $this->is_enabled() || empty( $secret_key ) ) { |
|
219 | + if ( ! $this->is_enabled() || empty($secret_key)) { |
|
220 | 220 | return; |
221 | 221 | } |
222 | 222 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | flush_rewrite_rules(); |
225 | 225 | |
226 | 226 | // Register the domain with Apple Pay. |
227 | - $this->register_domain_with_apple( $secret_key ); |
|
227 | + $this->register_domain_with_apple($secret_key); |
|
228 | 228 | |
229 | 229 | // Show/hide failure note if necessary. |
230 | 230 | WC_Stripe_Inbox_Notes::notify_of_apple_pay_domain_verification_if_needed(); |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | * @since 4.5.4 |
237 | 237 | * @version 4.5.4 |
238 | 238 | */ |
239 | - public function verify_domain_on_new_settings( $option, $settings ) { |
|
240 | - $this->verify_domain_on_updated_settings( array(), $settings ); |
|
239 | + public function verify_domain_on_new_settings($option, $settings) { |
|
240 | + $this->verify_domain_on_updated_settings(array(), $settings); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @since 4.5.3 |
247 | 247 | * @version 4.5.4 |
248 | 248 | */ |
249 | - public function verify_domain_on_updated_settings( $prev_settings, $settings ) { |
|
249 | + public function verify_domain_on_updated_settings($prev_settings, $settings) { |
|
250 | 250 | // Grab previous state and then update cached settings. |
251 | 251 | $this->stripe_settings = $prev_settings; |
252 | 252 | $prev_secret_key = $this->get_secret_key(); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $this->stripe_settings = $settings; |
255 | 255 | |
256 | 256 | // If Stripe or Payment Request Button wasn't enabled (or secret key was different) then might need to verify now. |
257 | - if ( ! $prev_is_enabled || ( $this->get_secret_key() !== $prev_secret_key ) ) { |
|
257 | + if ( ! $prev_is_enabled || ($this->get_secret_key() !== $prev_secret_key)) { |
|
258 | 258 | $this->verify_domain_if_configured(); |
259 | 259 | } |
260 | 260 | } |
@@ -265,16 +265,16 @@ discard block |
||
265 | 265 | * @since 4.0.6 |
266 | 266 | */ |
267 | 267 | public function admin_notices() { |
268 | - if ( ! $this->is_enabled() ) { |
|
268 | + if ( ! $this->is_enabled()) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
272 | + if ( ! current_user_can('manage_woocommerce')) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | - $empty_notice = empty( $this->apple_pay_verify_notice ); |
|
277 | - if ( $empty_notice && ( $this->apple_pay_domain_set || empty( $this->secret_key ) ) ) { |
|
276 | + $empty_notice = empty($this->apple_pay_verify_notice); |
|
277 | + if ($empty_notice && ($this->apple_pay_domain_set || empty($this->secret_key))) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
@@ -283,28 +283,28 @@ discard block |
||
283 | 283 | * when setting screen is displayed. So if domain verification is not set, |
284 | 284 | * something went wrong so lets notify user. |
285 | 285 | */ |
286 | - $allowed_html = array( |
|
286 | + $allowed_html = array( |
|
287 | 287 | 'a' => array( |
288 | 288 | 'href' => array(), |
289 | 289 | 'title' => array(), |
290 | 290 | ), |
291 | 291 | ); |
292 | - $verification_failed_without_error = __( 'Apple Pay domain verification failed.', 'woocommerce-gateway-stripe' ); |
|
293 | - $verification_failed_with_error = __( 'Apple Pay domain verification failed with the following error:', 'woocommerce-gateway-stripe' ); |
|
292 | + $verification_failed_without_error = __('Apple Pay domain verification failed.', 'woocommerce-gateway-stripe'); |
|
293 | + $verification_failed_with_error = __('Apple Pay domain verification failed with the following error:', 'woocommerce-gateway-stripe'); |
|
294 | 294 | $check_log_text = sprintf( |
295 | 295 | /* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */ |
296 | - esc_html__( 'Please check the %1$slogs%2$s for more details on this issue. Logging must be enabled to see recorded logs.', 'woocommerce-gateway-stripe' ), |
|
297 | - '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', |
|
296 | + esc_html__('Please check the %1$slogs%2$s for more details on this issue. Logging must be enabled to see recorded logs.', 'woocommerce-gateway-stripe'), |
|
297 | + '<a href="' . admin_url('admin.php?page=wc-status&tab=logs') . '">', |
|
298 | 298 | '</a>' |
299 | 299 | ); |
300 | 300 | |
301 | 301 | ?> |
302 | 302 | <div class="error stripe-apple-pay-message"> |
303 | - <?php if ( $empty_notice ) : ?> |
|
304 | - <p><?php echo esc_html( $verification_failed_without_error ); ?></p> |
|
303 | + <?php if ($empty_notice) : ?> |
|
304 | + <p><?php echo esc_html($verification_failed_without_error); ?></p> |
|
305 | 305 | <?php else : ?> |
306 | - <p><?php echo esc_html( $verification_failed_with_error ); ?></p> |
|
307 | - <p><i><?php echo wp_kses( make_clickable( esc_html( $this->apple_pay_verify_notice ) ), $allowed_html ); ?></i></p> |
|
306 | + <p><?php echo esc_html($verification_failed_with_error); ?></p> |
|
307 | + <p><i><?php echo wp_kses(make_clickable(esc_html($this->apple_pay_verify_notice)), $allowed_html); ?></i></p> |
|
308 | 308 | <?php endif; ?> |
309 | 309 | <p><?php echo $check_log_text; ?></p> |
310 | 310 | </div> |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * |
16 | 16 | */ |
17 | 17 | |
18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
18 | +if ( ! defined('ABSPATH')) { |
|
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Required minimums and constants |
24 | 24 | */ |
25 | -define( 'WC_STRIPE_VERSION', '4.5.3' ); // WRCS: DEFINED_VERSION. |
|
26 | -define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' ); |
|
27 | -define( 'WC_STRIPE_MIN_WC_VER', '3.0' ); |
|
28 | -define( 'WC_STRIPE_FUTURE_MIN_WC_VER', '3.0' ); |
|
29 | -define( 'WC_STRIPE_MAIN_FILE', __FILE__ ); |
|
30 | -define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
|
31 | -define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
25 | +define('WC_STRIPE_VERSION', '4.5.3'); // WRCS: DEFINED_VERSION. |
|
26 | +define('WC_STRIPE_MIN_PHP_VER', '5.6.0'); |
|
27 | +define('WC_STRIPE_MIN_WC_VER', '3.0'); |
|
28 | +define('WC_STRIPE_FUTURE_MIN_WC_VER', '3.0'); |
|
29 | +define('WC_STRIPE_MAIN_FILE', __FILE__); |
|
30 | +define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
|
31 | +define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
32 | 32 | |
33 | 33 | // phpcs:disable WordPress.Files.FileName |
34 | 34 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function woocommerce_stripe_missing_wc_notice() { |
42 | 42 | /* translators: 1. URL link. */ |
43 | - 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>'; |
|
43 | + 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>'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function woocommerce_stripe_wc_not_supported() { |
53 | 53 | /* translators: $1. Minimum WooCommerce version. $2. Current WooCommerce version. */ |
54 | - echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce %1$s or greater to be installed and active. WooCommerce %2$s is no longer supported.', 'woocommerce-gateway-stripe' ), WC_STRIPE_MIN_WC_VER, WC_VERSION ) . '</strong></p></div>'; |
|
54 | + echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce %1$s or greater to be installed and active. WooCommerce %2$s is no longer supported.', 'woocommerce-gateway-stripe'), WC_STRIPE_MIN_WC_VER, WC_VERSION) . '</strong></p></div>'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | function wc_stripe() { |
58 | 58 | |
59 | 59 | static $plugin; |
60 | 60 | |
61 | - if ( ! isset( $plugin ) ) { |
|
61 | + if ( ! isset($plugin)) { |
|
62 | 62 | |
63 | 63 | class WC_Stripe { |
64 | 64 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return Singleton The *Singleton* instance. |
74 | 74 | */ |
75 | 75 | public static function get_instance() { |
76 | - if ( null === self::$instance ) { |
|
76 | + if (null === self::$instance) { |
|
77 | 77 | self::$instance = new self(); |
78 | 78 | } |
79 | 79 | return self::$instance; |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * *Singleton* via the `new` operator from outside of this class. |
115 | 115 | */ |
116 | 116 | private function __construct() { |
117 | - add_action( 'admin_init', array( $this, 'install' ) ); |
|
117 | + add_action('admin_init', array($this, 'install')); |
|
118 | 118 | |
119 | 119 | $this->init(); |
120 | 120 | |
121 | 121 | $this->api = new WC_Stripe_Connect_API(); |
122 | - $this->connect = new WC_Stripe_Connect( $this->api ); |
|
122 | + $this->connect = new WC_Stripe_Connect($this->api); |
|
123 | 123 | |
124 | - add_action( 'rest_api_init', array( $this, 'register_connect_routes' ) ); |
|
124 | + add_action('rest_api_init', array($this, 'register_connect_routes')); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,56 +131,56 @@ discard block |
||
131 | 131 | * @version 4.0.0 |
132 | 132 | */ |
133 | 133 | public function init() { |
134 | - if ( is_admin() ) { |
|
135 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
134 | + if (is_admin()) { |
|
135 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
136 | 136 | } |
137 | 137 | |
138 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php'; |
|
139 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php'; |
|
140 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php'; |
|
141 | - include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php'; |
|
142 | - require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
143 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
144 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
145 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
146 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
147 | - require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php'; |
|
148 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
149 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
150 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
151 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
152 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
153 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
154 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
155 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
156 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
157 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
158 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
159 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
160 | - require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect.php'; |
|
161 | - require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect-api.php'; |
|
162 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php'; |
|
163 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
164 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php'; |
|
165 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php'; |
|
166 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-inbox-notes.php'; |
|
167 | - |
|
168 | - if ( is_admin() ) { |
|
169 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
138 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php'; |
|
139 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'; |
|
140 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'; |
|
141 | + include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php'; |
|
142 | + require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
143 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
144 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
145 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
146 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
147 | + require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'; |
|
148 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
149 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
150 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
151 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
152 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
153 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
154 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
155 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
156 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
157 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
158 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
159 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
160 | + require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect.php'; |
|
161 | + require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect-api.php'; |
|
162 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'; |
|
163 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
164 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'; |
|
165 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php'; |
|
166 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-inbox-notes.php'; |
|
167 | + |
|
168 | + if (is_admin()) { |
|
169 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // REMOVE IN THE FUTURE. |
173 | - require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
173 | + require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
174 | 174 | |
175 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
176 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
177 | - add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 ); |
|
175 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
176 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
177 | + add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2); |
|
178 | 178 | |
179 | 179 | // Modify emails emails. |
180 | - add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 ); |
|
180 | + add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20); |
|
181 | 181 | |
182 | - if ( version_compare( WC_VERSION, '3.4', '<' ) ) { |
|
183 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
182 | + if (version_compare(WC_VERSION, '3.4', '<')) { |
|
183 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | * @version 4.0.0 |
192 | 192 | */ |
193 | 193 | public function update_plugin_version() { |
194 | - delete_option( 'wc_stripe_version' ); |
|
195 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
194 | + delete_option('wc_stripe_version'); |
|
195 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -202,15 +202,15 @@ discard block |
||
202 | 202 | * @version 3.1.0 |
203 | 203 | */ |
204 | 204 | public function install() { |
205 | - if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
205 | + if ( ! is_plugin_active(plugin_basename(__FILE__))) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
209 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
210 | - do_action( 'woocommerce_stripe_updated' ); |
|
209 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
210 | + do_action('woocommerce_stripe_updated'); |
|
211 | 211 | |
212 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
213 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
212 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
213 | + define('WC_STRIPE_INSTALLING', true); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | $this->update_plugin_version(); |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | * @since 1.0.0 |
224 | 224 | * @version 4.0.0 |
225 | 225 | */ |
226 | - public function plugin_action_links( $links ) { |
|
226 | + public function plugin_action_links($links) { |
|
227 | 227 | $plugin_links = array( |
228 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
228 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
229 | 229 | ); |
230 | - return array_merge( $plugin_links, $links ); |
|
230 | + return array_merge($plugin_links, $links); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | * @param string $file Name of current file. |
239 | 239 | * @return array $links Update list of plugin links. |
240 | 240 | */ |
241 | - public function plugin_row_meta( $links, $file ) { |
|
242 | - if ( plugin_basename( __FILE__ ) === $file ) { |
|
241 | + public function plugin_row_meta($links, $file) { |
|
242 | + if (plugin_basename(__FILE__) === $file) { |
|
243 | 243 | $row_meta = array( |
244 | - 'docs' => '<a href="' . esc_url( apply_filters( 'woocommerce_gateway_stripe_docs_url', 'https://docs.woocommerce.com/document/stripe/' ) ) . '" title="' . esc_attr( __( 'View Documentation', 'woocommerce-gateway-stripe' ) ) . '">' . __( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>', |
|
245 | - 'support' => '<a href="' . esc_url( apply_filters( 'woocommerce_gateway_stripe_support_url', 'https://woocommerce.com/my-account/create-a-ticket?select=18627' ) ) . '" title="' . esc_attr( __( 'Open a support request at WooCommerce.com', 'woocommerce-gateway-stripe' ) ) . '">' . __( 'Support', 'woocommerce-gateway-stripe' ) . '</a>', |
|
244 | + 'docs' => '<a href="' . esc_url(apply_filters('woocommerce_gateway_stripe_docs_url', 'https://docs.woocommerce.com/document/stripe/')) . '" title="' . esc_attr(__('View Documentation', 'woocommerce-gateway-stripe')) . '">' . __('Docs', 'woocommerce-gateway-stripe') . '</a>', |
|
245 | + 'support' => '<a href="' . esc_url(apply_filters('woocommerce_gateway_stripe_support_url', 'https://woocommerce.com/my-account/create-a-ticket?select=18627')) . '" title="' . esc_attr(__('Open a support request at WooCommerce.com', 'woocommerce-gateway-stripe')) . '">' . __('Support', 'woocommerce-gateway-stripe') . '</a>', |
|
246 | 246 | ); |
247 | - return array_merge( $links, $row_meta ); |
|
247 | + return array_merge($links, $row_meta); |
|
248 | 248 | } |
249 | 249 | return (array) $links; |
250 | 250 | } |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | * @since 1.0.0 |
256 | 256 | * @version 4.0.0 |
257 | 257 | */ |
258 | - public function add_gateways( $methods ) { |
|
259 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) { |
|
258 | + public function add_gateways($methods) { |
|
259 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) { |
|
260 | 260 | $methods[] = 'WC_Stripe_Subs_Compat'; |
261 | 261 | $methods[] = 'WC_Stripe_Sepa_Subs_Compat'; |
262 | 262 | } else { |
@@ -282,28 +282,28 @@ discard block |
||
282 | 282 | * @since 4.0.0 |
283 | 283 | * @version 4.0.0 |
284 | 284 | */ |
285 | - public function filter_gateway_order_admin( $sections ) { |
|
286 | - unset( $sections['stripe'] ); |
|
287 | - unset( $sections['stripe_bancontact'] ); |
|
288 | - unset( $sections['stripe_sofort'] ); |
|
289 | - unset( $sections['stripe_giropay'] ); |
|
290 | - unset( $sections['stripe_eps'] ); |
|
291 | - unset( $sections['stripe_ideal'] ); |
|
292 | - unset( $sections['stripe_p24'] ); |
|
293 | - unset( $sections['stripe_alipay'] ); |
|
294 | - unset( $sections['stripe_sepa'] ); |
|
295 | - unset( $sections['stripe_multibanco'] ); |
|
285 | + public function filter_gateway_order_admin($sections) { |
|
286 | + unset($sections['stripe']); |
|
287 | + unset($sections['stripe_bancontact']); |
|
288 | + unset($sections['stripe_sofort']); |
|
289 | + unset($sections['stripe_giropay']); |
|
290 | + unset($sections['stripe_eps']); |
|
291 | + unset($sections['stripe_ideal']); |
|
292 | + unset($sections['stripe_p24']); |
|
293 | + unset($sections['stripe_alipay']); |
|
294 | + unset($sections['stripe_sepa']); |
|
295 | + unset($sections['stripe_multibanco']); |
|
296 | 296 | |
297 | 297 | $sections['stripe'] = 'Stripe'; |
298 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
299 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
300 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
301 | - $sections['stripe_eps'] = __( 'Stripe EPS', 'woocommerce-gateway-stripe' ); |
|
302 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
303 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
304 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
305 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
306 | - $sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' ); |
|
298 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
299 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
300 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
301 | + $sections['stripe_eps'] = __('Stripe EPS', 'woocommerce-gateway-stripe'); |
|
302 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
303 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
304 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
305 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
306 | + $sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe'); |
|
307 | 307 | |
308 | 308 | return $sections; |
309 | 309 | } |
@@ -314,16 +314,16 @@ discard block |
||
314 | 314 | * @param WC_Email[] $email_classes All existing emails. |
315 | 315 | * @return WC_Email[] |
316 | 316 | */ |
317 | - public function add_emails( $email_classes ) { |
|
317 | + public function add_emails($email_classes) { |
|
318 | 318 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php'; |
319 | 319 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php'; |
320 | 320 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php'; |
321 | 321 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication-retry.php'; |
322 | 322 | |
323 | 323 | // Add all emails, generated by the gateway. |
324 | - $email_classes['WC_Stripe_Email_Failed_Renewal_Authentication'] = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes ); |
|
325 | - $email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes ); |
|
326 | - $email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry( $email_classes ); |
|
324 | + $email_classes['WC_Stripe_Email_Failed_Renewal_Authentication'] = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes); |
|
325 | + $email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes); |
|
326 | + $email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry($email_classes); |
|
327 | 327 | |
328 | 328 | return $email_classes; |
329 | 329 | } |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-init-controller.php'; |
338 | 338 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-connect-controller.php'; |
339 | 339 | |
340 | - $oauth_init = new WC_Stripe_Connect_REST_Oauth_Init_Controller( $this->connect, $this->api ); |
|
341 | - $oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller( $this->connect, $this->api ); |
|
340 | + $oauth_init = new WC_Stripe_Connect_REST_Oauth_Init_Controller($this->connect, $this->api); |
|
341 | + $oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller($this->connect, $this->api); |
|
342 | 342 | |
343 | 343 | $oauth_init->register_routes(); |
344 | 344 | $oauth_connect->register_routes(); |
@@ -352,18 +352,18 @@ discard block |
||
352 | 352 | return $plugin; |
353 | 353 | } |
354 | 354 | |
355 | -add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' ); |
|
355 | +add_action('plugins_loaded', 'woocommerce_gateway_stripe_init'); |
|
356 | 356 | |
357 | 357 | function woocommerce_gateway_stripe_init() { |
358 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
358 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
359 | 359 | |
360 | - if ( ! class_exists( 'WooCommerce' ) ) { |
|
361 | - add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' ); |
|
360 | + if ( ! class_exists('WooCommerce')) { |
|
361 | + add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice'); |
|
362 | 362 | return; |
363 | 363 | } |
364 | 364 | |
365 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
366 | - add_action( 'admin_notices', 'woocommerce_stripe_wc_not_supported' ); |
|
365 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
366 | + add_action('admin_notices', 'woocommerce_stripe_wc_not_supported'); |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 |