@@ -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,20 +9,20 @@ 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 | - add_filter( 'woocommerce_get_settings_account', array( $this, 'account_settings' ) ); |
|
| 25 | + add_filter('woocommerce_get_settings_account', array($this, 'account_settings')); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -31,20 +31,20 @@ discard block |
||
| 31 | 31 | * @param array $settings |
| 32 | 32 | * @return array $settings Updated |
| 33 | 33 | */ |
| 34 | - public function account_settings( $settings ) { |
|
| 34 | + public function account_settings($settings) { |
|
| 35 | 35 | $insert_setting = array( |
| 36 | 36 | array( |
| 37 | - 'title' => __( 'Retain Stripe Data', 'woocommerce-gateway-stripe' ), |
|
| 38 | - 'desc_tip' => __( 'Retains any Stripe data such as Stripe customer ID, source ID.', 'woocommerce-gateway-stripe' ), |
|
| 37 | + 'title' => __('Retain Stripe Data', 'woocommerce-gateway-stripe'), |
|
| 38 | + 'desc_tip' => __('Retains any Stripe data such as Stripe customer ID, source ID.', 'woocommerce-gateway-stripe'), |
|
| 39 | 39 | 'id' => 'woocommerce_gateway_stripe_retention', |
| 40 | 40 | 'type' => 'relative_date_selector', |
| 41 | - 'placeholder' => __( 'N/A', 'woocommerce-gateway-stripe' ), |
|
| 41 | + 'placeholder' => __('N/A', 'woocommerce-gateway-stripe'), |
|
| 42 | 42 | 'default' => '', |
| 43 | 43 | 'autoload' => false, |
| 44 | 44 | ), |
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | - array_splice( $settings, ( count( $settings ) - 1 ), 0, $insert_setting ); |
|
| 47 | + array_splice($settings, (count($settings) - 1), 0, $insert_setting); |
|
| 48 | 48 | |
| 49 | 49 | return $settings; |
| 50 | 50 | } |
@@ -57,22 +57,22 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return array WP_Post |
| 59 | 59 | */ |
| 60 | - protected function get_stripe_orders( $email_address, $page ) { |
|
| 61 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
| 60 | + protected function get_stripe_orders($email_address, $page) { |
|
| 61 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
| 62 | 62 | |
| 63 | - $order_query = array( |
|
| 64 | - 'payment_method' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ), |
|
| 63 | + $order_query = array( |
|
| 64 | + 'payment_method' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'), |
|
| 65 | 65 | 'limit' => 10, |
| 66 | 66 | 'page' => $page, |
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | - if ( $user instanceof WP_User ) { |
|
| 69 | + if ($user instanceof WP_User) { |
|
| 70 | 70 | $order_query['customer_id'] = (int) $user->ID; |
| 71 | 71 | } else { |
| 72 | 72 | $order_query['billing_email'] = $email_address; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - return wc_get_orders( $order_query ); |
|
| 75 | + return wc_get_orders($order_query); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | */ |
| 82 | 82 | public function get_privacy_message() { |
| 83 | - 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/document/privacy-payments/#woocommerce-gateway-stripe' ) ); |
|
| 83 | + 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/document/privacy-payments/#woocommerce-gateway-stripe')); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -91,34 +91,34 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return array |
| 93 | 93 | */ |
| 94 | - public function order_data_exporter( $email_address, $page = 1 ) { |
|
| 94 | + public function order_data_exporter($email_address, $page = 1) { |
|
| 95 | 95 | $done = false; |
| 96 | 96 | $data_to_export = array(); |
| 97 | 97 | |
| 98 | - $orders = $this->get_stripe_orders( $email_address, (int) $page ); |
|
| 98 | + $orders = $this->get_stripe_orders($email_address, (int) $page); |
|
| 99 | 99 | |
| 100 | 100 | $done = true; |
| 101 | 101 | |
| 102 | - if ( 0 < count( $orders ) ) { |
|
| 103 | - foreach ( $orders as $order ) { |
|
| 102 | + if (0 < count($orders)) { |
|
| 103 | + foreach ($orders as $order) { |
|
| 104 | 104 | $data_to_export[] = array( |
| 105 | 105 | 'group_id' => 'woocommerce_orders', |
| 106 | - 'group_label' => __( 'Orders', 'woocommerce-gateway-stripe' ), |
|
| 106 | + 'group_label' => __('Orders', 'woocommerce-gateway-stripe'), |
|
| 107 | 107 | 'item_id' => 'order-' . $order->get_id(), |
| 108 | 108 | 'data' => array( |
| 109 | 109 | array( |
| 110 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
| 111 | - 'value' => get_post_meta( $order->get_id(), '_stripe_source_id', true ), |
|
| 110 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
| 111 | + 'value' => get_post_meta($order->get_id(), '_stripe_source_id', true), |
|
| 112 | 112 | ), |
| 113 | 113 | array( |
| 114 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
| 115 | - 'value' => get_post_meta( $order->get_id(), '_stripe_customer_id', true ), |
|
| 114 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
| 115 | + 'value' => get_post_meta($order->get_id(), '_stripe_customer_id', true), |
|
| 116 | 116 | ), |
| 117 | 117 | ), |
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - $done = 10 > count( $orders ); |
|
| 121 | + $done = 10 > count($orders); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return array( |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return array |
| 137 | 137 | */ |
| 138 | - public function subscriptions_data_exporter( $email_address, $page = 1 ) { |
|
| 138 | + public function subscriptions_data_exporter($email_address, $page = 1) { |
|
| 139 | 139 | $done = false; |
| 140 | 140 | $page = (int) $page; |
| 141 | 141 | $data_to_export = array(); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | 'relation' => 'AND', |
| 145 | 145 | array( |
| 146 | 146 | 'key' => '_payment_method', |
| 147 | - 'value' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ), |
|
| 147 | + 'value' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'), |
|
| 148 | 148 | 'compare' => 'IN', |
| 149 | 149 | ), |
| 150 | 150 | array( |
@@ -154,36 +154,36 @@ discard block |
||
| 154 | 154 | ), |
| 155 | 155 | ); |
| 156 | 156 | |
| 157 | - $subscription_query = array( |
|
| 157 | + $subscription_query = array( |
|
| 158 | 158 | 'posts_per_page' => 10, |
| 159 | 159 | 'page' => $page, |
| 160 | 160 | 'meta_query' => $meta_query, |
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | - $subscriptions = wcs_get_subscriptions( $subscription_query ); |
|
| 163 | + $subscriptions = wcs_get_subscriptions($subscription_query); |
|
| 164 | 164 | |
| 165 | 165 | $done = true; |
| 166 | 166 | |
| 167 | - if ( 0 < count( $subscriptions ) ) { |
|
| 168 | - foreach ( $subscriptions as $subscription ) { |
|
| 167 | + if (0 < count($subscriptions)) { |
|
| 168 | + foreach ($subscriptions as $subscription) { |
|
| 169 | 169 | $data_to_export[] = array( |
| 170 | 170 | 'group_id' => 'woocommerce_subscriptions', |
| 171 | - 'group_label' => __( 'Subscriptions', 'woocommerce-gateway-stripe' ), |
|
| 171 | + 'group_label' => __('Subscriptions', 'woocommerce-gateway-stripe'), |
|
| 172 | 172 | 'item_id' => 'subscription-' . $subscription->get_id(), |
| 173 | 173 | 'data' => array( |
| 174 | 174 | array( |
| 175 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
| 176 | - 'value' => get_post_meta( $subscription->get_id(), '_stripe_source_id', true ), |
|
| 175 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
| 176 | + 'value' => get_post_meta($subscription->get_id(), '_stripe_source_id', true), |
|
| 177 | 177 | ), |
| 178 | 178 | array( |
| 179 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
| 180 | - 'value' => get_post_meta( $subscription->get_id(), '_stripe_customer_id', true ), |
|
| 179 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
| 180 | + 'value' => get_post_meta($subscription->get_id(), '_stripe_customer_id', true), |
|
| 181 | 181 | ), |
| 182 | 182 | ), |
| 183 | 183 | ); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $done = 10 > count( $subscriptions ); |
|
| 186 | + $done = 10 > count($subscriptions); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return array( |
@@ -199,24 +199,24 @@ discard block |
||
| 199 | 199 | * @param int $page Page. |
| 200 | 200 | * @return array An array of personal data in name value pairs |
| 201 | 201 | */ |
| 202 | - public function customer_data_exporter( $email_address, $page ) { |
|
| 203 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
| 202 | + public function customer_data_exporter($email_address, $page) { |
|
| 203 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
| 204 | 204 | $data_to_export = array(); |
| 205 | 205 | |
| 206 | - if ( $user instanceof WP_User ) { |
|
| 207 | - $stripe_user = new WC_Stripe_Customer( $user->ID ); |
|
| 206 | + if ($user instanceof WP_User) { |
|
| 207 | + $stripe_user = new WC_Stripe_Customer($user->ID); |
|
| 208 | 208 | |
| 209 | 209 | $data_to_export[] = array( |
| 210 | 210 | 'group_id' => 'woocommerce_customer', |
| 211 | - 'group_label' => __( 'Customer Data', 'woocommerce-gateway-stripe' ), |
|
| 211 | + 'group_label' => __('Customer Data', 'woocommerce-gateway-stripe'), |
|
| 212 | 212 | 'item_id' => 'user', |
| 213 | 213 | 'data' => array( |
| 214 | 214 | array( |
| 215 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
| 216 | - 'value' => get_user_meta( $user->ID, '_stripe_source_id', true ), |
|
| 215 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
| 216 | + 'value' => get_user_meta($user->ID, '_stripe_source_id', true), |
|
| 217 | 217 | ), |
| 218 | 218 | array( |
| 219 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
| 219 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
| 220 | 220 | 'value' => $stripe_user->get_id(), |
| 221 | 221 | ), |
| 222 | 222 | ), |
@@ -236,25 +236,25 @@ discard block |
||
| 236 | 236 | * @param int $page Page. |
| 237 | 237 | * @return array An array of personal data in name value pairs |
| 238 | 238 | */ |
| 239 | - public function customer_data_eraser( $email_address, $page ) { |
|
| 239 | + public function customer_data_eraser($email_address, $page) { |
|
| 240 | 240 | $page = (int) $page; |
| 241 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
| 241 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
| 242 | 242 | $stripe_customer_id = ''; |
| 243 | 243 | $stripe_source_id = ''; |
| 244 | 244 | |
| 245 | - if ( $user instanceof WP_User ) { |
|
| 246 | - $stripe_customer_id = get_user_meta( $user->ID, '_stripe_customer_id', true ); |
|
| 247 | - $stripe_source_id = get_user_meta( $user->ID, '_stripe_source_id', true ); |
|
| 245 | + if ($user instanceof WP_User) { |
|
| 246 | + $stripe_customer_id = get_user_meta($user->ID, '_stripe_customer_id', true); |
|
| 247 | + $stripe_source_id = get_user_meta($user->ID, '_stripe_source_id', true); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | $items_removed = false; |
| 251 | 251 | $messages = array(); |
| 252 | 252 | |
| 253 | - if ( ! empty( $stripe_customer_id ) || ! empty( $stripe_source_id ) ) { |
|
| 253 | + if ( ! empty($stripe_customer_id) || ! empty($stripe_source_id)) { |
|
| 254 | 254 | $items_removed = true; |
| 255 | - delete_user_meta( $user->ID, '_stripe_customer_id' ); |
|
| 256 | - delete_user_meta( $user->ID, '_stripe_source_id' ); |
|
| 257 | - $messages[] = __( 'Stripe User Data Erased.', 'woocommerce-gateway-stripe' ); |
|
| 255 | + delete_user_meta($user->ID, '_stripe_customer_id'); |
|
| 256 | + delete_user_meta($user->ID, '_stripe_source_id'); |
|
| 257 | + $messages[] = __('Stripe User Data Erased.', 'woocommerce-gateway-stripe'); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return array( |
@@ -272,29 +272,29 @@ discard block |
||
| 272 | 272 | * @param int $page Page. |
| 273 | 273 | * @return array An array of personal data in name value pairs |
| 274 | 274 | */ |
| 275 | - public function order_data_eraser( $email_address, $page ) { |
|
| 276 | - $orders = $this->get_stripe_orders( $email_address, (int) $page ); |
|
| 275 | + public function order_data_eraser($email_address, $page) { |
|
| 276 | + $orders = $this->get_stripe_orders($email_address, (int) $page); |
|
| 277 | 277 | |
| 278 | 278 | $items_removed = false; |
| 279 | 279 | $items_retained = false; |
| 280 | 280 | $messages = array(); |
| 281 | 281 | |
| 282 | - foreach ( (array) $orders as $order ) { |
|
| 283 | - $order = wc_get_order( $order->get_id() ); |
|
| 282 | + foreach ((array) $orders as $order) { |
|
| 283 | + $order = wc_get_order($order->get_id()); |
|
| 284 | 284 | |
| 285 | - list( $removed, $retained, $msgs ) = $this->maybe_handle_order( $order ); |
|
| 285 | + list($removed, $retained, $msgs) = $this->maybe_handle_order($order); |
|
| 286 | 286 | $items_removed |= $removed; |
| 287 | 287 | $items_retained |= $retained; |
| 288 | - $messages = array_merge( $messages, $msgs ); |
|
| 288 | + $messages = array_merge($messages, $msgs); |
|
| 289 | 289 | |
| 290 | - list( $removed, $retained, $msgs ) = $this->maybe_handle_subscription( $order ); |
|
| 290 | + list($removed, $retained, $msgs) = $this->maybe_handle_subscription($order); |
|
| 291 | 291 | $items_removed |= $removed; |
| 292 | 292 | $items_retained |= $retained; |
| 293 | - $messages = array_merge( $messages, $msgs ); |
|
| 293 | + $messages = array_merge($messages, $msgs); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Tell core if we have more orders to work on still |
| 297 | - $done = count( $orders ) < 10; |
|
| 297 | + $done = count($orders) < 10; |
|
| 298 | 298 | |
| 299 | 299 | return array( |
| 300 | 300 | 'items_removed' => $items_removed, |
@@ -310,45 +310,45 @@ discard block |
||
| 310 | 310 | * @param WC_Order $order |
| 311 | 311 | * @return array |
| 312 | 312 | */ |
| 313 | - protected function maybe_handle_subscription( $order ) { |
|
| 314 | - if ( ! class_exists( 'WC_Subscriptions' ) ) { |
|
| 315 | - return array( false, false, array() ); |
|
| 313 | + protected function maybe_handle_subscription($order) { |
|
| 314 | + if ( ! class_exists('WC_Subscriptions')) { |
|
| 315 | + return array(false, false, array()); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( ! wcs_order_contains_subscription( $order ) ) { |
|
| 319 | - return array( false, false, array() ); |
|
| 318 | + if ( ! wcs_order_contains_subscription($order)) { |
|
| 319 | + return array(false, false, array()); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $subscription = current( wcs_get_subscriptions_for_order( $order->get_id() ) ); |
|
| 322 | + $subscription = current(wcs_get_subscriptions_for_order($order->get_id())); |
|
| 323 | 323 | $subscription_id = $subscription->get_id(); |
| 324 | 324 | |
| 325 | - $stripe_source_id = get_post_meta( $subscription_id, '_stripe_source_id', true ); |
|
| 325 | + $stripe_source_id = get_post_meta($subscription_id, '_stripe_source_id', true); |
|
| 326 | 326 | |
| 327 | - if ( empty( $stripe_source_id ) ) { |
|
| 328 | - return array( false, false, array() ); |
|
| 327 | + if (empty($stripe_source_id)) { |
|
| 328 | + return array(false, false, array()); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) { |
|
| 332 | - return array( false, true, array( sprintf( __( 'Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) ); |
|
| 331 | + if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) { |
|
| 332 | + return array(false, true, array(sprintf(__('Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id()))); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( $subscription->has_status( apply_filters( 'wc_stripe_privacy_eraser_subs_statuses', array( 'on-hold', 'active' ) ) ) ) { |
|
| 336 | - return array( false, true, array( sprintf( __( 'Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) ); |
|
| 335 | + if ($subscription->has_status(apply_filters('wc_stripe_privacy_eraser_subs_statuses', array('on-hold', 'active')))) { |
|
| 336 | + return array(false, true, array(sprintf(__('Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id()))); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders( $order->get_id() ); |
|
| 339 | + $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders($order->get_id()); |
|
| 340 | 340 | |
| 341 | - foreach ( $renewal_orders as $renewal_order_id ) { |
|
| 342 | - delete_post_meta( $renewal_order_id, '_stripe_source_id' ); |
|
| 343 | - delete_post_meta( $renewal_order_id, '_stripe_refund_id' ); |
|
| 344 | - delete_post_meta( $renewal_order_id, '_stripe_customer_id' ); |
|
| 341 | + foreach ($renewal_orders as $renewal_order_id) { |
|
| 342 | + delete_post_meta($renewal_order_id, '_stripe_source_id'); |
|
| 343 | + delete_post_meta($renewal_order_id, '_stripe_refund_id'); |
|
| 344 | + delete_post_meta($renewal_order_id, '_stripe_customer_id'); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - delete_post_meta( $subscription_id, '_stripe_source_id' ); |
|
| 348 | - delete_post_meta( $subscription_id, '_stripe_refund_id' ); |
|
| 349 | - delete_post_meta( $subscription_id, '_stripe_customer_id' ); |
|
| 347 | + delete_post_meta($subscription_id, '_stripe_source_id'); |
|
| 348 | + delete_post_meta($subscription_id, '_stripe_refund_id'); |
|
| 349 | + delete_post_meta($subscription_id, '_stripe_customer_id'); |
|
| 350 | 350 | |
| 351 | - return array( true, false, array( __( 'Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe' ) ) ); |
|
| 351 | + return array(true, false, array(__('Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe'))); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -357,60 +357,60 @@ discard block |
||
| 357 | 357 | * @param WC_Order $order |
| 358 | 358 | * @return array |
| 359 | 359 | */ |
| 360 | - protected function maybe_handle_order( $order ) { |
|
| 360 | + protected function maybe_handle_order($order) { |
|
| 361 | 361 | $order_id = $order->get_id(); |
| 362 | - $stripe_source_id = get_post_meta( $order_id, '_stripe_source_id', true ); |
|
| 363 | - $stripe_refund_id = get_post_meta( $order_id, '_stripe_refund_id', true ); |
|
| 364 | - $stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true ); |
|
| 362 | + $stripe_source_id = get_post_meta($order_id, '_stripe_source_id', true); |
|
| 363 | + $stripe_refund_id = get_post_meta($order_id, '_stripe_refund_id', true); |
|
| 364 | + $stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true); |
|
| 365 | 365 | |
| 366 | - if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) { |
|
| 367 | - return array( false, true, array( sprintf( __( 'Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) ); |
|
| 366 | + if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) { |
|
| 367 | + return array(false, true, array(sprintf(__('Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id()))); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if ( empty( $stripe_source_id ) && empty( $stripe_refund_id ) && empty( $stripe_customer_id ) ) { |
|
| 371 | - return array( false, false, array() ); |
|
| 370 | + if (empty($stripe_source_id) && empty($stripe_refund_id) && empty($stripe_customer_id)) { |
|
| 371 | + return array(false, false, array()); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - delete_post_meta( $order_id, '_stripe_source_id' ); |
|
| 375 | - delete_post_meta( $order_id, '_stripe_refund_id' ); |
|
| 376 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
| 374 | + delete_post_meta($order_id, '_stripe_source_id'); |
|
| 375 | + delete_post_meta($order_id, '_stripe_refund_id'); |
|
| 376 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
| 377 | 377 | |
| 378 | - return array( true, false, array( __( 'Stripe personal data erased.', 'woocommerce-gateway-stripe' ) ) ); |
|
| 378 | + return array(true, false, array(__('Stripe personal data erased.', 'woocommerce-gateway-stripe'))); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | 382 | * Checks if create date is passed retention duration. |
| 383 | 383 | * |
| 384 | 384 | */ |
| 385 | - public function is_retention_expired( $created_date ) { |
|
| 386 | - $retention = wc_parse_relative_date_option( get_option( 'woocommerce_gateway_stripe_retention' ) ); |
|
| 385 | + public function is_retention_expired($created_date) { |
|
| 386 | + $retention = wc_parse_relative_date_option(get_option('woocommerce_gateway_stripe_retention')); |
|
| 387 | 387 | $is_expired = false; |
| 388 | - $time_span = time() - strtotime( $created_date ); |
|
| 389 | - if ( empty( $retention ) || empty( $created_date ) ) { |
|
| 388 | + $time_span = time() - strtotime($created_date); |
|
| 389 | + if (empty($retention) || empty($created_date)) { |
|
| 390 | 390 | return false; |
| 391 | 391 | } |
| 392 | - switch ( $retention['unit'] ) { |
|
| 392 | + switch ($retention['unit']) { |
|
| 393 | 393 | case 'days': |
| 394 | 394 | $retention = $retention['number'] * DAY_IN_SECONDS; |
| 395 | - if ( $time_span > $retention ) { |
|
| 395 | + if ($time_span > $retention) { |
|
| 396 | 396 | $is_expired = true; |
| 397 | 397 | } |
| 398 | 398 | break; |
| 399 | 399 | case 'weeks': |
| 400 | 400 | $retention = $retention['number'] * WEEK_IN_SECONDS; |
| 401 | - if ( $time_span > $retention ) { |
|
| 401 | + if ($time_span > $retention) { |
|
| 402 | 402 | $is_expired = true; |
| 403 | 403 | } |
| 404 | 404 | break; |
| 405 | 405 | case 'months': |
| 406 | 406 | $retention = $retention['number'] * MONTH_IN_SECONDS; |
| 407 | - if ( $time_span > $retention ) { |
|
| 407 | + if ($time_span > $retention) { |
|
| 408 | 408 | $is_expired = true; |
| 409 | 409 | } |
| 410 | 410 | break; |
| 411 | 411 | case 'years': |
| 412 | 412 | $retention = $retention['number'] * YEAR_IN_SECONDS; |
| 413 | - if ( $time_span > $retention ) { |
|
| 413 | + if ($time_span > $retention) { |
|
| 414 | 414 | $is_expired = true; |
| 415 | 415 | } |
| 416 | 416 | break; |
@@ -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,85 +99,85 @@ discard block |
||
| 99 | 99 | * @version 4.0.0 |
| 100 | 100 | */ |
| 101 | 101 | public function stripe_check_environment() { |
| 102 | - $show_ssl_notice = get_option( 'wc_stripe_show_ssl_notice' ); |
|
| 103 | - $show_keys_notice = get_option( 'wc_stripe_show_keys_notice' ); |
|
| 104 | - $show_phpver_notice = get_option( 'wc_stripe_show_phpver_notice' ); |
|
| 105 | - $show_wcver_notice = get_option( 'wc_stripe_show_wcver_notice' ); |
|
| 106 | - $show_curl_notice = get_option( 'wc_stripe_show_curl_notice' ); |
|
| 107 | - $options = get_option( 'woocommerce_stripe_settings' ); |
|
| 108 | - $testmode = ( isset( $options['testmode'] ) && 'yes' === $options['testmode'] ) ? true : false; |
|
| 109 | - $test_pub_key = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : ''; |
|
| 110 | - $test_secret_key = isset( $options['test_secret_key'] ) ? $options['test_secret_key'] : ''; |
|
| 111 | - $live_pub_key = isset( $options['publishable_key'] ) ? $options['publishable_key'] : ''; |
|
| 112 | - $live_secret_key = isset( $options['secret_key'] ) ? $options['secret_key'] : ''; |
|
| 113 | - |
|
| 114 | - if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) { |
|
| 115 | - if ( empty( $show_phpver_notice ) ) { |
|
| 116 | - if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) { |
|
| 102 | + $show_ssl_notice = get_option('wc_stripe_show_ssl_notice'); |
|
| 103 | + $show_keys_notice = get_option('wc_stripe_show_keys_notice'); |
|
| 104 | + $show_phpver_notice = get_option('wc_stripe_show_phpver_notice'); |
|
| 105 | + $show_wcver_notice = get_option('wc_stripe_show_wcver_notice'); |
|
| 106 | + $show_curl_notice = get_option('wc_stripe_show_curl_notice'); |
|
| 107 | + $options = get_option('woocommerce_stripe_settings'); |
|
| 108 | + $testmode = (isset($options['testmode']) && 'yes' === $options['testmode']) ? true : false; |
|
| 109 | + $test_pub_key = isset($options['test_publishable_key']) ? $options['test_publishable_key'] : ''; |
|
| 110 | + $test_secret_key = isset($options['test_secret_key']) ? $options['test_secret_key'] : ''; |
|
| 111 | + $live_pub_key = isset($options['publishable_key']) ? $options['publishable_key'] : ''; |
|
| 112 | + $live_secret_key = isset($options['secret_key']) ? $options['secret_key'] : ''; |
|
| 113 | + |
|
| 114 | + if (isset($options['enabled']) && 'yes' === $options['enabled']) { |
|
| 115 | + if (empty($show_phpver_notice)) { |
|
| 116 | + if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) { |
|
| 117 | 117 | /* translators: 1) int version 2) int version */ |
| 118 | - $message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
| 118 | + $message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
| 119 | 119 | |
| 120 | - $this->add_admin_notice( 'phpver', 'error', sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ), true ); |
|
| 120 | + $this->add_admin_notice('phpver', 'error', sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()), true); |
|
| 121 | 121 | |
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if ( empty( $show_wcver_notice ) ) { |
|
| 127 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
| 126 | + if (empty($show_wcver_notice)) { |
|
| 127 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
| 128 | 128 | /* translators: 1) int version 2) int version */ |
| 129 | - $message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
| 129 | + $message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
| 130 | 130 | |
| 131 | - $this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ), true ); |
|
| 131 | + $this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION), true); |
|
| 132 | 132 | |
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( empty( $show_curl_notice ) ) { |
|
| 138 | - if ( ! function_exists( 'curl_init' ) ) { |
|
| 139 | - $this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true ); |
|
| 137 | + if (empty($show_curl_notice)) { |
|
| 138 | + if ( ! function_exists('curl_init')) { |
|
| 139 | + $this->add_admin_notice('curl', 'notice notice-warning', __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'), true); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if ( empty( $show_keys_notice ) ) { |
|
| 143 | + if (empty($show_keys_notice)) { |
|
| 144 | 144 | $secret = WC_Stripe_API::get_secret_key(); |
| 145 | 145 | |
| 146 | - if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) { |
|
| 146 | + if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) { |
|
| 147 | 147 | $setting_link = $this->get_setting_link(); |
| 148 | 148 | /* translators: 1) link */ |
| 149 | - $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 ); |
|
| 149 | + $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); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // Check if keys are entered properly per live/test mode. |
| 153 | - if ( $testmode ) { |
|
| 153 | + if ($testmode) { |
|
| 154 | 154 | if ( |
| 155 | - ! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key ) |
|
| 156 | - || ( ! empty( $test_secret_key ) && ! preg_match( '/^sk_test_/', $test_secret_key ) |
|
| 157 | - && ! empty( $test_secret_key ) && ! preg_match( '/^rk_test_/', $test_secret_key ) ) ) |
|
| 155 | + ! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key) |
|
| 156 | + || ( ! empty($test_secret_key) && ! preg_match('/^sk_test_/', $test_secret_key) |
|
| 157 | + && ! empty($test_secret_key) && ! preg_match('/^rk_test_/', $test_secret_key)) ) |
|
| 158 | 158 | { |
| 159 | 159 | $setting_link = $this->get_setting_link(); |
| 160 | 160 | /* translators: 1) link */ |
| 161 | - $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 ); |
|
| 161 | + $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); |
|
| 162 | 162 | } |
| 163 | 163 | } else { |
| 164 | 164 | if ( |
| 165 | - ! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key ) |
|
| 166 | - || ( ! empty( $live_secret_key ) && ! preg_match( '/^sk_live_/', $live_secret_key ) |
|
| 167 | - && ! empty( $live_secret_key ) && ! preg_match( '/^rk_live_/', $live_secret_key ) ) ) |
|
| 165 | + ! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key) |
|
| 166 | + || ( ! empty($live_secret_key) && ! preg_match('/^sk_live_/', $live_secret_key) |
|
| 167 | + && ! empty($live_secret_key) && ! preg_match('/^rk_live_/', $live_secret_key)) ) |
|
| 168 | 168 | { |
| 169 | 169 | $setting_link = $this->get_setting_link(); |
| 170 | 170 | /* translators: 1) link */ |
| 171 | - $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 ); |
|
| 171 | + $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); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ( empty( $show_ssl_notice ) ) { |
|
| 176 | + if (empty($show_ssl_notice)) { |
|
| 177 | 177 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
| 178 | - if ( ! wc_checkout_is_https() ) { |
|
| 178 | + if ( ! wc_checkout_is_https()) { |
|
| 179 | 179 | /* translators: 1) link */ |
| 180 | - $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> - Stripe will only work in test mode.', 'woocommerce-gateway-stripe' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true ); |
|
| 180 | + $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> - Stripe will only work in test mode.', 'woocommerce-gateway-stripe'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -191,16 +191,16 @@ discard block |
||
| 191 | 191 | public function payment_methods_check_environment() { |
| 192 | 192 | $payment_methods = $this->get_payment_methods(); |
| 193 | 193 | |
| 194 | - foreach ( $payment_methods as $method => $class ) { |
|
| 195 | - $show_notice = get_option( 'wc_stripe_show_' . strtolower( $method ) . '_notice' ); |
|
| 194 | + foreach ($payment_methods as $method => $class) { |
|
| 195 | + $show_notice = get_option('wc_stripe_show_' . strtolower($method) . '_notice'); |
|
| 196 | 196 | $gateway = new $class(); |
| 197 | 197 | |
| 198 | - if ( 'yes' !== $gateway->enabled || 'no' === $show_notice ) { |
|
| 198 | + if ('yes' !== $gateway->enabled || 'no' === $show_notice) { |
|
| 199 | 199 | continue; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency() ) ) { |
|
| 203 | - $this->add_admin_notice( $method, 'notice notice-error', sprintf( __( '%s is enabled - it requires store currency to be set to %s', 'woocommerce-gateway-stripe' ), $method, implode( ', ', $gateway->get_supported_currency() ) ), true ); |
|
| 202 | + if ( ! in_array(get_woocommerce_currency(), $gateway->get_supported_currency())) { |
|
| 203 | + $this->add_admin_notice($method, 'notice notice-error', sprintf(__('%s is enabled - it requires store currency to be set to %s', 'woocommerce-gateway-stripe'), $method, implode(', ', $gateway->get_supported_currency())), true); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -212,59 +212,59 @@ discard block |
||
| 212 | 212 | * @version 4.0.0 |
| 213 | 213 | */ |
| 214 | 214 | public function hide_notices() { |
| 215 | - if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) { |
|
| 216 | - if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) { |
|
| 217 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) ); |
|
| 215 | + if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) { |
|
| 216 | + if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) { |
|
| 217 | + wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe')); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
| 221 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
| 220 | + if ( ! current_user_can('manage_woocommerce')) { |
|
| 221 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $notice = wc_clean( $_GET['wc-stripe-hide-notice'] ); |
|
| 224 | + $notice = wc_clean($_GET['wc-stripe-hide-notice']); |
|
| 225 | 225 | |
| 226 | - switch ( $notice ) { |
|
| 226 | + switch ($notice) { |
|
| 227 | 227 | case 'phpver': |
| 228 | - update_option( 'wc_stripe_show_phpver_notice', 'no' ); |
|
| 228 | + update_option('wc_stripe_show_phpver_notice', 'no'); |
|
| 229 | 229 | break; |
| 230 | 230 | case 'wcver': |
| 231 | - update_option( 'wc_stripe_show_wcver_notice', 'no' ); |
|
| 231 | + update_option('wc_stripe_show_wcver_notice', 'no'); |
|
| 232 | 232 | break; |
| 233 | 233 | case 'curl': |
| 234 | - update_option( 'wc_stripe_show_curl_notice', 'no' ); |
|
| 234 | + update_option('wc_stripe_show_curl_notice', 'no'); |
|
| 235 | 235 | break; |
| 236 | 236 | case 'ssl': |
| 237 | - update_option( 'wc_stripe_show_ssl_notice', 'no' ); |
|
| 237 | + update_option('wc_stripe_show_ssl_notice', 'no'); |
|
| 238 | 238 | break; |
| 239 | 239 | case 'keys': |
| 240 | - update_option( 'wc_stripe_show_keys_notice', 'no' ); |
|
| 240 | + update_option('wc_stripe_show_keys_notice', 'no'); |
|
| 241 | 241 | break; |
| 242 | 242 | case 'Alipay': |
| 243 | - update_option( 'wc_stripe_show_alipay_notice', 'no' ); |
|
| 243 | + update_option('wc_stripe_show_alipay_notice', 'no'); |
|
| 244 | 244 | break; |
| 245 | 245 | case 'Bancontact': |
| 246 | - update_option( 'wc_stripe_show_bancontact_notice', 'no' ); |
|
| 246 | + update_option('wc_stripe_show_bancontact_notice', 'no'); |
|
| 247 | 247 | break; |
| 248 | 248 | case 'EPS': |
| 249 | - update_option( 'wc_stripe_show_eps_notice', 'no' ); |
|
| 249 | + update_option('wc_stripe_show_eps_notice', 'no'); |
|
| 250 | 250 | break; |
| 251 | 251 | case 'Giropay': |
| 252 | - update_option( 'wc_stripe_show_giropay_notice', 'no' ); |
|
| 252 | + update_option('wc_stripe_show_giropay_notice', 'no'); |
|
| 253 | 253 | break; |
| 254 | 254 | case 'iDeal': |
| 255 | - update_option( 'wc_stripe_show_ideal_notice', 'no' ); |
|
| 255 | + update_option('wc_stripe_show_ideal_notice', 'no'); |
|
| 256 | 256 | break; |
| 257 | 257 | case 'Multibanco': |
| 258 | - update_option( 'wc_stripe_show_multibanco_notice', 'no' ); |
|
| 258 | + update_option('wc_stripe_show_multibanco_notice', 'no'); |
|
| 259 | 259 | break; |
| 260 | 260 | case 'P24': |
| 261 | - update_option( 'wc_stripe_show_p24_notice', 'no' ); |
|
| 261 | + update_option('wc_stripe_show_p24_notice', 'no'); |
|
| 262 | 262 | break; |
| 263 | 263 | case 'SEPA': |
| 264 | - update_option( 'wc_stripe_show_sepa_notice', 'no' ); |
|
| 264 | + update_option('wc_stripe_show_sepa_notice', 'no'); |
|
| 265 | 265 | break; |
| 266 | 266 | case 'SOFORT': |
| 267 | - update_option( 'wc_stripe_show_sofort_notice', 'no' ); |
|
| 267 | + update_option('wc_stripe_show_sofort_notice', 'no'); |
|
| 268 | 268 | break; |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | * @return string Setting link |
| 279 | 279 | */ |
| 280 | 280 | public function get_setting_link() { |
| 281 | - $use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false; |
|
| 281 | + $use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false; |
|
| 282 | 282 | |
| 283 | - $section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' ); |
|
| 283 | + $section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe'); |
|
| 284 | 284 | |
| 285 | - return admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug ); |
|
| 285 | + return admin_url('admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug); |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |