@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | */ |
17 | 17 | |
18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
18 | +if ( ! defined('ABSPATH')) { |
|
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | |
@@ -29,29 +29,29 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function woocommerce_stripe_missing_wc_notice() { |
31 | 31 | /* translators: 1. URL link. */ |
32 | - 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 | + 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>'; |
|
33 | 33 | } |
34 | 34 | |
35 | -add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' ); |
|
35 | +add_action('plugins_loaded', 'woocommerce_gateway_stripe_init'); |
|
36 | 36 | |
37 | 37 | function woocommerce_gateway_stripe_init() { |
38 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
38 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
39 | 39 | |
40 | - if ( ! class_exists( 'WooCommerce' ) ) { |
|
41 | - add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' ); |
|
40 | + if ( ! class_exists('WooCommerce')) { |
|
41 | + add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice'); |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | - if ( ! class_exists( 'WC_Stripe' ) ) : |
|
45 | + if ( ! class_exists('WC_Stripe')) : |
|
46 | 46 | /** |
47 | 47 | * Required minimums and constants |
48 | 48 | */ |
49 | - define( 'WC_STRIPE_VERSION', '4.1.11' ); |
|
50 | - define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' ); |
|
51 | - define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' ); |
|
52 | - define( 'WC_STRIPE_MAIN_FILE', __FILE__ ); |
|
53 | - define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
|
54 | - define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
49 | + define('WC_STRIPE_VERSION', '4.1.11'); |
|
50 | + define('WC_STRIPE_MIN_PHP_VER', '5.6.0'); |
|
51 | + define('WC_STRIPE_MIN_WC_VER', '2.6.0'); |
|
52 | + define('WC_STRIPE_MAIN_FILE', __FILE__); |
|
53 | + define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
|
54 | + define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
55 | 55 | |
56 | 56 | class WC_Stripe { |
57 | 57 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return Singleton The *Singleton* instance. |
67 | 67 | */ |
68 | 68 | public static function get_instance() { |
69 | - if ( null === self::$instance ) { |
|
69 | + if (null === self::$instance) { |
|
70 | 70 | self::$instance = new self(); |
71 | 71 | } |
72 | 72 | return self::$instance; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * *Singleton* via the `new` operator from outside of this class. |
94 | 94 | */ |
95 | 95 | private function __construct() { |
96 | - add_action( 'admin_init', array( $this, 'install' ) ); |
|
96 | + add_action('admin_init', array($this, 'install')); |
|
97 | 97 | $this->init(); |
98 | 98 | } |
99 | 99 | |
@@ -104,48 +104,48 @@ discard block |
||
104 | 104 | * @version 4.0.0 |
105 | 105 | */ |
106 | 106 | public function init() { |
107 | - if ( is_admin() ) { |
|
108 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
107 | + if (is_admin()) { |
|
108 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
109 | 109 | } |
110 | 110 | |
111 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php'; |
|
112 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php'; |
|
113 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php'; |
|
114 | - include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php'; |
|
115 | - require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
116 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
117 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
118 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
119 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
120 | - require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php'; |
|
121 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
122 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
123 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
124 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
125 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
126 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
127 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
128 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
129 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
130 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
131 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
132 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
133 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php'; |
|
134 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
135 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php'; |
|
136 | - |
|
137 | - if ( is_admin() ) { |
|
138 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
111 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php'; |
|
112 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'; |
|
113 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'; |
|
114 | + include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php'; |
|
115 | + require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
116 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
117 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
118 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
119 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
120 | + require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'; |
|
121 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
122 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
123 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
124 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
125 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
126 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
127 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
128 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
129 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
130 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
131 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
132 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
133 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'; |
|
134 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
135 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'; |
|
136 | + |
|
137 | + if (is_admin()) { |
|
138 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // REMOVE IN THE FUTURE. |
142 | - require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
142 | + require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
143 | 143 | |
144 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
145 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
144 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
145 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
146 | 146 | |
147 | - if ( version_compare( WC_VERSION, '3.4', '<' ) ) { |
|
148 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
147 | + if (version_compare(WC_VERSION, '3.4', '<')) { |
|
148 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @version 4.0.0 |
157 | 157 | */ |
158 | 158 | public function update_plugin_version() { |
159 | - delete_option( 'wc_stripe_version' ); |
|
160 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
159 | + delete_option('wc_stripe_version'); |
|
160 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | * @version 3.1.0 |
168 | 168 | */ |
169 | 169 | public function install() { |
170 | - if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
170 | + if ( ! is_plugin_active(plugin_basename(__FILE__))) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
175 | - do_action( 'woocommerce_stripe_updated' ); |
|
174 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
175 | + do_action('woocommerce_stripe_updated'); |
|
176 | 176 | |
177 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
178 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
177 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
178 | + define('WC_STRIPE_INSTALLING', true); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | $this->update_plugin_version(); |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | * @since 1.0.0 |
189 | 189 | * @version 4.0.0 |
190 | 190 | */ |
191 | - public function plugin_action_links( $links ) { |
|
191 | + public function plugin_action_links($links) { |
|
192 | 192 | $plugin_links = array( |
193 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
194 | - '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>', |
|
195 | - '<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>', |
|
193 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
194 | + '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>', |
|
195 | + '<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>', |
|
196 | 196 | ); |
197 | - return array_merge( $plugin_links, $links ); |
|
197 | + return array_merge($plugin_links, $links); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @since 1.0.0 |
204 | 204 | * @version 4.0.0 |
205 | 205 | */ |
206 | - public function add_gateways( $methods ) { |
|
207 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) { |
|
206 | + public function add_gateways($methods) { |
|
207 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) { |
|
208 | 208 | $methods[] = 'WC_Stripe_Subs_Compat'; |
209 | 209 | $methods[] = 'WC_Stripe_Sepa_Subs_Compat'; |
210 | 210 | } else { |
@@ -230,28 +230,28 @@ discard block |
||
230 | 230 | * @since 4.0.0 |
231 | 231 | * @version 4.0.0 |
232 | 232 | */ |
233 | - public function filter_gateway_order_admin( $sections ) { |
|
234 | - unset( $sections['stripe'] ); |
|
235 | - unset( $sections['stripe_bancontact'] ); |
|
236 | - unset( $sections['stripe_sofort'] ); |
|
237 | - unset( $sections['stripe_giropay'] ); |
|
238 | - unset( $sections['stripe_eps'] ); |
|
239 | - unset( $sections['stripe_ideal'] ); |
|
240 | - unset( $sections['stripe_p24'] ); |
|
241 | - unset( $sections['stripe_alipay'] ); |
|
242 | - unset( $sections['stripe_sepa'] ); |
|
243 | - unset( $sections['stripe_multibanco'] ); |
|
233 | + public function filter_gateway_order_admin($sections) { |
|
234 | + unset($sections['stripe']); |
|
235 | + unset($sections['stripe_bancontact']); |
|
236 | + unset($sections['stripe_sofort']); |
|
237 | + unset($sections['stripe_giropay']); |
|
238 | + unset($sections['stripe_eps']); |
|
239 | + unset($sections['stripe_ideal']); |
|
240 | + unset($sections['stripe_p24']); |
|
241 | + unset($sections['stripe_alipay']); |
|
242 | + unset($sections['stripe_sepa']); |
|
243 | + unset($sections['stripe_multibanco']); |
|
244 | 244 | |
245 | 245 | $sections['stripe'] = 'Stripe'; |
246 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
247 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
248 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
249 | - $sections['stripe_eps'] = __( 'Stripe EPS', 'woocommerce-gateway-stripe' ); |
|
250 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
251 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
252 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
253 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
254 | - $sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' ); |
|
246 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
247 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
248 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
249 | + $sections['stripe_eps'] = __('Stripe EPS', 'woocommerce-gateway-stripe'); |
|
250 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
251 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
252 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
253 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
254 | + $sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe'); |
|
255 | 255 | |
256 | 256 | return $sections; |
257 | 257 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @since 4.1.0 |
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
25 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
24 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
25 | + add_action('wp_loaded', array($this, 'hide_notices')); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | * @since 1.0.0 |
32 | 32 | * @version 4.0.0 |
33 | 33 | */ |
34 | - public function add_admin_notice( $slug, $class, $message, $dismissible = false ) { |
|
35 | - $this->notices[ $slug ] = array( |
|
34 | + public function add_admin_notice($slug, $class, $message, $dismissible = false) { |
|
35 | + $this->notices[$slug] = array( |
|
36 | 36 | 'class' => $class, |
37 | 37 | 'message' => $message, |
38 | 38 | 'dismissible' => $dismissible, |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @version 4.0.0 |
47 | 47 | */ |
48 | 48 | public function admin_notices() { |
49 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
49 | + if ( ! current_user_can('manage_woocommerce')) { |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | // All other payment methods. |
57 | 57 | $this->payment_methods_check_environment(); |
58 | 58 | |
59 | - foreach ( (array) $this->notices as $notice_key => $notice ) { |
|
60 | - echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">'; |
|
59 | + foreach ((array) $this->notices as $notice_key => $notice) { |
|
60 | + echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">'; |
|
61 | 61 | |
62 | - if ( $notice['dismissible'] ) { |
|
62 | + if ($notice['dismissible']) { |
|
63 | 63 | ?> |
64 | - <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-stripe-hide-notice', $notice_key ), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce' ) ); ?>" class="woocommerce-message-close notice-dismiss" style="position:absolute;right:1px;padding:9px;text-decoration:none;"></a> |
|
64 | + <a href="<?php echo esc_url(wp_nonce_url(add_query_arg('wc-stripe-hide-notice', $notice_key), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce')); ?>" class="woocommerce-message-close notice-dismiss" style="position:absolute;right:1px;padding:9px;text-decoration:none;"></a> |
|
65 | 65 | <?php |
66 | 66 | } |
67 | 67 | |
68 | 68 | echo '<p>'; |
69 | - echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); |
|
69 | + echo wp_kses($notice['message'], array('a' => array('href' => array()))); |
|
70 | 70 | echo '</p></div>'; |
71 | 71 | } |
72 | 72 | } |
@@ -99,95 +99,95 @@ discard block |
||
99 | 99 | * @version 4.0.0 |
100 | 100 | */ |
101 | 101 | public function stripe_check_environment() { |
102 | - $show_styles_notice = get_option( 'wc_stripe_show_styles_notice' ); |
|
103 | - $show_ssl_notice = get_option( 'wc_stripe_show_ssl_notice' ); |
|
104 | - $show_keys_notice = get_option( 'wc_stripe_show_keys_notice' ); |
|
105 | - $show_phpver_notice = get_option( 'wc_stripe_show_phpver_notice' ); |
|
106 | - $show_wcver_notice = get_option( 'wc_stripe_show_wcver_notice' ); |
|
107 | - $show_curl_notice = get_option( 'wc_stripe_show_curl_notice' ); |
|
108 | - $options = get_option( 'woocommerce_stripe_settings' ); |
|
109 | - $testmode = ( isset( $options['testmode'] ) && 'yes' === $options['testmode'] ) ? true : false; |
|
110 | - $test_pub_key = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : ''; |
|
111 | - $test_secret_key = isset( $options['test_secret_key'] ) ? $options['test_secret_key'] : ''; |
|
112 | - $live_pub_key = isset( $options['publishable_key'] ) ? $options['publishable_key'] : ''; |
|
113 | - $live_secret_key = isset( $options['secret_key'] ) ? $options['secret_key'] : ''; |
|
114 | - |
|
115 | - if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) { |
|
116 | - if ( empty( $show_phpver_notice ) ) { |
|
117 | - if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) { |
|
102 | + $show_styles_notice = get_option('wc_stripe_show_styles_notice'); |
|
103 | + $show_ssl_notice = get_option('wc_stripe_show_ssl_notice'); |
|
104 | + $show_keys_notice = get_option('wc_stripe_show_keys_notice'); |
|
105 | + $show_phpver_notice = get_option('wc_stripe_show_phpver_notice'); |
|
106 | + $show_wcver_notice = get_option('wc_stripe_show_wcver_notice'); |
|
107 | + $show_curl_notice = get_option('wc_stripe_show_curl_notice'); |
|
108 | + $options = get_option('woocommerce_stripe_settings'); |
|
109 | + $testmode = (isset($options['testmode']) && 'yes' === $options['testmode']) ? true : false; |
|
110 | + $test_pub_key = isset($options['test_publishable_key']) ? $options['test_publishable_key'] : ''; |
|
111 | + $test_secret_key = isset($options['test_secret_key']) ? $options['test_secret_key'] : ''; |
|
112 | + $live_pub_key = isset($options['publishable_key']) ? $options['publishable_key'] : ''; |
|
113 | + $live_secret_key = isset($options['secret_key']) ? $options['secret_key'] : ''; |
|
114 | + |
|
115 | + if (isset($options['enabled']) && 'yes' === $options['enabled']) { |
|
116 | + if (empty($show_phpver_notice)) { |
|
117 | + if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) { |
|
118 | 118 | /* translators: 1) int version 2) int version */ |
119 | - $message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
119 | + $message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
120 | 120 | |
121 | - $this->add_admin_notice( 'phpver', 'error', sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ), true ); |
|
121 | + $this->add_admin_notice('phpver', 'error', sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()), true); |
|
122 | 122 | |
123 | 123 | return; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | 127 | // To be removed 4.1.12. |
128 | - if ( empty( $show_styles_notice ) ) { |
|
129 | - if ( version_compare( WC_STRIPE_VERSION, '4.1.12', '<' ) ) { |
|
130 | - $message = __( 'Action required: In January 2019 we will be introducing changes that could effect how Stripe looks in your checkout. <a href="https://docs.woocommerce.com/document/stripe/#section-45" target="_blank">Learn more</a> about how to make sure your site continues to look great.', 'woocommerce-gateway-stripe' ); |
|
128 | + if (empty($show_styles_notice)) { |
|
129 | + if (version_compare(WC_STRIPE_VERSION, '4.1.12', '<')) { |
|
130 | + $message = __('Action required: In January 2019 we will be introducing changes that could effect how Stripe looks in your checkout. <a href="https://docs.woocommerce.com/document/stripe/#section-45" target="_blank">Learn more</a> about how to make sure your site continues to look great.', 'woocommerce-gateway-stripe'); |
|
131 | 131 | |
132 | - $this->add_admin_notice( 'styles', 'notice notice-warning', $message, true ); |
|
132 | + $this->add_admin_notice('styles', 'notice notice-warning', $message, true); |
|
133 | 133 | |
134 | 134 | return; |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - if ( empty( $show_wcver_notice ) ) { |
|
139 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
138 | + if (empty($show_wcver_notice)) { |
|
139 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
140 | 140 | /* translators: 1) int version 2) int version */ |
141 | - $message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
141 | + $message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
142 | 142 | |
143 | - $this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ), true ); |
|
143 | + $this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION), true); |
|
144 | 144 | |
145 | 145 | return; |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - if ( empty( $show_curl_notice ) ) { |
|
150 | - if ( ! function_exists( 'curl_init' ) ) { |
|
151 | - $this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true ); |
|
149 | + if (empty($show_curl_notice)) { |
|
150 | + if ( ! function_exists('curl_init')) { |
|
151 | + $this->add_admin_notice('curl', 'notice notice-warning', __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'), true); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | - if ( empty( $show_keys_notice ) ) { |
|
155 | + if (empty($show_keys_notice)) { |
|
156 | 156 | $secret = WC_Stripe_API::get_secret_key(); |
157 | 157 | |
158 | - if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) { |
|
158 | + if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) { |
|
159 | 159 | $setting_link = $this->get_setting_link(); |
160 | 160 | /* translators: 1) link */ |
161 | - $this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true ); |
|
161 | + $this->add_admin_notice('keys', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Check if keys are entered properly per live/test mode. |
165 | - if ( $testmode ) { |
|
165 | + if ($testmode) { |
|
166 | 166 | if ( |
167 | - ! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key ) |
|
168 | - || ( ! empty( $test_secret_key ) && ! preg_match( '/^sk_test_/', $test_secret_key ) |
|
169 | - && ! empty( $test_secret_key ) && ! preg_match( '/^rk_test_/', $test_secret_key ) ) ) { |
|
167 | + ! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key) |
|
168 | + || ( ! empty($test_secret_key) && ! preg_match('/^sk_test_/', $test_secret_key) |
|
169 | + && ! empty($test_secret_key) && ! preg_match('/^rk_test_/', $test_secret_key)) ) { |
|
170 | 170 | $setting_link = $this->get_setting_link(); |
171 | 171 | /* translators: 1) link */ |
172 | - $this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true ); |
|
172 | + $this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true); |
|
173 | 173 | } |
174 | 174 | } else { |
175 | 175 | if ( |
176 | - ! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key ) |
|
177 | - || ( ! empty( $live_secret_key ) && ! preg_match( '/^sk_live_/', $live_secret_key ) |
|
178 | - && ! empty( $live_secret_key ) && ! preg_match( '/^rk_live_/', $live_secret_key ) ) ) { |
|
176 | + ! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key) |
|
177 | + || ( ! empty($live_secret_key) && ! preg_match('/^sk_live_/', $live_secret_key) |
|
178 | + && ! empty($live_secret_key) && ! preg_match('/^rk_live_/', $live_secret_key)) ) { |
|
179 | 179 | $setting_link = $this->get_setting_link(); |
180 | 180 | /* translators: 1) link */ |
181 | - $this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in live mode however your test keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true ); |
|
181 | + $this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in live mode however your test keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - if ( empty( $show_ssl_notice ) ) { |
|
186 | + if (empty($show_ssl_notice)) { |
|
187 | 187 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
188 | - if ( ! wc_checkout_is_https() ) { |
|
188 | + if ( ! wc_checkout_is_https()) { |
|
189 | 189 | /* translators: 1) link */ |
190 | - $this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true ); |
|
190 | + $this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
@@ -201,17 +201,17 @@ discard block |
||
201 | 201 | public function payment_methods_check_environment() { |
202 | 202 | $payment_methods = $this->get_payment_methods(); |
203 | 203 | |
204 | - foreach ( $payment_methods as $method => $class ) { |
|
205 | - $show_notice = get_option( 'wc_stripe_show_' . strtolower( $method ) . '_notice' ); |
|
204 | + foreach ($payment_methods as $method => $class) { |
|
205 | + $show_notice = get_option('wc_stripe_show_' . strtolower($method) . '_notice'); |
|
206 | 206 | $gateway = new $class(); |
207 | 207 | |
208 | - if ( 'yes' !== $gateway->enabled || 'no' === $show_notice ) { |
|
208 | + if ('yes' !== $gateway->enabled || 'no' === $show_notice) { |
|
209 | 209 | continue; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency() ) ) { |
|
212 | + if ( ! in_array(get_woocommerce_currency(), $gateway->get_supported_currency())) { |
|
213 | 213 | /* translators: %1$s Payment method, %2$s List of supported currencies */ |
214 | - $this->add_admin_notice( $method, 'notice notice-error', sprintf( __( '%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe' ), $method, implode( ', ', $gateway->get_supported_currency() ) ), true ); |
|
214 | + $this->add_admin_notice($method, 'notice notice-error', sprintf(__('%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe'), $method, implode(', ', $gateway->get_supported_currency())), true); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | } |
@@ -223,62 +223,62 @@ discard block |
||
223 | 223 | * @version 4.0.0 |
224 | 224 | */ |
225 | 225 | public function hide_notices() { |
226 | - if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) { |
|
227 | - if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) { |
|
228 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) ); |
|
226 | + if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) { |
|
227 | + if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) { |
|
228 | + wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe')); |
|
229 | 229 | } |
230 | 230 | |
231 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
232 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
231 | + if ( ! current_user_can('manage_woocommerce')) { |
|
232 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
233 | 233 | } |
234 | 234 | |
235 | - $notice = wc_clean( $_GET['wc-stripe-hide-notice'] ); |
|
235 | + $notice = wc_clean($_GET['wc-stripe-hide-notice']); |
|
236 | 236 | |
237 | - switch ( $notice ) { |
|
237 | + switch ($notice) { |
|
238 | 238 | case 'styles': |
239 | - update_option( 'wc_stripe_show_styles_notice', 'no' ); |
|
239 | + update_option('wc_stripe_show_styles_notice', 'no'); |
|
240 | 240 | break; |
241 | 241 | case 'styles': |
242 | - update_option( 'wc_stripe_show_phpver_notice', 'no' ); |
|
242 | + update_option('wc_stripe_show_phpver_notice', 'no'); |
|
243 | 243 | break; |
244 | 244 | case 'wcver': |
245 | - update_option( 'wc_stripe_show_wcver_notice', 'no' ); |
|
245 | + update_option('wc_stripe_show_wcver_notice', 'no'); |
|
246 | 246 | break; |
247 | 247 | case 'curl': |
248 | - update_option( 'wc_stripe_show_curl_notice', 'no' ); |
|
248 | + update_option('wc_stripe_show_curl_notice', 'no'); |
|
249 | 249 | break; |
250 | 250 | case 'ssl': |
251 | - update_option( 'wc_stripe_show_ssl_notice', 'no' ); |
|
251 | + update_option('wc_stripe_show_ssl_notice', 'no'); |
|
252 | 252 | break; |
253 | 253 | case 'keys': |
254 | - update_option( 'wc_stripe_show_keys_notice', 'no' ); |
|
254 | + update_option('wc_stripe_show_keys_notice', 'no'); |
|
255 | 255 | break; |
256 | 256 | case 'Alipay': |
257 | - update_option( 'wc_stripe_show_alipay_notice', 'no' ); |
|
257 | + update_option('wc_stripe_show_alipay_notice', 'no'); |
|
258 | 258 | break; |
259 | 259 | case 'Bancontact': |
260 | - update_option( 'wc_stripe_show_bancontact_notice', 'no' ); |
|
260 | + update_option('wc_stripe_show_bancontact_notice', 'no'); |
|
261 | 261 | break; |
262 | 262 | case 'EPS': |
263 | - update_option( 'wc_stripe_show_eps_notice', 'no' ); |
|
263 | + update_option('wc_stripe_show_eps_notice', 'no'); |
|
264 | 264 | break; |
265 | 265 | case 'Giropay': |
266 | - update_option( 'wc_stripe_show_giropay_notice', 'no' ); |
|
266 | + update_option('wc_stripe_show_giropay_notice', 'no'); |
|
267 | 267 | break; |
268 | 268 | case 'iDeal': |
269 | - update_option( 'wc_stripe_show_ideal_notice', 'no' ); |
|
269 | + update_option('wc_stripe_show_ideal_notice', 'no'); |
|
270 | 270 | break; |
271 | 271 | case 'Multibanco': |
272 | - update_option( 'wc_stripe_show_multibanco_notice', 'no' ); |
|
272 | + update_option('wc_stripe_show_multibanco_notice', 'no'); |
|
273 | 273 | break; |
274 | 274 | case 'P24': |
275 | - update_option( 'wc_stripe_show_p24_notice', 'no' ); |
|
275 | + update_option('wc_stripe_show_p24_notice', 'no'); |
|
276 | 276 | break; |
277 | 277 | case 'SEPA': |
278 | - update_option( 'wc_stripe_show_sepa_notice', 'no' ); |
|
278 | + update_option('wc_stripe_show_sepa_notice', 'no'); |
|
279 | 279 | break; |
280 | 280 | case 'SOFORT': |
281 | - update_option( 'wc_stripe_show_sofort_notice', 'no' ); |
|
281 | + update_option('wc_stripe_show_sofort_notice', 'no'); |
|
282 | 282 | break; |
283 | 283 | } |
284 | 284 | } |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | * @return string Setting link |
293 | 293 | */ |
294 | 294 | public function get_setting_link() { |
295 | - $use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false; |
|
295 | + $use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false; |
|
296 | 296 | |
297 | - $section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' ); |
|
297 | + $section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe'); |
|
298 | 298 | |
299 | - return admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug ); |
|
299 | + return admin_url('admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 |