Passed
Pull Request — master (#88)
by Kiran
03:50
created
includes/wpinv-gateway-functions.php 1 patch
Spacing   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -7,206 +7,206 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_get_payment_gateways() {
15 15
     // Default, built-in gateways
16 16
     $gateways = array(
17 17
         'paypal' => array(
18
-            'admin_label'    => __( 'PayPal Standard', 'invoicing' ),
19
-            'checkout_label' => __( 'PayPal Standard', 'invoicing' ),
18
+            'admin_label'    => __('PayPal Standard', 'invoicing'),
19
+            'checkout_label' => __('PayPal Standard', 'invoicing'),
20 20
             'ordering'       => 1,
21 21
         ),
22 22
         'authorizenet' => array(
23
-            'admin_label'    => __( 'Authorize.Net (AIM)', 'invoicing' ),
24
-            'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ),
23
+            'admin_label'    => __('Authorize.Net (AIM)', 'invoicing'),
24
+            'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'),
25 25
             'ordering'       => 4,
26 26
         ),
27 27
         'worldpay' => array(
28
-            'admin_label'    => __( 'Worldpay', 'invoicing' ),
29
-            'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ),
28
+            'admin_label'    => __('Worldpay', 'invoicing'),
29
+            'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'),
30 30
             'ordering'       => 5,
31 31
         ),
32 32
         'bank_transfer' => array(
33
-            'admin_label'    => __( 'Pre Bank Transfer', 'invoicing' ),
34
-            'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ),
33
+            'admin_label'    => __('Pre Bank Transfer', 'invoicing'),
34
+            'checkout_label' => __('Pre Bank Transfer', 'invoicing'),
35 35
             'ordering'       => 11,
36 36
         ),
37 37
         'manual' => array(
38
-            'admin_label'    => __( 'Test Payment', 'invoicing' ),
39
-            'checkout_label' => __( 'Test Payment', 'invoicing' ),
38
+            'admin_label'    => __('Test Payment', 'invoicing'),
39
+            'checkout_label' => __('Test Payment', 'invoicing'),
40 40
             'ordering'       => 12,
41 41
         ),
42 42
     );
43 43
 
44
-    return apply_filters( 'wpinv_payment_gateways', $gateways );
44
+    return apply_filters('wpinv_payment_gateways', $gateways);
45 45
 }
46 46
 
47
-function wpinv_payment_gateway_titles( $all_gateways ) {
47
+function wpinv_payment_gateway_titles($all_gateways) {
48 48
     global $wpinv_options;
49 49
     
50 50
     $gateways = array();
51
-    foreach ( $all_gateways as $key => $gateway ) {
52
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
53
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
51
+    foreach ($all_gateways as $key => $gateway) {
52
+        if (!empty($wpinv_options[$key . '_title'])) {
53
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
54 54
         }
55 55
         
56
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
56
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
57 57
     }
58 58
 
59
-    asort( $gateways );
59
+    asort($gateways);
60 60
     
61
-    foreach ( $gateways as $gateway => $key ) {
61
+    foreach ($gateways as $gateway => $key) {
62 62
         $gateways[$gateway] = $all_gateways[$gateway];
63 63
     }
64 64
     
65 65
     return $gateways;
66 66
 }
67
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
67
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
68 68
 
69
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
69
+function wpinv_get_enabled_payment_gateways($sort = false) {
70 70
     $gateways = wpinv_get_payment_gateways();
71
-    $enabled  = wpinv_get_option( 'gateways', false );
71
+    $enabled  = wpinv_get_option('gateways', false);
72 72
 
73 73
     $gateway_list = array();
74 74
 
75
-    foreach ( $gateways as $key => $gateway ) {
76
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
77
-            $gateway_list[ $key ] = $gateway;
75
+    foreach ($gateways as $key => $gateway) {
76
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
77
+            $gateway_list[$key] = $gateway;
78 78
         }
79 79
     }
80 80
 
81
-    if ( true === $sort ) {
82
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
81
+    if (true === $sort) {
82
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
83 83
         
84 84
         // Reorder our gateways so the default is first
85 85
         $default_gateway_id = wpinv_get_default_gateway();
86 86
 
87
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
88
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
89
-            unset( $gateway_list[ $default_gateway_id ] );
87
+        if (wpinv_is_gateway_active($default_gateway_id)) {
88
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
89
+            unset($gateway_list[$default_gateway_id]);
90 90
 
91
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
91
+            $gateway_list = array_merge($default_gateway, $gateway_list);
92 92
         }
93 93
     }
94 94
 
95
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
95
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
96 96
 }
97 97
 
98
-function wpinv_sort_gateway_order( $a, $b ) {
98
+function wpinv_sort_gateway_order($a, $b) {
99 99
     return $a['ordering'] - $b['ordering'];
100 100
 }
101 101
 
102
-function wpinv_is_gateway_active( $gateway ) {
102
+function wpinv_is_gateway_active($gateway) {
103 103
     $gateways = wpinv_get_enabled_payment_gateways();
104 104
 
105
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
105
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
106 106
 
107
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
107
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
108 108
 }
109 109
 
110 110
 function wpinv_get_default_gateway() {
111
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
111
+    $default = wpinv_get_option('default_gateway', 'paypal');
112 112
 
113
-    if ( !wpinv_is_gateway_active( $default ) ) {
113
+    if (!wpinv_is_gateway_active($default)) {
114 114
         $gateways = wpinv_get_enabled_payment_gateways();
115
-        $gateways = array_keys( $gateways );
116
-        $default  = reset( $gateways );
115
+        $gateways = array_keys($gateways);
116
+        $default  = reset($gateways);
117 117
     }
118 118
 
119
-    return apply_filters( 'wpinv_default_gateway', $default );
119
+    return apply_filters('wpinv_default_gateway', $default);
120 120
 }
121 121
 
122
-function wpinv_get_gateway_admin_label( $gateway ) {
122
+function wpinv_get_gateway_admin_label($gateway) {
123 123
     $gateways = wpinv_get_payment_gateways();
124
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
125
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
124
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
125
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
126 126
 
127
-    if( $gateway == 'manual' && $payment ) {
128
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
129
-            $label = __( 'Free Purchase', 'invoicing' );
127
+    if ($gateway == 'manual' && $payment) {
128
+        if (!((float)wpinv_payment_total($payment) > 0)) {
129
+            $label = __('Free Purchase', 'invoicing');
130 130
         }
131 131
     }
132 132
 
133
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
133
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
134 134
 }
135 135
 
136
-function wpinv_get_gateway_description( $gateway ) {
136
+function wpinv_get_gateway_description($gateway) {
137 137
     global $wpinv_options;
138 138
 
139
-    $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
139
+    $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
140 140
 
141
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
141
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
142 142
 }
143 143
 
144
-function wpinv_get_gateway_button_label( $gateway ) {
145
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
144
+function wpinv_get_gateway_button_label($gateway) {
145
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
146 146
 }
147 147
 
148
-function wpinv_get_gateway_checkout_label( $gateway ) {
148
+function wpinv_get_gateway_checkout_label($gateway) {
149 149
     $gateways = wpinv_get_payment_gateways();
150
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
150
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
151 151
 
152
-    if( $gateway == 'manual' ) {
153
-        $label = __( 'Manual Payment', 'invoicing' );
152
+    if ($gateway == 'manual') {
153
+        $label = __('Manual Payment', 'invoicing');
154 154
     }
155 155
 
156
-    return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway );
156
+    return apply_filters('wpinv_gateway_checkout_label', $label, $gateway);
157 157
 }
158 158
 
159
-function wpinv_settings_sections_gateways( $settings ) {
159
+function wpinv_settings_sections_gateways($settings) {
160 160
     $gateways = wpinv_get_payment_gateways();
161 161
     
162 162
     if (!empty($gateways)) {
163
-        foreach  ($gateways as $key => $gateway) {
163
+        foreach ($gateways as $key => $gateway) {
164 164
             $settings[$key] = $gateway['admin_label'];
165 165
         }
166 166
     }
167 167
     
168 168
     return $settings;    
169 169
 }
170
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
170
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
171 171
 
172
-function wpinv_settings_gateways( $settings ) {
172
+function wpinv_settings_gateways($settings) {
173 173
     $gateways = wpinv_get_payment_gateways();
174 174
     
175 175
     if (!empty($gateways)) {
176
-        foreach  ($gateways as $key => $gateway) {
176
+        foreach ($gateways as $key => $gateway) {
177 177
             $setting = array();
178 178
             $setting[$key . '_header'] = array(
179 179
                     'id'   => 'gateway_header',
180
-                    'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
180
+                    'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
181 181
                     'custom' => $key,
182 182
                     'type' => 'gateway_header',
183 183
                 );
184 184
             $setting[$key . '_active'] = array(
185 185
                     'id'   => $key . '_active',
186
-                    'name' => __( 'Active', 'invoicing' ),
187
-                    'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
186
+                    'name' => __('Active', 'invoicing'),
187
+                    'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
188 188
                     'type' => 'checkbox',
189 189
                 );
190 190
                 
191 191
             $setting[$key . '_title'] = array(
192 192
                     'id'   => $key . '_title',
193
-                    'name' => __( 'Title', 'invoicing' ),
194
-                    'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ),
193
+                    'name' => __('Title', 'invoicing'),
194
+                    'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'),
195 195
                     'type' => 'text',
196 196
                     'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : ''
197 197
                 );
198 198
             
199 199
             $setting[$key . '_desc'] = array(
200 200
                     'id'   => $key . '_desc',
201
-                    'name' => __( 'Description', 'invoicing' ),
202
-                    'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ),
201
+                    'name' => __('Description', 'invoicing'),
202
+                    'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'),
203 203
                     'type' => 'text',
204 204
                     'size' => 'large'
205 205
                 );
206 206
                 
207 207
             $setting[$key . '_ordering'] = array(
208 208
                     'id'   => $key . '_ordering',
209
-                    'name' => __( 'Display Order', 'invoicing' ),
209
+                    'name' => __('Display Order', 'invoicing'),
210 210
                     'type' => 'number',
211 211
                     'size' => 'small',
212 212
                     'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
                     'step' => '1'
216 216
                 );
217 217
                 
218
-            $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key );
219
-            $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting );
218
+            $setting = apply_filters('wpinv_gateway_settings', $setting, $key);
219
+            $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting);
220 220
             
221 221
             $settings[$key] = $setting;
222 222
         }
@@ -224,106 +224,106 @@  discard block
 block discarded – undo
224 224
     
225 225
     return $settings;    
226 226
 }
227
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
227
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
228 228
 
229
-function wpinv_gateway_header_callback( $args ) {
230
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
229
+function wpinv_gateway_header_callback($args) {
230
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
231 231
 }
232 232
 
233
-function wpinv_get_gateway_supports( $gateway ) {
233
+function wpinv_get_gateway_supports($gateway) {
234 234
     $gateways = wpinv_get_enabled_payment_gateways();
235
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
236
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
235
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
236
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
237 237
 }
238 238
 
239
-function wpinv_gateway_supports_buy_now( $gateway ) {
240
-    $supports = wpinv_get_gateway_supports( $gateway );
241
-    $ret = in_array( 'buy_now', $supports );
242
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
239
+function wpinv_gateway_supports_buy_now($gateway) {
240
+    $supports = wpinv_get_gateway_supports($gateway);
241
+    $ret = in_array('buy_now', $supports);
242
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
243 243
 }
244 244
 
245 245
 function wpinv_shop_supports_buy_now() {
246 246
     $gateways = wpinv_get_enabled_payment_gateways();
247 247
     $ret      = false;
248 248
 
249
-    if ( !wpinv_use_taxes()  && $gateways ) {
250
-        foreach ( $gateways as $gateway_id => $gateway ) {
251
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
249
+    if (!wpinv_use_taxes() && $gateways) {
250
+        foreach ($gateways as $gateway_id => $gateway) {
251
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
252 252
                 $ret = true;
253 253
                 break;
254 254
             }
255 255
         }
256 256
     }
257 257
 
258
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
258
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
259 259
 }
260 260
 
261
-function wpinv_send_to_gateway( $gateway, $payment_data ) {
262
-    $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' );
261
+function wpinv_send_to_gateway($gateway, $payment_data) {
262
+    $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway');
263 263
 
264 264
     // $gateway must match the ID used when registering the gateway
265
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
265
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
266 266
 }
267 267
 
268 268
 function wpinv_show_gateways() {
269 269
     $gateways = wpinv_get_enabled_payment_gateways();
270 270
     $show_gateways = false;
271 271
 
272
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
272
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
273 273
 
274
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
274
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
275 275
         $show_gateways = true;
276
-        if ( wpinv_get_cart_total() <= 0 ) {
276
+        if (wpinv_get_cart_total() <= 0) {
277 277
             $show_gateways = false;
278 278
         }
279 279
     }
280 280
     
281
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
281
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
282 282
         $show_gateways = true;
283 283
     }
284 284
 
285
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
285
+    return apply_filters('wpinv_show_gateways', $show_gateways);
286 286
 }
287 287
 
288
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
288
+function wpinv_get_chosen_gateway($invoice_id = 0) {
289
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
290 290
 
291 291
     $chosen = false;
292
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
292
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
298
+	if (false !== $chosen) {
299
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
300 300
 	}
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
302
+	if (!empty ($chosen)) {
303
+		$enabled_gateway = urldecode($chosen);
304
+	} else if (!empty($invoice) && (float)$invoice->get_subtotal() <= 0) {
305 305
 		$enabled_gateway = 'manual';
306 306
 	} else {
307 307
 		$enabled_gateway = wpinv_get_default_gateway();
308 308
 	}
309 309
     
310
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
310
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
311
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else {
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
320 320
 }
321 321
 
322
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
323
-    return wpinv_error_log( $message, $title );
322
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
323
+    return wpinv_error_log($message, $title);
324 324
 }
325 325
 
326
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
326
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
327 327
 	$ret  = 0;
328 328
 	$args = array(
329 329
 		'meta_key'    => '_wpinv_gateway',
@@ -334,48 +334,48 @@  discard block
 block discarded – undo
334 334
 		'fields'      => 'ids'
335 335
 	);
336 336
 
337
-	$payments = new WP_Query( $args );
337
+	$payments = new WP_Query($args);
338 338
 
339
-	if( $payments )
339
+	if ($payments)
340 340
 		$ret = $payments->post_count;
341 341
 	return $ret;
342 342
 }
343 343
 
344
-function wpinv_settings_update_gateways( $input ) {
344
+function wpinv_settings_update_gateways($input) {
345 345
     global $wpinv_options;
346 346
     
347
-    if ( !empty( $input['save_gateway'] ) ) {
348
-        $gateways = wpinv_get_option( 'gateways', false );
347
+    if (!empty($input['save_gateway'])) {
348
+        $gateways = wpinv_get_option('gateways', false);
349 349
         $gateways = !empty($gateways) ? $gateways : array();
350 350
         $gateway = $input['save_gateway'];
351 351
         
352
-        if ( !empty( $input[$gateway . '_active'] ) ) {
352
+        if (!empty($input[$gateway . '_active'])) {
353 353
             $gateways[$gateway] = 1;
354 354
         } else {
355
-            if ( isset( $gateways[$gateway] ) ) {
356
-                unset( $gateways[$gateway] );
355
+            if (isset($gateways[$gateway])) {
356
+                unset($gateways[$gateway]);
357 357
             }
358 358
         }
359 359
         
360 360
         $input['gateways'] = $gateways;
361 361
     }
362 362
     
363
-    if ( !empty( $input['default_gateway'] ) ) {
363
+    if (!empty($input['default_gateway'])) {
364 364
         $gateways = wpinv_get_payment_gateways();
365 365
         
366
-        foreach ( $gateways as $key => $gateway ) {
367
-            $active   = 0;
368
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
366
+        foreach ($gateways as $key => $gateway) {
367
+            $active = 0;
368
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
369 369
                 $active = 1;
370 370
             }
371 371
             
372 372
             $input[$key . '_active'] = $active;
373 373
             
374
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
374
+            if (empty($wpinv_options[$key . '_title'])) {
375 375
                 $input[$key . '_title'] = $gateway['checkout_label'];
376 376
             }
377 377
             
378
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
378
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
379 379
                 $input[$key . '_ordering'] = $gateway['ordering'];
380 380
             }
381 381
         }
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
     
384 384
     return $input;
385 385
 }
386
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
386
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
387 387
 
388 388
 // PayPal Standard settings
389
-function wpinv_gateway_settings_paypal( $setting ) {    
390
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
389
+function wpinv_gateway_settings_paypal($setting) {    
390
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
391 391
     
392 392
     $setting['paypal_sandbox'] = array(
393 393
             'type' => 'checkbox',
394 394
             'id'   => 'paypal_sandbox',
395
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
396
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
395
+            'name' => __('PayPal Sandbox', 'invoicing'),
396
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
397 397
             'std'  => 1
398 398
         );
399 399
         
400 400
     $setting['paypal_email'] = array(
401 401
             'type' => 'text',
402 402
             'id'   => 'paypal_email',
403
-            'name' => __( 'PayPal Email', 'invoicing' ),
404
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
405
-            'std' => __( '[email protected]', 'invoicing' ),
403
+            'name' => __('PayPal Email', 'invoicing'),
404
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
405
+            'std' => __('[email protected]', 'invoicing'),
406 406
         );
407 407
     /*
408 408
     $setting['paypal_ipn_url'] = array(
@@ -416,116 +416,116 @@  discard block
 block discarded – undo
416 416
         
417 417
     return $setting;
418 418
 }
419
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
419
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
420 420
 
421 421
 // Pre Bank Transfer settings
422
-function wpinv_gateway_settings_bank_transfer( $setting ) {
423
-    $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' );
422
+function wpinv_gateway_settings_bank_transfer($setting) {
423
+    $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing');
424 424
     
425 425
     $setting['bank_transfer_ac_name'] = array(
426 426
             'type' => 'text',
427 427
             'id' => 'bank_transfer_ac_name',
428
-            'name' => __( 'Account Name', 'invoicing' ),
429
-            'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ),
430
-            'std'  =>  __( 'Mr. John Martin', 'invoicing' ),
428
+            'name' => __('Account Name', 'invoicing'),
429
+            'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'),
430
+            'std'  =>  __('Mr. John Martin', 'invoicing'),
431 431
         );
432 432
     
433 433
     $setting['bank_transfer_ac_no'] = array(
434 434
             'type' => 'text',
435 435
             'id' => 'bank_transfer_ac_no',
436
-            'name' => __( 'Account Number', 'invoicing' ),
437
-            'desc' => __( 'Enter your bank account number.', 'invoicing' ),
438
-            'std'  =>  __( 'TEST1234567890', 'invoicing' ),
436
+            'name' => __('Account Number', 'invoicing'),
437
+            'desc' => __('Enter your bank account number.', 'invoicing'),
438
+            'std'  =>  __('TEST1234567890', 'invoicing'),
439 439
         );
440 440
     
441 441
     $setting['bank_transfer_bank_name'] = array(
442 442
             'type' => 'text',
443 443
             'id'   => 'bank_transfer_bank_name',
444
-            'name' => __( 'Bank Name', 'invoicing' ),
445
-            'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ),
446
-            'std' => __( 'ICICI Bank', 'invoicing' ),
444
+            'name' => __('Bank Name', 'invoicing'),
445
+            'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'),
446
+            'std' => __('ICICI Bank', 'invoicing'),
447 447
         );
448 448
     
449 449
     $setting['bank_transfer_ifsc'] = array(
450 450
             'type' => 'text',
451 451
             'id'   => 'bank_transfer_ifsc',
452
-            'name' => __( 'IFSC code', 'invoicing' ),
453
-            'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ),
454
-            'std'  =>  __( 'ICIC0001234', 'invoicing' ),
452
+            'name' => __('IFSC code', 'invoicing'),
453
+            'desc' => __('Enter your bank IFSC code.', 'invoicing'),
454
+            'std'  =>  __('ICIC0001234', 'invoicing'),
455 455
         );
456 456
         
457 457
     $setting['bank_transfer_iban'] = array(
458 458
             'type' => 'text',
459 459
             'id'   => 'bank_transfer_iban',
460
-            'name' => __( 'IBAN', 'invoicing' ),
461
-            'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ),
462
-            'std'  =>  __( 'GB29NWBK60161331926819', 'invoicing' ),
460
+            'name' => __('IBAN', 'invoicing'),
461
+            'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'),
462
+            'std'  =>  __('GB29NWBK60161331926819', 'invoicing'),
463 463
         );
464 464
         
465 465
     $setting['bank_transfer_bic'] = array(
466 466
             'type' => 'text',
467 467
             'id'   => 'bank_transfer_bic',
468
-            'name' => __( 'BIC/Swift code', 'invoicing' ),
469
-            'std'  =>  __( 'ICICGB2L129', 'invoicing' ),
468
+            'name' => __('BIC/Swift code', 'invoicing'),
469
+            'std'  =>  __('ICICGB2L129', 'invoicing'),
470 470
         );
471 471
         
472 472
     $setting['bank_transfer_info'] = array(
473 473
             'id'   => 'bank_transfer_info',
474
-            'name' => __( 'Instructions', 'invoicing' ),
475
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
474
+            'name' => __('Instructions', 'invoicing'),
475
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
476 476
             'type' => 'textarea',
477
-            'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ),
477
+            'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'),
478 478
             'cols' => 37,
479 479
             'rows' => 5
480 480
         );
481 481
         
482 482
     return $setting;
483 483
 }
484
-add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 );
484
+add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1);
485 485
 
486 486
 // Authorize.Net settings
487
-function wpinv_gateway_settings_authorizenet( $setting ) {
488
-    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( currencies supported: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' );
489
-    $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing' );
487
+function wpinv_gateway_settings_authorizenet($setting) {
488
+    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( currencies supported: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing');
489
+    $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing');
490 490
     
491 491
     $setting['authorizenet_sandbox'] = array(
492 492
             'type' => 'checkbox',
493 493
             'id'   => 'authorizenet_sandbox',
494
-            'name' => __( 'Authorize.Net Test Mode', 'invoicing' ),
495
-            'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ),
494
+            'name' => __('Authorize.Net Test Mode', 'invoicing'),
495
+            'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'),
496 496
             'std'  => 1
497 497
         );
498 498
         
499 499
     $setting['authorizenet_login_id'] = array(
500 500
             'type' => 'text',
501 501
             'id'   => 'authorizenet_login_id',
502
-            'name' => __( 'API Login ID', 'invoicing' ),
503
-            'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ),
502
+            'name' => __('API Login ID', 'invoicing'),
503
+            'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'),
504 504
             'std' => '2j4rBekUnD',
505 505
         );
506 506
     
507 507
     $setting['authorizenet_transaction_key'] = array(
508 508
             'type' => 'text',
509 509
             'id'   => 'authorizenet_transaction_key',
510
-            'name' => __( 'Transaction Key', 'invoicing' ),
511
-            'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ),
510
+            'name' => __('Transaction Key', 'invoicing'),
511
+            'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'),
512 512
             'std' => '4vyBUOJgR74679xa',
513 513
         );
514 514
         
515 515
     $setting['authorizenet_md5_hash'] = array(
516 516
             'type' => 'text',
517 517
             'id'   => 'authorizenet_md5_hash',
518
-            'name' => __( 'MD5-Hash', 'invoicing' ),
519
-            'desc' => __( 'The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ),
518
+            'name' => __('MD5-Hash', 'invoicing'),
519
+            'desc' => __('The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'),
520 520
             'std' => '',
521 521
         );
522 522
         
523 523
     $setting['authorizenet_ipn_url'] = array(
524 524
             'type' => 'ipn_url',
525 525
             'id'   => 'authorizenet_ipn_url',
526
-            'name' => __( 'Silent Post URL', 'invoicing' ),
527
-            'std' => wpinv_get_ipn_url( 'authorizenet' ),
528
-            'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ),
526
+            'name' => __('Silent Post URL', 'invoicing'),
527
+            'std' => wpinv_get_ipn_url('authorizenet'),
528
+            'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'),
529 529
             'size' => 'large',
530 530
             'custom' => 'authorizenet',
531 531
             'readonly' => true
@@ -533,25 +533,25 @@  discard block
 block discarded – undo
533 533
         
534 534
     return $setting;
535 535
 }
536
-add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 );
536
+add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1);
537 537
 
538 538
 // Worldpay settings
539
-function wpinv_gateway_settings_worldpay( $setting ) {
540
-    $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing' );
539
+function wpinv_gateway_settings_worldpay($setting) {
540
+    $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing');
541 541
     
542 542
     $setting['worldpay_sandbox'] = array(
543 543
             'type' => 'checkbox',
544 544
             'id'   => 'worldpay_sandbox',
545
-            'name' => __( 'Worldpay Test Mode', 'invoicing' ),
546
-            'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ),
545
+            'name' => __('Worldpay Test Mode', 'invoicing'),
546
+            'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'),
547 547
             'std'  => 1
548 548
         );
549 549
         
550 550
     $setting['worldpay_instId'] = array(
551 551
             'type' => 'text',
552 552
             'id'   => 'worldpay_instId',
553
-            'name' => __( 'Installation Id', 'invoicing' ),
554
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
553
+            'name' => __('Installation Id', 'invoicing'),
554
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
555 555
             'std' => '211616',
556 556
         );
557 557
     /*
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
     $setting['worldpay_ipn_url'] = array(
568 568
             'type' => 'ipn_url',
569 569
             'id'   => 'worldpay_ipn_url',
570
-            'name' => __( 'Worldpay Callback Url', 'invoicing' ),
571
-            'std' => wpinv_get_ipn_url( 'worldpay' ),
572
-            'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>' ),
570
+            'name' => __('Worldpay Callback Url', 'invoicing'),
571
+            'std' => wpinv_get_ipn_url('worldpay'),
572
+            'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>'),
573 573
             'size' => 'large',
574 574
             'custom' => 'worldpay',
575 575
             'readonly' => true
@@ -577,94 +577,94 @@  discard block
 block discarded – undo
577 577
         
578 578
     return $setting;
579 579
 }
580
-add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 );
580
+add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1);
581 581
 
582
-function wpinv_ipn_url_callback( $args ) {    
583
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
582
+function wpinv_ipn_url_callback($args) {    
583
+    $sanitize_id = wpinv_sanitize_key($args['id']);
584 584
     
585 585
     $attrs = $args['readonly'] ? ' readonly' : '';
586 586
 
587
-    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
588
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
587
+    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
588
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
589 589
 
590 590
     echo $html;
591 591
 }
592 592
 
593
-function wpinv_is_test_mode( $gateway = '' ) {
594
-    if ( empty( $gateway ) ) {
593
+function wpinv_is_test_mode($gateway = '') {
594
+    if (empty($gateway)) {
595 595
         return false;
596 596
     }
597 597
     
598
-    $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false );
598
+    $is_test_mode = wpinv_get_option($gateway . '_sandbox', false);
599 599
     
600
-    return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway );
600
+    return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway);
601 601
 }
602 602
 
603
-function wpinv_get_ipn_url( $gateway = '', $args = array() ) {
604
-    $data = array( 'wpi-listener' => 'IPN' );
603
+function wpinv_get_ipn_url($gateway = '', $args = array()) {
604
+    $data = array('wpi-listener' => 'IPN');
605 605
     
606
-    if ( !empty( $gateway ) ) {
607
-        $data['wpi-gateway'] = wpinv_sanitize_key( $gateway );
606
+    if (!empty($gateway)) {
607
+        $data['wpi-gateway'] = wpinv_sanitize_key($gateway);
608 608
     }
609 609
     
610
-    $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data;
610
+    $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data;
611 611
     
612
-    $ipn_url = add_query_arg( $args,  home_url( 'index.php' ) );
612
+    $ipn_url = add_query_arg($args, home_url('index.php'));
613 613
     
614
-    return apply_filters( 'wpinv_ipn_url', $ipn_url );
614
+    return apply_filters('wpinv_ipn_url', $ipn_url);
615 615
 }
616 616
 
617 617
 function wpinv_listen_for_payment_ipn() {
618 618
     // Regular PayPal IPN
619
-    if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) {
620
-        do_action( 'wpinv_verify_payment_ipn' );
619
+    if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') {
620
+        do_action('wpinv_verify_payment_ipn');
621 621
         
622
-        if ( !empty( $_GET['wpi-gateway'] ) ) {
623
-            wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'wpinv_listen_for_payment_ipn()', __FILE__, __LINE__ );
624
-            do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' );
622
+        if (!empty($_GET['wpi-gateway'])) {
623
+            wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'wpinv_listen_for_payment_ipn()', __FILE__, __LINE__);
624
+            do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn');
625 625
         }
626 626
     }
627 627
 }
628
-add_action( 'init', 'wpinv_listen_for_payment_ipn' );
628
+add_action('init', 'wpinv_listen_for_payment_ipn');
629 629
 
630 630
 function wpinv_get_bank_instructions() {
631
-    $bank_instructions = wpinv_get_option( 'bank_transfer_info' );
631
+    $bank_instructions = wpinv_get_option('bank_transfer_info');
632 632
     
633
-    return apply_filters( 'wpinv_bank_instructions', $bank_instructions );
633
+    return apply_filters('wpinv_bank_instructions', $bank_instructions);
634 634
 }
635 635
 
636
-function wpinv_get_bank_info( $filtered = false ) {
636
+function wpinv_get_bank_info($filtered = false) {
637 637
     $bank_fields = array(
638
-        'bank_transfer_ac_name' => __( 'Account Name', 'invoicing' ),
639
-        'bank_transfer_ac_no' => __( 'Account Number', 'invoicing' ),
640
-        'bank_transfer_bank_name' => __( 'Bank Name', 'invoicing' ),
641
-        'bank_transfer_ifsc' => __( 'IFSC code', 'invoicing' ),
642
-        'bank_transfer_iban' => __( 'IBAN', 'invoicing' ),
643
-        'bank_transfer_bic' => __( 'BIC/Swift code', 'invoicing' )
638
+        'bank_transfer_ac_name' => __('Account Name', 'invoicing'),
639
+        'bank_transfer_ac_no' => __('Account Number', 'invoicing'),
640
+        'bank_transfer_bank_name' => __('Bank Name', 'invoicing'),
641
+        'bank_transfer_ifsc' => __('IFSC code', 'invoicing'),
642
+        'bank_transfer_iban' => __('IBAN', 'invoicing'),
643
+        'bank_transfer_bic' => __('BIC/Swift code', 'invoicing')
644 644
     );
645 645
     
646 646
     $bank_info = array();
647
-    foreach ( $bank_fields as $field => $label ) {
648
-        if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) {
647
+    foreach ($bank_fields as $field => $label) {
648
+        if ($filtered && !($value = wpinv_get_option($field))) {
649 649
             continue;
650 650
         }
651 651
         
652
-        $bank_info[$field] = array( 'label' => $label, 'value' => $value );
652
+        $bank_info[$field] = array('label' => $label, 'value' => $value);
653 653
     }
654 654
     
655
-    return apply_filters( 'wpinv_bank_info', $bank_info, $filtered );
655
+    return apply_filters('wpinv_bank_info', $bank_info, $filtered);
656 656
 }
657 657
 
658
-function wpinv_process_before_send_to_gateway( $invoice, $invoice_data = array() ) {
659
-    if ( !empty( $invoice ) && $invoice->is_recurring() && $subscription_item = $invoice->get_recurring( true ) ) {        
658
+function wpinv_process_before_send_to_gateway($invoice, $invoice_data = array()) {
659
+    if (!empty($invoice) && $invoice->is_recurring() && $subscription_item = $invoice->get_recurring(true)) {        
660 660
         $args                          = array();
661 661
         $args['item_id']               = $subscription_item->ID;
662
-        $args['initial_amount']        = wpinv_round_amount( $invoice->get_total() );
663
-        $args['recurring_amount']      = wpinv_round_amount( $invoice->get_recurring_details( 'total' ) );
662
+        $args['initial_amount']        = wpinv_round_amount($invoice->get_total());
663
+        $args['recurring_amount']      = wpinv_round_amount($invoice->get_recurring_details('total'));
664 664
         $args['currency']              = $invoice->get_currency();
665 665
         $args['period']                = $subscription_item->get_recurring_period();
666 666
         $args['interval']              = $subscription_item->get_recurring_interval();
667
-        if ( $subscription_item->has_free_trial() ) {
667
+        if ($subscription_item->has_free_trial()) {
668 668
             $args['trial_period']      = $subscription_item->get_trial_period();
669 669
             $args['trial_interval']    = $subscription_item->get_trial_interval();
670 670
         } else {
@@ -673,25 +673,25 @@  discard block
 block discarded – undo
673 673
         }
674 674
         $args['bill_times']            = (int)$subscription_item->get_recurring_limit();
675 675
         
676
-        $invoice->update_subscription( $args );
676
+        $invoice->update_subscription($args);
677 677
     }
678 678
 }
679
-add_action( 'wpinv_checkout_before_send_to_gateway', 'wpinv_process_before_send_to_gateway', 10, 2 );
679
+add_action('wpinv_checkout_before_send_to_gateway', 'wpinv_process_before_send_to_gateway', 10, 2);
680 680
 
681
-function wpinv_get_post_data( $method = 'request' ) {
681
+function wpinv_get_post_data($method = 'request') {
682 682
     $data       = array();
683 683
     $request    = $_REQUEST;
684 684
     
685
-    if ( $method == 'post' ) {
686
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
685
+    if ($method == 'post') {
686
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
687 687
             return $data;
688 688
         }
689 689
         
690 690
         $request = $_POST;
691 691
     }
692 692
     
693
-    if ( $method == 'get' ) {
694
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
693
+    if ($method == 'get') {
694
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
695 695
             return $data;
696 696
         }
697 697
         
@@ -702,11 +702,11 @@  discard block
 block discarded – undo
702 702
     $post_data = '';
703 703
     
704 704
     // Fallback just in case post_max_size is lower than needed
705
-    if ( ini_get( 'allow_url_fopen' ) ) {
706
-        $post_data = file_get_contents( 'php://input' );
705
+    if (ini_get('allow_url_fopen')) {
706
+        $post_data = file_get_contents('php://input');
707 707
     } else {
708 708
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
709
-        ini_set( 'post_max_size', '12M' );
709
+        ini_set('post_max_size', '12M');
710 710
     }
711 711
     // Start the encoded data collection with notification command
712 712
     $encoded_data = 'cmd=_notify-validate';
@@ -715,58 +715,58 @@  discard block
 block discarded – undo
715 715
     $arg_separator = wpinv_get_php_arg_separator_output();
716 716
 
717 717
     // Verify there is a post_data
718
-    if ( $post_data || strlen( $post_data ) > 0 ) {
718
+    if ($post_data || strlen($post_data) > 0) {
719 719
         // Append the data
720 720
         $encoded_data .= $arg_separator . $post_data;
721 721
     } else {
722 722
         // Check if POST is empty
723
-        if ( empty( $request ) ) {
723
+        if (empty($request)) {
724 724
             // Nothing to do
725 725
             return;
726 726
         } else {
727 727
             // Loop through each POST
728
-            foreach ( $request as $key => $value ) {
728
+            foreach ($request as $key => $value) {
729 729
                 // Encode the value and append the data
730
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
730
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
731 731
             }
732 732
         }
733 733
     }
734 734
 
735 735
     // Convert collected post data to an array
736
-    parse_str( $encoded_data, $data );
736
+    parse_str($encoded_data, $data);
737 737
 
738
-    foreach ( $data as $key => $value ) {
739
-        if ( false !== strpos( $key, 'amp;' ) ) {
740
-            $new_key = str_replace( '&amp;', '&', $key );
741
-            $new_key = str_replace( 'amp;', '&' , $new_key );
738
+    foreach ($data as $key => $value) {
739
+        if (false !== strpos($key, 'amp;')) {
740
+            $new_key = str_replace('&amp;', '&', $key);
741
+            $new_key = str_replace('amp;', '&', $new_key);
742 742
 
743
-            unset( $data[ $key ] );
744
-            $data[ $new_key ] = sanitize_text_field( $value );
743
+            unset($data[$key]);
744
+            $data[$new_key] = sanitize_text_field($value);
745 745
         }
746 746
     }
747 747
     
748 748
     return $data;
749 749
 }
750 750
 
751
-function wpinv_gateway_support_subscription( $gateway ) {
751
+function wpinv_gateway_support_subscription($gateway) {
752 752
     $return = false;
753 753
     
754
-    if ( wpinv_is_gateway_active( $gateway ) ) {
755
-        $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false );
754
+    if (wpinv_is_gateway_active($gateway)) {
755
+        $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false);
756 756
     }
757 757
     
758 758
     return $return;
759 759
 }
760 760
 
761
-function wpinv_payment_gateways_on_cart( $gateways = array() ) {
762
-    if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) {
763
-        foreach ( $gateways as $gateway => $info ) {
764
-            if ( !wpinv_gateway_support_subscription( $gateway ) ) {
765
-                unset( $gateways[$gateway] );
761
+function wpinv_payment_gateways_on_cart($gateways = array()) {
762
+    if (!empty($gateways) && wpinv_cart_has_recurring_item()) {
763
+        foreach ($gateways as $gateway => $info) {
764
+            if (!wpinv_gateway_support_subscription($gateway)) {
765
+                unset($gateways[$gateway]);
766 766
             }
767 767
         }
768 768
     }
769 769
     
770 770
     return $gateways;
771 771
 }
772
-add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 );
773 772
\ No newline at end of file
773
+add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1);
774 774
\ No newline at end of file
Please login to merge, or discard this patch.