@@ -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,93 +99,93 @@ discard block |
||
| 99 | 99 | * @version 4.0.0 |
| 100 | 100 | */ |
| 101 | 101 | public function stripe_check_environment() { |
| 102 | - $show_style_notice = get_option( 'wc_stripe_show_style_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_style_notice ) ) { |
|
| 102 | + $show_style_notice = get_option('wc_stripe_show_style_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_style_notice)) { |
|
| 117 | 117 | /* translators: 1) int version 2) int version */ |
| 118 | - $message = __( 'WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#section-45" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe' ); |
|
| 118 | + $message = __('WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#section-45" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe'); |
|
| 119 | 119 | |
| 120 | - $this->add_admin_notice( 'style', 'error', $message, true ); |
|
| 120 | + $this->add_admin_notice('style', 'error', $message, true); |
|
| 121 | 121 | |
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( empty( $show_phpver_notice ) ) { |
|
| 126 | - if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) { |
|
| 125 | + if (empty($show_phpver_notice)) { |
|
| 126 | + if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) { |
|
| 127 | 127 | /* translators: 1) int version 2) int version */ |
| 128 | - $message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
| 128 | + $message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
| 129 | 129 | |
| 130 | - $this->add_admin_notice( 'phpver', 'error', sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ), true ); |
|
| 130 | + $this->add_admin_notice('phpver', 'error', sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()), true); |
|
| 131 | 131 | |
| 132 | 132 | return; |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( empty( $show_wcver_notice ) ) { |
|
| 137 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
| 136 | + if (empty($show_wcver_notice)) { |
|
| 137 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
| 138 | 138 | /* translators: 1) int version 2) int version */ |
| 139 | - $message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
| 139 | + $message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
| 140 | 140 | |
| 141 | - $this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ), true ); |
|
| 141 | + $this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION), true); |
|
| 142 | 142 | |
| 143 | 143 | return; |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if ( empty( $show_curl_notice ) ) { |
|
| 148 | - if ( ! function_exists( 'curl_init' ) ) { |
|
| 149 | - $this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true ); |
|
| 147 | + if (empty($show_curl_notice)) { |
|
| 148 | + if ( ! function_exists('curl_init')) { |
|
| 149 | + $this->add_admin_notice('curl', 'notice notice-warning', __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'), true); |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( empty( $show_keys_notice ) ) { |
|
| 153 | + if (empty($show_keys_notice)) { |
|
| 154 | 154 | $secret = WC_Stripe_API::get_secret_key(); |
| 155 | 155 | |
| 156 | - if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) { |
|
| 156 | + if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) { |
|
| 157 | 157 | $setting_link = $this->get_setting_link(); |
| 158 | 158 | /* translators: 1) link */ |
| 159 | - $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 ); |
|
| 159 | + $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); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // Check if keys are entered properly per live/test mode. |
| 163 | - if ( $testmode ) { |
|
| 163 | + if ($testmode) { |
|
| 164 | 164 | if ( |
| 165 | - ! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key ) |
|
| 166 | - || ( ! empty( $test_secret_key ) && ! preg_match( '/^sk_test_/', $test_secret_key ) |
|
| 167 | - && ! empty( $test_secret_key ) && ! preg_match( '/^rk_test_/', $test_secret_key ) ) ) { |
|
| 165 | + ! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key) |
|
| 166 | + || ( ! empty($test_secret_key) && ! preg_match('/^sk_test_/', $test_secret_key) |
|
| 167 | + && ! empty($test_secret_key) && ! preg_match('/^rk_test_/', $test_secret_key)) ) { |
|
| 168 | 168 | $setting_link = $this->get_setting_link(); |
| 169 | 169 | /* translators: 1) link */ |
| 170 | - $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 ); |
|
| 170 | + $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); |
|
| 171 | 171 | } |
| 172 | 172 | } else { |
| 173 | 173 | if ( |
| 174 | - ! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key ) |
|
| 175 | - || ( ! empty( $live_secret_key ) && ! preg_match( '/^sk_live_/', $live_secret_key ) |
|
| 176 | - && ! empty( $live_secret_key ) && ! preg_match( '/^rk_live_/', $live_secret_key ) ) ) { |
|
| 174 | + ! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key) |
|
| 175 | + || ( ! empty($live_secret_key) && ! preg_match('/^sk_live_/', $live_secret_key) |
|
| 176 | + && ! empty($live_secret_key) && ! preg_match('/^rk_live_/', $live_secret_key)) ) { |
|
| 177 | 177 | $setting_link = $this->get_setting_link(); |
| 178 | 178 | /* translators: 1) link */ |
| 179 | - $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 ); |
|
| 179 | + $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); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( empty( $show_ssl_notice ) ) { |
|
| 184 | + if (empty($show_ssl_notice)) { |
|
| 185 | 185 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
| 186 | - if ( ! wc_checkout_is_https() ) { |
|
| 186 | + if ( ! wc_checkout_is_https()) { |
|
| 187 | 187 | /* translators: 1) link */ |
| 188 | - $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 ); |
|
| 188 | + $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); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -199,17 +199,17 @@ discard block |
||
| 199 | 199 | public function payment_methods_check_environment() { |
| 200 | 200 | $payment_methods = $this->get_payment_methods(); |
| 201 | 201 | |
| 202 | - foreach ( $payment_methods as $method => $class ) { |
|
| 203 | - $show_notice = get_option( 'wc_stripe_show_' . strtolower( $method ) . '_notice' ); |
|
| 202 | + foreach ($payment_methods as $method => $class) { |
|
| 203 | + $show_notice = get_option('wc_stripe_show_' . strtolower($method) . '_notice'); |
|
| 204 | 204 | $gateway = new $class(); |
| 205 | 205 | |
| 206 | - if ( 'yes' !== $gateway->enabled || 'no' === $show_notice ) { |
|
| 206 | + if ('yes' !== $gateway->enabled || 'no' === $show_notice) { |
|
| 207 | 207 | continue; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency() ) ) { |
|
| 210 | + if ( ! in_array(get_woocommerce_currency(), $gateway->get_supported_currency())) { |
|
| 211 | 211 | /* translators: %1$s Payment method, %2$s List of supported currencies */ |
| 212 | - $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 ); |
|
| 212 | + $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); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -221,62 +221,62 @@ discard block |
||
| 221 | 221 | * @version 4.0.0 |
| 222 | 222 | */ |
| 223 | 223 | public function hide_notices() { |
| 224 | - if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) { |
|
| 225 | - if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) { |
|
| 226 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) ); |
|
| 224 | + if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) { |
|
| 225 | + if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) { |
|
| 226 | + wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe')); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
| 230 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
| 229 | + if ( ! current_user_can('manage_woocommerce')) { |
|
| 230 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $notice = wc_clean( $_GET['wc-stripe-hide-notice'] ); |
|
| 233 | + $notice = wc_clean($_GET['wc-stripe-hide-notice']); |
|
| 234 | 234 | |
| 235 | - switch ( $notice ) { |
|
| 235 | + switch ($notice) { |
|
| 236 | 236 | case 'style': |
| 237 | - update_option( 'wc_stripe_show_style_notice', 'no' ); |
|
| 237 | + update_option('wc_stripe_show_style_notice', 'no'); |
|
| 238 | 238 | break; |
| 239 | 239 | case 'phpver': |
| 240 | - update_option( 'wc_stripe_show_phpver_notice', 'no' ); |
|
| 240 | + update_option('wc_stripe_show_phpver_notice', 'no'); |
|
| 241 | 241 | break; |
| 242 | 242 | case 'wcver': |
| 243 | - update_option( 'wc_stripe_show_wcver_notice', 'no' ); |
|
| 243 | + update_option('wc_stripe_show_wcver_notice', 'no'); |
|
| 244 | 244 | break; |
| 245 | 245 | case 'curl': |
| 246 | - update_option( 'wc_stripe_show_curl_notice', 'no' ); |
|
| 246 | + update_option('wc_stripe_show_curl_notice', 'no'); |
|
| 247 | 247 | break; |
| 248 | 248 | case 'ssl': |
| 249 | - update_option( 'wc_stripe_show_ssl_notice', 'no' ); |
|
| 249 | + update_option('wc_stripe_show_ssl_notice', 'no'); |
|
| 250 | 250 | break; |
| 251 | 251 | case 'keys': |
| 252 | - update_option( 'wc_stripe_show_keys_notice', 'no' ); |
|
| 252 | + update_option('wc_stripe_show_keys_notice', 'no'); |
|
| 253 | 253 | break; |
| 254 | 254 | case 'Alipay': |
| 255 | - update_option( 'wc_stripe_show_alipay_notice', 'no' ); |
|
| 255 | + update_option('wc_stripe_show_alipay_notice', 'no'); |
|
| 256 | 256 | break; |
| 257 | 257 | case 'Bancontact': |
| 258 | - update_option( 'wc_stripe_show_bancontact_notice', 'no' ); |
|
| 258 | + update_option('wc_stripe_show_bancontact_notice', 'no'); |
|
| 259 | 259 | break; |
| 260 | 260 | case 'EPS': |
| 261 | - update_option( 'wc_stripe_show_eps_notice', 'no' ); |
|
| 261 | + update_option('wc_stripe_show_eps_notice', 'no'); |
|
| 262 | 262 | break; |
| 263 | 263 | case 'Giropay': |
| 264 | - update_option( 'wc_stripe_show_giropay_notice', 'no' ); |
|
| 264 | + update_option('wc_stripe_show_giropay_notice', 'no'); |
|
| 265 | 265 | break; |
| 266 | 266 | case 'iDeal': |
| 267 | - update_option( 'wc_stripe_show_ideal_notice', 'no' ); |
|
| 267 | + update_option('wc_stripe_show_ideal_notice', 'no'); |
|
| 268 | 268 | break; |
| 269 | 269 | case 'Multibanco': |
| 270 | - update_option( 'wc_stripe_show_multibanco_notice', 'no' ); |
|
| 270 | + update_option('wc_stripe_show_multibanco_notice', 'no'); |
|
| 271 | 271 | break; |
| 272 | 272 | case 'P24': |
| 273 | - update_option( 'wc_stripe_show_p24_notice', 'no' ); |
|
| 273 | + update_option('wc_stripe_show_p24_notice', 'no'); |
|
| 274 | 274 | break; |
| 275 | 275 | case 'SEPA': |
| 276 | - update_option( 'wc_stripe_show_sepa_notice', 'no' ); |
|
| 276 | + update_option('wc_stripe_show_sepa_notice', 'no'); |
|
| 277 | 277 | break; |
| 278 | 278 | case 'SOFORT': |
| 279 | - update_option( 'wc_stripe_show_sofort_notice', 'no' ); |
|
| 279 | + update_option('wc_stripe_show_sofort_notice', 'no'); |
|
| 280 | 280 | break; |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -290,11 +290,11 @@ discard block |
||
| 290 | 290 | * @return string Setting link |
| 291 | 291 | */ |
| 292 | 292 | public function get_setting_link() { |
| 293 | - $use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false; |
|
| 293 | + $use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false; |
|
| 294 | 294 | |
| 295 | - $section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' ); |
|
| 295 | + $section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe'); |
|
| 296 | 296 | |
| 297 | - return admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug ); |
|
| 297 | + return admin_url('admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug); |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
@@ -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.14' ); |
|
| 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.14'); |
|
| 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 | } |