1
1
<?php
2
- if ( ! defined ( 'ABSPATH ' ) ) {
2
+ if (! defined ('ABSPATH ' ) ) {
3
3
exit ; // Exit if accessed directly
4
4
}
5
5
@@ -119,25 +119,28 @@ abstract class WC_LemonWay_Payment_Gateway extends WC_Payment_Gateway
119
119
*
120
120
* @param string $warning Warning message.
121
121
*/
122
- protected function add_warning ( $ warning ) {
122
+ protected function add_warning ($ warning )
123
+ {
123
124
$ this ->warnings [] = $ warning ;
124
125
}
125
126
126
127
/**
127
128
* Get admin warning messages.
128
129
*/
129
- protected function get_warnings () {
130
+ protected function get_warnings ()
131
+ {
130
132
return $ this ->warnings ;
131
133
}
132
134
133
135
/**
134
136
* Display admin warning messages.
135
137
*/
136
- protected function display_warnings () {
137
- if ( $ this ->get_warnings () ) {
138
+ protected function display_warnings ()
139
+ {
140
+ if ($ this ->get_warnings ()) {
138
141
echo '<div id="woocommerce_warnings" class="notice-warning notice is-dismissible"> ' ;
139
- foreach ( $ this ->get_warnings () as $ warning ) {
140
- echo '<p> ' . wp_kses_post ( $ warning ) . '</p> ' ;
142
+ foreach ($ this ->get_warnings () as $ warning ) {
143
+ echo '<p> ' . wp_kses_post ($ warning ) . '</p> ' ;
141
144
}
142
145
echo '</div> ' ;
143
146
}
@@ -147,25 +150,25 @@ protected function display_warnings() {
147
150
* Load API settings
148
151
*/
149
152
protected function load_api_settings ()
150
- {
153
+ {
151
154
// Load main settings
152
155
$ settings_field_key = $ this ->get_option_key ();
153
- $ main_settings = get_option ( $ settings_field_key );
154
-
155
- $ this ->wlLogin = ! empty ( $ main_settings ['wlLogin ' ] ) ? $ main_settings ['wlLogin ' ] : '' ;
156
- $ this ->wlPass = ! empty ( $ main_settings ['wlPass ' ] ) ? $ main_settings ['wlPass ' ] : '' ;
157
- $ this ->test_mode = ( ! empty ( $ main_settings ['test_mode ' ] ) && 'yes ' === $ main_settings ['test_mode ' ] ) ? true : false ;
158
- $ this ->env_name = ! empty ( $ main_settings ['env_name ' ] ) ? $ main_settings ['env_name ' ] : '' ;
159
- $ this ->wallet = ! empty ( $ main_settings ['wallet ' ] ) ? $ main_settings ['wallet ' ] : '' ;
160
- $ this ->directkit_url = ! empty ( $ main_settings ['directkit_url ' ] ) ? $ main_settings ['directkit_url ' ] : '' ;
161
- $ this ->webkit_url = ! empty ( $ main_settings ['webkit_url ' ] ) ? $ main_settings ['webkit_url ' ] : '' ;
156
+ $ main_settings = get_option ($ settings_field_key );
157
+
158
+ $ this ->wlLogin = ! empty ($ main_settings ['wlLogin ' ]) ? $ main_settings ['wlLogin ' ] : '' ;
159
+ $ this ->wlPass = ! empty ($ main_settings ['wlPass ' ]) ? $ main_settings ['wlPass ' ] : '' ;
160
+ $ this ->test_mode = (! empty ($ main_settings ['test_mode ' ]) && 'yes ' === $ main_settings ['test_mode ' ]) ? true : false ;
161
+ $ this ->env_name = ! empty ($ main_settings ['env_name ' ]) ? $ main_settings ['env_name ' ] : '' ;
162
+ $ this ->wallet = ! empty ($ main_settings ['wallet ' ]) ? $ main_settings ['wallet ' ] : '' ;
163
+ $ this ->directkit_url = ! empty ($ main_settings ['directkit_url ' ]) ? $ main_settings ['directkit_url ' ] : '' ;
164
+ $ this ->webkit_url = ! empty ($ main_settings ['webkit_url ' ]) ? $ main_settings ['webkit_url ' ] : '' ;
162
165
}
163
166
164
167
/**
165
168
* Set up API
166
169
*/
167
170
protected function set_up_api ()
168
- {
171
+ {
169
172
$ settings = array (
170
173
'directkit_url ' => $ this ->directkit_url ,
171
174
'wlLogin ' => $ this ->wlLogin ,
@@ -190,8 +193,8 @@ protected function test_api()
190
193
try {
191
194
$ wallet_details = $ this ->api ->get_wallet_details ($ params );
192
195
} catch (WC_LemonWay_Exception $ e ) {
193
- if ( ! is_ajax () ) {
194
- $ this ->add_error ( $ e ->getLocalizedMessage () . ' ( ' . $ e ->getCode () . ') ' );
196
+ if (! is_ajax ()) {
197
+ $ this ->add_error ($ e ->getLocalizedMessage () . ' ( ' . $ e ->getCode () . ') ' );
195
198
$ this ->display_errors ();
196
199
}
197
200
@@ -206,7 +209,7 @@ protected function test_api()
206
209
*/
207
210
protected function format_amount ($ amount )
208
211
{
209
- return number_format ( $ amount , 2 , '. ' , '' );
212
+ return number_format ( $ amount , 2 , '. ' , '' );
210
213
}
211
214
212
215
/**
@@ -221,21 +224,21 @@ public function __construct()
221
224
$ this ->init_settings ();
222
225
223
226
// Get setting values.
224
- $ this ->title = $ this ->get_option ( 'title ' );
225
- $ this ->description = $ this ->get_option ( 'description ' );
227
+ $ this ->title = $ this ->get_option ('title ' );
228
+ $ this ->description = $ this ->get_option ('description ' );
226
229
227
230
// Load API settings
228
231
$ this ->load_api_settings ();
229
232
230
- if ( $ this ->test_mode ) {
233
+ if ($ this ->test_mode ) {
231
234
$ this ->title .= ' [TEST] ' ;
232
- $ this ->description = '[ ' . __ ( 'This is only a test payment. ' , LEMONWAY_TEXT_DOMAIN ) . ' <a href=" ' . __ ( 'https://lemonway.zendesk.com/hc/en-gb/articles/212557765-2-How-do-I-test-with-the-WooCommerce-module- ' , LEMONWAY_TEXT_DOMAIN ) . '" target="_blank"> ' . __ ( 'Click here to see how to use Test mode. ' , LEMONWAY_TEXT_DOMAIN ) . '</a> ' . '] ' . "\n" . $ this ->description ;
235
+ $ this ->description = '[ ' . __ ('This is only a test payment. ' , LEMONWAY_TEXT_DOMAIN ) . ' <a href=" ' . __ ('https://lemonway.zendesk.com/hc/en-gb/articles/212557765-2-How-do-I-test-with-the-WooCommerce-module- ' , LEMONWAY_TEXT_DOMAIN ) . '" target="_blank"> ' . __ ('Click here to see how to use Test mode. ' , LEMONWAY_TEXT_DOMAIN ) . '</a> ' . '] ' . "\n" . $ this ->description ;
233
236
}
234
237
235
238
// Set API language
236
- $ locale = substr ( get_locale (), 0 , 2 );
239
+ $ locale = substr (get_locale (), 0 , 2 );
237
240
238
- if ( array_key_exists ( $ locale , $ this ->supported_locales ) ) {
241
+ if (array_key_exists ($ locale , $ this ->supported_locales ) ) {
239
242
$ this ->language = $ this ->supported_locales [$ locale ];
240
243
} else {
241
244
$ this ->language = 'en ' ;
@@ -244,7 +247,7 @@ public function __construct()
244
247
// Set up API
245
248
$ this ->set_up_api ();
246
249
247
- add_action ( 'woocommerce_update_options_payment_gateways_ ' . $ this ->id , array ( $ this , 'process_admin_options ' ) );
250
+ add_action ('woocommerce_update_options_payment_gateways_ ' . $ this ->id , array ( $ this , 'process_admin_options ' ));
248
251
}
249
252
250
253
/**
0 commit comments