Passed
Push — master ( d0e164...00f338 )
by Brian
05:26
created
includes/wpinv-gateway-functions.php 1 patch
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains gateway functions.
4 4
  *
5 5
  */
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Returns an array of payment gateways.
@@ -11,30 +11,30 @@  discard block
 block discarded – undo
11 11
  * @return array
12 12
  */
13 13
 function wpinv_get_payment_gateways() {
14
-    return apply_filters( 'wpinv_payment_gateways', array() );
14
+    return apply_filters('wpinv_payment_gateways', array());
15 15
 }
16 16
 
17
-function wpinv_payment_gateway_titles( $all_gateways ) {
17
+function wpinv_payment_gateway_titles($all_gateways) {
18 18
 
19 19
     $options  = wpinv_get_options();
20 20
     $gateways = array();
21
-    foreach ( $all_gateways as $key => $gateway ) {
22
-        if ( !empty( $options[$key . '_title'] ) ) {
23
-            $all_gateways[$key]['checkout_label'] = __( $options[$key . '_title'], 'invoicing' );
21
+    foreach ($all_gateways as $key => $gateway) {
22
+        if (!empty($options[$key . '_title'])) {
23
+            $all_gateways[$key]['checkout_label'] = __($options[$key . '_title'], 'invoicing');
24 24
         }
25 25
 
26
-        $gateways[$key] = isset( $options[$key . '_ordering'] ) ? $options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
26
+        $gateways[$key] = isset($options[$key . '_ordering']) ? $options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
27 27
     }
28 28
 
29
-    asort( $gateways );
29
+    asort($gateways);
30 30
 
31
-    foreach ( $gateways as $gateway => $key ) {
31
+    foreach ($gateways as $gateway => $key) {
32 32
         $gateways[$gateway] = $all_gateways[$gateway];
33 33
     }
34 34
 
35 35
     return $gateways;
36 36
 }
37
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
37
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
38 38
 
39 39
 /**
40 40
  * Returns an array of enabled gateways.
@@ -42,38 +42,38 @@  discard block
 block discarded – undo
42 42
  * @param bool $sort
43 43
  * @return array
44 44
  */
45
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
45
+function wpinv_get_enabled_payment_gateways($sort = false) {
46 46
 
47 47
     $enabled = array();
48 48
 
49
-    foreach ( wpinv_get_payment_gateways() as $gateway => $data ) {
49
+    foreach (wpinv_get_payment_gateways() as $gateway => $data) {
50 50
 
51
-        if ( (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1 ) {
52
-            $enabled[ $gateway ] = $data;
51
+        if ((int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1) {
52
+            $enabled[$gateway] = $data;
53 53
         }
54 54
 
55 55
     }
56 56
 
57
-    if ( true === $sort ) {
58
-        uasort( $enabled, 'wpinv_sort_gateway_order' );
57
+    if (true === $sort) {
58
+        uasort($enabled, 'wpinv_sort_gateway_order');
59 59
 
60 60
         // Reorder our gateways so the default is first
61 61
         $default_gateway_id = wpinv_get_default_gateway();
62
-        if ( isset( $enabled[ $default_gateway_id ] ) ) {
62
+        if (isset($enabled[$default_gateway_id])) {
63 63
             $default_gateway = array(
64
-                $default_gateway_id => $enabled[ $default_gateway_id ]
64
+                $default_gateway_id => $enabled[$default_gateway_id]
65 65
             );
66 66
 
67
-            unset( $enabled[ $default_gateway_id ] );
68
-            $enabled = array_merge( $default_gateway, $enabled );
67
+            unset($enabled[$default_gateway_id]);
68
+            $enabled = array_merge($default_gateway, $enabled);
69 69
         }
70 70
 
71 71
     }
72 72
 
73
-    return apply_filters( 'wpinv_enabled_payment_gateways', $enabled );
73
+    return apply_filters('wpinv_enabled_payment_gateways', $enabled);
74 74
 }
75 75
 
76
-function wpinv_sort_gateway_order( $a, $b ) {
76
+function wpinv_sort_gateway_order($a, $b) {
77 77
     return $a['ordering'] - $b['ordering'];
78 78
 }
79 79
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
  * @param string $gateway
84 84
  * @return bool
85 85
  */
86
-function wpinv_is_gateway_active( $gateway ) {
87
-    $is_active = (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1 ;
88
-    return apply_filters( 'wpinv_is_gateway_active', $is_active, $gateway );
86
+function wpinv_is_gateway_active($gateway) {
87
+    $is_active = (int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1;
88
+    return apply_filters('wpinv_is_gateway_active', $is_active, $gateway);
89 89
 }
90 90
 
91 91
 /**
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
  * @return string|false
95 95
  */
96 96
 function wpinv_get_default_gateway() {
97
-    $default  = wpinv_get_option( 'default_gateway' );
97
+    $default  = wpinv_get_option('default_gateway');
98 98
     $gateways = wpinv_get_enabled_payment_gateways();
99
-    $default  = ! empty( $default ) && isset( $gateways[ $default ] ) ? $default : false;
99
+    $default  = !empty($default) && isset($gateways[$default]) ? $default : false;
100 100
 
101
-    return apply_filters( 'wpinv_default_gateway', $default );
101
+    return apply_filters('wpinv_default_gateway', $default);
102 102
 }
103 103
 
104 104
 /**
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
  * @param string $gateway The gateway to key.
108 108
  * @return string
109 109
  */
110
-function wpinv_get_gateway_admin_label( $gateway ) {
110
+function wpinv_get_gateway_admin_label($gateway) {
111 111
 
112
-    if ( empty( $gateway ) || 'none' == $gateway ) {
113
-        return esc_html__( 'No Gateway', 'invoicing' );
112
+    if (empty($gateway) || 'none' == $gateway) {
113
+        return esc_html__('No Gateway', 'invoicing');
114 114
     }
115 115
 
116 116
     $gateways = wpinv_get_payment_gateways();
117
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
118
-    $gateway  = apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
117
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
118
+    $gateway  = apply_filters('wpinv_gateway_admin_label', $label, $gateway);
119 119
 
120
-    return wpinv_clean( $gateway );
120
+    return wpinv_clean($gateway);
121 121
 }
122 122
 
123 123
 /**
@@ -125,48 +125,48 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @param string $gateway
127 127
  */
128
-function wpinv_get_gateway_description( $gateway ) {
128
+function wpinv_get_gateway_description($gateway) {
129 129
 
130 130
     $options     = wpinv_get_options();
131
-    $description = ! empty( $options[$gateway . '_desc'] ) ? $options[$gateway . '_desc'] : '';
131
+    $description = !empty($options[$gateway . '_desc']) ? $options[$gateway . '_desc'] : '';
132 132
 
133
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
133
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
134 134
 }
135 135
 
136
-function wpinv_get_gateway_button_label( $gateway ) {
137
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
136
+function wpinv_get_gateway_button_label($gateway) {
137
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
138 138
 }
139 139
 
140
-function wpinv_get_gateway_checkout_label( $gateway ) {
140
+function wpinv_get_gateway_checkout_label($gateway) {
141 141
     $gateways = wpinv_get_payment_gateways();
142
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
142
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
143 143
 
144
-    if ( $gateway == 'none' ) {
145
-        $label = __( 'None', 'invoicing' );
144
+    if ($gateway == 'none') {
145
+        $label = __('None', 'invoicing');
146 146
     }
147 147
 
148
-    return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway );
148
+    return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway);
149 149
 }
150 150
 
151
-function wpinv_settings_sections_gateways( $settings ) {
151
+function wpinv_settings_sections_gateways($settings) {
152 152
     $gateways = wpinv_get_payment_gateways();
153
-    ksort( $gateways );
153
+    ksort($gateways);
154 154
 
155
-    foreach  ( $gateways as $key => $gateway ) {
156
-        $settings[ $key ] = $gateway['admin_label'];
155
+    foreach ($gateways as $key => $gateway) {
156
+        $settings[$key] = $gateway['admin_label'];
157 157
     }
158 158
 
159 159
     return $settings;
160 160
 }
161
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
161
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
162 162
 
163 163
 /**
164 164
  * Adds GateWay settings.
165 165
  */
166
-function wpinv_settings_gateways( $settings ) {
166
+function wpinv_settings_gateways($settings) {
167 167
 
168 168
     // Loop through each gateway.
169
-    foreach  ( wpinv_get_payment_gateways() as $key => $gateway ) {
169
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
170 170
 
171 171
         $gateway_settings = array(
172 172
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             "{$key}_header" => array(
175 175
 
176 176
                 'id'     => "{$key}_gateway_header",
177
-                'name'   => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
177
+                'name'   => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
178 178
                 'custom' => $key,
179 179
                 'type'   => 'gateway_header',
180 180
 
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
             // Activate/Deactivate a gateway.
184 184
             "{$key}_active" => array(
185 185
                 'id'   => $key . '_active',
186
-                'name' => __( 'Activate', 'invoicing' ),
187
-                'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
186
+                'name' => __('Activate', 'invoicing'),
187
+                'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
188 188
                 'type' => 'checkbox',
189 189
                 'std'  => $key === 'manual' ? '1' : '0',
190 190
             ),
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
             // Activate/Deactivate sandbox.
193 193
             "{$key}_sandbox" => array(
194 194
                 'id'   => $key . '_sandbox',
195
-                'name' => __( 'Sandbox', 'invoicing' ),
196
-                'desc' => __( 'Enable sandbox to test payments', 'invoicing' ),
195
+                'name' => __('Sandbox', 'invoicing'),
196
+                'desc' => __('Enable sandbox to test payments', 'invoicing'),
197 197
                 'type' => 'checkbox',
198 198
                 'std'  => '1',
199 199
             ),
@@ -201,40 +201,40 @@  discard block
 block discarded – undo
201 201
             // Checkout title.
202 202
             "{$key}_title" => array(
203 203
                 'id'   => $key . '_title',
204
-                'name' => __( 'Checkout Title', 'invoicing' ),
205
-                'std'  => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '',
204
+                'name' => __('Checkout Title', 'invoicing'),
205
+                'std'  => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '',
206 206
                 'type' => 'text',
207 207
             ),
208 208
 
209 209
             // Checkout description.
210 210
             "{$key}_desc" => array(
211 211
                 'id'   => $key . '_desc',
212
-                'name' => __( 'Checkout Description', 'invoicing' ),
213
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
212
+                'name' => __('Checkout Description', 'invoicing'),
213
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
214 214
                 'type' => 'text',
215 215
             ),
216 216
 
217 217
             // Checkout order.
218 218
             "{$key}_ordering" => array(
219 219
                 'id'   => $key . '_ordering',
220
-                'name' => __( 'Priority', 'invoicing' ),
221
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
220
+                'name' => __('Priority', 'invoicing'),
221
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
222 222
                 'type' => 'number',
223 223
                 'step' => '1',
224 224
                 'min'  => '0',
225 225
                 'max'  => '100000',
226
-                'std'  => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10',
226
+                'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
227 227
             ),
228 228
 
229 229
         );
230 230
 
231 231
         // Maybe remove the sandbox.
232
-        if ( ! getpaid_payment_gateway_supports( $key, 'sandbox' ) ) {
233
-            unset( $gateway_settings["{$key}_sandbox"] );
232
+        if (!getpaid_payment_gateway_supports($key, 'sandbox')) {
233
+            unset($gateway_settings["{$key}_sandbox"]);
234 234
         }
235 235
 
236
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway );
237
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway );
236
+        $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway);
237
+        $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway);
238 238
 
239 239
         $settings[$key] = $gateway_settings;
240 240
     }
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
     return $settings;
243 243
 
244 244
 }
245
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
245
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
246 246
 
247
-function wpinv_gateway_header_callback( $args ) {
248
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
247
+function wpinv_gateway_header_callback($args) {
248
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
249 249
 }
250 250
 
251 251
 /**
@@ -256,61 +256,61 @@  discard block
 block discarded – undo
256 256
  * @return bool
257 257
  * @since 2.3.0
258 258
  */
259
-function getpaid_payment_gateway_supports( $gateway, $feature ) {
259
+function getpaid_payment_gateway_supports($gateway, $feature) {
260 260
 
261 261
     $supports = false;
262 262
 
263
-    $supports = apply_filters( "getpaid_{$gateway}_supports_{$feature}", false );
263
+    $supports = apply_filters("getpaid_{$gateway}_supports_{$feature}", false);
264 264
 
265 265
     // Backwards compatibility.
266
-    $supports = apply_filters( "wpinv_{$gateway}_supports_{$feature}", $supports );
267
-    $supports = apply_filters( "wpinv_{$gateway}_support_{$feature}", $supports );
266
+    $supports = apply_filters("wpinv_{$gateway}_supports_{$feature}", $supports);
267
+    $supports = apply_filters("wpinv_{$gateway}_support_{$feature}", $supports);
268 268
 
269
-    $supports = apply_filters( "getpaid_gateway_supports_{$feature}", $supports, $gateway );
270
-    $supports = apply_filters( 'getpaid_payment_gateway_supports', $supports, $feature, $gateway );
269
+    $supports = apply_filters("getpaid_gateway_supports_{$feature}", $supports, $gateway);
270
+    $supports = apply_filters('getpaid_payment_gateway_supports', $supports, $feature, $gateway);
271 271
 
272 272
     return $supports;
273 273
 }
274 274
 
275
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
276
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
275
+function wpinv_get_chosen_gateway($invoice_id = 0) {
276
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
277 277
 
278 278
     $chosen = false;
279
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
279
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
280 280
         $chosen = $invoice->get_gateway();
281 281
     }
282 282
 
283
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
283
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
284 284
 
285
-	if ( false !== $chosen ) {
286
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
285
+	if (false !== $chosen) {
286
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
287 287
 	}
288 288
 
289
-	if ( ! empty ( $chosen ) ) {
290
-		$enabled_gateway = urldecode( $chosen );
291
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
289
+	if (!empty ($chosen)) {
290
+		$enabled_gateway = urldecode($chosen);
291
+	} else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) {
292 292
 		$enabled_gateway = 'manual';
293 293
 	} else {
294 294
 		$enabled_gateway = wpinv_get_default_gateway();
295 295
 	}
296 296
 
297
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
298
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
297
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
298
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
299 299
             $enabled_gateway = wpinv_get_default_gateway();
300
-        }else{
300
+        } else {
301 301
             $enabled_gateway = $gateways[0];
302 302
         }
303 303
 
304 304
     }
305 305
 
306
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
306
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
307 307
 }
308 308
 
309
-function wpinv_record_gateway_error( $title = '', $message = '' ) {
310
-    return wpinv_error_log( $message, $title );
309
+function wpinv_record_gateway_error($title = '', $message = '') {
310
+    return wpinv_error_log($message, $title);
311 311
 }
312 312
 
313
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
313
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
314 314
 	$ret  = 0;
315 315
 	$args = array(
316 316
 		'meta_key'    => '_wpinv_gateway',
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
 		'fields'      => 'ids'
322 322
 	);
323 323
 
324
-	$payments = new WP_Query( $args );
324
+	$payments = new WP_Query($args);
325 325
 
326
-	if( $payments )
326
+	if ($payments)
327 327
 		$ret = $payments->post_count;
328 328
 	return $ret;
329 329
 }
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 /**
332 332
  * Displays the ipn url field.
333 333
  */
334
-function wpinv_ipn_url_callback( $args ) {
335
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
334
+function wpinv_ipn_url_callback($args) {
335
+    $sanitize_id = wpinv_sanitize_key($args['id']);
336 336
 
337 337
     $attrs = $args['readonly'] ? ' readonly' : '';
338 338
 
339
-    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
340
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
339
+    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
340
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
341 341
 
342 342
     echo $html;
343 343
 }
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
  *
350 350
  * @return bool
351 351
  */
352
-function wpinv_is_test_mode( $gateway = '' ) {
353
-    $sandbox  = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true );
354
-    $supports = getpaid_payment_gateway_supports( $gateway, 'sandbox' );
355
-    return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway );
352
+function wpinv_is_test_mode($gateway = '') {
353
+    $sandbox  = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true);
354
+    $supports = getpaid_payment_gateway_supports($gateway, 'sandbox');
355
+    return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway);
356 356
 }
357 357
 
358 358
 /**
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
  *
364 364
  * @return string
365 365
  */
366
-function wpinv_get_ipn_url( $gateway = false, $args = array() ) {
366
+function wpinv_get_ipn_url($gateway = false, $args = array()) {
367 367
     $args = wp_parse_args(
368 368
         array(
369 369
             'wpi-listener' => 'IPN',
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         $args
373 373
     );
374 374
 
375
-    return apply_filters( 'wpinv_ipn_url', add_query_arg( $args,  home_url( 'index.php' ) ), $gateway, $args );
375
+    return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args);
376 376
 
377 377
 }
378 378
 
@@ -383,34 +383,34 @@  discard block
 block discarded – undo
383 383
  *
384 384
  * @return string
385 385
  */
386
-function getpaid_get_non_query_string_ipn_url( $gateway ) {
387
-    $gateway = wpinv_sanitize_key( $gateway );
388
-    return home_url( "getpaid-ipn/$gateway" );
386
+function getpaid_get_non_query_string_ipn_url($gateway) {
387
+    $gateway = wpinv_sanitize_key($gateway);
388
+    return home_url("getpaid-ipn/$gateway");
389 389
 }
390 390
 
391 391
 
392 392
 /**
393 393
  * Retrieves request data with slashes removed slashes.
394 394
  */
395
-function wpinv_get_post_data( $method = 'request' ) {
395
+function wpinv_get_post_data($method = 'request') {
396 396
 
397
-    if ( $method == 'post' ) {
398
-        return wp_kses_post_deep( wp_unslash( $_POST ) );
397
+    if ($method == 'post') {
398
+        return wp_kses_post_deep(wp_unslash($_POST));
399 399
     }
400 400
 
401
-    if ( $method == 'get' ) {
402
-        return wp_kses_post_deep( wp_unslash( $_GET ) );
401
+    if ($method == 'get') {
402
+        return wp_kses_post_deep(wp_unslash($_GET));
403 403
     }
404 404
 
405
-    return wp_kses_post_deep( wp_unslash( $_REQUEST ) );
405
+    return wp_kses_post_deep(wp_unslash($_REQUEST));
406 406
 
407 407
 }
408 408
 
409 409
 /**
410 410
  * Checks if a given gateway supports subscription payments.
411 411
  */
412
-function wpinv_gateway_support_subscription( $gateway ) {
413
-    return getpaid_payment_gateway_supports( $gateway, 'subscription' );
412
+function wpinv_gateway_support_subscription($gateway) {
413
+    return getpaid_payment_gateway_supports($gateway, 'subscription');
414 414
 }
415 415
 
416 416
 /**
@@ -419,14 +419,14 @@  discard block
 block discarded – undo
419 419
  * @param array $gateways an array of gateways.
420 420
  * @param GetPaid_Payment_Form $form payment form.
421 421
  */
422
-function wpinv_payment_gateways_on_cart( $gateways, $form ) {
422
+function wpinv_payment_gateways_on_cart($gateways, $form) {
423 423
 
424
-    if ( $form->is_recurring() ) {
424
+    if ($form->is_recurring()) {
425 425
 
426
-        foreach ( array_keys( $gateways ) as $gateway ) {
426
+        foreach (array_keys($gateways) as $gateway) {
427 427
 
428
-            if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
429
-                unset( $gateways[$gateway] );
428
+            if (!wpinv_gateway_support_subscription($gateway)) {
429
+                unset($gateways[$gateway]);
430 430
             }
431 431
 
432 432
         }
@@ -435,4 +435,4 @@  discard block
 block discarded – undo
435 435
 
436 436
     return $gateways;
437 437
 }
438
-add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 );
438
+add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2);
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-worldpay-gateway.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Worldpay Payment Gateway class.
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @var array
47 47
 	 */
48
-    protected $supports = array( 'sandbox' );
48
+    protected $supports = array('sandbox');
49 49
     
50 50
     /**
51 51
 	 * Currencies this gateway is allowed for.
52 52
 	 *
53 53
 	 * @var array
54 54
 	 */
55
-	public $currencies = array( 'AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR' );
55
+	public $currencies = array('AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR');
56 56
 
57 57
     /**
58 58
 	 * URL to view a transaction.
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function __construct() {
75 75
 
76
-        $this->method_title         = __( 'Worldpay', 'invoicing' );
77
-        $this->title                = __( 'Worldpay - Credit Card / Debit Card', 'invoicing' );
78
-        $this->checkout_button_text = __( 'Proceed to Worldpay', 'invoicing' );
79
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
76
+        $this->method_title         = __('Worldpay', 'invoicing');
77
+        $this->title                = __('Worldpay - Credit Card / Debit Card', 'invoicing');
78
+        $this->checkout_button_text = __('Proceed to Worldpay', 'invoicing');
79
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
80 80
 
81
-        add_filter( 'wpinv_gateway_description', array( $this, 'sandbox_notice' ), 10, 2 );
82
-        add_filter( 'getpaid_worldpay_args', array( $this, 'hash_args' ) );
81
+        add_filter('wpinv_gateway_description', array($this, 'sandbox_notice'), 10, 2);
82
+        add_filter('getpaid_worldpay_args', array($this, 'hash_args'));
83 83
 
84 84
         parent::__construct();
85 85
     }
@@ -93,24 +93,24 @@  discard block
 block discarded – undo
93 93
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
94 94
 	 * @return array
95 95
 	 */
96
-	public function process_payment( $invoice, $submission_data, $submission ) {
96
+	public function process_payment($invoice, $submission_data, $submission) {
97 97
 
98 98
         // Get redirect url.
99
-        $worldpay_redirect = esc_url( $this->get_request_url( $invoice ) );
99
+        $worldpay_redirect = esc_url($this->get_request_url($invoice));
100 100
 
101 101
         // Get submission args.
102
-        $worldpay_args     = $this->get_worldpay_args( $invoice );
102
+        $worldpay_args     = $this->get_worldpay_args($invoice);
103 103
 
104 104
         $form = "<form action='$worldpay_redirect' name='wpi_worldpay_form' method='POST'>";
105 105
 
106
-        foreach ( $worldpay_args as $key => $value ) {
106
+        foreach ($worldpay_args as $key => $value) {
107 107
 
108
-            if ( false === $value || '' === trim( $value ) ) {
108
+            if (false === $value || '' === trim($value)) {
109 109
                 continue;
110 110
             }
111 111
 
112
-            $value = esc_attr( $value );
113
-            $key   = wpinv_clean( $key );
112
+            $value = esc_attr($value);
113
+            $key   = wpinv_clean($key);
114 114
             $form .= "<input type='hidden' name='$key' value='$value'>";
115 115
         }
116 116
 
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 	 * @param  WPInv_Invoice $invoice Invoice object.
134 134
 	 * @return string
135 135
 	 */
136
-	public function get_request_url( $invoice ) {
136
+	public function get_request_url($invoice) {
137 137
 
138 138
         // Endpoint for this request
139
-		$this->endpoint = $this->is_sandbox( $invoice ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
139
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
140 140
 
141 141
         return $this->endpoint;
142 142
 
@@ -148,34 +148,34 @@  discard block
 block discarded – undo
148 148
 	 * @param  WPInv_Invoice $invoice Invoice object.
149 149
 	 * @return array
150 150
 	 */
151
-	protected function get_worldpay_args( $invoice ) {
151
+	protected function get_worldpay_args($invoice) {
152 152
 
153 153
 		return apply_filters(
154 154
 			'getpaid_worldpay_args',
155 155
 			array(
156
-                'amount'         => wpinv_sanitize_amount( $invoice->get_total() ), // mandatory
157
-                'cartId'         => wpinv_clean( $invoice->get_number() ), // mandatory reference for the item purchased
158
-                'currency'       => wpinv_clean( $invoice->get_currency() ), // mandatory
159
-                'instId'         => wpinv_clean( $this->get_option( 'instId', '' ) ), // mandatory
160
-                'testMode'       => $this->is_sandbox( $invoice ) ? 100 : 0, // mandatory
161
-                'name'           => wpinv_clean( $invoice->get_full_name() ),
162
-                'address'        => wpinv_clean( $invoice->get_address() ),
163
-                'postcode'       => wpinv_clean( $invoice->get_zip() ),
164
-                'tel'            => wpinv_clean( $invoice->get_phone() ),
165
-                'email'          => sanitize_email( $invoice->get_email() ),
166
-                'country'        => wpinv_clean( $invoice->get_country() ),
167
-                'desc'           => sprintf( __( 'Payment for invoice %s.', 'invoicing' ), wpinv_clean( $invoice->get_number() ) ),
168
-                'MC_description' => sprintf( __( 'Payment for invoice %s.', 'invoicing' ), wpinv_clean( $invoice->get_number() ) ),
169
-                'MC_callback'    => esc_url_raw( $this->notify_url ),
170
-                'resultfile'     => esc_url_raw( $this->get_return_url( $invoice ) ),
171
-                'MC_key'         => wpinv_clean( $invoice->get_key() ),
156
+                'amount'         => wpinv_sanitize_amount($invoice->get_total()), // mandatory
157
+                'cartId'         => wpinv_clean($invoice->get_number()), // mandatory reference for the item purchased
158
+                'currency'       => wpinv_clean($invoice->get_currency()), // mandatory
159
+                'instId'         => wpinv_clean($this->get_option('instId', '')), // mandatory
160
+                'testMode'       => $this->is_sandbox($invoice) ? 100 : 0, // mandatory
161
+                'name'           => wpinv_clean($invoice->get_full_name()),
162
+                'address'        => wpinv_clean($invoice->get_address()),
163
+                'postcode'       => wpinv_clean($invoice->get_zip()),
164
+                'tel'            => wpinv_clean($invoice->get_phone()),
165
+                'email'          => sanitize_email($invoice->get_email()),
166
+                'country'        => wpinv_clean($invoice->get_country()),
167
+                'desc'           => sprintf(__('Payment for invoice %s.', 'invoicing'), wpinv_clean($invoice->get_number())),
168
+                'MC_description' => sprintf(__('Payment for invoice %s.', 'invoicing'), wpinv_clean($invoice->get_number())),
169
+                'MC_callback'    => esc_url_raw($this->notify_url),
170
+                'resultfile'     => esc_url_raw($this->get_return_url($invoice)),
171
+                'MC_key'         => wpinv_clean($invoice->get_key()),
172 172
                 'MC_invoice_id'  => $invoice->get_id(),
173
-                'address1'       => wpinv_clean( $invoice->get_address() ),
174
-                'town'           => wpinv_clean( $invoice->get_city() ),
175
-                'region'         => wpinv_clean( $invoice->get_state() ),
176
-                'amountString'   => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
177
-                'countryString'  => wpinv_clean( wpinv_country_name( $invoice->get_country() ) ),
178
-                'compName'       => wpinv_clean( $invoice->get_company() ),
173
+                'address1'       => wpinv_clean($invoice->get_address()),
174
+                'town'           => wpinv_clean($invoice->get_city()),
175
+                'region'         => wpinv_clean($invoice->get_state()),
176
+                'amountString'   => wpinv_price($invoice->get_total(), $invoice->get_currency()),
177
+                'countryString'  => wpinv_clean(wpinv_country_name($invoice->get_country())),
178
+                'compName'       => wpinv_clean($invoice->get_company()),
179 179
             ),
180 180
 			$invoice
181 181
 		);
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 	 * @param  array $args Gateway args.
189 189
 	 * @return array
190 190
 	 */
191
-	public function hash_args( $args ) {
191
+	public function hash_args($args) {
192 192
 
193
-        $md5_secret = $this->get_option( 'md5_secret' );
193
+        $md5_secret = $this->get_option('md5_secret');
194 194
 
195 195
         // Abort if there is no secret.
196
-        if ( empty( $md5_secret ) ) {
196
+        if (empty($md5_secret)) {
197 197
             return $args;
198 198
         }
199 199
 
200 200
         // Hash the args.
201
-        $args['signature'] = md5( "$md5_secret:{$args['instId']}:{$args['amount']}:{$args['currency']}:{$args['cartId']}" );
201
+        $args['signature'] = md5("$md5_secret:{$args['instId']}:{$args['amount']}:{$args['currency']}:{$args['cartId']}");
202 202
 
203 203
         return $args;
204 204
     }
@@ -211,43 +211,43 @@  discard block
 block discarded – undo
211 211
 	public function verify_ipn() {
212 212
 
213 213
         // Validate the IPN.
214
-        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
215
-		    wp_die( 'Worldpay IPN Request Failure', 'Worldpay IPN', array( 'response' => 500 ) );
214
+        if (empty($_POST) || !$this->validate_ipn()) {
215
+		    wp_die('Worldpay IPN Request Failure', 'Worldpay IPN', array('response' => 500));
216 216
 		}
217 217
 
218 218
         // Process the IPN.
219
-        $posted  = wp_kses_post_deep( wp_unslash( $_POST ) );
220
-        $invoice = wpinv_get_invoice( $posted['MC_invoice_id'] );
219
+        $posted  = wp_kses_post_deep(wp_unslash($_POST));
220
+        $invoice = wpinv_get_invoice($posted['MC_invoice_id']);
221 221
 
222
-        if ( $invoice && $this->id == $invoice->get_gateway() ) {
222
+        if ($invoice && $this->id == $invoice->get_gateway()) {
223 223
 
224
-            wpinv_error_log( 'Found invoice #' . $invoice->get_number() );
225
-            wpinv_error_log( 'Payment status:' . $posted['transStatus'] );
224
+            wpinv_error_log('Found invoice #' . $invoice->get_number());
225
+            wpinv_error_log('Payment status:' . $posted['transStatus']);
226 226
 
227 227
             // Update the transaction id.
228
-            if ( ! empty( $posted['transId'] ) ) {
229
-                $invoice->set_transaction_id( wpinv_clean( $posted['transId'] ) );
228
+            if (!empty($posted['transId'])) {
229
+                $invoice->set_transaction_id(wpinv_clean($posted['transId']));
230 230
             }
231 231
 
232 232
              // Update the ip address.
233
-             if ( ! empty( $posted['ipAddress'] ) ) {
234
-                $invoice->set_ip( wpinv_clean( $posted['ipAddress'] ) );
233
+             if (!empty($posted['ipAddress'])) {
234
+                $invoice->set_ip(wpinv_clean($posted['ipAddress']));
235 235
             }
236 236
 
237
-            if ( $posted['transStatus'] == 'Y' ) {
238
-                $invoice->set_completed_date( date( 'Y-m-d H:i:s', $posted['transTime'] ) );
237
+            if ($posted['transStatus'] == 'Y') {
238
+                $invoice->set_completed_date(date('Y-m-d H:i:s', $posted['transTime']));
239 239
                 $invoice->mark_paid();
240 240
                 return;
241 241
             }
242 242
 
243
-            if ( $posted['transStatus'] == 'C' ) {
244
-                $invoice->set_status( 'wpi-failed' );
245
-                $invoice->add_note( __( 'Payment transaction failed while processing Worldpay payment.', 'invoicing' ), false, false, true );
243
+            if ($posted['transStatus'] == 'C') {
244
+                $invoice->set_status('wpi-failed');
245
+                $invoice->add_note(__('Payment transaction failed while processing Worldpay payment.', 'invoicing'), false, false, true);
246 246
                 $invoice->save();
247 247
                 return;
248 248
             }
249 249
 
250
-            wpinv_error_log( 'Aborting, Invalid transaction status:' . $posted['transStatus'] );
250
+            wpinv_error_log('Aborting, Invalid transaction status:' . $posted['transStatus']);
251 251
             $invoice->save();
252 252
 
253 253
         }
@@ -261,27 +261,27 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function validate_ipn() {
263 263
 
264
-        wpinv_error_log( 'Validating Worldpay IPN response' );
264
+        wpinv_error_log('Validating Worldpay IPN response');
265 265
 
266
-        $data = wp_kses_post_deep( wp_unslash( $_POST ) );
266
+        $data = wp_kses_post_deep(wp_unslash($_POST));
267 267
 
268 268
         // Verify installation.
269
-        if ( empty( $data['instId'] ) || $data['instId'] != wpinv_clean( $this->get_option( 'instId', '' ) ) ) {
270
-            wpinv_error_log( 'Received invalid installation ID from Worldpay IPN' );
269
+        if (empty($data['instId']) || $data['instId'] != wpinv_clean($this->get_option('instId', ''))) {
270
+            wpinv_error_log('Received invalid installation ID from Worldpay IPN');
271 271
             return false;
272 272
         }
273 273
 
274 274
         // Verify invoice.
275
-        if ( empty( $data['cartId'] ) || !  wpinv_get_id_by_invoice_number( $data['cartId'] ) ) {
276
-            wpinv_error_log( 'Received invalid invoice number from Worldpay IPN' );
275
+        if (empty($data['cartId']) || !wpinv_get_id_by_invoice_number($data['cartId'])) {
276
+            wpinv_error_log('Received invalid invoice number from Worldpay IPN');
277 277
             return false;
278 278
         }
279 279
         
280 280
         // (maybe) verify password.
281
-        $password = $this->get_option( 'callback_password' );
281
+        $password = $this->get_option('callback_password');
282 282
 
283
-        if ( ! empty( $password ) && ( empty( $data['callbackPW'] ) || $password != $data['callbackPW'] ) ) {
284
-            wpinv_error_log( 'Received invalid invoice number from Worldpay IPN' );
283
+        if (!empty($password) && (empty($data['callbackPW']) || $password != $data['callbackPW'])) {
284
+            wpinv_error_log('Received invalid invoice number from Worldpay IPN');
285 285
             return false;
286 286
         }
287 287
 
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
     /**
293 293
      * Displays a notice on the checkout page if sandbox is enabled.
294 294
      */
295
-    public function sandbox_notice( $description, $gateway ) {
296
-        if ( 'worldpay' == $gateway && wpinv_is_test_mode( 'worldpay' ) ) {
295
+    public function sandbox_notice($description, $gateway) {
296
+        if ('worldpay' == $gateway && wpinv_is_test_mode('worldpay')) {
297 297
             $description .= '<br>' . sprintf(
298
-                __( 'SANDBOX ENABLED. See the %sWorldpay Sandbox Testing Guide%s for more details.', 'invoicing' ),
298
+                __('SANDBOX ENABLED. See the %sWorldpay Sandbox Testing Guide%s for more details.', 'invoicing'),
299 299
                 '<a href="https://developer.worldpay.com/docs/wpg/directintegration/abouttesting">',
300 300
                 '</a>'
301 301
             );
@@ -309,43 +309,43 @@  discard block
 block discarded – undo
309 309
 	 * 
310 310
 	 * @param array $admin_settings
311 311
 	 */
312
-	public function admin_settings( $admin_settings ) {
312
+	public function admin_settings($admin_settings) {
313 313
 
314 314
         $currencies = sprintf(
315
-            __( 'Supported Currencies: %s', 'invoicing' ),
316
-            implode( ', ', $this->currencies )
315
+            __('Supported Currencies: %s', 'invoicing'),
316
+            implode(', ', $this->currencies)
317 317
         );
318 318
 
319 319
         $admin_settings['worldpay_active']['desc'] = $admin_settings['worldpay_active']['desc'] . " ($currencies)";
320
-        $admin_settings['worldpay_desc']['std']    = __( 'Pay securely via Worldpay using your PayPal account, credit or debit card.', 'invoicing' );
320
+        $admin_settings['worldpay_desc']['std']    = __('Pay securely via Worldpay using your PayPal account, credit or debit card.', 'invoicing');
321 321
 
322 322
         $admin_settings['worldpay_instId'] = array(
323 323
             'type' => 'text',
324 324
             'id'   => 'worldpay_instId',
325
-            'name' => __( 'Installation Id', 'invoicing' ),
326
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
325
+            'name' => __('Installation Id', 'invoicing'),
326
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
327 327
         );
328 328
 
329 329
         $admin_settings['worldpay_md5_secret'] = array(
330 330
             'type' => 'text',
331 331
             'id'   => 'worldpay_md5_secret',
332
-            'name' => __( 'MD5 secret', 'invoicing' ),
333
-            'desc' => __( 'Optionally enter your MD5 secret here. Next, open your installation settings and ensure that your SignatureFields parameter is set to ', 'invoicing' ) . '<code>instId:amount:currency:cartId</code>',
332
+            'name' => __('MD5 secret', 'invoicing'),
333
+            'desc' => __('Optionally enter your MD5 secret here. Next, open your installation settings and ensure that your SignatureFields parameter is set to ', 'invoicing') . '<code>instId:amount:currency:cartId</code>',
334 334
         );
335 335
 
336 336
         $admin_settings['worldpay_callbackPW'] = array(
337 337
             'type' => 'text',
338 338
             'id'   => 'worldpay_callbackPW',
339
-            'name' => __( 'Payment Response password', 'invoicing' ),
340
-            'desc' => __( 'Recommended. Enter your WorldPay response password to validate payment notifications.', 'invoicing' ),
339
+            'name' => __('Payment Response password', 'invoicing'),
340
+            'desc' => __('Recommended. Enter your WorldPay response password to validate payment notifications.', 'invoicing'),
341 341
         );
342 342
 
343 343
         $admin_settings['worldpay_ipn_url'] = array(
344 344
             'type'     => 'ipn_url',
345 345
             'id'       => 'worldpay_ipn_url',
346
-            'name'     => __( 'Payment Response URL', 'invoicing' ),
346
+            'name'     => __('Payment Response URL', 'invoicing'),
347 347
             'std'      => $this->notify_url,
348
-            'desc'     => __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and enter the above URL.', 'invoicing' ),
348
+            'desc'     => __('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and enter the above URL.', 'invoicing'),
349 349
             'custom'   => 'worldpay',
350 350
             'readonly' => true
351 351
         );
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -16,82 +16,82 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Items {
18 18
 
19
-    public static function get_columns( $invoice ) {
19
+    public static function get_columns($invoice) {
20 20
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
21 21
         $columns            = array(
22
-            'id'     => __( 'ID', 'invoicing' ),
23
-            'title'  => __( 'Item', 'invoicing' ),
22
+            'id'     => __('ID', 'invoicing'),
23
+            'title'  => __('Item', 'invoicing'),
24 24
             'price'  => sprintf(
25 25
                 '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span>
26 26
                 <span class="getpaid-hide-if-hours hide-if-amount">%s</span>
27 27
                 <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>',
28
-                __( 'Amount', 'invoicing' ),
29
-                __( 'Price', 'invoicing' ),
30
-                __( 'Rate', 'invoicing' )
28
+                __('Amount', 'invoicing'),
29
+                __('Price', 'invoicing'),
30
+                __('Rate', 'invoicing')
31 31
             ),
32 32
             'qty'    => sprintf(
33 33
                 '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>',
34
-                __( 'Quantity', 'invoicing' ),
35
-                __( 'Hours', 'invoicing' )
34
+                __('Quantity', 'invoicing'),
35
+                __('Hours', 'invoicing')
36 36
             ),
37
-            'total'  => __( 'Total', 'invoicing' ),
38
-            'tax'    => __( 'Tax (%)', 'invoicing' ),
37
+            'total'  => __('Total', 'invoicing'),
38
+            'tax'    => __('Tax (%)', 'invoicing'),
39 39
             'action' => '',
40 40
         );
41 41
 
42
-        if ( ! $use_taxes ) {
43
-            unset( $columns['tax'] );
42
+        if (!$use_taxes) {
43
+            unset($columns['tax']);
44 44
         }
45 45
 
46 46
         return $columns;
47 47
     }
48 48
 
49
-    public static function output( $post, $invoice = false ) {
49
+    public static function output($post, $invoice = false) {
50 50
 
51
-        if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) {
52
-            return self::output2( $post );
51
+        if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) {
52
+            return self::output2($post);
53 53
         }
54 54
 
55
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
56
-        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id );
55
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
56
+        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id);
57 57
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
58
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
59
-        $columns            = self::get_columns( $invoice );
60
-        $cols               = count( $columns );
58
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
59
+        $columns            = self::get_columns($invoice);
60
+        $cols               = count($columns);
61 61
         $class              = '';
62 62
 
63
-        unset( $item_types['adv'] );
64
-        unset( $item_types['package'] );
63
+        unset($item_types['adv']);
64
+        unset($item_types['package']);
65 65
 
66
-        if ( $invoice->is_paid() ) {
66
+        if ($invoice->is_paid()) {
67 67
             $class .= ' wpinv-paid';
68 68
         }
69 69
 
70
-        if ( $invoice->is_refunded() ) {
70
+        if ($invoice->is_refunded()) {
71 71
             $class .= ' wpinv-refunded';
72 72
         }
73 73
 
74
-        if ( $invoice->is_recurring() ) {
74
+        if ($invoice->is_recurring()) {
75 75
             $class .= ' wpi-recurring';
76 76
         }
77 77
 
78 78
     ?>
79 79
 
80
-        <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>">
80
+        <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>">
81 81
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
82 82
 
83 83
                 <thead>
84 84
                     <tr>
85
-                        <?php foreach ( $columns as $key => $label ) : ?>
86
-                            <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th>
85
+                        <?php foreach ($columns as $key => $label) : ?>
86
+                            <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th>
87 87
                         <?php endforeach; ?>
88 88
                     </tr>
89 89
                 </thead>
90 90
 
91 91
                 <tbody class="wpinv-line-items">
92 92
                     <?php
93
-                        foreach ( $invoice->get_items() as $int => $item ) {
94
-                            self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
93
+                        foreach ($invoice->get_items() as $int => $item) {
94
+                            self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd');
95 95
                         }
96 96
                     ?>
97 97
                 </tbody>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                                             <div class="wp-clearfix">
109 109
                                                 <label class="wpi-item-name">
110 110
                                                     <span class="input-text-wrap">
111
-                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
111
+                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
112 112
                                                     </span>
113 113
                                                 </label>
114 114
                                             </div>
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                                             <div class="wp-clearfix">
117 117
                                                 <label class="wpi-item-price">
118 118
                                                     <span class="input-text-wrap">
119
-                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
-                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
119
+                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
+                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
121 121
                                                     </span>
122 122
                                                 </label>
123 123
                                             </div>
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                                             <div class="wp-clearfix">
126 126
                                                 <label class="wpi-item-name">
127 127
                                                     <span class="input-text-wrap">
128
-                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
128
+                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
129 129
                                                     </span>
130 130
                                                 </label>
131 131
                                             </div>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                                             <div class="wp-clearfix">
134 134
                                                 <label class="wpi-item-type">
135 135
                                                     <span class="input-text-wrap">
136
-                                                        <?php echo wpinv_html_select( array(
136
+                                                        <?php echo wpinv_html_select(array(
137 137
                                                             'options'          => $item_types,
138 138
                                                             'name'             => '_wpinv_quick[type]',
139 139
                                                             'id'               => '_wpinv_quick_type',
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
                                                             'show_option_all'  => false,
142 142
                                                             'show_option_none' => false,
143 143
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
144
-                                                        ) ); ?>
144
+                                                        )); ?>
145 145
                                                     </span>
146 146
                                                 </label>
147 147
                                             </div>
148 148
 
149
-                                            <?php if ( $use_taxes ) : ?>
149
+                                            <?php if ($use_taxes) : ?>
150 150
                                                 <div class="wp-clearfix">
151 151
                                                     <label class="wpi-vat-rule">
152 152
                                                         <span class="input-text-wrap">
153 153
                                                             <?php
154
-                                                                echo wpinv_html_select( array(
154
+                                                                echo wpinv_html_select(array(
155 155
                                                                     'options'          => array_merge(
156
-                                                                        array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
156
+                                                                        array('' => __('Select VAT Rule', 'invoicing')),
157 157
                                                                         getpaid_get_tax_rules()
158 158
                                                                     ),
159 159
                                                                     'name'             => '_wpinv_quick[vat_rule]',
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                                                                     'show_option_all'  => false,
162 162
                                                                     'show_option_none' => false,
163 163
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
164
-                                                                ) );
164
+                                                                ));
165 165
                                                             ?>
166 166
                                                         </span>
167 167
                                                     </label>
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
                                                     <label class="wpi-vat-class">
171 171
                                                         <span class="input-text-wrap">
172 172
                                                             <?php
173
-                                                                echo wpinv_html_select( array(
173
+                                                                echo wpinv_html_select(array(
174 174
                                                                     'options'          => array_merge(
175
-                                                                        array( '' => __( 'Select VAT Class', 'invoicing' ) ),
175
+                                                                        array('' => __('Select VAT Class', 'invoicing')),
176 176
                                                                         getpaid_get_tax_classes()
177 177
                                                                     ),
178 178
                                                                     'name'             => '_wpinv_quick[vat_class]',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                                                                     'show_option_all'  => false,
181 181
                                                                     'show_option_none' => false,
182 182
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
183
-                                                                ) );
183
+                                                                ));
184 184
                                                             ?>
185 185
                                                         </span>
186 186
                                                     </label>
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
                         </td>
202 202
                     </tr>
203 203
                     <tr class="totals">
204
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
204
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
205 205
                         <td colspan="4">
206 206
                             <table cellspacing="0" cellpadding="0">
207 207
                                 <tr class="subtotal">
208
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
209
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td>
208
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
209
+                                    <td class="total"><?php echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td>
210 210
                                     <td class="action"></td>
211 211
                                 </tr>
212 212
                                 <tr class="discount">
213
-                                    <td class="name"><?php _e( 'Discount:', 'invoicing' ) ; ?></td>
214
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td>
213
+                                    <td class="name"><?php _e('Discount:', 'invoicing'); ?></td>
214
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td>
215 215
                                     <td class="action"></td>
216 216
                                 </tr>
217
-                                <?php if ( $use_taxes ) : ?>
217
+                                <?php if ($use_taxes) : ?>
218 218
                                 <tr class="tax">
219
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
220
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td>
219
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
220
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td>
221 221
                                     <td class="action"></td>
222 222
                                 </tr>
223 223
                                 <?php endif; ?>
224 224
                                 <tr class="total">
225
-                                    <td class="name"><?php _e( 'Total:', 'invoicing' );?></td>
226
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );?></td>
225
+                                    <td class="name"><?php _e('Total:', 'invoicing'); ?></td>
226
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total(), $invoice->get_currency()); ?></td>
227 227
                                     <td class="action"></td>
228 228
                                 </tr>
229 229
                             </table>
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             </table>
235 235
             <div class="wpinv-actions">
236 236
                 <?php
237
-                    if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
237
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
238 238
                         echo wpinv_item_dropdown(
239 239
                             array(
240 240
                                 'name'             => 'wpinv_invoice_item',
@@ -244,61 +244,61 @@  discard block
 block discarded – undo
244 244
                             )
245 245
                         );
246 246
 
247
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>';
248
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
249
-                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
247
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>';
248
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>';
249
+                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>';
250 250
 
251 251
                     }
252 252
                 ?>
253
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
253
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
254 254
             </div>
255 255
         </div>
256 256
         <?php
257 257
     }
258 258
 
259
-    public static function output_row( $columns, $item, $invoice, $class='even' ) {
259
+    public static function output_row($columns, $item, $invoice, $class = 'even') {
260 260
 
261 261
     ?>
262
-        <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>">
263
-            <?php foreach ( array_keys( $columns ) as $column ) : ?>
264
-                <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
262
+        <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>">
263
+            <?php foreach (array_keys($columns) as $column) : ?>
264
+                <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
265 265
                     <?php
266
-                        switch ( $column ) {
266
+                        switch ($column) {
267 267
                             case 'id':
268 268
                                 echo (int) $item->get_id();
269 269
                                 break;
270 270
                             case 'title':
271 271
                                 printf(
272 272
                                     '<a href="%s" target="_blank">%s</a>',
273
-                                    get_edit_post_link( $item->get_id() ),
274
-                                    esc_html( $item->get_raw_name() )
273
+                                    get_edit_post_link($item->get_id()),
274
+                                    esc_html($item->get_raw_name())
275 275
                                 );
276 276
 
277
-                                $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
278
-                                if ( $summary !== '' ) {
277
+                                $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice);
278
+                                if ($summary !== '') {
279 279
                                     printf(
280 280
                                         '<span class="meta">%s</span>',
281
-                                        wpautop( wp_kses_post( $summary ) )
281
+                                        wpautop(wp_kses_post($summary))
282 282
                                     );
283 283
                                 }
284 284
 
285 285
                                 printf(
286 286
                                     '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
287
-                                    esc_attr( $item->get_raw_name() ),
287
+                                    esc_attr($item->get_raw_name()),
288 288
                                     (int) $item->get_id()
289 289
                                 );
290 290
 
291 291
                                 printf(
292 292
                                     '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
293 293
                                     (int) $item->get_id(),
294
-                                    esc_attr( $item->get_description() )
294
+                                    esc_attr($item->get_description())
295 295
                                 );
296 296
 
297 297
                                 break;
298 298
                             case 'price':
299 299
                                 printf(
300 300
                                     '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
301
-                                    esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
301
+                                    esc_attr(getpaid_unstandardize_amount($item->get_price())),
302 302
                                     (int) $item->get_id()
303 303
                                 );
304 304
 
@@ -306,26 +306,26 @@  discard block
 block discarded – undo
306 306
                             case 'qty':
307 307
                                 printf(
308 308
                                     '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
309
-                                    floatval( $item->get_quantity() ),
309
+                                    floatval($item->get_quantity()),
310 310
                                     (int) $item->get_id()
311 311
                                 );
312 312
 
313 313
                                 break;
314 314
                             case 'total':
315
-                                echo wpinv_price( $item->get_sub_total(), $invoice->get_currency() );
315
+                                echo wpinv_price($item->get_sub_total(), $invoice->get_currency());
316 316
 
317 317
                                 break;
318 318
                             case 'tax':
319
-                                echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%';
319
+                                echo wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%';
320 320
 
321 321
                                 break;
322 322
                             case 'action':
323
-                                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
323
+                                if (!$invoice->is_paid() && !$invoice->is_refunded()) {
324 324
                                     echo '<i class="fa fa-trash wpinv-item-remove"></i>';
325 325
                                 }
326 326
                                 break;
327 327
                         }
328
-                        do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice );
328
+                        do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice);
329 329
                     ?>
330 330
                 </td>
331 331
             <?php endforeach; ?>
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @param WP_Post $post
340 340
 	 */
341
-    public static function output2( $post ) {
341
+    public static function output2($post) {
342 342
 
343 343
         // Prepare the invoice.
344
-        $invoice = new WPInv_Invoice( $post );
344
+        $invoice = new WPInv_Invoice($post);
345 345
 
346 346
         // Invoice items.
347 347
         $items = $invoice->get_items();
@@ -349,28 +349,28 @@  discard block
 block discarded – undo
349 349
         $totals = array(
350 350
 
351 351
             'subtotal'  => array(
352
-                'label' => __( 'Items Subtotal', 'invoicing' ),
353
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
352
+                'label' => __('Items Subtotal', 'invoicing'),
353
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
354 354
             ),
355 355
 
356 356
             'discount'  => array(
357
-                'label' => __( 'Total Discount', 'invoicing' ),
358
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
357
+                'label' => __('Total Discount', 'invoicing'),
358
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
359 359
             ),
360 360
 
361 361
             'tax'       => array(
362
-                'label' => __( 'Total Tax', 'invoicing' ),
363
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
362
+                'label' => __('Total Tax', 'invoicing'),
363
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
364 364
             ),
365 365
 
366 366
             'total'     => array(
367
-                'label' => __( 'Invoice Total', 'invoicing' ),
368
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
367
+                'label' => __('Invoice Total', 'invoicing'),
368
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
369 369
             )
370 370
         );
371 371
 
372
-        if ( ! wpinv_use_taxes() ) {
373
-            unset( $totals['tax'] );
372
+        if (!wpinv_use_taxes()) {
373
+            unset($totals['tax']);
374 374
         }
375 375
 
376 376
         $item_args = array(
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             'orderby'        => 'title',
379 379
             'order'          => 'ASC',
380 380
             'posts_per_page' => -1,
381
-            'post_status'    => array( 'publish' ),
381
+            'post_status'    => array('publish'),
382 382
             'meta_query'     => array(
383 383
                 array(
384 384
                     'key'       => '_wpinv_type',
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
             }
403 403
         </style>
404 404
 
405
-                <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
405
+                <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
406 406
 
407
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
408
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
407
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
408
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
409 409
 
410 410
                         <div class="row">
411 411
                             <div class="col-12 col-sm-6">
@@ -414,15 +414,15 @@  discard block
 block discarded – undo
414 414
                                         array(
415 415
                                             'id'          => 'wpinv_template',
416 416
                                             'name'        => 'wpinv_template',
417
-                                            'label'       => __( 'Template', 'invoicing' ),
417
+                                            'label'       => __('Template', 'invoicing'),
418 418
                                             'label_type'  => 'vertical',
419
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
419
+                                            'placeholder' => __('Choose a template', 'invoicing'),
420 420
                                             'class'       => 'form-control-sm',
421
-                                            'value'       => $invoice->get_template( 'edit' ),
421
+                                            'value'       => $invoice->get_template('edit'),
422 422
                                             'options'     => array(
423
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
424
-                                                'hours'    => __( 'Hours', 'invoicing' ),
425
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
423
+                                                'quantity' => __('Quantity', 'invoicing'),
424
+                                                'hours'    => __('Hours', 'invoicing'),
425
+                                                'amount'   => __('Amount Only', 'invoicing'),
426 426
                                             ),
427 427
                                             'data-allow-clear' => 'false',
428 428
                                             'select2'          => true,
@@ -438,11 +438,11 @@  discard block
 block discarded – undo
438 438
                                         array(
439 439
                                             'id'          => 'wpinv_currency',
440 440
                                             'name'        => 'wpinv_currency',
441
-                                            'label'       => __( 'Currency', 'invoicing' ),
441
+                                            'label'       => __('Currency', 'invoicing'),
442 442
                                             'label_type'  => 'vertical',
443
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
443
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
444 444
                                             'class'       => 'form-control-sm',
445
-                                            'value'       => $invoice->get_currency( 'edit' ),
445
+                                            'value'       => $invoice->get_currency('edit'),
446 446
                                             'required'    => false,
447 447
                                             'data-allow-clear' => 'false',
448 448
                                             'select2'          => true,
@@ -454,24 +454,24 @@  discard block
 block discarded – undo
454 454
                             </div>
455 455
                         </div>
456 456
 
457
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
457
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
458 458
                     <?php endif; ?>
459 459
 
460 460
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
461 461
                         <thead>
462 462
                             <tr>
463
-                                <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th>
463
+                                <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th>
464 464
                                 <th class="getpaid-quantity hide-if-amount text-right">
465
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
466
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
465
+                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
466
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
467 467
                                 </th>
468 468
                                 <th class="getpaid-price hide-if-amount text-right">
469
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span>
470
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span>
469
+                                    <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span>
470
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span>
471 471
                                 </th>
472 472
                                 <th class="getpaid-item-subtotal text-right">
473
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span>
474
-                                    <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span>
473
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span>
474
+                                    <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span>
475 475
                                 </th>
476 476
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
477 477
                             </tr>
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 		                <tbody class="getpaid_invoice_line_items">
480 480
                             <tr class="hide-if-has-items hide-if-not-editable">
481 481
                                 <td colspan="2" class="pt-4 pb-4">
482
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button>
483
-                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button>
482
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button>
483
+                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button>
484 484
                                 </td>
485 485
                                 <td class="hide-if-amount">&nbsp;</th>
486 486
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
                             <div class="col-12 col-sm-6 offset-sm-6">
513 513
                                 <table class="getpaid-invoice-totals text-right w-100">
514 514
                                     <tbody>
515
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
516
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
517
-                                                <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td>
515
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
516
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
517
+                                                <td class="label"><?php echo esc_html($data['label']) ?>:</td>
518 518
                                                 <td width="1%"></td>
519
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td>
519
+                                                <td class="value"><?php echo wp_kses_post($data['value']) ?></td>
520 520
                                             </tr>
521 521
                                         <?php endforeach; ?>
522 522
                                     </tbody>
@@ -529,18 +529,18 @@  discard block
 block discarded – undo
529 529
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
530 530
                         <div class="row">
531 531
                             <div class="text-left col-12 col-sm-8">
532
-                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button>
533
-                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button>
534
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
532
+                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button>
533
+                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button>
534
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
535 535
                             </div>
536 536
                             <div class="text-right col-12 col-sm-4">
537
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button>
537
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button>
538 538
                             </div>
539 539
                         </div>
540 540
                     </div>
541 541
 
542 542
                     <div class="getpaid-invoice-item-actions hide-if-editable">
543
-                        <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
543
+                        <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p>
544 544
                     </div>
545 545
 
546 546
                     <!-- Add items to an invoice -->
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
                         <div class="modal-dialog modal-dialog-centered" role="document">
549 549
                             <div class="modal-content">
550 550
                                 <div class="modal-header">
551
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5>
552
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
551
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5>
552
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
553 553
                                         <span aria-hidden="true">&times;</span>
554 554
                                     </button>
555 555
                                 </div>
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
                                     <table class="widefat">
558 558
                                         <thead>
559 559
                                             <tr>
560
-                                                <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th>
560
+                                                <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th>
561 561
                                                 <th class="pr-0 text-right hide-if-amount">
562
-                                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
563
-                                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
562
+                                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
563
+                                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
564 564
                                                 </th>
565 565
                                             </tr>
566 566
                                         </thead>
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 								            <tr>
569 569
 									            <td class="pl-0 text-left">
570 570
                                                     <select class="regular-text getpaid-add-invoice-item-select">
571
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
572
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
573
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option>
571
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
572
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
573
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags($item->post_title); ?></option>
574 574
                                                         <?php endforeach; ?>
575 575
                                                     </select>
576 576
                                                 </td>
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 						            </table>
583 583
                                 </div>
584 584
                                 <div class="modal-footer">
585
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
586
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button>
585
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
586
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button>
587 587
                                 </div>
588 588
                             </div>
589 589
                         </div>
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
                         <div class="modal-dialog modal-dialog-centered" role="document">
595 595
                             <div class="modal-content">
596 596
                                 <div class="modal-header">
597
-                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e( "Create Item", 'invoicing' ); ?></h5>
598
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
597
+                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e("Create Item", 'invoicing'); ?></h5>
598
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
599 599
                                         <span aria-hidden="true">&times;</span>
600 600
                                     </button>
601 601
                                 </div>
@@ -603,27 +603,27 @@  discard block
 block discarded – undo
603 603
                                     <div class="getpaid-create-item-div">
604 604
                                         <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id">
605 605
                                         <label class="form-group w-100">
606
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
607
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
606
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
607
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
608 608
                                         </label>
609 609
                                         <label class="form-group w-100">
610
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
611
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
612
-                                            <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
610
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
611
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
612
+                                            <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
613 613
                                         </label>
614 614
                                         <label class="form-group w-100 hide-if-amount">
615
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
615
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
616 616
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
617 617
                                         </label>
618 618
                                         <label class="form-group w-100">
619
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
620
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
619
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
620
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
621 621
                                         </label>
622 622
                                     </div>
623 623
                                 </div>
624 624
                                 <div class="modal-footer">
625
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
626
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Create', 'invoicing' ); ?></button>
625
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
626
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Create', 'invoicing'); ?></button>
627 627
                                 </div>
628 628
                             </div>
629 629
                         </div>
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
                         <div class="modal-dialog modal-dialog-centered" role="document">
635 635
                             <div class="modal-content">
636 636
                                 <div class="modal-header">
637
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5>
638
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
637
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5>
638
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
639 639
                                         <span aria-hidden="true">&times;</span>
640 640
                                     </button>
641 641
                                 </div>
@@ -643,27 +643,27 @@  discard block
 block discarded – undo
643 643
                                     <div class="getpaid-edit-item-div">
644 644
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
645 645
                                         <label class="form-group w-100">
646
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
647
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
646
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
647
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
648 648
                                         </label>
649 649
                                         <label class="form-group w-100">
650
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
651
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
652
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
650
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
651
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
652
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
653 653
                                         </label>
654 654
                                         <label class="form-group w-100 hide-if-amount">
655
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
655
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
656 656
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
657 657
                                         </label>
658 658
                                         <label class="form-group w-100">
659
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
660
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
659
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
660
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
661 661
                                         </label>
662 662
                                     </div>
663 663
                                 </div>
664 664
                                 <div class="modal-footer">
665
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
666
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button>
665
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
666
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button>
667 667
                                 </div>
668 668
                             </div>
669 669
                         </div>
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-resend-invoice.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit; // Exit if accessed directly
10 10
 }
11 11
 
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param WP_Post $post
21 21
 	 */
22
-    public static function output( $post ) {
22
+    public static function output($post) {
23 23
 
24 24
         // Fetch the invoice.
25
-        $invoice = new WPInv_Invoice( $post );
25
+        $invoice = new WPInv_Invoice($post);
26 26
 
27
-        do_action( 'wpinv_metabox_resend_invoice_before', $invoice );
27
+        do_action('wpinv_metabox_resend_invoice_before', $invoice);
28 28
 
29 29
         $invoice_actions = array(
30 30
             'resend-email' => array(
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
                     'getpaid-nonce',
39 39
                     'getpaid-nonce'
40 40
                 ),
41
-                'label' => __( 'Resend Invoice', 'invoicing' ),
41
+                'label' => __('Resend Invoice', 'invoicing'),
42 42
             )
43 43
         );
44 44
 
45
-        if ( $invoice->needs_payment() ) {
45
+        if ($invoice->needs_payment()) {
46 46
 
47 47
             $invoice_actions['send-reminder'] = array(
48 48
                 'url' => wp_nonce_url(
@@ -55,29 +55,29 @@  discard block
 block discarded – undo
55 55
                     'getpaid-nonce',
56 56
                     'getpaid-nonce'
57 57
                 ),
58
-                'label' => __( 'Send Reminder', 'invoicing' ),
58
+                'label' => __('Send Reminder', 'invoicing'),
59 59
             );
60 60
 
61 61
         }
62 62
 
63
-        $invoice_actions = apply_filters( 'getpaid_edit_invoice_actions', $invoice_actions, $invoice );
63
+        $invoice_actions = apply_filters('getpaid_edit_invoice_actions', $invoice_actions, $invoice);
64 64
 
65
-        foreach ( $invoice_actions as $key => $action ) {
65
+        foreach ($invoice_actions as $key => $action) {
66 66
 
67
-            if ( 'resend-email' === $key ) {
68
-                echo wpautop( __( "This will send a copy of the invoice to the customer's email address.", 'invoicing' ) );
67
+            if ('resend-email' === $key) {
68
+                echo wpautop(__("This will send a copy of the invoice to the customer's email address.", 'invoicing'));
69 69
             }
70 70
 
71 71
             printf(
72 72
                 '<p class="wpi-meta-row wpi-%s"><a href="%s" class="button button-secondary">%s</a>',
73
-                esc_attr( $key ),
74
-                esc_url( $action['url'] ),
75
-                esc_html( $action['label'] )
73
+                esc_attr($key),
74
+                esc_url($action['url']),
75
+                esc_html($action['label'])
76 76
             );
77 77
 
78 78
         }
79 79
 
80
-        do_action( 'wpinv_metabox_resend_invoice_after', $invoice );
80
+        do_action('wpinv_metabox_resend_invoice_after', $invoice);
81 81
 
82 82
     }
83 83
 
Please login to merge, or discard this patch.
includes/admin/class-wpinv-customers-table.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if (!defined('ABSPATH')) exit;
9 9
 
10 10
 // Load WP_List_Table if not loaded
11
-if ( ! class_exists( 'WP_List_Table' ) ) {
11
+if (!class_exists('WP_List_Table')) {
12 12
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	public function __construct() {
43 43
 
44 44
 		// Set parent defaults
45
-		parent::__construct( array(
45
+		parent::__construct(array(
46 46
 			'singular' => 'id',
47 47
 			'plural'   => 'ids',
48 48
 			'ajax'     => false,
49
-		) );
49
+		));
50 50
 
51 51
 	}
52 52
 
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return string Column Name
74 74
 	 */
75
-	public function column_default( $item, $column_name ) {
76
-		$value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
77
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
75
+	public function column_default($item, $column_name) {
76
+		$value = esc_html(get_user_meta($item->ID, '_wpinv_' . $column_name, true));
77
+		return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item);
78 78
 	}
79 79
 
80 80
 	/**
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return string Column Name
88 88
 	 */
89
-	public function column_country( $user ) {
90
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
91
-		if ( $country ) {
92
-			$country = wpinv_country_name( $country );
89
+	public function column_country($user) {
90
+		$country = wpinv_sanitize_country($user->_wpinv_country);
91
+		if ($country) {
92
+			$country = wpinv_country_name($country);
93 93
 		}
94
-		return esc_html( $country );
94
+		return esc_html($country);
95 95
 	}
96 96
 
97 97
 	/**
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return string Column Name
105 105
 	 */
106
-	public function column_state( $user ) {
107
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
106
+	public function column_state($user) {
107
+		$country = wpinv_sanitize_country($user->_wpinv_country);
108 108
 		$state   = $user->_wpinv_state;
109
-		if ( $state ) {
110
-			$state = wpinv_state_name( $state, $country );
109
+		if ($state) {
110
+			$state = wpinv_state_name($state, $country);
111 111
 		}
112 112
 
113
-		return esc_html( $state );
113
+		return esc_html($state);
114 114
 	}
115 115
 
116 116
 	/**
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return string Column Name
124 124
 	 */
125
-	public function column_signup( $user ) {
126
-		return getpaid_format_date_value( $user->user_registered );
125
+	public function column_signup($user) {
126
+		return getpaid_format_date_value($user->user_registered);
127 127
 	}
128 128
 
129 129
 	/**
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @return string Column Name
137 137
 	 */
138
-	public function column_total( $user ) {
139
-		return wpinv_price( $this->column_total_raw( $user ) );
138
+	public function column_total($user) {
139
+		return wpinv_price($this->column_total_raw($user));
140 140
 	}
141 141
 
142 142
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return float
150 150
 	 */
151
-	public function column_total_raw( $user ) {
151
+	public function column_total_raw($user) {
152 152
 
153 153
 		$args = array(
154 154
 			'data'             => array(
@@ -164,17 +164,17 @@  discard block
 block discarded – undo
164 164
 
165 165
 				'author'       => array(
166 166
 					'type'     => 'post_data',
167
-					'value'    => absint( $user->ID ),
167
+					'value'    => absint($user->ID),
168 168
 					'key'      => 'posts.post_author',
169 169
 					'operator' => '=',
170 170
 				),
171 171
 
172 172
 			),
173 173
 			'query_type'     => 'get_var',
174
-			'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
174
+			'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'),
175 175
 		);
176 176
 
177
-		return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
177
+		return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args));
178 178
 
179 179
 	}
180 180
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @return string Column Name
189 189
 	 */
190
-	public function column_invoices( $user ) {
190
+	public function column_invoices($user) {
191 191
 
192 192
 		$args = array(
193 193
 			'data'             => array(
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 
205 205
 				'author'       => array(
206 206
 					'type'     => 'post_data',
207
-					'value'    => absint( $user->ID ),
207
+					'value'    => absint($user->ID),
208 208
 					'key'      => 'posts.post_author',
209 209
 					'operator' => '=',
210 210
 				),
211 211
 
212 212
 			),
213 213
 			'query_type'     => 'get_var',
214
-			'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
214
+			'invoice_status' => array_keys(wpinv_get_invoice_statuses()),
215 215
 		);
216 216
 
217
-		return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
217
+		return absint(GetPaid_Reports_Helper::get_invoice_report_data($args));
218 218
 
219 219
 	}
220 220
 
@@ -224,15 +224,15 @@  discard block
 block discarded – undo
224 224
 	 *
225 225
 	 * @param int $item The user id.
226 226
 	 */
227
-	public function single_row( $item ) {
228
-		$item = get_user_by( 'id', $item );
227
+	public function single_row($item) {
228
+		$item = get_user_by('id', $item);
229 229
 
230
-		if ( empty( $item ) ) {
230
+		if (empty($item)) {
231 231
 			return;
232 232
 		}
233 233
 
234 234
 		echo '<tr>';
235
-		$this->single_row_columns( $item );
235
+		$this->single_row_columns($item);
236 236
 		echo '</tr>';
237 237
 	}
238 238
 
@@ -242,30 +242,30 @@  discard block
 block discarded – undo
242 242
 	 * @param  WP_User $customer customer.
243 243
 	 * @return string
244 244
 	 */
245
-	public function column_name( $customer ) {
245
+	public function column_name($customer) {
246 246
 
247 247
 		// Customer view URL.
248
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
248
+		$view_url    = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php')));
249 249
 		$row_actions = $this->row_actions(
250 250
 			array(
251
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
251
+				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>',
252 252
 			)
253 253
 		);
254 254
 
255 255
 		// Get user's address.
256
-		$address = wpinv_get_user_address( $customer->ID );
256
+		$address = wpinv_get_user_address($customer->ID);
257 257
 
258 258
 		// Customer email address.
259
-		$email       = sanitize_email( $customer->user_email );
259
+		$email = sanitize_email($customer->user_email);
260 260
 
261 261
 		// Customer's avatar.
262
-		$avatar = esc_url( get_avatar_url( $email ) );
262
+		$avatar = esc_url(get_avatar_url($email));
263 263
 		$avatar = "<img src='$avatar' height='32' width='32'/>";
264 264
 
265 265
 		// Customer's name.
266
-		$name   = esc_html( "{$address['first_name']} {$address['last_name']}" );
266
+		$name   = esc_html("{$address['first_name']} {$address['last_name']}");
267 267
 
268
-		if ( ! empty( $name ) ) {
268
+		if (!empty($name)) {
269 269
 			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
270 270
 		}
271 271
 
@@ -284,19 +284,19 @@  discard block
 block discarded – undo
284 284
 	public function get_columns() {
285 285
 
286 286
 		$columns = array(
287
-			'name'     => __( 'Name', 'invoicing' ),
288
-			'country'  => __( 'Country', 'invoicing' ),
289
-			'state'    => __( 'State', 'invoicing' ),
290
-			'city'     => __( 'City', 'invoicing' ),
291
-			'zip'      => __( 'ZIP', 'invoicing' ),
292
-			'address'  => __( 'Address', 'invoicing' ),
293
-			'phone'    => __( 'Phone', 'invoicing' ),
294
-			'company'  => __( 'Company', 'invoicing' ),
295
-			'invoices' => __( 'Invoices', 'invoicing' ),
296
-			'total'    => __( 'Total Spend', 'invoicing' ),
297
-			'signup'   => __( 'Date created', 'invoicing' ),
287
+			'name'     => __('Name', 'invoicing'),
288
+			'country'  => __('Country', 'invoicing'),
289
+			'state'    => __('State', 'invoicing'),
290
+			'city'     => __('City', 'invoicing'),
291
+			'zip'      => __('ZIP', 'invoicing'),
292
+			'address'  => __('Address', 'invoicing'),
293
+			'phone'    => __('Phone', 'invoicing'),
294
+			'company'  => __('Company', 'invoicing'),
295
+			'invoices' => __('Invoices', 'invoicing'),
296
+			'total'    => __('Total Spend', 'invoicing'),
297
+			'signup'   => __('Date created', 'invoicing'),
298 298
 		);
299
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
299
+		return apply_filters('wpinv_customers_table_columns', $columns);
300 300
 
301 301
 	}
302 302
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 * @return int Current page number
308 308
 	 */
309 309
 	public function get_paged() {
310
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
310
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
311 311
 	}
312 312
 
313 313
 	/**
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @since 1.0.19
317 317
 	 * @return void
318 318
 	 */
319
-	public function bulk_actions( $which = '' ) {
319
+	public function bulk_actions($which = '') {
320 320
 		return array();
321 321
 	}
322 322
 
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
 
329 329
 		$post_types = '';
330 330
 
331
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
332
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
331
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
332
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
333 333
 		}
334 334
 
335
-		$post_types = rtrim( $post_types, ' OR' );
335
+		$post_types = rtrim($post_types, ' OR');
336 336
 
337 337
 		// Maybe search.
338
-		if ( ! empty( $_POST['s'] ) ) {
338
+		if (!empty($_POST['s'])) {
339 339
 			$users = get_users(
340 340
 				array(
341
-					'search'         => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*',
342
-					'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
341
+					'search'         => '*' . sanitize_text_field(urldecode($_POST['s'])) . '*',
342
+					'search_columns' => array('user_login', 'user_email', 'display_name'),
343 343
 					'fields'         => 'ID',
344 344
 				)
345 345
 			);
346 346
 
347
-			$users      = implode( ', ', $users );
347
+			$users      = implode(', ', $users);
348 348
 			$post_types = "($post_types) AND ( post_author IN ( $users ) )";
349 349
 		}
350 350
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		);
359 359
 
360 360
 		$this->items = $customers;
361
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" );
361
+		$this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types");
362 362
 
363 363
 	}
364 364
 
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 		$columns               = $this->get_columns();
373 373
 		$hidden                = array(); // No hidden columns
374 374
 		$sortable              = $this->get_sortable_columns();
375
-		$this->_column_headers = array( $columns, $hidden, $sortable );
375
+		$this->_column_headers = array($columns, $hidden, $sortable);
376 376
 		$this->prepare_query();
377 377
 
378 378
 		$this->set_pagination_args(
379 379
 			array(
380 380
 			'total_items' => $this->total,
381 381
 			'per_page'    => $this->per_page,
382
-			'total_pages' => ceil( $this->total / $this->per_page )
382
+			'total_pages' => ceil($this->total / $this->per_page)
383 383
 			)
384 384
 		);
385 385
 
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15 15
             echo $discount->get_code();
16 16
         break;
@@ -21,31 +21,31 @@  discard block
 block discarded – undo
21 21
             echo $discount->get_usage();
22 22
         break;
23 23
         case 'start_date' :
24
-            echo getpaid_format_date_value( $discount->get_start_date() );
24
+            echo getpaid_format_date_value($discount->get_start_date());
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) );
27
+            echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_discount' ) {
37
-        $actions = wpinv_discount_row_actions( $post, $actions );
36
+    if ($post_type == 'wpi_discount') {
37
+        $actions = wpinv_discount_row_actions($post, $actions);
38 38
     }
39 39
 
40 40
     return $actions;
41 41
 }
42 42
 
43
-function wpinv_discount_row_actions( $discount, $row_actions ) {
44
-    $row_actions  = array();
45
-    $edit_link = get_edit_post_link( $discount->ID );
46
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
43
+function wpinv_discount_row_actions($discount, $row_actions) {
44
+    $row_actions = array();
45
+    $edit_link = get_edit_post_link($discount->ID);
46
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
47 47
 
48
-    if ( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
48
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
49 49
 
50 50
         $url = wp_nonce_url(
51 51
             add_query_arg(
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
             'getpaid-nonce',
58 58
             'getpaid-nonce'
59 59
         );
60
-		$anchor = __( 'Deactivate', 'invoicing' );
61
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
60
+		$anchor = __('Deactivate', 'invoicing');
61
+		$title  = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing');
62 62
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
63 63
 
64
-    } else if( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
64
+    } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
65 65
 
66
-        $url    = wp_nonce_url(
66
+        $url = wp_nonce_url(
67 67
             add_query_arg(
68 68
                 array(
69 69
                     'getpaid-admin-action' => 'activate_discount',
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
             'getpaid-nonce',
74 74
             'getpaid-nonce'
75 75
         );
76
-		$anchor = __( 'Activate', 'invoicing' );
77
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
76
+		$anchor = __('Activate', 'invoicing');
77
+		$title  = esc_attr__('Are you sure you want to activate this discount?', 'invoicing');
78 78
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
79 79
 
80 80
     }
81 81
 
82
-    $url    = esc_url(
82
+    $url = esc_url(
83 83
         wp_nonce_url(
84 84
             add_query_arg(
85 85
                 array(
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
             'getpaid-nonce'
92 92
         )
93 93
     );
94
-	$anchor = __( 'Delete', 'invoicing' );
95
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
94
+	$anchor = __('Delete', 'invoicing');
95
+	$title  = esc_attr__('Are you sure you want to delete this discount?', 'invoicing');
96 96
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
97 97
 
98
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
98
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
99 99
 
100 100
     return $row_actions;
101 101
 }
@@ -103,68 +103,68 @@  discard block
 block discarded – undo
103 103
 function wpinv_restrict_manage_posts() {
104 104
     global $typenow;
105 105
 
106
-    if( 'wpi_discount' == $typenow ) {
106
+    if ('wpi_discount' == $typenow) {
107 107
         wpinv_discount_filters();
108 108
     }
109 109
 }
110
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
110
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
111 111
 
112 112
 function wpinv_discount_filters() {
113 113
 
114 114
     ?>
115 115
     <select name="discount_type" id="dropdown_wpinv_discount_type">
116
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
116
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
117 117
         <?php
118 118
             $types = wpinv_get_discount_types();
119 119
 
120
-            foreach ( $types as $name => $type ) {
121
-                echo '<option value="' . esc_attr( $name ) . '"';
120
+            foreach ($types as $name => $type) {
121
+                echo '<option value="' . esc_attr($name) . '"';
122 122
 
123
-                if ( isset( $_GET['discount_type'] ) )
124
-                    selected( $name, $_GET['discount_type'] );
123
+                if (isset($_GET['discount_type']))
124
+                    selected($name, $_GET['discount_type']);
125 125
 
126
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
126
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
127 127
             }
128 128
         ?>
129 129
     </select>
130 130
     <?php
131 131
 }
132 132
 
133
-function wpinv_request( $vars ) {
133
+function wpinv_request($vars) {
134 134
     global $typenow, $wp_post_statuses;
135 135
 
136
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
137
-        if ( ! isset( $vars['post_status'] ) ) {
138
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
136
+    if (getpaid_is_invoice_post_type($typenow)) {
137
+        if (!isset($vars['post_status'])) {
138
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
139 139
 
140
-            foreach ( $post_statuses as $status => $value ) {
141
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
142
-                    unset( $post_statuses[ $status ] );
140
+            foreach ($post_statuses as $status => $value) {
141
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
142
+                    unset($post_statuses[$status]);
143 143
                 }
144 144
             }
145 145
 
146
-            $vars['post_status'] = array_keys( $post_statuses );
146
+            $vars['post_status'] = array_keys($post_statuses);
147 147
         }
148 148
 
149
-    } else if ( 'wpi_discount' == $typenow ) {
150
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
149
+    } else if ('wpi_discount' == $typenow) {
150
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
151 151
         // Filter vat rule type
152
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
152
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
153 153
             $meta_query[] = array(
154 154
                     'key'   => '_wpi_discount_type',
155
-                    'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ),
155
+                    'value' => sanitize_key(urldecode($_GET['discount_type'])),
156 156
                     'compare' => '='
157 157
                 );
158 158
         }
159 159
 
160
-        if ( !empty( $meta_query ) ) {
160
+        if (!empty($meta_query)) {
161 161
             $vars['meta_query'] = $meta_query;
162 162
         }
163 163
     }
164 164
 
165 165
     return $vars;
166 166
 }
167
-add_filter( 'request', 'wpinv_request' );
167
+add_filter('request', 'wpinv_request');
168 168
 
169 169
 /**
170 170
  * Create a page and store the ID in an option.
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
  * @param int $post_parent (default: 0) Parent for the new page
177 177
  * @return int page ID
178 178
  */
179
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
179
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
180 180
     global $wpdb;
181 181
 
182
-    $option_value = wpinv_get_option( $option );
182
+    $option_value = wpinv_get_option($option);
183 183
 
184
-    if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) {
185
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
184
+    if (!empty($option_value) && ($page_object = get_post($option_value))) {
185
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
186 186
             // Valid page is already in place
187 187
             return $page_object->ID;
188 188
         }
189 189
     }
190 190
 
191
-    if(!empty($post_parent)){
191
+    if (!empty($post_parent)) {
192 192
         $page = get_page_by_path($post_parent);
193 193
         if ($page) {
194 194
             $post_parent = $page->ID;
@@ -197,40 +197,40 @@  discard block
 block discarded – undo
197 197
         }
198 198
     }
199 199
 
200
-    if ( strlen( $page_content ) > 0 ) {
200
+    if (strlen($page_content) > 0) {
201 201
         // Search for an existing page with the specified page content (typically a shortcode)
202
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
202
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
203 203
     } else {
204 204
         // Search for an existing page with the specified page slug
205
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
205
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
206 206
     }
207 207
 
208
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
208
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
209 209
 
210
-    if ( $valid_page_found ) {
211
-        if ( $option ) {
212
-            wpinv_update_option( $option, $valid_page_found );
210
+    if ($valid_page_found) {
211
+        if ($option) {
212
+            wpinv_update_option($option, $valid_page_found);
213 213
         }
214 214
         return $valid_page_found;
215 215
     }
216 216
 
217 217
     // Search for a matching valid trashed page
218
-    if ( strlen( $page_content ) > 0 ) {
218
+    if (strlen($page_content) > 0) {
219 219
         // Search for an existing page with the specified page content (typically a shortcode)
220
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
220
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
221 221
     } else {
222 222
         // Search for an existing page with the specified page slug
223
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
223
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
224 224
     }
225 225
 
226
-    if ( $trashed_page_found ) {
226
+    if ($trashed_page_found) {
227 227
         $page_id   = $trashed_page_found;
228 228
         $page_data = array(
229 229
             'ID'             => $page_id,
230 230
             'post_status'    => 'publish',
231 231
             'post_parent'    => $post_parent,
232 232
         );
233
-        wp_update_post( $page_data );
233
+        wp_update_post($page_data);
234 234
     } else {
235 235
         $page_data = array(
236 236
             'post_status'    => 'publish',
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
             'post_parent'    => $post_parent,
243 243
             'comment_status' => 'closed',
244 244
         );
245
-        $page_id = wp_insert_post( $page_data );
245
+        $page_id = wp_insert_post($page_data);
246 246
     }
247 247
 
248
-    if ( $option ) {
249
-        wpinv_update_option( $option, (int) $page_id );
248
+    if ($option) {
249
+        wpinv_update_option($option, (int) $page_id);
250 250
     }
251 251
 
252 252
     return $page_id;
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
  *
260 260
  * @return array
261 261
  */
262
-function wpinv_add_aui_screens($screen_ids){
262
+function wpinv_add_aui_screens($screen_ids) {
263 263
 
264 264
     // load on these pages if set
265
-    $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() );
265
+    $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids());
266 266
 
267 267
     return $screen_ids;
268 268
 }
269
-add_filter('aui_screen_ids','wpinv_add_aui_screens');
270 269
\ No newline at end of file
270
+add_filter('aui_screen_ids', 'wpinv_add_aui_screens');
271 271
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/html-gateways-edit.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,29 +4,29 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 $gateways = wpinv_get_payment_gateways();
10
-ksort( $gateways );
10
+ksort($gateways);
11 11
 
12 12
 ?>
13 13
 <div class="table-responsive">
14 14
     <table id="wpinv_gateways_select" class="table border bg-white form-table">
15
-        <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption>
15
+        <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption>
16 16
 
17 17
         <thead>
18 18
             <tr class="table-light">
19 19
 
20 20
                 <th scope="col" class="border-bottom border-top text-left">
21
-                    <?php _e( 'Payment Method', 'invoicing' ); ?>
21
+                    <?php _e('Payment Method', 'invoicing'); ?>
22 22
                 </th>
23 23
 
24 24
                 <th scope="col" class="border-bottom border-top text-center">
25
-                    <?php _e( 'Enabled', 'invoicing' ); ?>
25
+                    <?php _e('Enabled', 'invoicing'); ?>
26 26
                 </th>
27 27
 
28 28
                 <th scope="col" class="border-bottom border-top text-center">
29
-                    <?php _e( 'Supports Subscriptions', 'invoicing' ); ?>
29
+                    <?php _e('Supports Subscriptions', 'invoicing'); ?>
30 30
                 </th>
31 31
 
32 32
                 <th scope="col" class="border-bottom border-top text-right" style="width:32px">&nbsp;</th>
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
         </thead>
36 36
 
37 37
         <tbody>
38
-            <?php foreach ( $gateways as $id => $gateway ) : ?>
38
+            <?php foreach ($gateways as $id => $gateway) : ?>
39 39
                 <tr>
40 40
                     <td class="getpaid-payment-method text-left">
41
-                        <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo esc_html( $gateway['admin_label'] ); ?></a>
41
+                        <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo esc_html($gateway['admin_label']); ?></a>
42 42
                     </td>
43 43
                     <td class="getpaid-payment-method-enabled text-center">
44 44
                         <?php
45 45
 
46
-                            if ( wpinv_is_gateway_active( $id ) ) {
46
+                            if (wpinv_is_gateway_active($id)) {
47 47
                                 echo "<i class='text-success fa fa-check'></i>";
48 48
                             } else {
49 49
                                 echo "<i class='text-dark fa fa-times'></i>";
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
                     <td class="getpaid-payment-method-subscription text-center">
55 55
                         <?php
56 56
 
57
-                            $supports = apply_filters( "wpinv_{$id}_support_subscription", false );
58
-                            $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id );
57
+                            $supports = apply_filters("wpinv_{$id}_support_subscription", false);
58
+                            $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id);
59 59
 
60
-                            if ( $supports ) {
60
+                            if ($supports) {
61 61
                                 echo "<i class='text-success fa fa-check'></i>";
62 62
                             } else {
63 63
                                 echo "<i class='text-dark fa fa-times'></i>";
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                     </td>
68 68
 
69 69
                     <td class="getpaid-payment-method-action text-right">
70
-                        <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a>
70
+                        <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a>
71 71
                     </td>
72 72
 
73 73
                 </tr>
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
         <tfoot>
78 78
             <tr class="table-light">
79 79
                 <td colspan="4" class="border-top">
80
-                    <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url( admin_url( 'admin.php?page=wpi-addons&tab=gateways' ) ); ?>">
81
-                        <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span>
80
+                    <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url(admin_url('admin.php?page=wpi-addons&tab=gateways')); ?>">
81
+                        <span><?php _e('Add Payment Methods', 'invoicing'); ?></span>
82 82
                     </a>
83 83
                 </td>
84 84
             </tr>
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rate-edit.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @var array $tax_rate
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 ?>
12 12
 
@@ -18,54 +18,54 @@  discard block
 block discarded – undo
18 18
             $country = aui()->select(
19 19
                 array(
20 20
                     'options'     => array_merge(
21
-                        array( '' => __( 'All Countries', 'invoicing' ) ),
21
+                        array('' => __('All Countries', 'invoicing')),
22 22
                         wpinv_get_country_list()
23 23
                     ),
24 24
                     'name'        => "tax_rates[$key][country]",
25
-                    'id'          => uniqid( 'tax_rate_country' ),
26
-                    'value'       => esc_html( $tax_rate['country'] ),
27
-                    'label'       => __( 'Country', 'invoicing' ),
25
+                    'id'          => uniqid('tax_rate_country'),
26
+                    'value'       => esc_html($tax_rate['country']),
27
+                    'label'       => __('Country', 'invoicing'),
28 28
                     'class'       => 'wpinv_country',
29 29
                     'no_wrap'     => true,
30 30
                 )
31 31
             );
32 32
 
33
-            echo str_replace( 'custom-select', '', $country );
33
+            echo str_replace('custom-select', '', $country);
34 34
         ?>
35 35
     </td>
36 36
 
37 37
     <td class="wpinv_tax_state">
38 38
 
39 39
         <label class="w-100">
40
-            <span class="screen-reader-text"><?php _e( 'States', 'invoicing' ); ?></span>
41
-            <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo esc_attr( $key ) ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? esc_attr( $tax_rate['state'] ) : ''; ?>"/>
40
+            <span class="screen-reader-text"><?php _e('States', 'invoicing'); ?></span>
41
+            <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo esc_attr($key) ?>][state]" value="<?php echo empty($tax_rate['global']) ? esc_attr($tax_rate['state']) : ''; ?>"/>
42 42
         </label>
43 43
 
44 44
     </td>
45 45
 
46 46
     <td class="wpinv_standard_rate">
47 47
         <label class="w-100">
48
-            <span class="screen-reader-text"><?php _e( 'Standard Rate', 'invoicing' ); ?></span>
49
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ) ?>][rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['rate'] ); ?>"/>
48
+            <span class="screen-reader-text"><?php _e('Standard Rate', 'invoicing'); ?></span>
49
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key) ?>][rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['rate']); ?>"/>
50 50
         </label>
51 51
     </td>
52 52
 
53 53
     <td class="wpinv_reduced_rate">
54 54
         <label class="w-100">
55
-            <span class="screen-reader-text"><?php _e( 'Reduced Rate', 'invoicing' ); ?></span>
56
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ) ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['reduced_rate'] ); ?>"/>
55
+            <span class="screen-reader-text"><?php _e('Reduced Rate', 'invoicing'); ?></span>
56
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key) ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['reduced_rate']); ?>"/>
57 57
         </label>
58 58
     </td>
59 59
 
60 60
     <td class="wpinv_tax_name">
61 61
         <label class="w-100">
62
-            <span class="screen-reader-text"><?php _e( 'Tax Name', 'invoicing' ); ?></span>
63
-            <input type="text" name="tax_rates[<?php echo esc_attr( $key ) ?>][name]" value="<?php echo esc_attr( $tax_rate['name'] ); ?>"/>
62
+            <span class="screen-reader-text"><?php _e('Tax Name', 'invoicing'); ?></span>
63
+            <input type="text" name="tax_rates[<?php echo esc_attr($key) ?>][name]" value="<?php echo esc_attr($tax_rate['name']); ?>"/>
64 64
         </label>
65 65
     </td>
66 66
 
67 67
     <td class="wpinv_tax_remove">
68
-        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>">
68
+        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>">
69 69
             <span aria-hidden="true">&times;</span>
70 70
         </button>
71 71
     </td>
Please login to merge, or discard this patch.
templates/payment-forms/elements/price_select.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Ensure that we have options.
13
-if ( empty( $options ) ) {
13
+if (empty($options)) {
14 14
     return;
15 15
 }
16 16
 
17 17
 // Prepare price options.
18
-$options = getpaid_convert_price_string_to_options( $options );
19
-$keys    = array_keys( $options );
20
-$value   = empty( $options ) ? '' : $keys[0];
18
+$options = getpaid_convert_price_string_to_options($options);
19
+$keys    = array_keys($options);
20
+$value   = empty($options) ? '' : $keys[0];
21 21
 
22 22
 // Prepare id.
23
-$id = esc_attr( $id );
23
+$id = esc_attr($id);
24 24
 
25
-$select_type = empty( $select_type ) ? 'select' : $select_type;
25
+$select_type = empty($select_type) ? 'select' : $select_type;
26 26
 
27 27
 // Item select;
28
-if ( $select_type == 'select' ) {
28
+if ($select_type == 'select') {
29 29
     echo aui()->select(
30 30
         array(
31 31
             'name'       => $id,
32
-            'id'         => $id . uniqid( '_' ),
33
-            'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ),
32
+            'id'         => $id . uniqid('_'),
33
+            'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder),
34 34
             'value'      => $value,
35
-            'label'      => empty( $label ) ? '' : esc_html( $label ),
35
+            'label'      => empty($label) ? '' : esc_html($label),
36 36
             'label_type' => 'vertical',
37 37
             'class'      => 'getpaid-price-select-dropdown getpaid-refresh-on-change',
38
-            'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
38
+            'help_text'  => empty($description) ? '' : wp_kses_post($description),
39 39
             'options'    => $options,
40 40
         )
41 41
     );
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
 }
44 44
 
45 45
 // Item radios;
46
-if ( $select_type == 'radios' ) {
46
+if ($select_type == 'radios') {
47 47
     echo aui()->radio(
48 48
         array(
49
-            'name'       => esc_attr( $id ),
50
-            'id'         => esc_attr( $id ) . uniqid( '_' ),
51
-            'label'      => empty( $label ) ? '' : esc_html( $label ),
49
+            'name'       => esc_attr($id),
50
+            'id'         => esc_attr($id) . uniqid('_'),
51
+            'label'      => empty($label) ? '' : esc_html($label),
52 52
             'label_type' => 'vertical',
53 53
             'class'      => 'getpaid-price-select-radio getpaid-refresh-on-change w-100',
54 54
             'value'      => $value,
55 55
             'inline'     => false,
56 56
             'options'    => $options,
57
-            'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
57
+            'help_text'  => empty($description) ? '' : wp_kses_post($description),
58 58
         )
59 59
     );
60 60
     return;
@@ -62,30 +62,30 @@  discard block
 block discarded – undo
62 62
 
63 63
 
64 64
 // Display the label.
65
-if ( ! empty( $label ) ) {
66
-    $label = esc_html( $label );
65
+if (!empty($label)) {
66
+    $label = esc_html($label);
67 67
     echo "<label>$label</label>";
68 68
 }
69 69
 
70 70
 // Item buttons;
71
-if ( $select_type == 'buttons' || $select_type == 'circles' ) {
71
+if ($select_type == 'buttons' || $select_type == 'circles') {
72 72
 
73 73
     $class = 'getpaid-price-buttons';
74 74
 
75
-    if ( $select_type == 'circles' ) {
75
+    if ($select_type == 'circles') {
76 76
         $class .= ' getpaid-price-circles';
77 77
     }
78 78
     echo "<div class='$class'>";
79 79
 
80
-    foreach ( $options as $price => $label ) {
81
-        $label   = esc_html( $label );
82
-        $price   = esc_attr( $price );
83
-        $_id     = $id . uniqid( '_' );
84
-        $checked = checked( $price, $value, false );
80
+    foreach ($options as $price => $label) {
81
+        $label   = esc_html($label);
82
+        $price   = esc_attr($price);
83
+        $_id     = $id . uniqid('_');
84
+        $checked = checked($price, $value, false);
85 85
 
86 86
         $class = 'rounded';
87 87
 
88
-        if ( $select_type == 'circles' ) {
88
+        if ($select_type == 'circles') {
89 89
             $class = '';
90 90
         }
91 91
         echo "
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 }
102 102
 
103 103
 // Item checkboxes;
104
-if ( $select_type == 'checkboxes' ) {
104
+if ($select_type == 'checkboxes') {
105 105
     echo '<div class="form-group">';
106 106
 
107
-    foreach ( $options as $price => $label ) {
108
-        $label   = esc_html( $label );
109
-        $price   = esc_attr( $price );
110
-        $checked = checked( $price, $value, false );
107
+    foreach ($options as $price => $label) {
108
+        $label   = esc_html($label);
109
+        $price   = esc_attr($price);
110
+        $checked = checked($price, $value, false);
111 111
         echo "
112 112
             <label class='d-block'>
113 113
                 <input type='checkbox' class='getpaid-price-select-checkbox getpaid-refresh-on-change w-auto' name='{$id}[]' value='$price' $checked />
@@ -120,6 +120,6 @@  discard block
 block discarded – undo
120 120
 
121 121
 }
122 122
 
123
-if ( ! empty( $description ) ) {
123
+if (!empty($description)) {
124 124
     echo "<small class='form-text text-muted'>$description</small>";
125 125
 }
Please login to merge, or discard this patch.