Passed
Pull Request — master (#375)
by Brian
85:55 queued 10s
created
includes/class-getpaid-payment-form.php 2 patches
Indentation   +408 added lines, -408 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,48 +10,48 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'payment_form';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'payment_form';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'payment_form';
25 25
 
26 26
     /**
27
-	 * Form Data array. This is the core form data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'status'               => 'draft',
34
-		'version'              => '',
35
-		'date_created'         => null,
27
+     * Form Data array. This is the core form data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'status'               => 'draft',
34
+        'version'              => '',
35
+        'date_created'         => null,
36 36
         'date_modified'        => null,
37 37
         'name'                 => '',
38 38
         'author'               => 1,
39 39
         'elements'             => null,
40
-		'items'                => null,
41
-		'earned'               => 0,
42
-		'refunded'             => 0,
43
-		'cancelled'            => 0,
44
-		'failed'               => 0,
45
-	);
40
+        'items'                => null,
41
+        'earned'               => 0,
42
+        'refunded'             => 0,
43
+        'cancelled'            => 0,
44
+        'failed'               => 0,
45
+    );
46 46
 
47 47
     /**
48
-	 * Stores meta in cache for future reads.
49
-	 *
50
-	 * A group must be set to to enable caching.
51
-	 *
52
-	 * @var string
53
-	 */
54
-	protected $cache_group = 'getpaid_forms';
48
+     * Stores meta in cache for future reads.
49
+     *
50
+     * A group must be set to to enable caching.
51
+     *
52
+     * @var string
53
+     */
54
+    protected $cache_group = 'getpaid_forms';
55 55
 
56 56
     /**
57 57
      * Stores a reference to the original WP_Post object
@@ -61,32 +61,32 @@  discard block
 block discarded – undo
61 61
     protected $post = null;
62 62
 
63 63
     /**
64
-	 * Get the form if ID is passed, otherwise the form is new and empty.
65
-	 *
66
-	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
67
-	 */
68
-	public function __construct( $form = 0 ) {
69
-		parent::__construct( $form );
70
-
71
-		if ( is_numeric( $form ) && $form > 0 ) {
72
-			$this->set_id( $form );
73
-		} elseif ( $form instanceof self ) {
74
-			$this->set_id( $form->get_id() );
75
-		} elseif ( ! empty( $form->ID ) ) {
76
-			$this->set_id( $form->ID );
77
-		} else {
78
-			$this->set_object_read( true );
79
-		}
64
+     * Get the form if ID is passed, otherwise the form is new and empty.
65
+     *
66
+     * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
67
+     */
68
+    public function __construct( $form = 0 ) {
69
+        parent::__construct( $form );
70
+
71
+        if ( is_numeric( $form ) && $form > 0 ) {
72
+            $this->set_id( $form );
73
+        } elseif ( $form instanceof self ) {
74
+            $this->set_id( $form->get_id() );
75
+        } elseif ( ! empty( $form->ID ) ) {
76
+            $this->set_id( $form->ID );
77
+        } else {
78
+            $this->set_object_read( true );
79
+        }
80 80
 
81 81
         // Load the datastore.
82
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
82
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
83 83
 
84
-		if ( $this->get_id() > 0 ) {
84
+        if ( $this->get_id() > 0 ) {
85 85
             $this->post = get_post( $this->get_id() );
86
-			$this->data_store->read( $this );
86
+            $this->data_store->read( $this );
87 87
         }
88 88
 
89
-	}
89
+    }
90 90
 
91 91
     /*
92 92
 	|--------------------------------------------------------------------------
@@ -104,245 +104,245 @@  discard block
 block discarded – undo
104 104
     */
105 105
 
106 106
     /**
107
-	 * Get plugin version when the form was created.
108
-	 *
109
-	 * @since 1.0.19
110
-	 * @param  string $context View or edit context.
111
-	 * @return string
112
-	 */
113
-	public function get_version( $context = 'view' ) {
114
-		return $this->get_prop( 'version', $context );
107
+     * Get plugin version when the form was created.
108
+     *
109
+     * @since 1.0.19
110
+     * @param  string $context View or edit context.
111
+     * @return string
112
+     */
113
+    public function get_version( $context = 'view' ) {
114
+        return $this->get_prop( 'version', $context );
115 115
     }
116 116
 
117 117
     /**
118
-	 * Get date when the form was created.
119
-	 *
120
-	 * @since 1.0.19
121
-	 * @param  string $context View or edit context.
122
-	 * @return string
123
-	 */
124
-	public function get_date_created( $context = 'view' ) {
125
-		return $this->get_prop( 'date_created', $context );
118
+     * Get date when the form was created.
119
+     *
120
+     * @since 1.0.19
121
+     * @param  string $context View or edit context.
122
+     * @return string
123
+     */
124
+    public function get_date_created( $context = 'view' ) {
125
+        return $this->get_prop( 'date_created', $context );
126 126
     }
127 127
 
128 128
     /**
129
-	 * Get GMT date when the form was created.
130
-	 *
131
-	 * @since 1.0.19
132
-	 * @param  string $context View or edit context.
133
-	 * @return string
134
-	 */
135
-	public function get_date_created_gmt( $context = 'view' ) {
129
+     * Get GMT date when the form was created.
130
+     *
131
+     * @since 1.0.19
132
+     * @param  string $context View or edit context.
133
+     * @return string
134
+     */
135
+    public function get_date_created_gmt( $context = 'view' ) {
136 136
         $date = $this->get_date_created( $context );
137 137
 
138 138
         if ( $date ) {
139 139
             $date = get_gmt_from_date( $date );
140 140
         }
141
-		return $date;
141
+        return $date;
142 142
     }
143 143
 
144 144
     /**
145
-	 * Get date when the form was last modified.
146
-	 *
147
-	 * @since 1.0.19
148
-	 * @param  string $context View or edit context.
149
-	 * @return string
150
-	 */
151
-	public function get_date_modified( $context = 'view' ) {
152
-		return $this->get_prop( 'date_modified', $context );
145
+     * Get date when the form was last modified.
146
+     *
147
+     * @since 1.0.19
148
+     * @param  string $context View or edit context.
149
+     * @return string
150
+     */
151
+    public function get_date_modified( $context = 'view' ) {
152
+        return $this->get_prop( 'date_modified', $context );
153 153
     }
154 154
 
155 155
     /**
156
-	 * Get GMT date when the form was last modified.
157
-	 *
158
-	 * @since 1.0.19
159
-	 * @param  string $context View or edit context.
160
-	 * @return string
161
-	 */
162
-	public function get_date_modified_gmt( $context = 'view' ) {
156
+     * Get GMT date when the form was last modified.
157
+     *
158
+     * @since 1.0.19
159
+     * @param  string $context View or edit context.
160
+     * @return string
161
+     */
162
+    public function get_date_modified_gmt( $context = 'view' ) {
163 163
         $date = $this->get_date_modified( $context );
164 164
 
165 165
         if ( $date ) {
166 166
             $date = get_gmt_from_date( $date );
167 167
         }
168
-		return $date;
168
+        return $date;
169 169
     }
170 170
 
171 171
     /**
172
-	 * Get the form name.
173
-	 *
174
-	 * @since 1.0.19
175
-	 * @param  string $context View or edit context.
176
-	 * @return string
177
-	 */
178
-	public function get_name( $context = 'view' ) {
179
-		return $this->get_prop( 'name', $context );
172
+     * Get the form name.
173
+     *
174
+     * @since 1.0.19
175
+     * @param  string $context View or edit context.
176
+     * @return string
177
+     */
178
+    public function get_name( $context = 'view' ) {
179
+        return $this->get_prop( 'name', $context );
180 180
     }
181 181
 
182 182
     /**
183
-	 * Alias of self::get_name().
184
-	 *
185
-	 * @since 1.0.19
186
-	 * @param  string $context View or edit context.
187
-	 * @return string
188
-	 */
189
-	public function get_title( $context = 'view' ) {
190
-		return $this->get_name( $context );
191
-	}
183
+     * Alias of self::get_name().
184
+     *
185
+     * @since 1.0.19
186
+     * @param  string $context View or edit context.
187
+     * @return string
188
+     */
189
+    public function get_title( $context = 'view' ) {
190
+        return $this->get_name( $context );
191
+    }
192 192
 
193 193
     /**
194
-	 * Get the owner of the form.
195
-	 *
196
-	 * @since 1.0.19
197
-	 * @param  string $context View or edit context.
198
-	 * @return int
199
-	 */
200
-	public function get_author( $context = 'view' ) {
201
-		return (int) $this->get_prop( 'author', $context );
194
+     * Get the owner of the form.
195
+     *
196
+     * @since 1.0.19
197
+     * @param  string $context View or edit context.
198
+     * @return int
199
+     */
200
+    public function get_author( $context = 'view' ) {
201
+        return (int) $this->get_prop( 'author', $context );
202 202
     }
203 203
 
204 204
     /**
205
-	 * Get the elements that make up the form.
206
-	 *
207
-	 * @since 1.0.19
208
-	 * @param  string $context View or edit context.
209
-	 * @return array
210
-	 */
211
-	public function get_elements( $context = 'view' ) {
212
-		$elements = $this->get_prop( 'elements', $context );
205
+     * Get the elements that make up the form.
206
+     *
207
+     * @since 1.0.19
208
+     * @param  string $context View or edit context.
209
+     * @return array
210
+     */
211
+    public function get_elements( $context = 'view' ) {
212
+        $elements = $this->get_prop( 'elements', $context );
213 213
 
214
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
214
+        if ( empty( $elements ) || ! is_array( $elements ) ) {
215 215
             return wpinv_get_data( 'sample-payment-form' );
216 216
         }
217 217
         return $elements;
218
-	}
219
-
220
-	/**
221
-	 * Get the items sold via the form.
222
-	 *
223
-	 * @since 1.0.19
224
-	 * @param  string $context View or edit context.
225
-	 * @param  string $return objects or arrays.
226
-	 * @return GetPaid_Form_Item[]|array
227
-	 */
228
-	public function get_items( $context = 'view', $return = 'objects' ) {
229
-		$items = $this->get_prop( 'items', $context );
230
-
231
-		if ( empty( $items ) || ! is_array( $items ) ) {
218
+    }
219
+
220
+    /**
221
+     * Get the items sold via the form.
222
+     *
223
+     * @since 1.0.19
224
+     * @param  string $context View or edit context.
225
+     * @param  string $return objects or arrays.
226
+     * @return GetPaid_Form_Item[]|array
227
+     */
228
+    public function get_items( $context = 'view', $return = 'objects' ) {
229
+        $items = $this->get_prop( 'items', $context );
230
+
231
+        if ( empty( $items ) || ! is_array( $items ) ) {
232 232
             $items = wpinv_get_data( 'sample-payment-form-items' );
233
-		}
233
+        }
234 234
 		
235
-		if ( 'view' != $context ) {
236
-			return $items;
237
-		}
238
-
239
-		// Convert the items.
240
-		$prepared = array();
241
-
242
-		foreach ( $items as $key => $value ) {
243
-
244
-			// $item_id => $quantity
245
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
246
-				$item   = new GetPaid_Form_Item( $key );
247
-
248
-				if ( $item->can_purchase() ) {
249
-					$item->set_quantity( $value );
250
-					$prepared[] = $item;
251
-				}
252
-
253
-				continue;
254
-			}
255
-
256
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
257
-
258
-				$item = new GetPaid_Form_Item( $value['id'] );
259
-
260
-				if ( ! $item->can_purchase() ) {
261
-					continue;
262
-				}
263
-
264
-				// Sub-total (Cart items).
265
-				if ( isset( $value['subtotal'] ) ) {
266
-					$item->set_price( $value['subtotal'] );
267
-				}
268
-
269
-				if ( isset( $value['quantity'] ) ) {
270
-					$item->set_quantity( $value['quantity'] );
271
-				}
272
-
273
-				if ( isset( $value['allow_quantities'] ) ) {
274
-					$item->set_allow_quantities( $value['allow_quantities'] );
275
-				}
276
-
277
-				if ( isset( $value['required'] ) ) {
278
-					$item->set_is_required( $value['required'] );
279
-				}
280
-
281
-				if ( isset( $value['description'] ) ) {
282
-					$item->set_custom_description( $value['description'] );
283
-				}
284
-
285
-				$prepared[] = $item;
286
-				continue;
287
-
288
-			}
289
-		}
290
-
291
-		if ( 'objects' == $return ) {
292
-			return $prepared;
293
-		}
294
-
295
-		$items = array();
296
-		foreach ( $prepared as $item ) {
297
-			$items[] = $item->prepare_data_for_use();
298
-		}
299
-
300
-		return $items;
301
-	}
302
-
303
-	/**
304
-	 * Get the total amount earned via this form.
305
-	 *
306
-	 * @since 1.0.19
307
-	 * @param  string $context View or edit context.
308
-	 * @return array
309
-	 */
310
-	public function get_earned( $context = 'view' ) {
311
-		return $this->get_prop( 'earned', $context );
312
-	}
313
-
314
-	/**
315
-	 * Get the total amount refunded via this form.
316
-	 *
317
-	 * @since 1.0.19
318
-	 * @param  string $context View or edit context.
319
-	 * @return array
320
-	 */
321
-	public function get_refunded( $context = 'view' ) {
322
-		return $this->get_prop( 'refunded', $context );
323
-	}
324
-
325
-	/**
326
-	 * Get the total amount cancelled via this form.
327
-	 *
328
-	 * @since 1.0.19
329
-	 * @param  string $context View or edit context.
330
-	 * @return array
331
-	 */
332
-	public function get_cancelled( $context = 'view' ) {
333
-		return $this->get_prop( 'cancelled', $context );
334
-	}
335
-
336
-	/**
337
-	 * Get the total amount failed via this form.
338
-	 *
339
-	 * @since 1.0.19
340
-	 * @param  string $context View or edit context.
341
-	 * @return array
342
-	 */
343
-	public function get_failed( $context = 'view' ) {
344
-		return $this->get_prop( 'failed', $context );
345
-	}
235
+        if ( 'view' != $context ) {
236
+            return $items;
237
+        }
238
+
239
+        // Convert the items.
240
+        $prepared = array();
241
+
242
+        foreach ( $items as $key => $value ) {
243
+
244
+            // $item_id => $quantity
245
+            if ( is_numeric( $key ) && is_numeric( $value ) ) {
246
+                $item   = new GetPaid_Form_Item( $key );
247
+
248
+                if ( $item->can_purchase() ) {
249
+                    $item->set_quantity( $value );
250
+                    $prepared[] = $item;
251
+                }
252
+
253
+                continue;
254
+            }
255
+
256
+            if ( is_array( $value ) && isset( $value['id'] ) ) {
257
+
258
+                $item = new GetPaid_Form_Item( $value['id'] );
259
+
260
+                if ( ! $item->can_purchase() ) {
261
+                    continue;
262
+                }
263
+
264
+                // Sub-total (Cart items).
265
+                if ( isset( $value['subtotal'] ) ) {
266
+                    $item->set_price( $value['subtotal'] );
267
+                }
268
+
269
+                if ( isset( $value['quantity'] ) ) {
270
+                    $item->set_quantity( $value['quantity'] );
271
+                }
272
+
273
+                if ( isset( $value['allow_quantities'] ) ) {
274
+                    $item->set_allow_quantities( $value['allow_quantities'] );
275
+                }
276
+
277
+                if ( isset( $value['required'] ) ) {
278
+                    $item->set_is_required( $value['required'] );
279
+                }
280
+
281
+                if ( isset( $value['description'] ) ) {
282
+                    $item->set_custom_description( $value['description'] );
283
+                }
284
+
285
+                $prepared[] = $item;
286
+                continue;
287
+
288
+            }
289
+        }
290
+
291
+        if ( 'objects' == $return ) {
292
+            return $prepared;
293
+        }
294
+
295
+        $items = array();
296
+        foreach ( $prepared as $item ) {
297
+            $items[] = $item->prepare_data_for_use();
298
+        }
299
+
300
+        return $items;
301
+    }
302
+
303
+    /**
304
+     * Get the total amount earned via this form.
305
+     *
306
+     * @since 1.0.19
307
+     * @param  string $context View or edit context.
308
+     * @return array
309
+     */
310
+    public function get_earned( $context = 'view' ) {
311
+        return $this->get_prop( 'earned', $context );
312
+    }
313
+
314
+    /**
315
+     * Get the total amount refunded via this form.
316
+     *
317
+     * @since 1.0.19
318
+     * @param  string $context View or edit context.
319
+     * @return array
320
+     */
321
+    public function get_refunded( $context = 'view' ) {
322
+        return $this->get_prop( 'refunded', $context );
323
+    }
324
+
325
+    /**
326
+     * Get the total amount cancelled via this form.
327
+     *
328
+     * @since 1.0.19
329
+     * @param  string $context View or edit context.
330
+     * @return array
331
+     */
332
+    public function get_cancelled( $context = 'view' ) {
333
+        return $this->get_prop( 'cancelled', $context );
334
+    }
335
+
336
+    /**
337
+     * Get the total amount failed via this form.
338
+     *
339
+     * @since 1.0.19
340
+     * @param  string $context View or edit context.
341
+     * @return array
342
+     */
343
+    public function get_failed( $context = 'view' ) {
344
+        return $this->get_prop( 'failed', $context );
345
+    }
346 346
 
347 347
     /*
348 348
 	|--------------------------------------------------------------------------
@@ -355,22 +355,22 @@  discard block
 block discarded – undo
355 355
     */
356 356
 
357 357
     /**
358
-	 * Set plugin version when the item was created.
359
-	 *
360
-	 * @since 1.0.19
361
-	 */
362
-	public function set_version( $value ) {
363
-		$this->set_prop( 'version', $value );
358
+     * Set plugin version when the item was created.
359
+     *
360
+     * @since 1.0.19
361
+     */
362
+    public function set_version( $value ) {
363
+        $this->set_prop( 'version', $value );
364 364
     }
365 365
 
366 366
     /**
367
-	 * Set date when the item was created.
368
-	 *
369
-	 * @since 1.0.19
370
-	 * @param string $value Value to set.
367
+     * Set date when the item was created.
368
+     *
369
+     * @since 1.0.19
370
+     * @param string $value Value to set.
371 371
      * @return bool Whether or not the date was set.
372
-	 */
373
-	public function set_date_created( $value ) {
372
+     */
373
+    public function set_date_created( $value ) {
374 374
         $date = strtotime( $value );
375 375
 
376 376
         if ( $date ) {
@@ -383,13 +383,13 @@  discard block
 block discarded – undo
383 383
     }
384 384
 
385 385
     /**
386
-	 * Set date when the item was last modified.
387
-	 *
388
-	 * @since 1.0.19
389
-	 * @param string $value Value to set.
386
+     * Set date when the item was last modified.
387
+     *
388
+     * @since 1.0.19
389
+     * @param string $value Value to set.
390 390
      * @return bool Whether or not the date was set.
391
-	 */
392
-	public function set_date_modified( $value ) {
391
+     */
392
+    public function set_date_modified( $value ) {
393 393
         $date = strtotime( $value );
394 394
 
395 395
         if ( $date ) {
@@ -402,118 +402,118 @@  discard block
 block discarded – undo
402 402
     }
403 403
 
404 404
     /**
405
-	 * Set the item name.
406
-	 *
407
-	 * @since 1.0.19
408
-	 * @param  string $value New name.
409
-	 */
410
-	public function set_name( $value ) {
411
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
412
-    }
413
-
414
-    /**
415
-	 * Alias of self::set_name().
416
-	 *
417
-	 * @since 1.0.19
418
-	 * @param  string $value New name.
419
-	 */
420
-	public function set_title( $value ) {
421
-		$this->set_name( $value );
422
-    }
423
-
424
-    /**
425
-	 * Set the owner of the item.
426
-	 *
427
-	 * @since 1.0.19
428
-	 * @param  int $value New author.
429
-	 */
430
-	public function set_author( $value ) {
431
-		$this->set_prop( 'author', (int) $value );
432
-	}
433
-
434
-	/**
435
-	 * Set the form elements.
436
-	 *
437
-	 * @since 1.0.19
438
-	 * @param  array $value Form elements.
439
-	 */
440
-	public function set_elements( $value ) {
441
-		if ( is_array( $value ) ) {
442
-			$this->set_prop( 'elements', $value );
443
-		}
444
-	}
445
-
446
-	/**
447
-	 * Set the form items.
448
-	 *
449
-	 * @since 1.0.19
450
-	 * @param  array $value Form elements.
451
-	 */
452
-	public function set_items( $value ) {
453
-		if ( is_array( $value ) ) {
454
-			$this->set_prop( 'items', $value );
455
-		}
456
-	}
405
+     * Set the item name.
406
+     *
407
+     * @since 1.0.19
408
+     * @param  string $value New name.
409
+     */
410
+    public function set_name( $value ) {
411
+        $this->set_prop( 'name', sanitize_text_field( $value ) );
412
+    }
413
+
414
+    /**
415
+     * Alias of self::set_name().
416
+     *
417
+     * @since 1.0.19
418
+     * @param  string $value New name.
419
+     */
420
+    public function set_title( $value ) {
421
+        $this->set_name( $value );
422
+    }
423
+
424
+    /**
425
+     * Set the owner of the item.
426
+     *
427
+     * @since 1.0.19
428
+     * @param  int $value New author.
429
+     */
430
+    public function set_author( $value ) {
431
+        $this->set_prop( 'author', (int) $value );
432
+    }
433
+
434
+    /**
435
+     * Set the form elements.
436
+     *
437
+     * @since 1.0.19
438
+     * @param  array $value Form elements.
439
+     */
440
+    public function set_elements( $value ) {
441
+        if ( is_array( $value ) ) {
442
+            $this->set_prop( 'elements', $value );
443
+        }
444
+    }
445
+
446
+    /**
447
+     * Set the form items.
448
+     *
449
+     * @since 1.0.19
450
+     * @param  array $value Form elements.
451
+     */
452
+    public function set_items( $value ) {
453
+        if ( is_array( $value ) ) {
454
+            $this->set_prop( 'items', $value );
455
+        }
456
+    }
457 457
 	
458
-	/**
459
-	 * Set the total amount earned via this form.
460
-	 *
461
-	 * @since 1.0.19
462
-	 * @param  float $value Amount earned.
463
-	 * @return array
464
-	 */
465
-	public function set_earned( $value ) {
466
-		return $this->set_prop( 'earned', $value );
467
-	}
468
-
469
-	/**
470
-	 * Set the total amount refunded via this form.
471
-	 *
472
-	 * @since 1.0.19
473
-	 * @param  float $value Amount refunded.
474
-	 * @return array
475
-	 */
476
-	public function set_refunded( $value ) {
477
-		return $this->set_prop( 'refunded', $value );
478
-	}
479
-
480
-	/**
481
-	 * Set the total amount cancelled via this form.
482
-	 *
483
-	 * @since 1.0.19
484
-	 * @param  float $value Amount cancelled.
485
-	 * @return array
486
-	 */
487
-	public function set_cancelled( $value ) {
488
-		return $this->set_prop( 'cancelled', $value );
489
-	}
490
-
491
-	/**
492
-	 * Set the total amount failed via this form.
493
-	 *
494
-	 * @since 1.0.19
495
-	 * @param  float $value Amount cancelled.
496
-	 * @return array
497
-	 */
498
-	public function set_failed( $value ) {
499
-		return $this->set_prop( 'failed', $value );
500
-	}
458
+    /**
459
+     * Set the total amount earned via this form.
460
+     *
461
+     * @since 1.0.19
462
+     * @param  float $value Amount earned.
463
+     * @return array
464
+     */
465
+    public function set_earned( $value ) {
466
+        return $this->set_prop( 'earned', $value );
467
+    }
468
+
469
+    /**
470
+     * Set the total amount refunded via this form.
471
+     *
472
+     * @since 1.0.19
473
+     * @param  float $value Amount refunded.
474
+     * @return array
475
+     */
476
+    public function set_refunded( $value ) {
477
+        return $this->set_prop( 'refunded', $value );
478
+    }
479
+
480
+    /**
481
+     * Set the total amount cancelled via this form.
482
+     *
483
+     * @since 1.0.19
484
+     * @param  float $value Amount cancelled.
485
+     * @return array
486
+     */
487
+    public function set_cancelled( $value ) {
488
+        return $this->set_prop( 'cancelled', $value );
489
+    }
490
+
491
+    /**
492
+     * Set the total amount failed via this form.
493
+     *
494
+     * @since 1.0.19
495
+     * @param  float $value Amount cancelled.
496
+     * @return array
497
+     */
498
+    public function set_failed( $value ) {
499
+        return $this->set_prop( 'failed', $value );
500
+    }
501 501
 
502 502
     /**
503 503
      * Create an item. For backwards compatibilty.
504 504
      *
505 505
      * @deprecated
506
-	 * @return int item id
506
+     * @return int item id
507 507
      */
508 508
     public function create( $data = array() ) {
509 509
 
510
-		// Set the properties.
511
-		if ( is_array( $data ) ) {
512
-			$this->set_props( $data );
513
-		}
510
+        // Set the properties.
511
+        if ( is_array( $data ) ) {
512
+            $this->set_props( $data );
513
+        }
514 514
 
515
-		// Save the item.
516
-		return $this->save();
515
+        // Save the item.
516
+        return $this->save();
517 517
 
518 518
     }
519 519
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      * Updates an item. For backwards compatibilty.
522 522
      *
523 523
      * @deprecated
524
-	 * @return int item id
524
+     * @return int item id
525 525
      */
526 526
     public function update( $data = array() ) {
527 527
         return $this->create( $data );
@@ -537,22 +537,22 @@  discard block
 block discarded – undo
537 537
 	*/
538 538
 
539 539
     /**
540
-	 * Checks whether this is the default payment form.
541
-	 *
542
-	 * @since 1.0.19
543
-	 * @return bool
544
-	 */
540
+     * Checks whether this is the default payment form.
541
+     *
542
+     * @since 1.0.19
543
+     * @return bool
544
+     */
545 545
     public function is_default() {
546 546
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
547 547
         return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
548
-	}
548
+    }
549 549
 
550 550
     /**
551
-	 * Checks whether the form is active.
552
-	 *
553
-	 * @since 1.0.19
554
-	 * @return bool
555
-	 */
551
+     * Checks whether the form is active.
552
+     *
553
+     * @since 1.0.19
554
+     * @return bool
555
+     */
556 556
     public function is_active() {
557 557
         $is_active = null !== $this->get_id();
558 558
 
@@ -561,33 +561,33 @@  discard block
 block discarded – undo
561 561
         }
562 562
 
563 563
         return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
564
-	}
564
+    }
565 565
 	
566
-	/**
567
-	 * Displays the payment form.
568
-	 *
569
-	 * @param bool $echo whether to return or echo the value.
570
-	 * @since 1.0.19
571
-	 */
566
+    /**
567
+     * Displays the payment form.
568
+     *
569
+     * @param bool $echo whether to return or echo the value.
570
+     * @since 1.0.19
571
+     */
572 572
     public function display( $echo = true ) {
573
-		global $invoicing;
573
+        global $invoicing;
574 574
 		
575
-		// Ensure that it is active.
576
-		if ( ! $this->is_active() ) {
577
-			$html = aui()->alert(
578
-				array(
579
-					'type'    => 'warning',
580
-					'content' => __( 'This payment form is no longer active', 'invoicing' ),
581
-				)
582
-			);
583
-
584
-			if ( $echo ) {
585
-				echo $html;
586
-				return;
587
-			}
588
-
589
-			return $html;
590
-		}
575
+        // Ensure that it is active.
576
+        if ( ! $this->is_active() ) {
577
+            $html = aui()->alert(
578
+                array(
579
+                    'type'    => 'warning',
580
+                    'content' => __( 'This payment form is no longer active', 'invoicing' ),
581
+                )
582
+            );
583
+
584
+            if ( $echo ) {
585
+                echo $html;
586
+                return;
587
+            }
588
+
589
+            return $html;
590
+        }
591 591
     }
592 592
 
593 593
 }
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
67 67
 	 */
68
-	public function __construct( $form = 0 ) {
69
-		parent::__construct( $form );
68
+	public function __construct($form = 0) {
69
+		parent::__construct($form);
70 70
 
71
-		if ( is_numeric( $form ) && $form > 0 ) {
72
-			$this->set_id( $form );
73
-		} elseif ( $form instanceof self ) {
74
-			$this->set_id( $form->get_id() );
75
-		} elseif ( ! empty( $form->ID ) ) {
76
-			$this->set_id( $form->ID );
71
+		if (is_numeric($form) && $form > 0) {
72
+			$this->set_id($form);
73
+		} elseif ($form instanceof self) {
74
+			$this->set_id($form->get_id());
75
+		} elseif (!empty($form->ID)) {
76
+			$this->set_id($form->ID);
77 77
 		} else {
78
-			$this->set_object_read( true );
78
+			$this->set_object_read(true);
79 79
 		}
80 80
 
81 81
         // Load the datastore.
82
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
82
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
83 83
 
84
-		if ( $this->get_id() > 0 ) {
85
-            $this->post = get_post( $this->get_id() );
86
-			$this->data_store->read( $this );
84
+		if ($this->get_id() > 0) {
85
+            $this->post = get_post($this->get_id());
86
+			$this->data_store->read($this);
87 87
         }
88 88
 
89 89
 	}
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 * @param  string $context View or edit context.
111 111
 	 * @return string
112 112
 	 */
113
-	public function get_version( $context = 'view' ) {
114
-		return $this->get_prop( 'version', $context );
113
+	public function get_version($context = 'view') {
114
+		return $this->get_prop('version', $context);
115 115
     }
116 116
 
117 117
     /**
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 	 * @param  string $context View or edit context.
122 122
 	 * @return string
123 123
 	 */
124
-	public function get_date_created( $context = 'view' ) {
125
-		return $this->get_prop( 'date_created', $context );
124
+	public function get_date_created($context = 'view') {
125
+		return $this->get_prop('date_created', $context);
126 126
     }
127 127
 
128 128
     /**
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	 * @param  string $context View or edit context.
133 133
 	 * @return string
134 134
 	 */
135
-	public function get_date_created_gmt( $context = 'view' ) {
136
-        $date = $this->get_date_created( $context );
135
+	public function get_date_created_gmt($context = 'view') {
136
+        $date = $this->get_date_created($context);
137 137
 
138
-        if ( $date ) {
139
-            $date = get_gmt_from_date( $date );
138
+        if ($date) {
139
+            $date = get_gmt_from_date($date);
140 140
         }
141 141
 		return $date;
142 142
     }
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @param  string $context View or edit context.
149 149
 	 * @return string
150 150
 	 */
151
-	public function get_date_modified( $context = 'view' ) {
152
-		return $this->get_prop( 'date_modified', $context );
151
+	public function get_date_modified($context = 'view') {
152
+		return $this->get_prop('date_modified', $context);
153 153
     }
154 154
 
155 155
     /**
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 * @param  string $context View or edit context.
160 160
 	 * @return string
161 161
 	 */
162
-	public function get_date_modified_gmt( $context = 'view' ) {
163
-        $date = $this->get_date_modified( $context );
162
+	public function get_date_modified_gmt($context = 'view') {
163
+        $date = $this->get_date_modified($context);
164 164
 
165
-        if ( $date ) {
166
-            $date = get_gmt_from_date( $date );
165
+        if ($date) {
166
+            $date = get_gmt_from_date($date);
167 167
         }
168 168
 		return $date;
169 169
     }
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @param  string $context View or edit context.
176 176
 	 * @return string
177 177
 	 */
178
-	public function get_name( $context = 'view' ) {
179
-		return $this->get_prop( 'name', $context );
178
+	public function get_name($context = 'view') {
179
+		return $this->get_prop('name', $context);
180 180
     }
181 181
 
182 182
     /**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 * @param  string $context View or edit context.
187 187
 	 * @return string
188 188
 	 */
189
-	public function get_title( $context = 'view' ) {
190
-		return $this->get_name( $context );
189
+	public function get_title($context = 'view') {
190
+		return $this->get_name($context);
191 191
 	}
192 192
 
193 193
     /**
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param  string $context View or edit context.
198 198
 	 * @return int
199 199
 	 */
200
-	public function get_author( $context = 'view' ) {
201
-		return (int) $this->get_prop( 'author', $context );
200
+	public function get_author($context = 'view') {
201
+		return (int) $this->get_prop('author', $context);
202 202
     }
203 203
 
204 204
     /**
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 	 * @param  string $context View or edit context.
209 209
 	 * @return array
210 210
 	 */
211
-	public function get_elements( $context = 'view' ) {
212
-		$elements = $this->get_prop( 'elements', $context );
211
+	public function get_elements($context = 'view') {
212
+		$elements = $this->get_prop('elements', $context);
213 213
 
214
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
215
-            return wpinv_get_data( 'sample-payment-form' );
214
+		if (empty($elements) || !is_array($elements)) {
215
+            return wpinv_get_data('sample-payment-form');
216 216
         }
217 217
         return $elements;
218 218
 	}
@@ -225,61 +225,61 @@  discard block
 block discarded – undo
225 225
 	 * @param  string $return objects or arrays.
226 226
 	 * @return GetPaid_Form_Item[]|array
227 227
 	 */
228
-	public function get_items( $context = 'view', $return = 'objects' ) {
229
-		$items = $this->get_prop( 'items', $context );
228
+	public function get_items($context = 'view', $return = 'objects') {
229
+		$items = $this->get_prop('items', $context);
230 230
 
231
-		if ( empty( $items ) || ! is_array( $items ) ) {
232
-            $items = wpinv_get_data( 'sample-payment-form-items' );
231
+		if (empty($items) || !is_array($items)) {
232
+            $items = wpinv_get_data('sample-payment-form-items');
233 233
 		}
234 234
 		
235
-		if ( 'view' != $context ) {
235
+		if ('view' != $context) {
236 236
 			return $items;
237 237
 		}
238 238
 
239 239
 		// Convert the items.
240 240
 		$prepared = array();
241 241
 
242
-		foreach ( $items as $key => $value ) {
242
+		foreach ($items as $key => $value) {
243 243
 
244 244
 			// $item_id => $quantity
245
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
246
-				$item   = new GetPaid_Form_Item( $key );
245
+			if (is_numeric($key) && is_numeric($value)) {
246
+				$item = new GetPaid_Form_Item($key);
247 247
 
248
-				if ( $item->can_purchase() ) {
249
-					$item->set_quantity( $value );
248
+				if ($item->can_purchase()) {
249
+					$item->set_quantity($value);
250 250
 					$prepared[] = $item;
251 251
 				}
252 252
 
253 253
 				continue;
254 254
 			}
255 255
 
256
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
256
+			if (is_array($value) && isset($value['id'])) {
257 257
 
258
-				$item = new GetPaid_Form_Item( $value['id'] );
258
+				$item = new GetPaid_Form_Item($value['id']);
259 259
 
260
-				if ( ! $item->can_purchase() ) {
260
+				if (!$item->can_purchase()) {
261 261
 					continue;
262 262
 				}
263 263
 
264 264
 				// Sub-total (Cart items).
265
-				if ( isset( $value['subtotal'] ) ) {
266
-					$item->set_price( $value['subtotal'] );
265
+				if (isset($value['subtotal'])) {
266
+					$item->set_price($value['subtotal']);
267 267
 				}
268 268
 
269
-				if ( isset( $value['quantity'] ) ) {
270
-					$item->set_quantity( $value['quantity'] );
269
+				if (isset($value['quantity'])) {
270
+					$item->set_quantity($value['quantity']);
271 271
 				}
272 272
 
273
-				if ( isset( $value['allow_quantities'] ) ) {
274
-					$item->set_allow_quantities( $value['allow_quantities'] );
273
+				if (isset($value['allow_quantities'])) {
274
+					$item->set_allow_quantities($value['allow_quantities']);
275 275
 				}
276 276
 
277
-				if ( isset( $value['required'] ) ) {
278
-					$item->set_is_required( $value['required'] );
277
+				if (isset($value['required'])) {
278
+					$item->set_is_required($value['required']);
279 279
 				}
280 280
 
281
-				if ( isset( $value['description'] ) ) {
282
-					$item->set_custom_description( $value['description'] );
281
+				if (isset($value['description'])) {
282
+					$item->set_custom_description($value['description']);
283 283
 				}
284 284
 
285 285
 				$prepared[] = $item;
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 			}
289 289
 		}
290 290
 
291
-		if ( 'objects' == $return ) {
291
+		if ('objects' == $return) {
292 292
 			return $prepared;
293 293
 		}
294 294
 
295 295
 		$items = array();
296
-		foreach ( $prepared as $item ) {
296
+		foreach ($prepared as $item) {
297 297
 			$items[] = $item->prepare_data_for_use();
298 298
 		}
299 299
 
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 	 * @param  string $context View or edit context.
308 308
 	 * @return array
309 309
 	 */
310
-	public function get_earned( $context = 'view' ) {
311
-		return $this->get_prop( 'earned', $context );
310
+	public function get_earned($context = 'view') {
311
+		return $this->get_prop('earned', $context);
312 312
 	}
313 313
 
314 314
 	/**
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 	 * @param  string $context View or edit context.
319 319
 	 * @return array
320 320
 	 */
321
-	public function get_refunded( $context = 'view' ) {
322
-		return $this->get_prop( 'refunded', $context );
321
+	public function get_refunded($context = 'view') {
322
+		return $this->get_prop('refunded', $context);
323 323
 	}
324 324
 
325 325
 	/**
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 * @param  string $context View or edit context.
330 330
 	 * @return array
331 331
 	 */
332
-	public function get_cancelled( $context = 'view' ) {
333
-		return $this->get_prop( 'cancelled', $context );
332
+	public function get_cancelled($context = 'view') {
333
+		return $this->get_prop('cancelled', $context);
334 334
 	}
335 335
 
336 336
 	/**
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 	 * @param  string $context View or edit context.
341 341
 	 * @return array
342 342
 	 */
343
-	public function get_failed( $context = 'view' ) {
344
-		return $this->get_prop( 'failed', $context );
343
+	public function get_failed($context = 'view') {
344
+		return $this->get_prop('failed', $context);
345 345
 	}
346 346
 
347 347
     /*
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 	 *
360 360
 	 * @since 1.0.19
361 361
 	 */
362
-	public function set_version( $value ) {
363
-		$this->set_prop( 'version', $value );
362
+	public function set_version($value) {
363
+		$this->set_prop('version', $value);
364 364
     }
365 365
 
366 366
     /**
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
 	 * @param string $value Value to set.
371 371
      * @return bool Whether or not the date was set.
372 372
 	 */
373
-	public function set_date_created( $value ) {
374
-        $date = strtotime( $value );
373
+	public function set_date_created($value) {
374
+        $date = strtotime($value);
375 375
 
376
-        if ( $date ) {
377
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
376
+        if ($date) {
377
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
378 378
             return true;
379 379
         }
380 380
 
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 	 * @param string $value Value to set.
390 390
      * @return bool Whether or not the date was set.
391 391
 	 */
392
-	public function set_date_modified( $value ) {
393
-        $date = strtotime( $value );
392
+	public function set_date_modified($value) {
393
+        $date = strtotime($value);
394 394
 
395
-        if ( $date ) {
396
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
395
+        if ($date) {
396
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
397 397
             return true;
398 398
         }
399 399
 
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
 	 * @since 1.0.19
408 408
 	 * @param  string $value New name.
409 409
 	 */
410
-	public function set_name( $value ) {
411
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
410
+	public function set_name($value) {
411
+		$this->set_prop('name', sanitize_text_field($value));
412 412
     }
413 413
 
414 414
     /**
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
 	 * @since 1.0.19
418 418
 	 * @param  string $value New name.
419 419
 	 */
420
-	public function set_title( $value ) {
421
-		$this->set_name( $value );
420
+	public function set_title($value) {
421
+		$this->set_name($value);
422 422
     }
423 423
 
424 424
     /**
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	 * @since 1.0.19
428 428
 	 * @param  int $value New author.
429 429
 	 */
430
-	public function set_author( $value ) {
431
-		$this->set_prop( 'author', (int) $value );
430
+	public function set_author($value) {
431
+		$this->set_prop('author', (int) $value);
432 432
 	}
433 433
 
434 434
 	/**
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 	 * @since 1.0.19
438 438
 	 * @param  array $value Form elements.
439 439
 	 */
440
-	public function set_elements( $value ) {
441
-		if ( is_array( $value ) ) {
442
-			$this->set_prop( 'elements', $value );
440
+	public function set_elements($value) {
441
+		if (is_array($value)) {
442
+			$this->set_prop('elements', $value);
443 443
 		}
444 444
 	}
445 445
 
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 	 * @since 1.0.19
450 450
 	 * @param  array $value Form elements.
451 451
 	 */
452
-	public function set_items( $value ) {
453
-		if ( is_array( $value ) ) {
454
-			$this->set_prop( 'items', $value );
452
+	public function set_items($value) {
453
+		if (is_array($value)) {
454
+			$this->set_prop('items', $value);
455 455
 		}
456 456
 	}
457 457
 	
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 	 * @param  float $value Amount earned.
463 463
 	 * @return array
464 464
 	 */
465
-	public function set_earned( $value ) {
466
-		return $this->set_prop( 'earned', $value );
465
+	public function set_earned($value) {
466
+		return $this->set_prop('earned', $value);
467 467
 	}
468 468
 
469 469
 	/**
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	 * @param  float $value Amount refunded.
474 474
 	 * @return array
475 475
 	 */
476
-	public function set_refunded( $value ) {
477
-		return $this->set_prop( 'refunded', $value );
476
+	public function set_refunded($value) {
477
+		return $this->set_prop('refunded', $value);
478 478
 	}
479 479
 
480 480
 	/**
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	 * @param  float $value Amount cancelled.
485 485
 	 * @return array
486 486
 	 */
487
-	public function set_cancelled( $value ) {
488
-		return $this->set_prop( 'cancelled', $value );
487
+	public function set_cancelled($value) {
488
+		return $this->set_prop('cancelled', $value);
489 489
 	}
490 490
 
491 491
 	/**
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 	 * @param  float $value Amount cancelled.
496 496
 	 * @return array
497 497
 	 */
498
-	public function set_failed( $value ) {
499
-		return $this->set_prop( 'failed', $value );
498
+	public function set_failed($value) {
499
+		return $this->set_prop('failed', $value);
500 500
 	}
501 501
 
502 502
     /**
@@ -505,11 +505,11 @@  discard block
 block discarded – undo
505 505
      * @deprecated
506 506
 	 * @return int item id
507 507
      */
508
-    public function create( $data = array() ) {
508
+    public function create($data = array()) {
509 509
 
510 510
 		// Set the properties.
511
-		if ( is_array( $data ) ) {
512
-			$this->set_props( $data );
511
+		if (is_array($data)) {
512
+			$this->set_props($data);
513 513
 		}
514 514
 
515 515
 		// Save the item.
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
      * @deprecated
524 524
 	 * @return int item id
525 525
      */
526
-    public function update( $data = array() ) {
527
-        return $this->create( $data );
526
+    public function update($data = array()) {
527
+        return $this->create($data);
528 528
     }
529 529
 
530 530
     /*
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 	 */
545 545
     public function is_default() {
546 546
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
547
-        return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
547
+        return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this);
548 548
 	}
549 549
 
550 550
     /**
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
     public function is_active() {
557 557
         $is_active = null !== $this->get_id();
558 558
 
559
-        if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) {
559
+        if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') {
560 560
             $is_active = false;
561 561
         }
562 562
 
563
-        return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
563
+        return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this);
564 564
 	}
565 565
 	
566 566
 	/**
@@ -569,19 +569,19 @@  discard block
 block discarded – undo
569 569
 	 * @param bool $echo whether to return or echo the value.
570 570
 	 * @since 1.0.19
571 571
 	 */
572
-    public function display( $echo = true ) {
572
+    public function display($echo = true) {
573 573
 		global $invoicing;
574 574
 		
575 575
 		// Ensure that it is active.
576
-		if ( ! $this->is_active() ) {
576
+		if (!$this->is_active()) {
577 577
 			$html = aui()->alert(
578 578
 				array(
579 579
 					'type'    => 'warning',
580
-					'content' => __( 'This payment form is no longer active', 'invoicing' ),
580
+					'content' => __('This payment form is no longer active', 'invoicing'),
581 581
 				)
582 582
 			);
583 583
 
584
-			if ( $echo ) {
584
+			if ($echo) {
585 585
 				echo $html;
586 586
 				return;
587 587
 			}
Please login to merge, or discard this patch.
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +476 added lines, -476 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
     exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct() {
15 15
 
16
-        foreach( $this->get_elements() as $element ) {
16
+        foreach ($this->get_elements() as $element) {
17 17
             $element = $element['type'];
18 18
 
19
-            if ( method_exists( $this, "render_{$element}_template" ) ) {
20
-                add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 );
19
+            if (method_exists($this, "render_{$element}_template")) {
20
+                add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2);
21 21
             }
22 22
 
23
-            if ( method_exists( $this, "edit_{$element}_template" ) ) {
24
-                add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 );
23
+            if (method_exists($this, "edit_{$element}_template")) {
24
+                add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2);
25 25
             }
26 26
 
27 27
 
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function get_elements() {
36 36
 
37
-        if ( ! empty( $this->elements ) ) {
37
+        if (!empty($this->elements)) {
38 38
             return $this->elements;
39 39
         }
40 40
 
41
-        $this->elements = wpinv_get_data( 'payment-form-elements' );
41
+        $this->elements = wpinv_get_data('payment-form-elements');
42 42
 
43
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
43
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
44 44
         return $this->elements;
45 45
     }
46 46
 
47 47
     /**
48 48
      * Returns the restrict markup.
49 49
      */
50
-    public function get_restrict_markup( $field, $field_type ) {
50
+    public function get_restrict_markup($field, $field_type) {
51 51
         $restrict = "$field.type=='$field_type'";
52 52
         return "v-if=\"$restrict\"";
53 53
     }
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
     /**
56 56
      * Renders the title element template.
57 57
      */
58
-    public function render_heading_template( $field ) {
59
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
58
+    public function render_heading_template($field) {
59
+        $restrict = $this->get_restrict_markup($field, 'heading');
60 60
         echo "<component :is='$field.level' $restrict v-html='$field.text'></component>";
61 61
     }
62 62
 
63 63
     /**
64 64
      * Renders the edit title element template.
65 65
      */
66
-    public function edit_heading_template( $field ) {
67
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
68
-        $label    = __( 'Heading', 'invoicing' );
69
-        $label2   = __( 'Select Heading Level', 'invoicing' );
66
+    public function edit_heading_template($field) {
67
+        $restrict = $this->get_restrict_markup($field, 'heading');
68
+        $label    = __('Heading', 'invoicing');
69
+        $label2   = __('Select Heading Level', 'invoicing');
70 70
         $id       = $field . '.id + "_edit"';
71 71
         $id2      = $field . '.id + "_edit2"';
72 72
 
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
     /**
99 99
      * Renders a paragraph element template.
100 100
      */
101
-    public function render_paragraph_template( $field ) {
102
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
101
+    public function render_paragraph_template($field) {
102
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
103 103
         $label    = "$field.text";
104 104
         echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>";
105 105
     }
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
     /**
108 108
      * Renders the edit paragraph element template.
109 109
      */
110
-    public function edit_paragraph_template( $field ) {
111
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
112
-        $label    = __( 'Enter your text', 'invoicing' );
110
+    public function edit_paragraph_template($field) {
111
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
112
+        $label    = __('Enter your text', 'invoicing');
113 113
         $id       = $field . '.id + "_edit"';
114 114
         echo "
115 115
             <div $restrict>
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
     /**
126 126
      * Renders the text element template.
127 127
      */
128
-    public function render_text_template( $field ) {
129
-        $restrict = $this->get_restrict_markup( $field, 'text' );
128
+    public function render_text_template($field) {
129
+        $restrict = $this->get_restrict_markup($field, 'text');
130 130
         $label    = "$field.label";
131 131
         echo "
132 132
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
     /**
142 142
      * Renders the edit text element template.
143 143
      */
144
-    public function edit_text_template( $field ) {
145
-        $restrict = $this->get_restrict_markup( $field, 'text' );
146
-        $label    = __( 'Field Label', 'invoicing' );
144
+    public function edit_text_template($field) {
145
+        $restrict = $this->get_restrict_markup($field, 'text');
146
+        $label    = __('Field Label', 'invoicing');
147 147
         $id       = $field . '.id + "_edit"';
148
-        $label2   = __( 'Placeholder text', 'invoicing' );
148
+        $label2   = __('Placeholder text', 'invoicing');
149 149
         $id2      = $field . '.id + "_edit2"';
150
-        $label3   = __( 'Help text', 'invoicing' );
151
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
150
+        $label3   = __('Help text', 'invoicing');
151
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
152 152
         $id3      = $field . '.id + "_edit3"';
153
-        $label5   = __( 'Is this field required?', 'invoicing' );
153
+        $label5   = __('Is this field required?', 'invoicing');
154 154
         $id4      = $field . '.id + "_edit4"';
155 155
         echo "
156 156
             <div $restrict>
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
     /**
179 179
      * Renders the textarea element template.
180 180
      */
181
-    public function render_textarea_template( $field ) {
182
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
181
+    public function render_textarea_template($field) {
182
+        $restrict = $this->get_restrict_markup($field, 'textarea');
183 183
         $label    = "$field.label";
184 184
         echo "
185 185
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -194,16 +194,16 @@  discard block
 block discarded – undo
194 194
     /**
195 195
      * Renders the edit textarea element template.
196 196
      */
197
-    public function edit_textarea_template( $field ) {
198
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
199
-        $label    = __( 'Field Label', 'invoicing' );
197
+    public function edit_textarea_template($field) {
198
+        $restrict = $this->get_restrict_markup($field, 'textarea');
199
+        $label    = __('Field Label', 'invoicing');
200 200
         $id       = $field . '.id + "_edit"';
201
-        $label2   = __( 'Placeholder text', 'invoicing' );
201
+        $label2   = __('Placeholder text', 'invoicing');
202 202
         $id2      = $field . '.id + "_edit2"';
203
-        $label3   = __( 'Help text', 'invoicing' );
204
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
203
+        $label3   = __('Help text', 'invoicing');
204
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
205 205
         $id3      = $field . '.id + "_edit3"';
206
-        $label5   = __( 'Is this field required?', 'invoicing' );
206
+        $label5   = __('Is this field required?', 'invoicing');
207 207
         $id4      = $field . '.id + "_edit4"';
208 208
         echo "
209 209
             <div $restrict>
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
     /**
232 232
      * Renders the select element template.
233 233
      */
234
-    public function render_select_template( $field ) {
235
-        $restrict    = $this->get_restrict_markup( $field, 'select' );
234
+    public function render_select_template($field) {
235
+        $restrict    = $this->get_restrict_markup($field, 'select');
236 236
         $label       = "$field.label";
237 237
         $placeholder = "$field.placeholder";
238 238
         $id          = $field . '.id';
@@ -252,18 +252,18 @@  discard block
 block discarded – undo
252 252
     /**
253 253
      * Renders the edit select element template.
254 254
      */
255
-    public function edit_select_template( $field ) {
256
-        $restrict = $this->get_restrict_markup( $field, 'select' );
257
-        $label    = __( 'Field Label', 'invoicing' );
255
+    public function edit_select_template($field) {
256
+        $restrict = $this->get_restrict_markup($field, 'select');
257
+        $label    = __('Field Label', 'invoicing');
258 258
         $id       = $field . '.id + "_edit"';
259
-        $label2   = __( 'Placeholder text', 'invoicing' );
259
+        $label2   = __('Placeholder text', 'invoicing');
260 260
         $id2      = $field . '.id + "_edit2"';
261
-        $label3   = __( 'Help text', 'invoicing' );
262
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
261
+        $label3   = __('Help text', 'invoicing');
262
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
263 263
         $id3      = $field . '.id + "_edit3"';
264
-        $label5   = __( 'Is this field required?', 'invoicing' );
264
+        $label5   = __('Is this field required?', 'invoicing');
265 265
         $id4      = $field . '.id + "_edit4"';
266
-        $label6   = __( 'Available Options', 'invoicing' );
266
+        $label6   = __('Available Options', 'invoicing');
267 267
         echo "
268 268
             <div $restrict>
269 269
                 <div class='form-group'>
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
     /**
302 302
      * Renders the checkbox element template.
303 303
      */
304
-    public function render_checkbox_template( $field ) {
305
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
304
+    public function render_checkbox_template($field) {
305
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
306 306
         echo "
307 307
             <div class='form-check' $restrict>
308 308
                 <div class='wpinv-payment-form-field-preview-overlay'></div>
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
     /**
317 317
      * Renders the edit checkbox element template.
318 318
      */
319
-    public function edit_checkbox_template( $field ) {
320
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
321
-        $label    = __( 'Field Label', 'invoicing' );
319
+    public function edit_checkbox_template($field) {
320
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
321
+        $label    = __('Field Label', 'invoicing');
322 322
         $id       = $field . '.id + "_edit"';
323
-        $label2   = __( 'Help text', 'invoicing' );
324
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
323
+        $label2   = __('Help text', 'invoicing');
324
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
325 325
         $id2      = $field . '.id + "_edit2"';
326
-        $label4   = __( 'Is this field required?', 'invoicing' );
326
+        $label4   = __('Is this field required?', 'invoicing');
327 327
         $id3      = $field . '.id + "_edit3"';
328 328
         echo "
329 329
             <div $restrict>
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
     /**
348 348
      * Renders the radio element template.
349 349
      */
350
-    public function render_radio_template( $field ) {
351
-        $restrict    = $this->get_restrict_markup( $field, 'radio' );
350
+    public function render_radio_template($field) {
351
+        $restrict    = $this->get_restrict_markup($field, 'radio');
352 352
         $label       = "$field.label";
353 353
         $id          = $field . '.id';
354 354
         echo "
@@ -367,16 +367,16 @@  discard block
 block discarded – undo
367 367
     /**
368 368
      * Renders the edit radio element template.
369 369
      */
370
-    public function edit_radio_template( $field ) {
371
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
372
-        $label    = __( 'Field Label', 'invoicing' );
370
+    public function edit_radio_template($field) {
371
+        $restrict = $this->get_restrict_markup($field, 'radio');
372
+        $label    = __('Field Label', 'invoicing');
373 373
         $id       = $field . '.id + "_edit"';
374
-        $label2   = __( 'Help text', 'invoicing' );
375
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
374
+        $label2   = __('Help text', 'invoicing');
375
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
376 376
         $id2      = $field . '.id + "_edit3"';
377
-        $label4   = __( 'Is this field required?', 'invoicing' );
377
+        $label4   = __('Is this field required?', 'invoicing');
378 378
         $id3      = $field . '.id + "_edit4"';
379
-        $label5   = __( 'Available Options', 'invoicing' );
379
+        $label5   = __('Available Options', 'invoicing');
380 380
         echo "
381 381
             <div $restrict>
382 382
                 <div class='form-group'>
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
     /**
411 411
      * Renders the address element template.
412 412
      */
413
-    public function render_address_template( $field ) {
414
-        $restrict    = $this->get_restrict_markup( $field, 'address' );
413
+    public function render_address_template($field) {
414
+        $restrict = $this->get_restrict_markup($field, 'address');
415 415
 
416 416
         echo "
417 417
             <div class='wpinv-address-wrapper' $restrict>
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
     /**
434 434
      * Renders the edit address element template.
435 435
      */
436
-    public function edit_address_template( $field ) {
437
-        $restrict  = $this->get_restrict_markup( $field, 'address' );
438
-        $label     = __( 'Field Label', 'invoicing' );
439
-        $label2    = __( 'Placeholder', 'invoicing' );
440
-        $label3    = __( 'Description', 'invoicing' );
441
-        $label4    = __( 'Is required', 'invoicing' );
442
-        $label5    = __( 'Is visible', 'invoicing' );
436
+    public function edit_address_template($field) {
437
+        $restrict  = $this->get_restrict_markup($field, 'address');
438
+        $label     = __('Field Label', 'invoicing');
439
+        $label2    = __('Placeholder', 'invoicing');
440
+        $label3    = __('Description', 'invoicing');
441
+        $label4    = __('Is required', 'invoicing');
442
+        $label5    = __('Is visible', 'invoicing');
443 443
         $id        = $field . '.id + "_edit_label"';
444 444
         $id2       = $field . '.id + "_edit_placeholder"';
445 445
         $id3       = $field . '.id + "_edit_description"';
@@ -507,8 +507,8 @@  discard block
 block discarded – undo
507 507
     /**
508 508
      * Renders the email element template.
509 509
      */
510
-    public function render_email_template( $field ) {
511
-        $restrict = $this->get_restrict_markup( $field, 'email' );
510
+    public function render_email_template($field) {
511
+        $restrict = $this->get_restrict_markup($field, 'email');
512 512
         $label    = "$field.label";
513 513
         echo "
514 514
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
     /**
524 524
      * Renders the billing_email element template.
525 525
      */
526
-    public function render_billing_email_template( $field ) {
527
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
526
+    public function render_billing_email_template($field) {
527
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
528 528
         $label    = "$field.label";
529 529
         echo "
530 530
             <div $restrict>
@@ -538,16 +538,16 @@  discard block
 block discarded – undo
538 538
     /**
539 539
      * Renders the edit email element template.
540 540
      */
541
-    public function edit_email_template( $field ) {
542
-        $restrict = $this->get_restrict_markup( $field, 'email' );
543
-        $label    = __( 'Field Label', 'invoicing' );
541
+    public function edit_email_template($field) {
542
+        $restrict = $this->get_restrict_markup($field, 'email');
543
+        $label    = __('Field Label', 'invoicing');
544 544
         $id       = $field . '.id + "_edit"';
545
-        $label2   = __( 'Placeholder text', 'invoicing' );
545
+        $label2   = __('Placeholder text', 'invoicing');
546 546
         $id2      = $field . '.id + "_edit2"';
547
-        $label3   = __( 'Help text', 'invoicing' );
548
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
547
+        $label3   = __('Help text', 'invoicing');
548
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
549 549
         $id3      = $field . '.id + "_edit3"';
550
-        $label5   = __( 'Is this field required?', 'invoicing' );
550
+        $label5   = __('Is this field required?', 'invoicing');
551 551
         $id4      = $field . '.id + "_edit4"';
552 552
         echo "
553 553
             <div $restrict>
@@ -575,16 +575,16 @@  discard block
 block discarded – undo
575 575
     /**
576 576
      * Renders the edit billing_email element template.
577 577
      */
578
-    public function edit_billing_email_template( $field ) {
579
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
580
-        $label    = __( 'Field Label', 'invoicing' );
578
+    public function edit_billing_email_template($field) {
579
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
580
+        $label    = __('Field Label', 'invoicing');
581 581
         $id       = $field . '.id + "_edit"';
582
-        $label2   = __( 'Placeholder text', 'invoicing' );
582
+        $label2   = __('Placeholder text', 'invoicing');
583 583
         $id2      = $field . '.id + "_edit2"';
584
-        $label3   = __( 'Help text', 'invoicing' );
585
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
584
+        $label3   = __('Help text', 'invoicing');
585
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
586 586
         $id3      = $field . '.id + "_edit3"';
587
-        $label5   = __( 'Is this field required?', 'invoicing' );
587
+        $label5   = __('Is this field required?', 'invoicing');
588 588
         $id4      = $field . '.id + "_edit4"';
589 589
         echo "
590 590
             <div $restrict>
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
     /**
609 609
      * Renders the website element template.
610 610
      */
611
-    public function render_website_template( $field ) {
612
-        $restrict = $this->get_restrict_markup( $field, 'website' );
611
+    public function render_website_template($field) {
612
+        $restrict = $this->get_restrict_markup($field, 'website');
613 613
         $label    = "$field.label";
614 614
         echo "
615 615
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -624,16 +624,16 @@  discard block
 block discarded – undo
624 624
     /**
625 625
      * Renders the edit website element template.
626 626
      */
627
-    public function edit_website_template( $field ) {
628
-        $restrict = $this->get_restrict_markup( $field, 'website' );
629
-        $label    = __( 'Field Label', 'invoicing' );
627
+    public function edit_website_template($field) {
628
+        $restrict = $this->get_restrict_markup($field, 'website');
629
+        $label    = __('Field Label', 'invoicing');
630 630
         $id       = $field . '.id + "_edit"';
631
-        $label2   = __( 'Placeholder text', 'invoicing' );
631
+        $label2   = __('Placeholder text', 'invoicing');
632 632
         $id2      = $field . '.id + "_edit2"';
633
-        $label3   = __( 'Help text', 'invoicing' );
634
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
633
+        $label3   = __('Help text', 'invoicing');
634
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
635 635
         $id3      = $field . '.id + "_edit3"';
636
-        $label5   = __( 'Is this field required?', 'invoicing' );
636
+        $label5   = __('Is this field required?', 'invoicing');
637 637
         $id4      = $field . '.id + "_edit4"';
638 638
         echo "
639 639
             <div $restrict>
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
     /**
662 662
      * Renders the date element template.
663 663
      */
664
-    public function render_date_template( $field ) {
665
-        $restrict = $this->get_restrict_markup( $field, 'date' );
664
+    public function render_date_template($field) {
665
+        $restrict = $this->get_restrict_markup($field, 'date');
666 666
         $label    = "$field.label";
667 667
         echo "
668 668
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -677,14 +677,14 @@  discard block
 block discarded – undo
677 677
     /**
678 678
      * Renders the edit date element template.
679 679
      */
680
-    public function edit_date_template( $field ) {
681
-        $restrict = $this->get_restrict_markup( $field, 'date' );
682
-        $label    = __( 'Field Label', 'invoicing' );
680
+    public function edit_date_template($field) {
681
+        $restrict = $this->get_restrict_markup($field, 'date');
682
+        $label    = __('Field Label', 'invoicing');
683 683
         $id       = $field . '.id + "_edit"';
684
-        $label3   = __( 'Help text', 'invoicing' );
685
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
684
+        $label3   = __('Help text', 'invoicing');
685
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
686 686
         $id3      = $field . '.id + "_edit3"';
687
-        $label5   = __( 'Is this field required?', 'invoicing' );
687
+        $label5   = __('Is this field required?', 'invoicing');
688 688
         $id4      = $field . '.id + "_edit4"';
689 689
         echo "
690 690
             <div $restrict>
@@ -708,8 +708,8 @@  discard block
 block discarded – undo
708 708
     /**
709 709
      * Renders the time element template.
710 710
      */
711
-    public function render_time_template( $field ) {
712
-        $restrict = $this->get_restrict_markup( $field, 'time' );
711
+    public function render_time_template($field) {
712
+        $restrict = $this->get_restrict_markup($field, 'time');
713 713
         $label    = "$field.label";
714 714
         echo "
715 715
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -724,14 +724,14 @@  discard block
 block discarded – undo
724 724
     /**
725 725
      * Renders the edit time element template.
726 726
      */
727
-    public function edit_time_template( $field ) {
728
-        $restrict = $this->get_restrict_markup( $field, 'time' );
729
-        $label    = __( 'Field Label', 'invoicing' );
727
+    public function edit_time_template($field) {
728
+        $restrict = $this->get_restrict_markup($field, 'time');
729
+        $label    = __('Field Label', 'invoicing');
730 730
         $id       = $field . '.id + "_edit"';
731
-        $label3   = __( 'Help text', 'invoicing' );
732
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
731
+        $label3   = __('Help text', 'invoicing');
732
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
733 733
         $id3      = $field . '.id + "_edit3"';
734
-        $label5   = __( 'Is this field required?', 'invoicing' );
734
+        $label5   = __('Is this field required?', 'invoicing');
735 735
         $id4      = $field . '.id + "_edit4"';
736 736
         echo "
737 737
             <div $restrict>
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
     /**
756 756
      * Renders the number element template.
757 757
      */
758
-    public function render_number_template( $field ) {
759
-        $restrict = $this->get_restrict_markup( $field, 'number' );
758
+    public function render_number_template($field) {
759
+        $restrict = $this->get_restrict_markup($field, 'number');
760 760
         $label    = "$field.label";
761 761
         echo "
762 762
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -771,16 +771,16 @@  discard block
 block discarded – undo
771 771
     /**
772 772
      * Renders the edit number element template.
773 773
      */
774
-    public function edit_number_template( $field ) {
775
-        $restrict = $this->get_restrict_markup( $field, 'number' );
776
-        $label    = __( 'Field Label', 'invoicing' );
774
+    public function edit_number_template($field) {
775
+        $restrict = $this->get_restrict_markup($field, 'number');
776
+        $label    = __('Field Label', 'invoicing');
777 777
         $id       = $field . '.id + "_edit"';
778
-        $label2   = __( 'Placeholder text', 'invoicing' );
778
+        $label2   = __('Placeholder text', 'invoicing');
779 779
         $id2      = $field . '.id + "_edit2"';
780
-        $label3   = __( 'Help text', 'invoicing' );
781
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
780
+        $label3   = __('Help text', 'invoicing');
781
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
782 782
         $id3      = $field . '.id + "_edit3"';
783
-        $label5   = __( 'Is this field required?', 'invoicing' );
783
+        $label5   = __('Is this field required?', 'invoicing');
784 784
         $id4      = $field . '.id + "_edit4"';
785 785
         echo "
786 786
             <div $restrict>
@@ -808,16 +808,16 @@  discard block
 block discarded – undo
808 808
     /**
809 809
      * Renders the separator element template.
810 810
      */
811
-    public function render_separator_template( $field ) {
812
-        $restrict = $this->get_restrict_markup( $field, 'separator' );
811
+    public function render_separator_template($field) {
812
+        $restrict = $this->get_restrict_markup($field, 'separator');
813 813
         echo "<hr class='featurette-divider' $restrict>";
814 814
     }
815 815
 
816 816
     /**
817 817
      * Renders the pay button element template.
818 818
      */
819
-    public function render_pay_button_template( $field ) {
820
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
819
+    public function render_pay_button_template($field) {
820
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
821 821
         $label    = "$field.label";
822 822
         echo "
823 823
             <div $restrict>
@@ -830,14 +830,14 @@  discard block
 block discarded – undo
830 830
     /**
831 831
      * Renders the pay button element template.
832 832
      */
833
-    public function edit_pay_button_template( $field ) {
834
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
835
-        $label    = __( 'Button Text', 'invoicing' );
833
+    public function edit_pay_button_template($field) {
834
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
835
+        $label    = __('Button Text', 'invoicing');
836 836
         $id       = $field . '.id + "_edit"';
837
-        $label2   = __( 'Help text', 'invoicing' );
838
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
837
+        $label2   = __('Help text', 'invoicing');
838
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
839 839
         $id2      = $field . '.id + "_edit2"';
840
-        $label4   = esc_attr__( 'Button Type', 'invoicing' );
840
+        $label4   = esc_attr__('Button Type', 'invoicing');
841 841
         $id3      = $field . '.id + "_edit3"';
842 842
         echo "
843 843
             <div $restrict>
@@ -853,15 +853,15 @@  discard block
 block discarded – undo
853 853
                     <label :for='$id3'>$label4</label>
854 854
 
855 855
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
856
-                        <option value='btn-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
857
-                        <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
858
-                        <option value='btn-success'>"   . __( 'Success', 'invoicing' ) ."</option>
859
-                        <option value='btn-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
860
-                        <option value='btn-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
861
-                        <option value='btn-info'>"      . __( 'Info', 'invoicing' ) ."</option>
862
-                        <option value='btn-light'>"     . __( 'Light', 'invoicing' ) ."</option>
863
-                        <option value='btn-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
864
-                        <option value='btn-link'>"      . __( 'Link', 'invoicing' ) ."</option>
856
+                        <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option>
857
+                        <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option>
858
+                        <option value='btn-success'>"   . __('Success', 'invoicing') . "</option>
859
+                        <option value='btn-danger'>"    . __('Danger', 'invoicing') . "</option>
860
+                        <option value='btn-warning'>"   . __('Warning', 'invoicing') . "</option>
861
+                        <option value='btn-info'>"      . __('Info', 'invoicing') . "</option>
862
+                        <option value='btn-light'>"     . __('Light', 'invoicing') . "</option>
863
+                        <option value='btn-dark'>"      . __('Dark', 'invoicing') . "</option>
864
+                        <option value='btn-link'>"      . __('Link', 'invoicing') . "</option>
865 865
                     </select>
866 866
                 </div>
867 867
             </div>
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
     /**
873 873
      * Renders the alert element template.
874 874
      */
875
-    public function render_alert_template( $field ) {
876
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
875
+    public function render_alert_template($field) {
876
+        $restrict = $this->get_restrict_markup($field, 'alert');
877 877
         $text     = "$field.text";
878 878
         echo "
879 879
             <div $restrict class='alert' :class='$field.class' role='alert'>
@@ -888,14 +888,14 @@  discard block
 block discarded – undo
888 888
     /**
889 889
      * Renders the alert element template.
890 890
      */
891
-    public function edit_alert_template( $field ) {
892
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
893
-        $label    = __( 'Alert Text', 'invoicing' );
894
-        $label2   = esc_attr__( 'Enter your alert text here', 'invoicing' );
891
+    public function edit_alert_template($field) {
892
+        $restrict = $this->get_restrict_markup($field, 'alert');
893
+        $label    = __('Alert Text', 'invoicing');
894
+        $label2   = esc_attr__('Enter your alert text here', 'invoicing');
895 895
         $id       = $field . '.id + "_edit"';
896
-        $label3   = __( 'Is Dismissible?', 'invoicing' );
896
+        $label3   = __('Is Dismissible?', 'invoicing');
897 897
         $id2      = $field . '.id + "_edit2"';
898
-        $label4   = esc_attr__( 'Alert Type', 'invoicing' );
898
+        $label4   = esc_attr__('Alert Type', 'invoicing');
899 899
         $id3      = $field . '.id + "_edit3"';
900 900
         echo "
901 901
             <div $restrict>
@@ -911,14 +911,14 @@  discard block
 block discarded – undo
911 911
                     <label :for='$id3'>$label4</label>
912 912
 
913 913
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
914
-                        <option value='alert-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
915
-                        <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
916
-                        <option value='alert-success'>"   . __( 'Success', 'invoicing' ) ."</option>
917
-                        <option value='alert-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
918
-                        <option value='alert-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
919
-                        <option value='alert-info'>"      . __( 'Info', 'invoicing' ) ."</option>
920
-                        <option value='alert-light'>"     . __( 'Light', 'invoicing' ) ."</option>
921
-                        <option value='alert-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
914
+                        <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option>
915
+                        <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option>
916
+                        <option value='alert-success'>"   . __('Success', 'invoicing') . "</option>
917
+                        <option value='alert-danger'>"    . __('Danger', 'invoicing') . "</option>
918
+                        <option value='alert-warning'>"   . __('Warning', 'invoicing') . "</option>
919
+                        <option value='alert-info'>"      . __('Info', 'invoicing') . "</option>
920
+                        <option value='alert-light'>"     . __('Light', 'invoicing') . "</option>
921
+                        <option value='alert-dark'>"      . __('Dark', 'invoicing') . "</option>
922 922
                     </select>
923 923
                 </div>
924 924
             </div>
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
     /**
930 930
      * Renders the discount element template.
931 931
      */
932
-    public function render_discount_template( $field ) {
933
-        $restrict  = $this->get_restrict_markup( $field, 'discount' );
932
+    public function render_discount_template($field) {
933
+        $restrict = $this->get_restrict_markup($field, 'discount');
934 934
         ?>
935 935
 
936 936
             <div <?php echo $restrict; ?> class="discount_field border rounded p-3 wpinv-payment-form-field-preview">
@@ -948,12 +948,12 @@  discard block
 block discarded – undo
948 948
     /**
949 949
      * Renders the discount element template.
950 950
      */
951
-    public function edit_discount_template( $field ) {
952
-        $restrict = $this->get_restrict_markup( $field, 'discount' );
953
-        $label    = __( 'Discount Input Placeholder', 'invoicing' );
954
-        $label2   = __( 'Help Text', 'invoicing' );
955
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
956
-        $label4   = __( 'Button Text', 'invoicing' );
951
+    public function edit_discount_template($field) {
952
+        $restrict = $this->get_restrict_markup($field, 'discount');
953
+        $label    = __('Discount Input Placeholder', 'invoicing');
954
+        $label2   = __('Help Text', 'invoicing');
955
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
956
+        $label4   = __('Button Text', 'invoicing');
957 957
         $id       = $field . '.id + "_edit"';
958 958
         $id2      = $field . '.id + "_edit2"';
959 959
         $id3      = $field . '.id + "_edit3"';
@@ -982,17 +982,17 @@  discard block
 block discarded – undo
982 982
     /**
983 983
      * Renders the items element template.
984 984
      */
985
-    public function render_items_template( $field ) {
986
-        $restrict  = $this->get_restrict_markup( $field, 'items' );
985
+    public function render_items_template($field) {
986
+        $restrict = $this->get_restrict_markup($field, 'items');
987 987
         ?>
988 988
 
989 989
         <div <?php echo $restrict; ?> class='item_totals text-center'>
990 990
             <div v-if='!is_default'>
991
-                <div v-if='! canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='p-4 bg-warning text-light'><?php _e( 'Item totals will appear here. Click to set items.', 'invoicing' ) ?></div>
992
-                <div v-if='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='p-4 bg-danger'><?php _e( 'Your form allows customers to buy several recurring items. This is not supported and will lead to unexpected behaviour.', 'invoicing' ); _e( 'To prevent this, limit customers to selecting a single item.', 'invoicing' ); ?></div>
991
+                <div v-if='! canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='p-4 bg-warning text-light'><?php _e('Item totals will appear here. Click to set items.', 'invoicing') ?></div>
992
+                <div v-if='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='p-4 bg-danger'><?php _e('Your form allows customers to buy several recurring items. This is not supported and will lead to unexpected behaviour.', 'invoicing'); _e('To prevent this, limit customers to selecting a single item.', 'invoicing'); ?></div>
993 993
             </div>
994 994
                 <div v-if='is_default'>
995
-                    <div class='p-4 bg-warning'><?php _e( 'Item totals will appear here.', 'invoicing' ) ?></div>
995
+                    <div class='p-4 bg-warning'><?php _e('Item totals will appear here.', 'invoicing') ?></div>
996 996
                 </div>
997 997
             </div>
998 998
 
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
     /**
1003 1003
      * Renders the items element on the frontend.
1004 1004
      */
1005
-    public function frontend_render_items_template( $field, $items ) {
1005
+    public function frontend_render_items_template($field, $items) {
1006 1006
         $tax       = 0;
1007 1007
         $sub_total = 0;
1008 1008
         $total     = 0;
@@ -1010,15 +1010,15 @@  discard block
 block discarded – undo
1010 1010
         ?>
1011 1011
             <div class="border item_totals_type_total">
1012 1012
                 <?php
1013
-                    foreach( $items as $item ) {
1014
-                        $amount = floatval( $item['price'] );
1013
+                    foreach ($items as $item) {
1014
+                        $amount = floatval($item['price']);
1015 1015
 
1016 1016
                         // Include the tax.
1017
-                        if ( wpinv_use_taxes() ) {
1018
-                            $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1017
+                        if (wpinv_use_taxes()) {
1018
+                            $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1019 1019
 
1020
-                            if ( wpinv_prices_include_tax() ) {
1021
-                                $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1020
+                            if (wpinv_prices_include_tax()) {
1021
+                                $pre_tax  = ($amount - $amount * $rate * 0.01);
1022 1022
                                 $item_tax = $amount - $pre_tax;
1023 1023
                             } else {
1024 1024
                                 $pre_tax  = $amount;
@@ -1030,32 +1030,32 @@  discard block
 block discarded – undo
1030 1030
                             $total     = $sub_total + $tax;
1031 1031
 
1032 1032
                         } else {
1033
-                            $total  = $total + $amount;
1033
+                            $total = $total + $amount;
1034 1034
                         }
1035 1035
 
1036 1036
                         $class  = 'col-8';
1037 1037
                         $class2 = '';
1038 1038
 
1039
-                        if ( ! empty( $item['allow_quantities'] ) ) {
1039
+                        if (!empty($item['allow_quantities'])) {
1040 1040
                             $class = 'col-6 pt-2';
1041 1041
                             $class2 = 'pt-2';
1042 1042
                         }
1043 1043
 
1044
-                        if ( ! empty( $item['custom_price'] ) ) {
1044
+                        if (!empty($item['custom_price'])) {
1045 1045
                             $class .= ' pt-2';
1046 1046
                         }
1047 1047
 
1048 1048
                         $quantity = 1;
1049
-                        if ( ! empty( $item['quantity'] ) ) {
1050
-                            $quantity = absint( $item['quantity'] );
1049
+                        if (!empty($item['quantity'])) {
1050
+                            $quantity = absint($item['quantity']);
1051 1051
                         }
1052 1052
 
1053 1053
                 ?>
1054 1054
                 <div  class="item_totals_item">
1055 1055
                     <div class='row pl-2 pr-2 pt-2'>
1056
-                        <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div>
1056
+                        <div class='<?php echo $class; ?>'><?php echo sanitize_text_field($item['title']) ?></div>
1057 1057
 
1058
-                        <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1058
+                        <?php  if (!empty($item['allow_quantities'])) { ?>
1059 1059
 
1060 1060
                             <div class='col-2'>
1061 1061
                                 <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='<?php echo $quantity ?>' min='1' required>
@@ -1063,11 +1063,11 @@  discard block
 block discarded – undo
1063 1063
 
1064 1064
                         <?php } else { ?>
1065 1065
                             <input type='hidden' class='wpinv-item-quantity-input' value='<?php echo $quantity ?>'>
1066
-                        <?php } if ( empty( $item['custom_price'] ) ) { ?>
1066
+                        <?php } if (empty($item['custom_price'])) { ?>
1067 1067
 
1068 1068
                             <div class='col-4 <?php echo $class2; ?>'>
1069
-                                <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1070
-                                <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1069
+                                <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1070
+                                <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1071 1071
                             </div>
1072 1072
 
1073 1073
                         <?php } else {?>
@@ -1075,15 +1075,15 @@  discard block
 block discarded – undo
1075 1075
                         <div class='col-4'>
1076 1076
                             <div class='input-group'>
1077 1077
 
1078
-                                <?php if ( 'left' == wpinv_currency_position() ) { ?>
1078
+                                <?php if ('left' == wpinv_currency_position()) { ?>
1079 1079
                                     <div class='input-group-prepend'>
1080 1080
                                         <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1081 1081
                                     </div>
1082 1082
                                 <?php } ?>
1083 1083
 
1084
-                                <input type='text' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1084
+                                <input type='text' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1085 1085
                             
1086
-                                <?php if ( 'left' != wpinv_currency_position() ) { ?>
1086
+                                <?php if ('left' != wpinv_currency_position()) { ?>
1087 1087
                                     <div class='input-group-append'>
1088 1088
                                         <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1089 1089
                                     </div>
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
                     <?php } ?>
1095 1095
 
1096 1096
                 </div>
1097
-                <?php if ( ! empty( $item['description'] )) { ?>
1098
-                    <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1097
+                <?php if (!empty($item['description'])) { ?>
1098
+                    <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1099 1099
                 <?php } ?>
1100 1100
             </div>
1101 1101
         <?php } ?>
@@ -1103,25 +1103,25 @@  discard block
 block discarded – undo
1103 1103
         <div class='mt-4 border-top item_totals_total p-2'>
1104 1104
 
1105 1105
             <div class='row'>
1106
-                <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1107
-                <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1106
+                <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1107
+                <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1108 1108
             </div>
1109 1109
 
1110 1110
             <div class='row' style='display: none;'>
1111
-                <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div>
1112
-                <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price( wpinv_format_amount( 0 ) ) ?></strong></div>
1111
+                <div class='col-8'><strong class='mr-5'><?php _e('Discount', 'invoicing'); ?></strong></div>
1112
+                <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price(wpinv_format_amount(0)) ?></strong></div>
1113 1113
             </div>
1114 1114
 
1115
-            <?php if ( wpinv_use_taxes() ) { ?>
1115
+            <?php if (wpinv_use_taxes()) { ?>
1116 1116
                 <div class='row'>
1117
-                    <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1118
-                    <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1117
+                    <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1118
+                    <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1119 1119
                 </div>
1120 1120
             <?php } ?>
1121 1121
 
1122 1122
             <div class='row'>
1123
-                <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1124
-                <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1123
+                <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1124
+                <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1125 1125
             </div>
1126 1126
 
1127 1127
         </div>
@@ -1130,13 +1130,13 @@  discard block
 block discarded – undo
1130 1130
         <?php
1131 1131
         echo "<div class='form-group item_totals'>";
1132 1132
         
1133
-        $id = esc_attr( $field['id'] );
1133
+        $id = esc_attr($field['id']);
1134 1134
 
1135
-        if ( empty( $field[ 'items_type' ] ) ) {
1136
-            $field[ 'items_type' ] = 'total';
1135
+        if (empty($field['items_type'])) {
1136
+            $field['items_type'] = 'total';
1137 1137
         }
1138 1138
 
1139
-        if ( 'total' == $field[ 'items_type' ] ) {
1139
+        if ('total' == $field['items_type']) {
1140 1140
             $total     = 0;
1141 1141
             $tax       = 0;
1142 1142
             $sub_total = 0;
@@ -1145,16 +1145,16 @@  discard block
 block discarded – undo
1145 1145
             <div class="border item_totals_type_total">
1146 1146
 
1147 1147
                 <?php
1148
-                    foreach( $items as $item ) {
1148
+                    foreach ($items as $item) {
1149 1149
 
1150
-                        $amount = floatval( $item['price'] );
1150
+                        $amount = floatval($item['price']);
1151 1151
 
1152
-                        if ( wpinv_use_taxes() ) {
1152
+                        if (wpinv_use_taxes()) {
1153 1153
 
1154
-                            $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1154
+                            $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1155 1155
 
1156
-                            if ( wpinv_prices_include_tax() ) {
1157
-                                $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1156
+                            if (wpinv_prices_include_tax()) {
1157
+                                $pre_tax  = ($amount - $amount * $rate * 0.01);
1158 1158
                                 $item_tax = $amount - $pre_tax;
1159 1159
                             } else {
1160 1160
                                 $pre_tax  = $amount;
@@ -1166,32 +1166,32 @@  discard block
 block discarded – undo
1166 1166
                             $total     = $sub_total + $tax;
1167 1167
 
1168 1168
                         } else {
1169
-                            $total  = $total + $amount;
1169
+                            $total = $total + $amount;
1170 1170
                         }
1171 1171
 
1172 1172
                         $class  = 'col-8';
1173 1173
                         $class2 = '';
1174 1174
 
1175
-                        if ( ! empty( $item['allow_quantities'] ) ) {
1175
+                        if (!empty($item['allow_quantities'])) {
1176 1176
                             $class = 'col-6 pt-2';
1177 1177
                             $class2 = 'pt-2';
1178 1178
                         }
1179 1179
 
1180
-                        if ( ! empty( $item['custom_price'] ) ) {
1180
+                        if (!empty($item['custom_price'])) {
1181 1181
                             $class .= ' pt-2';
1182 1182
                         }
1183 1183
 
1184 1184
                         $quantity = 1;
1185
-                        if ( ! empty( $item['quantity'] ) ) {
1186
-                            $quantity = absint( $item['quantity'] );
1185
+                        if (!empty($item['quantity'])) {
1186
+                            $quantity = absint($item['quantity']);
1187 1187
                         }
1188 1188
             
1189 1189
                 ?>
1190 1190
                     <div  class="item_totals_item">
1191 1191
                         <div class='row pl-2 pr-2 pt-2'>
1192
-                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div>
1192
+                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field($item['title']) ?></div>
1193 1193
 
1194
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1194
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1195 1195
 
1196 1196
                                 <div class='col-2'>
1197 1197
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='<?php echo $quantity ?>' min='1' required>
@@ -1199,11 +1199,11 @@  discard block
 block discarded – undo
1199 1199
 
1200 1200
                             <?php } else { ?>
1201 1201
                                 <input type='hidden' class='wpinv-item-quantity-input' value='<?php echo $quantity ?>'>
1202
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1202
+                            <?php } if (empty($item['custom_price'])) { ?>
1203 1203
 
1204 1204
                                 <div class='col-4 <?php echo $class2; ?>'>
1205
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1206
-                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1205
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1206
+                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1207 1207
                                 </div>
1208 1208
 
1209 1209
                             <?php } else {?>
@@ -1211,15 +1211,15 @@  discard block
 block discarded – undo
1211 1211
                                 <div class='col-4'>
1212 1212
                                     <div class='input-group'>
1213 1213
 
1214
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1214
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1215 1215
                                             <div class='input-group-prepend'>
1216 1216
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1217 1217
                                             </div>
1218 1218
                                         <?php } ?>
1219 1219
 
1220
-                                        <input type='text' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1220
+                                        <input type='text' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1221 1221
                                     
1222
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1222
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1223 1223
                                             <div class='input-group-append'>
1224 1224
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1225 1225
                                             </div>
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
                             <?php } ?>
1231 1231
 
1232 1232
                         </div>
1233
-                        <?php if ( ! empty( $item['description'] )) { ?>
1234
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1233
+                        <?php if (!empty($item['description'])) { ?>
1234
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1235 1235
                         <?php } ?>
1236 1236
                     </div>
1237 1237
                 <?php } ?>
@@ -1239,25 +1239,25 @@  discard block
 block discarded – undo
1239 1239
                 <div class='mt-4 border-top item_totals_total p-2'>
1240 1240
 
1241 1241
                     <div class='row'>
1242
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1243
-                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1242
+                        <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1243
+                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1244 1244
                     </div>
1245 1245
 
1246 1246
                     <div class='row' style='display: none;'>
1247
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div>
1248
-                        <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price( wpinv_format_amount( 0 ) ) ?></strong></div>
1247
+                        <div class='col-8'><strong class='mr-5'><?php _e('Discount', 'invoicing'); ?></strong></div>
1248
+                        <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price(wpinv_format_amount(0)) ?></strong></div>
1249 1249
                     </div>
1250 1250
 
1251
-                    <?php if ( wpinv_use_taxes() ) { ?>
1251
+                    <?php if (wpinv_use_taxes()) { ?>
1252 1252
                         <div class='row'>
1253
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1254
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1253
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1254
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1255 1255
                         </div>
1256 1256
                     <?php } ?>
1257 1257
 
1258 1258
                     <div class='row'>
1259
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1260
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1259
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1260
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1261 1261
                     </div>
1262 1262
 
1263 1263
                 </div>
@@ -1265,22 +1265,22 @@  discard block
 block discarded – undo
1265 1265
             </div>
1266 1266
         <?php } ?>
1267 1267
 
1268
-        <?php if ( 'radio' == $field[ 'items_type' ] ) { ?>
1268
+        <?php if ('radio' == $field['items_type']) { ?>
1269 1269
             <div class="item_totals_type_radio">
1270 1270
 
1271 1271
                 <?php
1272
-                    foreach( $items as $index => $item ) {
1272
+                    foreach ($items as $index => $item) {
1273 1273
 
1274
-                        if ( ! empty( $item['required'] ) ) {
1274
+                        if (!empty($item['required'])) {
1275 1275
                             continue;
1276 1276
                         }
1277 1277
                 ?>
1278 1278
                     <div  class="form-check">
1279
-                        <input class='form-check-input wpinv-items-selector' <?php checked( ! isset( $selected_radio_item ) ); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'>
1280
-                        <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?>&nbsp;<strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) ); ?></strong></label>
1279
+                        <input class='form-check-input wpinv-items-selector' <?php checked(!isset($selected_radio_item)); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'>
1280
+                        <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field($item['title']); ?>&nbsp;<strong><?php echo wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); ?></strong></label>
1281 1281
                     </div>
1282
-                    <?php if ( ! empty( $item['description'] )) { ?>
1283
-                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1282
+                    <?php if (!empty($item['description'])) { ?>
1283
+                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1284 1284
                     <?php } ?>
1285 1285
                 <?php } ?>
1286 1286
 
@@ -1292,32 +1292,32 @@  discard block
 block discarded – undo
1292 1292
                         $tax       = 0;
1293 1293
                         $sub_total = 0;
1294 1294
 
1295
-                        foreach ( $items as $item ) {
1295
+                        foreach ($items as $item) {
1296 1296
 
1297 1297
                             $class  = 'col-8';
1298 1298
                             $class2 = '';
1299 1299
 
1300
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1300
+                            if (!empty($item['allow_quantities'])) {
1301 1301
                                 $class = 'col-6 pt-2';
1302 1302
                                 $class2 = 'pt-2';
1303 1303
                             }
1304 1304
 
1305
-                            if ( ! empty( $item['custom_price'] ) ) {
1305
+                            if (!empty($item['custom_price'])) {
1306 1306
                                 $class .= ' pt-2';
1307 1307
                             }
1308 1308
 
1309 1309
                             $class3 = 'd-none';
1310 1310
                             $name   = '';
1311
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) {
1311
+                            if (!empty($item['required']) || !isset($totals_selected_radio_item)) {
1312 1312
 
1313
-                                $amount = floatval( $item['price'] );
1313
+                                $amount = floatval($item['price']);
1314 1314
 
1315
-                                if ( wpinv_use_taxes() ) {
1315
+                                if (wpinv_use_taxes()) {
1316 1316
 
1317
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1317
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1318 1318
 
1319
-                                    if ( wpinv_prices_include_tax() ) {
1320
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1319
+                                    if (wpinv_prices_include_tax()) {
1320
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
1321 1321
                                         $item_tax = $amount - $pre_tax;
1322 1322
                                     } else {
1323 1323
                                         $pre_tax  = $amount;
@@ -1329,13 +1329,13 @@  discard block
 block discarded – undo
1329 1329
                                     $total     = $sub_total + $tax;
1330 1330
 
1331 1331
                                 } else {
1332
-                                    $total  = $total + $amount;
1332
+                                    $total = $total + $amount;
1333 1333
                                 }
1334 1334
 
1335 1335
                                 $class3 = '';
1336 1336
                                 $name   = "wpinv-items[{$item['id']}]";
1337 1337
 
1338
-                                if ( empty( $item['required'] ) ) {
1338
+                                if (empty($item['required'])) {
1339 1339
                                     $totals_selected_radio_item = 1;
1340 1340
                                 }
1341 1341
 
@@ -1347,9 +1347,9 @@  discard block
 block discarded – undo
1347 1347
 
1348 1348
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
1349 1349
                         <div class='row pl-2 pr-2 pt-2'>
1350
-                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div>
1350
+                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field($item['title']) ?></div>
1351 1351
 
1352
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1352
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1353 1353
 
1354 1354
                                 <div class='col-2'>
1355 1355
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1357,11 +1357,11 @@  discard block
 block discarded – undo
1357 1357
 
1358 1358
                             <?php } else { ?>
1359 1359
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1360
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1360
+                            <?php } if (empty($item['custom_price'])) { ?>
1361 1361
 
1362 1362
                                 <div class='col-4 <?php echo $class2; ?>'>
1363
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1364
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1363
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1364
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1365 1365
                                 </div>
1366 1366
 
1367 1367
                             <?php } else {?>
@@ -1369,15 +1369,15 @@  discard block
 block discarded – undo
1369 1369
                                 <div class='col-4'>
1370 1370
                                     <div class='input-group'>
1371 1371
 
1372
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1372
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1373 1373
                                             <div class='input-group-prepend'>
1374 1374
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1375 1375
                                             </div>
1376 1376
                                         <?php } ?>
1377 1377
 
1378
-                                        <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1378
+                                        <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1379 1379
                                     
1380
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1380
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1381 1381
                                             <div class='input-group-append'>
1382 1382
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1383 1383
                                             </div>
@@ -1388,8 +1388,8 @@  discard block
 block discarded – undo
1388 1388
                             <?php } ?>
1389 1389
 
1390 1390
                         </div>
1391
-                        <?php if ( ! empty( $item['description'] )) { ?>
1392
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1391
+                        <?php if (!empty($item['description'])) { ?>
1392
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1393 1393
                         <?php } ?>
1394 1394
                     </div>
1395 1395
                 <?php } ?>
@@ -1397,25 +1397,25 @@  discard block
 block discarded – undo
1397 1397
                 <div class='mt-4 border-top item_totals_total p-2'>
1398 1398
 
1399 1399
                     <div class='row'>
1400
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1401
-                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1400
+                        <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1401
+                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1402 1402
                     </div>
1403 1403
 
1404 1404
                     <div class='row' style='display: none;'>
1405
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div>
1405
+                        <div class='col-8'><strong class='mr-5'><?php _e('Discount', 'invoicing'); ?></strong></div>
1406 1406
                         <div class='col-4'><strong class='wpinv-items-discount'></strong></div>
1407 1407
                     </div>
1408 1408
 
1409
-                    <?php if ( wpinv_use_taxes() ) { ?>
1409
+                    <?php if (wpinv_use_taxes()) { ?>
1410 1410
                         <div class='row'>
1411
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1412
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1411
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1412
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1413 1413
                         </div>
1414 1414
                     <?php } ?>
1415 1415
 
1416 1416
                     <div class='row'>
1417
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1418
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1417
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1418
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1419 1419
                     </div>
1420 1420
                 </div>
1421 1421
 
@@ -1423,22 +1423,22 @@  discard block
 block discarded – undo
1423 1423
             </div>
1424 1424
         <?php } ?>
1425 1425
 
1426
-        <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?>
1426
+        <?php if ('checkbox' == $field['items_type']) { ?>
1427 1427
 
1428 1428
             <div class="item_totals_type_checkbox">
1429 1429
 
1430 1430
                 <?php
1431
-                    foreach ( $items as $index => $item ) {
1431
+                    foreach ($items as $index => $item) {
1432 1432
 
1433
-                        if ( ! empty( $item['required'] ) ) {
1433
+                        if (!empty($item['required'])) {
1434 1434
                             continue;
1435 1435
                         }
1436 1436
 
1437
-                        $title = sanitize_text_field(  $item['title'] );
1438
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
1439
-                        $item_id    = esc_attr( $id . "_$index" );
1440
-                        $value = esc_attr( $item['id'] );
1441
-                        $checked = checked( ! isset( $selected_checkbox_item ), true, false );
1437
+                        $title = sanitize_text_field($item['title']);
1438
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
1439
+                        $item_id = esc_attr($id . "_$index");
1440
+                        $value = esc_attr($item['id']);
1441
+                        $checked = checked(!isset($selected_checkbox_item), true, false);
1442 1442
                         $selected_checkbox_item = 1;
1443 1443
 
1444 1444
                         echo "
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
                                 <label for='$item_id' class='custom-control-label'>$title &nbsp; ($price)</label>
1448 1448
                             </div>";
1449 1449
 
1450
-                        if ( ! empty( $item['description'] ) ) {
1450
+                        if (!empty($item['description'])) {
1451 1451
                             echo "<small class='form-text text-muted'>{$item['description']}</small>";
1452 1452
                         }
1453 1453
                     }
@@ -1461,31 +1461,31 @@  discard block
 block discarded – undo
1461 1461
                         $tax       = 0;
1462 1462
                         $sub_total = 0;
1463 1463
 
1464
-                        foreach ( $items as $item ) {
1464
+                        foreach ($items as $item) {
1465 1465
 
1466 1466
                             $class  = 'col-8';
1467 1467
                             $class2 = '';
1468 1468
 
1469
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1469
+                            if (!empty($item['allow_quantities'])) {
1470 1470
                                 $class = 'col-6 pt-2';
1471 1471
                                 $class2 = 'pt-2';
1472 1472
                             }
1473 1473
 
1474
-                            if ( ! empty( $item['custom_price'] ) ) {
1474
+                            if (!empty($item['custom_price'])) {
1475 1475
                                 $class .= ' pt-2';
1476 1476
                             }
1477 1477
 
1478 1478
                             $class3 = 'd-none';
1479
-                            $name  = '';
1480
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) {
1479
+                            $name = '';
1480
+                            if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) {
1481 1481
 
1482
-                                $amount = floatval( $item['price'] );
1483
-                                if ( wpinv_use_taxes() ) {
1482
+                                $amount = floatval($item['price']);
1483
+                                if (wpinv_use_taxes()) {
1484 1484
 
1485
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1485
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1486 1486
 
1487
-                                    if ( wpinv_prices_include_tax() ) {
1488
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1487
+                                    if (wpinv_prices_include_tax()) {
1488
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
1489 1489
                                         $item_tax = $amount - $pre_tax;
1490 1490
                                     } else {
1491 1491
                                         $pre_tax  = $amount;
@@ -1497,13 +1497,13 @@  discard block
 block discarded – undo
1497 1497
                                     $total     = $sub_total + $tax;
1498 1498
 
1499 1499
                                 } else {
1500
-                                    $total  = $total + $amount;
1500
+                                    $total = $total + $amount;
1501 1501
                                 }
1502 1502
 
1503 1503
                                 $class3 = '';
1504
-                                $name  = "wpinv-items[{$item['id']}]";
1504
+                                $name = "wpinv-items[{$item['id']}]";
1505 1505
 
1506
-                                if ( empty( $item['required'] ) ) {
1506
+                                if (empty($item['required'])) {
1507 1507
                                     $totals_selected_checkbox_item = 1;
1508 1508
                                 }
1509 1509
 
@@ -1515,9 +1515,9 @@  discard block
 block discarded – undo
1515 1515
 
1516 1516
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
1517 1517
                         <div class='row pl-2 pr-2 pt-2'>
1518
-                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div>
1518
+                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field($item['title']) ?></div>
1519 1519
 
1520
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1520
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1521 1521
 
1522 1522
                                 <div class='col-2'>
1523 1523
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1525,11 +1525,11 @@  discard block
 block discarded – undo
1525 1525
 
1526 1526
                             <?php } else { ?>
1527 1527
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1528
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1528
+                            <?php } if (empty($item['custom_price'])) { ?>
1529 1529
 
1530 1530
                                 <div class='col-4 <?php echo $class2; ?>'>
1531
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1532
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1531
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1532
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1533 1533
                                 </div>
1534 1534
 
1535 1535
                             <?php } else {?>
@@ -1537,15 +1537,15 @@  discard block
 block discarded – undo
1537 1537
                                 <div class='col-4'>
1538 1538
                                     <div class='input-group'>
1539 1539
 
1540
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1540
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1541 1541
                                             <div class='input-group-prepend'>
1542 1542
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1543 1543
                                             </div>
1544 1544
                                         <?php } ?>
1545 1545
 
1546
-                                        <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1546
+                                        <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1547 1547
                                     
1548
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1548
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1549 1549
                                             <div class='input-group-append'>
1550 1550
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1551 1551
                                             </div>
@@ -1556,8 +1556,8 @@  discard block
 block discarded – undo
1556 1556
                             <?php } ?>
1557 1557
 
1558 1558
                         </div>
1559
-                        <?php if ( ! empty( $item['description'] )) { ?>
1560
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1559
+                        <?php if (!empty($item['description'])) { ?>
1560
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1561 1561
                         <?php } ?>
1562 1562
                     </div>
1563 1563
                 <?php } ?>
@@ -1565,32 +1565,32 @@  discard block
 block discarded – undo
1565 1565
                 <div class='mt-4 border-top item_totals_total p-2'>
1566 1566
 
1567 1567
                     <div class='row'>
1568
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1569
-                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1568
+                        <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1569
+                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1570 1570
                     </div>
1571 1571
 
1572 1572
                     <div class='row' style='display: none;'>
1573
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div>
1574
-                        <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price( wpinv_format_amount( 0 ) ) ?></strong></div>
1573
+                        <div class='col-8'><strong class='mr-5'><?php _e('Discount', 'invoicing'); ?></strong></div>
1574
+                        <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price(wpinv_format_amount(0)) ?></strong></div>
1575 1575
                     </div>
1576 1576
 
1577
-                    <?php if ( wpinv_use_taxes() ) { ?>
1577
+                    <?php if (wpinv_use_taxes()) { ?>
1578 1578
                         <div class='row'>
1579
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1580
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1579
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1580
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1581 1581
                         </div>
1582 1582
                     <?php } ?>
1583 1583
 
1584 1584
                     <div class='row'>
1585
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1586
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1585
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1586
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1587 1587
                     </div>
1588 1588
                 </div>
1589 1589
             </div>
1590 1590
             </div>
1591 1591
         <?php } ?>
1592 1592
 
1593
-        <?php if ( 'select' == $field[ 'items_type' ] ) { ?>
1593
+        <?php if ('select' == $field['items_type']) { ?>
1594 1594
 
1595 1595
             <div class="item_totals_type_select">
1596 1596
 
@@ -1598,17 +1598,17 @@  discard block
 block discarded – undo
1598 1598
 
1599 1599
                     $options  = array();
1600 1600
                     $selected = '';
1601
-                    foreach ( $items as $index => $item ) {
1601
+                    foreach ($items as $index => $item) {
1602 1602
 
1603
-                        if ( ! empty( $item['required'] ) ) {
1603
+                        if (!empty($item['required'])) {
1604 1604
                             continue;
1605 1605
                         }
1606 1606
 
1607
-                        $title = sanitize_text_field(  $item['title'] );
1608
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
1609
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
1607
+                        $title = sanitize_text_field($item['title']);
1608
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
1609
+                        $options[$item['id']] = "$title &nbsp; ($price)";
1610 1610
 
1611
-                        if ( ! isset( $selected_item ) ) {
1611
+                        if (!isset($selected_item)) {
1612 1612
                             $selected = $item['id'];
1613 1613
                             $selected_item = 1;
1614 1614
                         }
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
                         array(
1620 1620
                                 'name'        => 'payment-form-items',
1621 1621
                                 'id'          => $id,
1622
-                                'placeholder' => __( 'Select an item', 'invoicing' ),
1622
+                                'placeholder' => __('Select an item', 'invoicing'),
1623 1623
                                 'no_wrap'     => true,
1624 1624
                                 'options'     => $options,
1625 1625
                                 'class'       => 'wpi_select2 wpinv-items-select-selector',
@@ -1636,31 +1636,31 @@  discard block
 block discarded – undo
1636 1636
                         $tax       = 0;
1637 1637
                         $sub_total = 0;
1638 1638
 
1639
-                        foreach ( $items as $item ) {
1639
+                        foreach ($items as $item) {
1640 1640
 
1641 1641
                             $class  = 'col-8';
1642 1642
                             $class2 = '';
1643 1643
 
1644
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1644
+                            if (!empty($item['allow_quantities'])) {
1645 1645
                                 $class = 'col-6 pt-2';
1646 1646
                                 $class2 = 'pt-2';
1647 1647
                             }
1648 1648
 
1649
-                            if ( ! empty( $item['custom_price'] ) ) {
1649
+                            if (!empty($item['custom_price'])) {
1650 1650
                                 $class .= ' pt-2';
1651 1651
                             }
1652 1652
 
1653 1653
                             $class3 = 'd-none';
1654
-                            $name  = '';
1655
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
1654
+                            $name = '';
1655
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
1656 1656
 
1657
-                                $amount = floatval( $item['price'] );
1658
-                                if ( wpinv_use_taxes() ) {
1657
+                                $amount = floatval($item['price']);
1658
+                                if (wpinv_use_taxes()) {
1659 1659
 
1660
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1660
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1661 1661
 
1662
-                                    if ( wpinv_prices_include_tax() ) {
1663
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1662
+                                    if (wpinv_prices_include_tax()) {
1663
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
1664 1664
                                         $item_tax = $amount - $pre_tax;
1665 1665
                                     } else {
1666 1666
                                         $pre_tax  = $amount;
@@ -1672,13 +1672,13 @@  discard block
 block discarded – undo
1672 1672
                                     $total     = $sub_total + $tax;
1673 1673
 
1674 1674
                                 } else {
1675
-                                    $total  = $total + $amount;
1675
+                                    $total = $total + $amount;
1676 1676
                                 }
1677 1677
 
1678 1678
                                 $class3 = '';
1679
-                                $name  = "wpinv-items[{$item['id']}]";
1679
+                                $name = "wpinv-items[{$item['id']}]";
1680 1680
 
1681
-                                if ( empty( $item['required'] ) ) {
1681
+                                if (empty($item['required'])) {
1682 1682
                                     $totals_selected_select_item = 1;
1683 1683
                                 }
1684 1684
 
@@ -1690,9 +1690,9 @@  discard block
 block discarded – undo
1690 1690
 
1691 1691
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
1692 1692
                         <div class='row pl-2 pr-2 pt-2'>
1693
-                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div>
1693
+                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field($item['title']) ?></div>
1694 1694
 
1695
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1695
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1696 1696
 
1697 1697
                                 <div class='col-2'>
1698 1698
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1700,11 +1700,11 @@  discard block
 block discarded – undo
1700 1700
 
1701 1701
                             <?php } else { ?>
1702 1702
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1703
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1703
+                            <?php } if (empty($item['custom_price'])) { ?>
1704 1704
 
1705 1705
                                 <div class='col-4 <?php echo $class2; ?>'>
1706
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1707
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1706
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1707
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1708 1708
                                 </div>
1709 1709
 
1710 1710
                             <?php } else {?>
@@ -1712,15 +1712,15 @@  discard block
 block discarded – undo
1712 1712
                                 <div class='col-4'>
1713 1713
                                     <div class='input-group'>
1714 1714
 
1715
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1715
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1716 1716
                                             <div class='input-group-prepend'>
1717 1717
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1718 1718
                                             </div>
1719 1719
                                         <?php } ?>
1720 1720
 
1721
-                                        <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1721
+                                        <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1722 1722
                                     
1723
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1723
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1724 1724
                                             <div class='input-group-append'>
1725 1725
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1726 1726
                                             </div>
@@ -1731,8 +1731,8 @@  discard block
 block discarded – undo
1731 1731
                             <?php } ?>
1732 1732
 
1733 1733
                         </div>
1734
-                        <?php if ( ! empty( $item['description'] )) { ?>
1735
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1734
+                        <?php if (!empty($item['description'])) { ?>
1735
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1736 1736
                         <?php } ?>
1737 1737
                     </div>
1738 1738
                 <?php } ?>
@@ -1740,31 +1740,31 @@  discard block
 block discarded – undo
1740 1740
                 <div class='mt-4 border-top item_totals_total p-2'>
1741 1741
 
1742 1742
                     <div class='row'>
1743
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1744
-                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1743
+                        <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1744
+                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1745 1745
                     </div>
1746 1746
 
1747 1747
                     <div class='row' style='display: none;'>
1748
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div>
1749
-                        <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price( wpinv_format_amount( 0 ) ) ?></strong></div>
1748
+                        <div class='col-8'><strong class='mr-5'><?php _e('Discount', 'invoicing'); ?></strong></div>
1749
+                        <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price(wpinv_format_amount(0)) ?></strong></div>
1750 1750
                     </div>
1751 1751
 
1752
-                    <?php if ( wpinv_use_taxes() ) { ?>
1752
+                    <?php if (wpinv_use_taxes()) { ?>
1753 1753
                         <div class='row'>
1754
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1755
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1754
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1755
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1756 1756
                         </div>
1757 1757
                     <?php } ?>
1758 1758
                     <div class='row'>
1759
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1760
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1759
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1760
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1761 1761
                     </div>
1762 1762
                 </div>
1763 1763
 
1764 1764
             </div>
1765 1765
         <?php } ?>
1766 1766
 
1767
-        <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?>
1767
+        <?php if ('multi_select' == $field['items_type']) { ?>
1768 1768
 
1769 1769
             <div class="item_totals_type_multi_select">
1770 1770
 
@@ -1773,18 +1773,18 @@  discard block
 block discarded – undo
1773 1773
                     $options  = array();
1774 1774
                     $selected = array();
1775 1775
 
1776
-                    foreach ( $items as $index => $item ) {
1776
+                    foreach ($items as $index => $item) {
1777 1777
 
1778
-                        if ( ! empty( $item['required'] ) ) {
1778
+                        if (!empty($item['required'])) {
1779 1779
                             continue;
1780 1780
                         }
1781 1781
 
1782
-                        $title = sanitize_text_field(  $item['title'] );
1783
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
1784
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
1782
+                        $title = sanitize_text_field($item['title']);
1783
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
1784
+                        $options[$item['id']] = "$title &nbsp; ($price)";
1785 1785
 
1786
-                        if ( ! isset( $selected_item ) ) {
1787
-                            $selected = array( $item['id'] );
1786
+                        if (!isset($selected_item)) {
1787
+                            $selected = array($item['id']);
1788 1788
                             $selected_item = 1;
1789 1789
                         }
1790 1790
 
@@ -1811,31 +1811,31 @@  discard block
 block discarded – undo
1811 1811
                         $tax       = 0;
1812 1812
                         $sub_total = 0;
1813 1813
 
1814
-                        foreach ( $items as $item ) {
1814
+                        foreach ($items as $item) {
1815 1815
 
1816 1816
                             $class  = 'col-8';
1817 1817
                             $class2 = '';
1818 1818
 
1819
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1819
+                            if (!empty($item['allow_quantities'])) {
1820 1820
                                 $class = 'col-6 pt-2';
1821 1821
                                 $class2 = 'pt-2';
1822 1822
                             }
1823 1823
 
1824
-                            if ( ! empty( $item['custom_price'] ) ) {
1824
+                            if (!empty($item['custom_price'])) {
1825 1825
                                 $class .= ' pt-2';
1826 1826
                             }
1827 1827
 
1828 1828
                             $class3 = 'd-none';
1829
-                            $name  = '';
1830
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
1829
+                            $name = '';
1830
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
1831 1831
 
1832
-                                $amount = floatval( $item['price'] );
1833
-                                if ( wpinv_use_taxes() ) {
1832
+                                $amount = floatval($item['price']);
1833
+                                if (wpinv_use_taxes()) {
1834 1834
 
1835
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1835
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1836 1836
 
1837
-                                    if ( wpinv_prices_include_tax() ) {
1838
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1837
+                                    if (wpinv_prices_include_tax()) {
1838
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
1839 1839
                                         $item_tax = $amount - $pre_tax;
1840 1840
                                     } else {
1841 1841
                                         $pre_tax  = $amount;
@@ -1847,13 +1847,13 @@  discard block
 block discarded – undo
1847 1847
                                     $total     = $sub_total + $tax;
1848 1848
 
1849 1849
                                 } else {
1850
-                                    $total  = $total + $amount;
1850
+                                    $total = $total + $amount;
1851 1851
                                 }
1852 1852
 
1853 1853
                                 $class3 = '';
1854
-                                $name  = "wpinv-items[{$item['id']}]";
1854
+                                $name = "wpinv-items[{$item['id']}]";
1855 1855
 
1856
-                                if ( empty( $item['required'] ) ) {
1856
+                                if (empty($item['required'])) {
1857 1857
                                     $totals_selected_select_item = 1;
1858 1858
                                 }
1859 1859
 
@@ -1865,9 +1865,9 @@  discard block
 block discarded – undo
1865 1865
 
1866 1866
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
1867 1867
                         <div class='row pl-2 pr-2 pt-2'>
1868
-                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div>
1868
+                            <div class='<?php echo $class; ?>'><?php echo sanitize_text_field($item['title']) ?></div>
1869 1869
 
1870
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1870
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1871 1871
 
1872 1872
                                 <div class='col-2'>
1873 1873
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1875,11 +1875,11 @@  discard block
 block discarded – undo
1875 1875
 
1876 1876
                             <?php } else { ?>
1877 1877
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1878
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1878
+                            <?php } if (empty($item['custom_price'])) { ?>
1879 1879
 
1880 1880
                                 <div class='col-4 <?php echo $class2; ?>'>
1881
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1882
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1881
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1882
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1883 1883
                                 </div>
1884 1884
 
1885 1885
                             <?php } else {?>
@@ -1887,15 +1887,15 @@  discard block
 block discarded – undo
1887 1887
                                 <div class='col-4'>
1888 1888
                                     <div class='input-group'>
1889 1889
 
1890
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1890
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1891 1891
                                             <div class='input-group-prepend'>
1892 1892
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1893 1893
                                             </div>
1894 1894
                                         <?php } ?>
1895 1895
 
1896
-                                        <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1896
+                                        <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1897 1897
                                     
1898
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1898
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1899 1899
                                             <div class='input-group-append'>
1900 1900
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1901 1901
                                             </div>
@@ -1906,8 +1906,8 @@  discard block
 block discarded – undo
1906 1906
                             <?php } ?>
1907 1907
 
1908 1908
                         </div>
1909
-                        <?php if ( ! empty( $item['description'] )) { ?>
1910
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1909
+                        <?php if (!empty($item['description'])) { ?>
1910
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1911 1911
                         <?php } ?>
1912 1912
                     </div>
1913 1913
                 <?php } ?>
@@ -1915,32 +1915,32 @@  discard block
 block discarded – undo
1915 1915
                 <div class='mt-4 border-top item_totals_total p-2'>
1916 1916
 
1917 1917
                     <div class='row'>
1918
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1919
-                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1918
+                        <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1919
+                        <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1920 1920
                     </div>
1921 1921
 
1922 1922
                     <div class='row' style='display: none;'>
1923
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div>
1924
-                        <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price( wpinv_format_amount( 0 ) ) ?></strong></div>
1923
+                        <div class='col-8'><strong class='mr-5'><?php _e('Discount', 'invoicing'); ?></strong></div>
1924
+                        <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price(wpinv_format_amount(0)) ?></strong></div>
1925 1925
                     </div>
1926 1926
 
1927
-                    <?php if ( wpinv_use_taxes() ) { ?>
1927
+                    <?php if (wpinv_use_taxes()) { ?>
1928 1928
                         <div class='row'>
1929
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1930
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1929
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1930
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1931 1931
                         </div>
1932 1932
                     <?php } ?>
1933 1933
 
1934 1934
                     <div class='row'>
1935
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1936
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1935
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1936
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1937 1937
                     </div>
1938 1938
                 </div>
1939 1939
 
1940 1940
             </div>
1941 1941
         <?php } ?>
1942
-        <?php if ( ! empty( $field[ 'description' ] ) ) { ?>
1943
-            <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small>
1942
+        <?php if (!empty($field['description'])) { ?>
1943
+            <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small>
1944 1944
         <?php } ?>
1945 1945
         </div>
1946 1946
         <?php
@@ -1949,20 +1949,20 @@  discard block
 block discarded – undo
1949 1949
     /**
1950 1950
      * Renders the items element template.
1951 1951
      */
1952
-    public function edit_items_template( $field ) {
1952
+    public function edit_items_template($field) {
1953 1953
         global $wpinv_euvat, $post;
1954 1954
 
1955
-        $restrict = $this->get_restrict_markup( $field, 'items' );
1955
+        $restrict = $this->get_restrict_markup($field, 'items');
1956 1956
         $id2      = $field . '.id + "_edit2"';
1957 1957
         $id3      = $field . '.id + "_edit3"';
1958 1958
 
1959 1959
         // Item types.
1960
-        $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
1960
+        $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
1961 1961
 
1962 1962
         ?>
1963 1963
         <div <?php echo $restrict; ?>>
1964 1964
             <div v-if="!is_default">
1965
-                <div class="mb-1"><?php _e( 'Form Items', 'invoicing' ); ?></div>
1965
+                <div class="mb-1"><?php _e('Form Items', 'invoicing'); ?></div>
1966 1966
                 <draggable v-model='form_items' group='selectable_form_items'>
1967 1967
                     <div class='wpinv-available-items-editor' v-for='(item, index) in form_items' :class="'item_' + item.id" :key="item.id">
1968 1968
 
@@ -1980,35 +1980,35 @@  discard block
 block discarded – undo
1980 1980
 
1981 1981
                                 <div class="form-group" v-if="! item.new">
1982 1982
                                     <span class='form-text'>
1983
-                                        <a target="_blank" :href="'<?php echo esc_url( admin_url( '/post.php?action=edit&post' ) ) ?>=' + item.id">
1984
-                                            <?php _e( 'Edit the item name, price and other details', 'invoicing' ); ?>
1983
+                                        <a target="_blank" :href="'<?php echo esc_url(admin_url('/post.php?action=edit&post')) ?>=' + item.id">
1984
+                                            <?php _e('Edit the item name, price and other details', 'invoicing'); ?>
1985 1985
                                         </a>
1986 1986
                                     </span>
1987 1987
                                 </div>
1988 1988
 
1989 1989
                                 <div class='form-group' v-if="item.new">
1990 1990
                                     <label class='mb-0 w-100'>
1991
-                                        <span><?php _e( 'Item Name', 'invoicing' ); ?></span>
1991
+                                        <span><?php _e('Item Name', 'invoicing'); ?></span>
1992 1992
                                         <input v-model='item.title' type='text' class='w-100'/>
1993 1993
                                     </label>
1994 1994
                                 </div>
1995 1995
 
1996 1996
                                 <div class='form-group'  v-if="item.new">
1997 1997
                                     <label class='mb-0 w-100'>
1998
-                                        <span v-if='!item.custom_price'><?php _e( 'Item Price', 'invoicing' ); ?></span>
1999
-                                        <span v-if='item.custom_price'><?php _e( 'Recommended Price', 'invoicing' ); ?></span>
1998
+                                        <span v-if='!item.custom_price'><?php _e('Item Price', 'invoicing'); ?></span>
1999
+                                        <span v-if='item.custom_price'><?php _e('Recommended Price', 'invoicing'); ?></span>
2000 2000
                                         <input v-model='item.price' type='text' class='w-100'/>
2001 2001
                                     </label>
2002 2002
                                 </div>
2003 2003
 
2004 2004
                                 <div class='form-group' v-if='item.new'>
2005 2005
                                     <label :for="'edit_item_type' + item.id" class='mb-0 w-100'>
2006
-                                        <span><?php _e( 'Item Type', 'invoicing' ); ?></span>
2006
+                                        <span><?php _e('Item Type', 'invoicing'); ?></span>
2007 2007
                                         <select class='w-100' v-model='item.type'>
2008 2008
                                             <?php
2009
-                                                foreach ( $item_types as $type => $_label ) {
2010
-                                                    $type  = esc_attr( $type );
2011
-                                                    $_label = esc_html( $_label );
2009
+                                                foreach ($item_types as $type => $_label) {
2010
+                                                    $type = esc_attr($type);
2011
+                                                    $_label = esc_html($_label);
2012 2012
                                                     echo "<option value='$type'>$_label</type>";
2013 2013
                                                 }
2014 2014
                                             ?>
@@ -2017,71 +2017,71 @@  discard block
 block discarded – undo
2017 2017
                                 </div>
2018 2018
 
2019 2019
                                 <div v-if='item.new'>
2020
-                                    <?php if ( $wpinv_euvat->allow_vat_rules() ) : ?>
2020
+                                    <?php if ($wpinv_euvat->allow_vat_rules()) : ?>
2021 2021
                                         <div class='form-group'>
2022
-                                            <label class='w-100 mb-0'><?php _e( 'VAT Rule', 'invoicing' ) ; ?>
2022
+                                            <label class='w-100 mb-0'><?php _e('VAT Rule', 'invoicing'); ?>
2023 2023
                                                 <select class='w-100' v-model='item.rule'>
2024 2024
                                                     <?php
2025
-                                                        foreach ( $wpinv_euvat->get_rules() as $type => $_label ) {
2026
-                                                            $type  = esc_attr( $type );
2027
-                                                            $_label = esc_html( $_label );
2025
+                                                        foreach ($wpinv_euvat->get_rules() as $type => $_label) {
2026
+                                                            $type = esc_attr($type);
2027
+                                                            $_label = esc_html($_label);
2028 2028
                                                             echo "<option value='$type'>$_label</type>";
2029 2029
                                                         }
2030 2030
                                                     ?>
2031 2031
                                                 </select>
2032 2032
                                             </label>
2033 2033
                                         </div>
2034
-                                    <?php endif;?>
2034
+                                    <?php endif; ?>
2035 2035
 
2036
-                                    <?php if ( $wpinv_euvat->allow_vat_classes() ) : ?>
2036
+                                    <?php if ($wpinv_euvat->allow_vat_classes()) : ?>
2037 2037
                                         <div class='form-group'>
2038
-                                            <label class='w-100 mb-0'><?php _e( 'VAT class', 'invoicing' ) ; ?>
2038
+                                            <label class='w-100 mb-0'><?php _e('VAT class', 'invoicing'); ?>
2039 2039
                                                 <select class='w-100' v-model='item.class'>
2040 2040
                                                     <?php
2041
-                                                        foreach ( $wpinv_euvat->get_all_classes() as $type => $_label ) {
2042
-                                                            $type  = esc_attr( $type );
2043
-                                                            $_label = esc_html( $_label );
2041
+                                                        foreach ($wpinv_euvat->get_all_classes() as $type => $_label) {
2042
+                                                            $type = esc_attr($type);
2043
+                                                            $_label = esc_html($_label);
2044 2044
                                                             echo "<option value='$type'>$_label</type>"; 
2045 2045
                                                         }
2046 2046
                                                     ?>
2047 2047
                                                 </select>
2048 2048
                                             </label>
2049 2049
                                         </div>
2050
-                                    <?php endif;?>
2050
+                                    <?php endif; ?>
2051 2051
                                                         
2052 2052
                                 </div>
2053 2053
 
2054 2054
                                 <label v-if='item.new' class='form-group'>
2055 2055
                                     <input v-model='item.custom_price' type='checkbox' />
2056
-                                    <span class='form-check-label'><?php _e( 'Allow users to pay what they want', 'invoicing' ); ?></span>
2056
+                                    <span class='form-check-label'><?php _e('Allow users to pay what they want', 'invoicing'); ?></span>
2057 2057
                                 </label>
2058 2058
 
2059 2059
                                 <div class='form-group' v-if='item.new && item.custom_price'>
2060 2060
                                     <label class='mb-0 w-100'>
2061
-                                        <span><?php _e( 'Minimum Price', 'invoicing' ); ?></span>
2061
+                                        <span><?php _e('Minimum Price', 'invoicing'); ?></span>
2062 2062
                                         <input placeholder='0.00' v-model='item.minimum_price' class='w-100' />
2063
-                                        <small class='form-text text-muted'><?php _e( 'Enter the minimum price that a user can pay', 'invoicing' ); ?></small>
2063
+                                        <small class='form-text text-muted'><?php _e('Enter the minimum price that a user can pay', 'invoicing'); ?></small>
2064 2064
                                     </label>
2065 2065
                                 </div>
2066 2066
 
2067 2067
                                 <label class='form-group'>
2068 2068
                                     <input v-model='item.allow_quantities' type='checkbox' />
2069
-                                    <span><?php _e( 'Allow users to buy several quantities', 'invoicing' ); ?></span>
2069
+                                    <span><?php _e('Allow users to buy several quantities', 'invoicing'); ?></span>
2070 2070
                                 </label>
2071 2071
 
2072 2072
                                 <label class='form-group'>
2073 2073
                                     <input v-model='item.required' type='checkbox' />
2074
-                                    <span><?php _e( 'This item is required', 'invoicing' ); ?></span>
2074
+                                    <span><?php _e('This item is required', 'invoicing'); ?></span>
2075 2075
                                 </label>
2076 2076
 
2077 2077
                                 <div class='form-group'>
2078 2078
                                     <label class="mb-0 w-100">
2079
-                                        <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
2079
+                                        <span><?php _e('Item Description', 'invoicing'); ?></span>
2080 2080
                                         <textarea v-model='item.description' class='w-100'></textarea>
2081 2081
                                     </label>
2082 2082
                                 </div>
2083 2083
 
2084
-                                    <button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'><?php _e( 'Delete Item', 'invoicing' ); ?></button>
2084
+                                    <button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'><?php _e('Delete Item', 'invoicing'); ?></button>
2085 2085
 
2086 2086
                                 </div>
2087 2087
                             </div>
@@ -2089,37 +2089,37 @@  discard block
 block discarded – undo
2089 2089
                         </div>
2090 2090
                 </draggable>
2091 2091
 
2092
-                <small v-if='! form_items.length' class='form-text text-danger'><?php _e( 'You have not set up any items. Please select an item below or create a new item.', 'invoicing' ); ?></small>
2092
+                <small v-if='! form_items.length' class='form-text text-danger'><?php _e('You have not set up any items. Please select an item below or create a new item.', 'invoicing'); ?></small>
2093 2093
 
2094 2094
                 <div class='form-group mt-2'>
2095 2095
 
2096 2096
                     <select class='w-100' style="padding: 6px 24px 6px 8px; border-color: #e0e0e0;" v-model='selected_item' @change='addSelectedItem'>
2097
-                        <option value=''><?php _e( 'Select an item to add...', 'invoicing' ) ?></option>
2097
+                        <option value=''><?php _e('Select an item to add...', 'invoicing') ?></option>
2098 2098
                         <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option>
2099 2099
                     </select>
2100 2100
 
2101 2101
                 </div>
2102 2102
 
2103 2103
                 <div class='form-group'>
2104
-                    <button @click.prevent='addNewItem' class="button button-link"><?php _e( 'Or create a new item.', 'invoicing' ) ?></button>
2104
+                    <button @click.prevent='addNewItem' class="button button-link"><?php _e('Or create a new item.', 'invoicing') ?></button>
2105 2105
                 </div>
2106 2106
 
2107 2107
                 <div class='form-group mt-5'>
2108
-                    <label :for='<?php echo $id2; ?>'><?php _e( 'Let customers...', 'invoicing' ) ?></label>
2108
+                    <label :for='<?php echo $id2; ?>'><?php _e('Let customers...', 'invoicing') ?></label>
2109 2109
 
2110 2110
                     <select class='w-100' style="padding: 6px 24px 6px 8px; border-color: #e0e0e0;" :id='<?php echo $id2; ?>' v-model='<?php echo $field; ?>.items_type'>
2111
-                        <option value='total' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Buy all items on the list', 'invoicing' ); ?></option>
2112
-                        <option value='radio'><?php _e( 'Select a single item from the list', 'invoicing' ); ?></option>
2113
-                        <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Select one or more items on the list', 'invoicing' ) ;?></option>
2114
-                        <option value='select'><?php _e( 'Select a single item from a dropdown', 'invoicing' ); ?></option>
2115
-                        <option value='multi_select' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Select a one or more items from a dropdown', 'invoicing' ) ;?></option>
2111
+                        <option value='total' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e('Buy all items on the list', 'invoicing'); ?></option>
2112
+                        <option value='radio'><?php _e('Select a single item from the list', 'invoicing'); ?></option>
2113
+                        <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e('Select one or more items on the list', 'invoicing'); ?></option>
2114
+                        <option value='select'><?php _e('Select a single item from a dropdown', 'invoicing'); ?></option>
2115
+                        <option value='multi_select' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e('Select a one or more items from a dropdown', 'invoicing'); ?></option>
2116 2116
                     </select>
2117 2117
 
2118 2118
                 </div>
2119 2119
             </div>
2120 2120
             <div class='form-group'>
2121
-                <label :for='<?php echo $id3; ?>'><?php _e( 'Help Text', 'invoicing' ); ?></label>
2122
-                <textarea placeholder='<?php esc_attr_e( 'Add some help text for this element', 'invoicing' ); ?>' :id='<?php echo $id3; ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea>
2121
+                <label :for='<?php echo $id3; ?>'><?php _e('Help Text', 'invoicing'); ?></label>
2122
+                <textarea placeholder='<?php esc_attr_e('Add some help text for this element', 'invoicing'); ?>' :id='<?php echo $id3; ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea>
2123 2123
             </div>
2124 2124
 
2125 2125
         </div>
@@ -2138,7 +2138,7 @@  discard block
 block discarded – undo
2138 2138
             'orderby'        => 'title',
2139 2139
             'order'          => 'ASC',
2140 2140
             'posts_per_page' => -1,
2141
-            'post_status'    => array( 'publish' ),
2141
+            'post_status'    => array('publish'),
2142 2142
             'meta_query'     => array(
2143 2143
                 array(
2144 2144
                     'key'       => '_wpinv_type',
@@ -2148,15 +2148,15 @@  discard block
 block discarded – undo
2148 2148
             )
2149 2149
         );
2150 2150
 
2151
-        $items = get_posts( apply_filters( 'getpaid_payment_form_item_dropdown_query_args', $item_args ) );
2151
+        $items = get_posts(apply_filters('getpaid_payment_form_item_dropdown_query_args', $item_args));
2152 2152
 
2153
-        if ( empty( $items ) ) {
2153
+        if (empty($items)) {
2154 2154
             return array();
2155 2155
         }
2156 2156
 
2157
-        $options    = array();
2158
-        foreach ( $items as $item ) {
2159
-            $item      = new GetPaid_Form_Item( $item );
2157
+        $options = array();
2158
+        foreach ($items as $item) {
2159
+            $item      = new GetPaid_Form_Item($item);
2160 2160
             $options[] = $item->prepare_data_for_use();
2161 2161
         }
2162 2162
         return $options;
@@ -2166,39 +2166,39 @@  discard block
 block discarded – undo
2166 2166
     /**
2167 2167
      * Returns an array of items for the currently being edited form.
2168 2168
      */
2169
-    public function get_form_items( $id = false ) {
2170
-        $form = new GetPaid_Payment_Form( $id );
2169
+    public function get_form_items($id = false) {
2170
+        $form = new GetPaid_Payment_Form($id);
2171 2171
 
2172 2172
         // Is this a default form?
2173
-        if ( $form->is_default() ) {
2173
+        if ($form->is_default()) {
2174 2174
             return array();
2175 2175
         }
2176 2176
 
2177
-        return $form->get_items( 'view', 'arrays' );
2177
+        return $form->get_items('view', 'arrays');
2178 2178
     }
2179 2179
 
2180 2180
     /**
2181 2181
      * Converts form items for use.
2182 2182
      */
2183
-    public function convert_checkout_items( $items, $invoice ) {
2183
+    public function convert_checkout_items($items, $invoice) {
2184 2184
 
2185 2185
         $converted = array();
2186
-        foreach ( $items as $item ) {
2186
+        foreach ($items as $item) {
2187 2187
 
2188 2188
             $item_id = $item['id'];
2189
-            $_item   = new WPInv_Item( $item_id );
2189
+            $_item   = new WPInv_Item($item_id);
2190 2190
 
2191
-            if( ! $_item ) {
2191
+            if (!$_item) {
2192 2192
                 continue;
2193 2193
             }
2194 2194
 
2195 2195
             $converted[] = array(
2196
-                'title'            => esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $_item ),
2196
+                'title'            => esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($_item),
2197 2197
                 'id'               => $item['id'],
2198 2198
                 'price'            => $item['subtotal'],
2199 2199
                 'custom_price'     => $_item->get_is_dynamic_pricing(),
2200 2200
                 'recurring'        => $_item->is_recurring(),
2201
-                'description'      => apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice ),
2201
+                'description'      => apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice),
2202 2202
                 'minimum_price'    => $_item->get_minimum_price(),
2203 2203
                 'allow_quantities' => false,
2204 2204
                 'quantity'         => $item['quantity'],
@@ -2212,27 +2212,27 @@  discard block
 block discarded – undo
2212 2212
     /**
2213 2213
      * Converts an array of id => quantity for use.
2214 2214
      */
2215
-    public function convert_normal_items( $items ) {
2215
+    public function convert_normal_items($items) {
2216 2216
 
2217 2217
         $converted = array();
2218
-        foreach ( $items as $item_id => $quantity ) {
2218
+        foreach ($items as $item_id => $quantity) {
2219 2219
 
2220
-            $item   = new WPInv_Item( $item_id );
2220
+            $item = new WPInv_Item($item_id);
2221 2221
 
2222
-            if( ! $item ) {
2222
+            if (!$item) {
2223 2223
                 continue;
2224 2224
             }
2225 2225
 
2226 2226
             $converted[] = array(
2227
-                'title'            => esc_html( $item->get_name() ) . wpinv_get_item_suffix( $item ),
2227
+                'title'            => esc_html($item->get_name()) . wpinv_get_item_suffix($item),
2228 2228
                 'id'               => $item_id,
2229 2229
                 'price'            => $item->get_price(),
2230 2230
                 'custom_price'     => $item->get_is_dynamic_pricing(),
2231 2231
                 'recurring'        => $item->is_recurring(),
2232 2232
                 'description'      => $item->get_summary(),
2233 2233
                 'minimum_price'    => $item->get_minimum_price(),
2234
-                'allow_quantities' => ! empty( $quantity ),
2235
-                'quantity'         => empty( $quantity ) ? 1 : $quantity,
2234
+                'allow_quantities' => !empty($quantity),
2235
+                'quantity'         => empty($quantity) ? 1 : $quantity,
2236 2236
                 'required'         => true,
2237 2237
             );
2238 2238
 
@@ -2245,28 +2245,28 @@  discard block
 block discarded – undo
2245 2245
     /**
2246 2246
      * Returns an array of elements for the currently being edited form.
2247 2247
      */
2248
-    public function get_form_elements( $id = false ) {
2248
+    public function get_form_elements($id = false) {
2249 2249
 
2250
-        if ( empty( $id ) ) {
2251
-            return wpinv_get_data( 'sample-payment-form' );
2250
+        if (empty($id)) {
2251
+            return wpinv_get_data('sample-payment-form');
2252 2252
         }
2253 2253
         
2254
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
2254
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
2255 2255
 
2256
-        if ( is_array( $form_elements ) ) {
2256
+        if (is_array($form_elements)) {
2257 2257
             return $form_elements;
2258 2258
         }
2259 2259
 
2260
-        return wpinv_get_data( 'sample-payment-form' );
2260
+        return wpinv_get_data('sample-payment-form');
2261 2261
     }
2262 2262
 
2263 2263
     /**
2264 2264
      * Sends a redrect response to payment details.
2265 2265
      *
2266 2266
      */
2267
-    public function send_redirect_response( $url ) {
2268
-        $url = urlencode( $url );
2269
-        wp_send_json_success( $url );
2267
+    public function send_redirect_response($url) {
2268
+        $url = urlencode($url);
2269
+        wp_send_json_success($url);
2270 2270
     }
2271 2271
 
2272 2272
     /**
@@ -2277,12 +2277,12 @@  discard block
 block discarded – undo
2277 2277
 
2278 2278
         $errors = wpinv_get_errors();
2279 2279
 
2280
-        if ( ! empty( $errors ) ) {
2280
+        if (!empty($errors)) {
2281 2281
             wpinv_print_errors();
2282 2282
             exit;
2283 2283
         }
2284 2284
 
2285
-        wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) );
2285
+        wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing'));
2286 2286
         exit;
2287 2287
 
2288 2288
     }
Please login to merge, or discard this patch.
includes/gateways/paypal.php 1 patch
Spacing   +282 added lines, -282 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_paypal_cc_form', '__return_false' );
6
-add_filter( 'wpinv_paypal_support_subscription', '__return_true' );
5
+add_action('wpinv_paypal_cc_form', '__return_false');
6
+add_filter('wpinv_paypal_support_subscription', '__return_true');
7 7
 
8 8
 
9
-function wpinv_paypal_gateway_description_sandbox_notice( $description, $gateway ) {
10
-    if ( 'paypal' == $gateway && wpinv_is_test_mode( 'paypal' ) ) {
9
+function wpinv_paypal_gateway_description_sandbox_notice($description, $gateway) {
10
+    if ('paypal' == $gateway && wpinv_is_test_mode('paypal')) {
11 11
         $description .= '<br>' . sprintf(
12
-            __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
12
+            __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'),
13 13
             '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
14 14
             '</a>'
15 15
         );
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     return $description;
18 18
 
19 19
 }
20
-add_filter( 'wpinv_gateway_description', 'wpinv_paypal_gateway_description_sandbox_notice', 10, 2 );
20
+add_filter('wpinv_gateway_description', 'wpinv_paypal_gateway_description_sandbox_notice', 10, 2);
21 21
 
22
-function wpinv_process_paypal_payment( $purchase_data ) {
23
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
24
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
22
+function wpinv_process_paypal_payment($purchase_data) {
23
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
24
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
25 25
     }
26 26
 
27 27
     // Collect payment data
@@ -39,24 +39,24 @@  discard block
 block discarded – undo
39 39
     );
40 40
 
41 41
     // Record the pending payment
42
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
42
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
43 43
 
44 44
     // Check payment
45
-    if ( ! $invoice ) {
45
+    if (!$invoice) {
46 46
         // Record the error
47
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
47
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
48 48
         // Problems? send back
49
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
49
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
50 50
     } else {
51 51
         // Only send to PayPal if the pending payment is created successfully
52
-        $listener_url = wpinv_get_ipn_url( 'paypal' );
52
+        $listener_url = wpinv_get_ipn_url('paypal');
53 53
 
54 54
         // Get the success url
55
-        $return_url = add_query_arg( array(
55
+        $return_url = add_query_arg(array(
56 56
                 'payment-confirm' => 'paypal',
57 57
                 'invoice-id'      => $invoice->ID,
58 58
                 'utm_nooverride'  => 1
59
-            ), get_permalink( wpinv_get_option( 'success_page', false ) ) );
59
+            ), get_permalink(wpinv_get_option('success_page', false)));
60 60
 
61 61
         // Get the PayPal redirect uri
62 62
         $paypal_redirect = wpinv_get_paypal_redirect();
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         $paypal_args = array(
66 66
             'cmd'           => '_cart',
67 67
             'upload'        => '1',
68
-            'business'      => wpinv_get_option( 'paypal_email', false ),
68
+            'business'      => wpinv_get_option('paypal_email', false),
69 69
             'email'         => $invoice->get_email(),
70 70
             'first_name'    => $invoice->get_first_name(),
71 71
             'last_name'     => $invoice->get_last_name(),
@@ -74,88 +74,88 @@  discard block
 block discarded – undo
74 74
             'shipping'      => '0',
75 75
             'no_note'       => '1',
76 76
             'currency_code' => $invoice->get_currency(),
77
-            'charset'       => get_bloginfo( 'charset' ),
77
+            'charset'       => get_bloginfo('charset'),
78 78
             'custom'        => $invoice->ID,
79 79
             'rm'            => is_ssl() ? 2 : 1,
80
-            'return'        => esc_url_raw( $return_url ),
80
+            'return'        => esc_url_raw($return_url),
81 81
             'cancel_return' => $invoice->get_checkout_payment_url(),
82 82
             'notify_url'    => $listener_url,
83
-            'cbt'           => get_bloginfo( 'name' ),
83
+            'cbt'           => get_bloginfo('name'),
84 84
             'bn'            => 'WPInvoicing_SP',
85 85
         );
86 86
 
87 87
         // Add cart items
88 88
         $i = 1;
89
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
90
-            foreach ( $purchase_data['cart_details'] as $item ) {
89
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
90
+            foreach ($purchase_data['cart_details'] as $item) {
91 91
                 $item['quantity'] = $item['quantity'] > 0 ? $item['quantity'] : 1;
92
-                $item_amount = wpinv_sanitize_amount( $item['subtotal'] / $item['quantity'], 2 );
92
+                $item_amount = wpinv_sanitize_amount($item['subtotal'] / $item['quantity'], 2);
93 93
 
94
-                if ( $item_amount <= 0 ) {
94
+                if ($item_amount <= 0) {
95 95
                     $item_amount = 0;
96 96
                 }
97 97
 
98
-                $paypal_args['item_number_' . $i ]      = $item['id'];
99
-                $paypal_args['item_name_' . $i ]        = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( $item ), ENT_COMPAT, 'UTF-8' ) );
100
-                $paypal_args['quantity_' . $i ]         = $item['quantity'];
101
-                $paypal_args['amount_' . $i ]           = $item_amount;
102
-                $paypal_args['discount_amount_' . $i ]  = wpinv_sanitize_amount( $item['discount'], 2 );
98
+                $paypal_args['item_number_' . $i]      = $item['id'];
99
+                $paypal_args['item_name_' . $i]        = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name($item), ENT_COMPAT, 'UTF-8'));
100
+                $paypal_args['quantity_' . $i]         = $item['quantity'];
101
+                $paypal_args['amount_' . $i]           = $item_amount;
102
+                $paypal_args['discount_amount_' . $i]  = wpinv_sanitize_amount($item['discount'], 2);
103 103
 
104 104
                 $i++;
105 105
             }
106 106
         }
107 107
 
108 108
         // Add taxes to the cart
109
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
110
-            $paypal_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_tax(), 2 );
109
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
110
+            $paypal_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_tax(), 2);
111 111
         }
112 112
 
113
-        $paypal_args = apply_filters( 'wpinv_paypal_args', $paypal_args, $purchase_data, $invoice );
113
+        $paypal_args = apply_filters('wpinv_paypal_args', $paypal_args, $purchase_data, $invoice);
114 114
 
115 115
         // Build query
116
-        $paypal_redirect .= http_build_query( $paypal_args );
116
+        $paypal_redirect .= http_build_query($paypal_args);
117 117
 
118 118
         // Fix for some sites that encode the entities
119
-        $paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
119
+        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
120 120
 
121 121
         // Get rid of cart contents
122 122
         wpinv_empty_cart();
123 123
         
124 124
         // Redirect to PayPal
125
-        wp_redirect( $paypal_redirect );
125
+        wp_redirect($paypal_redirect);
126 126
         exit;
127 127
     }
128 128
 }
129
-add_action( 'wpinv_gateway_paypal', 'wpinv_process_paypal_payment' );
129
+add_action('wpinv_gateway_paypal', 'wpinv_process_paypal_payment');
130 130
 
131
-function wpinv_get_paypal_recurring_args( $paypal_args, $purchase_data, $invoice ) {
132
-    if ( $invoice->is_recurring() && $subscription = wpinv_get_subscription( $invoice->ID ) ) {
131
+function wpinv_get_paypal_recurring_args($paypal_args, $purchase_data, $invoice) {
132
+    if ($invoice->is_recurring() && $subscription = wpinv_get_subscription($invoice->ID)) {
133 133
 
134
-        $period             = strtoupper( substr( $subscription->period, 0, 1) );
134
+        $period             = strtoupper(substr($subscription->period, 0, 1));
135 135
         $interval           = $subscription->frequency;
136 136
         $bill_times         = (int) $subscription->bill_times;
137 137
         
138
-        $initial_amount     = wpinv_sanitize_amount( $invoice->get_total(), 2 );
139
-        $recurring_amount   = wpinv_sanitize_amount( $invoice->get_recurring_details( 'total' ), 2 );
138
+        $initial_amount     = wpinv_sanitize_amount($invoice->get_total(), 2);
139
+        $recurring_amount   = wpinv_sanitize_amount($invoice->get_recurring_details('total'), 2);
140 140
         
141 141
         $paypal_args['cmd'] = '_xclick-subscriptions';
142 142
         $paypal_args['sra'] = '1';
143 143
         $paypal_args['src'] = '1';
144 144
         
145 145
         // Set item description
146
-        $item_name                  = wpinv_get_cart_item_name( array( 'id' => $subscription->product_id ) );
147
-        $paypal_args['item_name']   = stripslashes_deep( html_entity_decode( $item_name, ENT_COMPAT, 'UTF-8' ) );
146
+        $item_name                  = wpinv_get_cart_item_name(array('id' => $subscription->product_id));
147
+        $paypal_args['item_name']   = stripslashes_deep(html_entity_decode($item_name, ENT_COMPAT, 'UTF-8'));
148 148
         $paypal_args['item_number'] = $subscription->product_id;
149
-        $item   = new WPInv_Item( $subscription->period );
149
+        $item = new WPInv_Item($subscription->period);
150 150
 
151
-        if ( $invoice->is_free_trial() && $item->has_free_trial() ) {
151
+        if ($invoice->is_free_trial() && $item->has_free_trial()) {
152 152
             $paypal_args['a1']  = $initial_amount;
153 153
             $paypal_args['p1']  = $item->get_trial_interval();
154 154
             $paypal_args['t1']  = $item->get_trial_period();
155 155
             
156 156
             // Set the recurring amount
157 157
             $paypal_args['a3']  = $recurring_amount;
158
-        } else if ( $initial_amount != $recurring_amount && $bill_times != 1 ) {
158
+        } else if ($initial_amount != $recurring_amount && $bill_times != 1) {
159 159
             $paypal_args['a1']  = $initial_amount;
160 160
             $paypal_args['p1']  = $interval;
161 161
             $paypal_args['t1']  = $period;
@@ -163,63 +163,63 @@  discard block
 block discarded – undo
163 163
             // Set the recurring amount
164 164
             $paypal_args['a3']  = $recurring_amount;
165 165
             
166
-            if ( $bill_times > 1 ) {
166
+            if ($bill_times > 1) {
167 167
                 $bill_times--;
168 168
             }
169 169
         } else {
170
-            $paypal_args['a3']  = $initial_amount;
170
+            $paypal_args['a3'] = $initial_amount;
171 171
         }
172 172
         
173 173
         $paypal_args['p3']  = $interval;
174 174
         $paypal_args['t3']  = $period;
175 175
         
176
-        if ( $bill_times > 1 ) {
176
+        if ($bill_times > 1) {
177 177
             // Make sure it's not over the max of 52
178
-            $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
178
+            $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
179 179
         }
180 180
                 
181 181
         // Remove cart items
182 182
         $i = 1;
183
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
184
-            foreach ( $purchase_data['cart_details'] as $item ) {                
185
-                if ( isset( $paypal_args['item_number_' . $i] ) ) {
186
-                    unset( $paypal_args['item_number_' . $i] );
183
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
184
+            foreach ($purchase_data['cart_details'] as $item) {                
185
+                if (isset($paypal_args['item_number_' . $i])) {
186
+                    unset($paypal_args['item_number_' . $i]);
187 187
                 }
188
-                if ( isset( $paypal_args['item_name_' . $i] ) ) {
189
-                    unset( $paypal_args['item_name_' . $i] );
188
+                if (isset($paypal_args['item_name_' . $i])) {
189
+                    unset($paypal_args['item_name_' . $i]);
190 190
                 }
191
-                if ( isset( $paypal_args['quantity_' . $i] ) ) {
192
-                    unset( $paypal_args['quantity_' . $i] );
191
+                if (isset($paypal_args['quantity_' . $i])) {
192
+                    unset($paypal_args['quantity_' . $i]);
193 193
                 }
194
-                if ( isset( $paypal_args['amount_' . $i] ) ) {
195
-                    unset( $paypal_args['amount_' . $i] );
194
+                if (isset($paypal_args['amount_' . $i])) {
195
+                    unset($paypal_args['amount_' . $i]);
196 196
                 }
197
-                if ( isset( $paypal_args['discount_amount_' . $i] ) ) {
198
-                    unset( $paypal_args['discount_amount_' . $i] );
197
+                if (isset($paypal_args['discount_amount_' . $i])) {
198
+                    unset($paypal_args['discount_amount_' . $i]);
199 199
                 }
200 200
 
201 201
                 $i++;
202 202
             }
203 203
         }
204 204
         
205
-        if ( isset( $paypal_args['tax_cart'] ) ) {
206
-            unset( $paypal_args['tax_cart'] );
205
+        if (isset($paypal_args['tax_cart'])) {
206
+            unset($paypal_args['tax_cart']);
207 207
         }
208 208
                 
209
-        if ( isset( $paypal_args['upload'] ) ) {
210
-            unset( $paypal_args['upload'] );
209
+        if (isset($paypal_args['upload'])) {
210
+            unset($paypal_args['upload']);
211 211
         }
212 212
         
213
-        $paypal_args = apply_filters( 'wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice );
213
+        $paypal_args = apply_filters('wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice);
214 214
     }
215 215
     
216 216
     return $paypal_args;
217 217
 }
218
-add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 );
218
+add_filter('wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3);
219 219
 
220 220
 function wpinv_process_paypal_ipn() {
221 221
 	// Check the request method is POST
222
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
222
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
223 223
 		return;
224 224
 	}
225 225
 
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 	$post_data = '';
228 228
 
229 229
 	// Fallback just in case post_max_size is lower than needed
230
-	if ( ini_get( 'allow_url_fopen' ) ) {
231
-		$post_data = file_get_contents( 'php://input' );
230
+	if (ini_get('allow_url_fopen')) {
231
+		$post_data = file_get_contents('php://input');
232 232
 	} else {
233 233
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
234
-		ini_set( 'post_max_size', '12M' );
234
+		ini_set('post_max_size', '12M');
235 235
 	}
236 236
 	// Start the encoded data collection with notification command
237 237
 	$encoded_data = 'cmd=_notify-validate';
@@ -240,43 +240,43 @@  discard block
 block discarded – undo
240 240
 	$arg_separator = wpinv_get_php_arg_separator_output();
241 241
 
242 242
 	// Verify there is a post_data
243
-	if ( $post_data || strlen( $post_data ) > 0 ) {
243
+	if ($post_data || strlen($post_data) > 0) {
244 244
 		// Append the data
245
-		$encoded_data .= $arg_separator.$post_data;
245
+		$encoded_data .= $arg_separator . $post_data;
246 246
 	} else {
247 247
 		// Check if POST is empty
248
-		if ( empty( $_POST ) ) {
248
+		if (empty($_POST)) {
249 249
 			// Nothing to do
250 250
 			return;
251 251
 		} else {
252 252
 			// Loop through each POST
253
-			foreach ( $_POST as $key => $value ) {
253
+			foreach ($_POST as $key => $value) {
254 254
 				// Encode the value and append the data
255
-				$encoded_data .= $arg_separator."$key=" . urlencode( $value );
255
+				$encoded_data .= $arg_separator . "$key=" . urlencode($value);
256 256
 			}
257 257
 		}
258 258
 	}
259 259
 
260 260
 	// Convert collected post data to an array
261
-	wp_parse_str( $encoded_data, $encoded_data_array );
261
+	wp_parse_str($encoded_data, $encoded_data_array);
262 262
 
263
-	foreach ( $encoded_data_array as $key => $value ) {
264
-		if ( false !== strpos( $key, 'amp;' ) ) {
265
-			$new_key = str_replace( '&amp;', '&', $key );
266
-			$new_key = str_replace( 'amp;', '&' , $new_key );
263
+	foreach ($encoded_data_array as $key => $value) {
264
+		if (false !== strpos($key, 'amp;')) {
265
+			$new_key = str_replace('&amp;', '&', $key);
266
+			$new_key = str_replace('amp;', '&', $new_key);
267 267
 
268
-			unset( $encoded_data_array[ $key ] );
269
-			$encoded_data_array[ $new_key ] = $value;
268
+			unset($encoded_data_array[$key]);
269
+			$encoded_data_array[$new_key] = $value;
270 270
 		}
271 271
 	}
272 272
 
273 273
 	// Get the PayPal redirect uri
274
-	$paypal_redirect = wpinv_get_paypal_redirect( true );
274
+	$paypal_redirect = wpinv_get_paypal_redirect(true);
275 275
 
276
-	if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
276
+	if (!wpinv_get_option('disable_paypal_verification', false)) {
277 277
 		// Validate the IPN
278 278
 
279
-		$remote_post_vars      = array(
279
+		$remote_post_vars = array(
280 280
 			'method'           => 'POST',
281 281
 			'timeout'          => 45,
282 282
 			'redirection'      => 5,
@@ -294,21 +294,21 @@  discard block
 block discarded – undo
294 294
 		);
295 295
 
296 296
 		// Get response
297
-		$api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
297
+		$api_response = wp_remote_post(wpinv_get_paypal_redirect(), $remote_post_vars);
298 298
 
299
-		if ( is_wp_error( $api_response ) ) {
300
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
299
+		if (is_wp_error($api_response)) {
300
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
301 301
 			return; // Something went wrong
302 302
 		}
303 303
 
304
-		if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
305
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
304
+		if ($api_response['body'] !== 'VERIFIED' && wpinv_get_option('disable_paypal_verification', false)) {
305
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
306 306
 			return; // Response not okay
307 307
 		}
308 308
 	}
309 309
 
310 310
 	// Check if $post_data_array has been populated
311
-	if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
311
+	if (!is_array($encoded_data_array) && !empty($encoded_data_array))
312 312
 		return;
313 313
 
314 314
 	$defaults = array(
@@ -316,265 +316,265 @@  discard block
 block discarded – undo
316 316
 		'payment_status' => ''
317 317
 	);
318 318
 
319
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
319
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
320 320
 
321
-	$invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
321
+	$invoice_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
322 322
     
323
-	wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
324
-	wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
323
+	wpinv_error_log($encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__);
324
+	wpinv_error_log($encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__);
325 325
 
326
-	if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
326
+	if (has_action('wpinv_paypal_' . $encoded_data_array['txn_type'])) {
327 327
 		// Allow PayPal IPN types to be processed separately
328
-		do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
328
+		do_action('wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id);
329 329
 	} else {
330 330
 		// Fallback to web accept just in case the txn_type isn't present
331
-		do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
331
+		do_action('wpinv_paypal_web_accept', $encoded_data_array, $invoice_id);
332 332
 	}
333 333
 	exit;
334 334
 }
335
-add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' );
335
+add_action('wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn');
336 336
 
337
-function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) {
338
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
337
+function wpinv_process_paypal_web_accept_and_cart($data, $invoice_id) {
338
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
339 339
 		return;
340 340
 	}
341 341
 
342
-	if( empty( $invoice_id ) ) {
342
+	if (empty($invoice_id)) {
343 343
 		return;
344 344
 	}
345 345
 
346 346
 	// Collect payment details
347
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
347
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
348 348
 	$paypal_amount  = $data['mc_gross'];
349
-	$payment_status = strtolower( $data['payment_status'] );
350
-	$currency_code  = strtolower( $data['mc_currency'] );
351
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
352
-	$payment_meta   = wpinv_get_invoice_meta( $invoice_id );
349
+	$payment_status = strtolower($data['payment_status']);
350
+	$currency_code  = strtolower($data['mc_currency']);
351
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
352
+	$payment_meta   = wpinv_get_invoice_meta($invoice_id);
353 353
 
354
-	if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
354
+	if (wpinv_get_payment_gateway($invoice_id) != 'paypal') {
355 355
 		return; // this isn't a PayPal standard IPN
356 356
 	}
357 357
 
358 358
 	// Verify payment recipient
359
-	if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
360
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
361
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
362
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
359
+	if (strcasecmp($business_email, trim(wpinv_get_option('paypal_email', false))) != 0) {
360
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
361
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
362
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid PayPal business email.', 'invoicing'), '', '', true);
363 363
 		return;
364 364
 	}
365 365
 
366 366
 	// Verify payment currency
367
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
368
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
369
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
370
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
367
+	if ($currency_code != strtolower($payment_meta['currency'])) {
368
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
369
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
370
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid currency in PayPal IPN.', 'invoicing'), '', '', true);
371 371
 		return;
372 372
 	}
373 373
 
374
-	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
374
+	if (!wpinv_get_payment_user_email($invoice_id)) {
375 375
 		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
376 376
 		// No email associated with purchase, so store from PayPal
377
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
377
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_email', $data['payer_email']);
378 378
 
379 379
 		// Setup and store the customer's details
380 380
 		$user_info = array(
381 381
 			'user_id'    => '-1',
382
-			'email'      => sanitize_text_field( $data['payer_email'] ),
383
-			'first_name' => sanitize_text_field( $data['first_name'] ),
384
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
382
+			'email'      => sanitize_text_field($data['payer_email']),
383
+			'first_name' => sanitize_text_field($data['first_name']),
384
+			'last_name'  => sanitize_text_field($data['last_name']),
385 385
 			'discount'   => '',
386 386
 		);
387
-		$user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
388
-		$user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
389
-		$user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
390
-		$user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
391
-		$user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
387
+		$user_info['address'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
388
+		$user_info['city']    = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
389
+		$user_info['state']   = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
390
+		$user_info['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
391
+		$user_info['zip']     = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
392 392
 
393 393
 		$payment_meta['user_info'] = $user_info;
394
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
394
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_payment_meta', $payment_meta);
395 395
 	}
396 396
 
397
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
397
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
398 398
 		// Process a refund
399
-		wpinv_process_paypal_refund( $data, $invoice_id );
399
+		wpinv_process_paypal_refund($data, $invoice_id);
400 400
 	} else {
401
-		if ( get_post_status( $invoice_id ) == 'publish' ) {
401
+		if (get_post_status($invoice_id) == 'publish') {
402 402
 			return; // Only paid payments once
403 403
 		}
404 404
 
405 405
 		// Retrieve the total purchase amount (before PayPal)
406
-		$payment_amount = wpinv_payment_total( $invoice_id );
406
+		$payment_amount = wpinv_payment_total($invoice_id);
407 407
 
408
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
408
+		if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
409 409
 			// The prices don't match
410
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
411
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
412
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
410
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
411
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
412
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid amount in PayPal IPN.', 'invoicing'), '', '', true);
413 413
 			return;
414 414
 		}
415
-		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
415
+		if ($purchase_key != wpinv_get_payment_key($invoice_id)) {
416 416
 			// Purchase keys don't match
417
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
418
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
419
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
417
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
418
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
419
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing'), '', '', true);
420 420
 			return;
421 421
 		}
422 422
 
423
-		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
424
-			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
425
-			wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
426
-			wpinv_update_payment_status( $invoice_id, 'publish' );
427
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
423
+		if ('complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode('paypal')) {
424
+			wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
425
+			wpinv_set_payment_transaction_id($invoice_id, $data['txn_id']);
426
+			wpinv_update_payment_status($invoice_id, 'publish');
427
+		} else if ('pending' == $payment_status && isset($data['pending_reason'])) {
428 428
 			// Look for possible pending reasons, such as an echeck
429 429
 			$note = '';
430 430
 
431
-			switch( strtolower( $data['pending_reason'] ) ) {
431
+			switch (strtolower($data['pending_reason'])) {
432 432
 				case 'echeck' :
433
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
433
+					$note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing');
434 434
 					break;
435 435
 				
436 436
                 case 'address' :
437
-					$note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
437
+					$note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing');
438 438
 					break;
439 439
 				
440 440
                 case 'intl' :
441
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
441
+					$note = __('Payment must be accepted manually through PayPal due to international account regulations', 'invoicing');
442 442
 					break;
443 443
 				
444 444
                 case 'multi-currency' :
445
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
445
+					$note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing');
446 446
 					break;
447 447
 				
448 448
                 case 'paymentreview' :
449 449
                 case 'regulatory_review' :
450
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
450
+					$note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing');
451 451
 					break;
452 452
 				
453 453
                 case 'unilateral' :
454
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
454
+					$note = __('Payment was sent to non-confirmed or non-registered email address.', 'invoicing');
455 455
 					break;
456 456
 				
457 457
                 case 'upgrade' :
458
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
458
+					$note = __('PayPal account must be upgraded before this payment can be accepted', 'invoicing');
459 459
 					break;
460 460
 				
461 461
                 case 'verify' :
462
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
462
+					$note = __('PayPal account is not verified. Verify account in order to accept this payment', 'invoicing');
463 463
 					break;
464 464
 
465 465
 				case 'other' :
466
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
466
+					$note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing');
467 467
 					break;
468 468
 			}
469 469
 
470
-			if ( ! empty( $note ) ) {
471
-				wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
470
+			if (!empty($note)) {
471
+				wpinv_insert_payment_note($invoice_id, $note, '', '', true);
472 472
 			}
473 473
 		} else {
474
-			wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
474
+			wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal IPN has been received with invalid payment status: %s', 'invoicing'), $payment_status), '', '', true);
475 475
 		}
476 476
 	}
477 477
 }
478
-add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 );
478
+add_action('wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2);
479 479
 
480 480
 // Process PayPal subscription sign ups
481
-add_action( 'wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup' );
481
+add_action('wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup');
482 482
 
483 483
 // Process PayPal subscription payments
484
-add_action( 'wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment' );
484
+add_action('wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment');
485 485
 
486 486
 // Process PayPal subscription cancellations
487
-add_action( 'wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel' );
487
+add_action('wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel');
488 488
 
489 489
 // Process PayPal subscription end of term notices
490
-add_action( 'wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot' );
490
+add_action('wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot');
491 491
 
492 492
 // Process PayPal payment failed
493
-add_action( 'wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed' );
493
+add_action('wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed');
494 494
 
495 495
 
496 496
 /**
497 497
  * Process the subscription started IPN.
498 498
  */
499
-function wpinv_process_paypal_subscr_signup( $ipn_data ) {
500
-    $parent_invoice_id = absint( $ipn_data['custom'] );
501
-    if( empty( $parent_invoice_id ) ) {
499
+function wpinv_process_paypal_subscr_signup($ipn_data) {
500
+    $parent_invoice_id = absint($ipn_data['custom']);
501
+    if (empty($parent_invoice_id)) {
502 502
         return;
503 503
     }
504 504
 
505
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
506
-    if ( empty( $invoice ) ) {
505
+    $invoice = wpinv_get_invoice($parent_invoice_id);
506
+    if (empty($invoice)) {
507 507
         return;
508 508
     }
509 509
 
510
-    if ( $invoice->is_free_trial() && !empty( $ipn_data['invoice'] ) ) {
511
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Invoice ID: %s', 'invoicing' ) , $ipn_data['invoice'] ), '', '', true);
512
-        if ( !empty( $ipn_data['txn_id'] ) ) {
513
-            wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
510
+    if ($invoice->is_free_trial() && !empty($ipn_data['invoice'])) {
511
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Invoice ID: %s', 'invoicing'), $ipn_data['invoice']), '', '', true);
512
+        if (!empty($ipn_data['txn_id'])) {
513
+            wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
514 514
         }
515 515
     }
516 516
 
517
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
518
-    if ( false === $subscription ) {
517
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
518
+    if (false === $subscription) {
519 519
         return;
520 520
     }
521 521
     
522
-    wpinv_update_payment_status( $parent_invoice_id, 'publish' );
522
+    wpinv_update_payment_status($parent_invoice_id, 'publish');
523 523
     sleep(1);
524
-    wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
525
-    update_post_meta($parent_invoice_id,'_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
524
+    wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
525
+    update_post_meta($parent_invoice_id, '_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
526 526
 
527 527
     $status     = 'trialling' == $subscription->status ? 'trialling' : 'active';
528
-    $diff_days  = absint( ( ( strtotime( $subscription->expiration ) - strtotime( $subscription->created ) ) / DAY_IN_SECONDS ) );
529
-    $created    = date_i18n( 'Y-m-d H:i:s' );
530
-    $expiration = date_i18n( 'Y-m-d 23:59:59', ( strtotime( $created ) + ( $diff_days * DAY_IN_SECONDS ) ) );
528
+    $diff_days  = absint(((strtotime($subscription->expiration) - strtotime($subscription->created)) / DAY_IN_SECONDS));
529
+    $created    = date_i18n('Y-m-d H:i:s');
530
+    $expiration = date_i18n('Y-m-d 23:59:59', (strtotime($created) + ($diff_days * DAY_IN_SECONDS)));
531 531
 
532 532
     // Retrieve pending subscription from database and update it's status to active and set proper profile ID
533
-    $subscription->update( array( 'profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration ) );
533
+    $subscription->update(array('profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration));
534 534
 }
535 535
 
536 536
 /**
537 537
  * Process the subscription payment received IPN.
538 538
  */
539
-function wpinv_process_paypal_subscr_payment( $ipn_data ) {
540
-    $parent_invoice_id = absint( $ipn_data['custom'] );
539
+function wpinv_process_paypal_subscr_payment($ipn_data) {
540
+    $parent_invoice_id = absint($ipn_data['custom']);
541 541
 
542
-    $parent_invoice = wpinv_get_invoice( $parent_invoice_id );
543
-    if ( empty( $parent_invoice ) ) {
542
+    $parent_invoice = wpinv_get_invoice($parent_invoice_id);
543
+    if (empty($parent_invoice)) {
544 544
         return;
545 545
     }
546 546
 
547
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
548
-    if ( false === $subscription ) {
547
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
548
+    if (false === $subscription) {
549 549
         return;
550 550
     }
551 551
 
552
-    $transaction_id = wpinv_get_payment_transaction_id( $parent_invoice_id );
552
+    $transaction_id = wpinv_get_payment_transaction_id($parent_invoice_id);
553 553
     $times_billed   = $subscription->get_times_billed();
554
-    $signup_date    = strtotime( $subscription->created );
555
-    $today          = date( 'Ynd', $signup_date ) == date( 'Ynd', strtotime( $ipn_data['payment_date'] ) );
554
+    $signup_date    = strtotime($subscription->created);
555
+    $today          = date('Ynd', $signup_date) == date('Ynd', strtotime($ipn_data['payment_date']));
556 556
 
557 557
     // Look to see if payment is same day as signup and we have set the transaction ID on the parent payment yet.
558
-    if ( (empty($times_billed) || $today) && ( !$transaction_id || $transaction_id == $parent_invoice_id ) ) {
559
-        wpinv_update_payment_status( $parent_invoice_id, 'publish' );
558
+    if ((empty($times_billed) || $today) && (!$transaction_id || $transaction_id == $parent_invoice_id)) {
559
+        wpinv_update_payment_status($parent_invoice_id, 'publish');
560 560
         sleep(1);
561 561
         
562 562
         // This is the very first payment
563
-        wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
564
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
563
+        wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
564
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
565 565
         return;
566 566
     }
567 567
 
568
-    if ( wpinv_get_id_by_transaction_id( $ipn_data['txn_id'] ) ) {
568
+    if (wpinv_get_id_by_transaction_id($ipn_data['txn_id'])) {
569 569
         return; // Payment already recorded
570 570
     }
571 571
 
572
-    $currency_code = strtolower( $ipn_data['mc_currency'] );
572
+    $currency_code = strtolower($ipn_data['mc_currency']);
573 573
 
574 574
     // verify details
575
-    if ( $currency_code != strtolower( wpinv_get_currency() ) ) {
575
+    if ($currency_code != strtolower(wpinv_get_currency())) {
576 576
         // the currency code is invalid
577
-        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: ', 'invoicing' ), json_encode( $ipn_data ) ) );
577
+        wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: ', 'invoicing'), json_encode($ipn_data)));
578 578
         return;
579 579
     }
580 580
 
@@ -584,11 +584,11 @@  discard block
 block discarded – undo
584 584
         'gateway'        => 'paypal'
585 585
     );
586 586
     
587
-    $invoice_id = $subscription->add_payment( $args );
587
+    $invoice_id = $subscription->add_payment($args);
588 588
 
589
-    if ( $invoice_id > 0 ) {
590
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
591
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
589
+    if ($invoice_id > 0) {
590
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
591
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
592 592
 
593 593
         $subscription->renew();
594 594
     }
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
 /**
598 598
  * Process the subscription canceled IPN.
599 599
  */
600
-function wpinv_process_paypal_subscr_cancel( $ipn_data ) {
601
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
600
+function wpinv_process_paypal_subscr_cancel($ipn_data) {
601
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
602 602
 
603
-    if( false === $subscription ) {
603
+    if (false === $subscription) {
604 604
         return;
605 605
     }
606 606
 
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
 /**
611 611
  * Process the subscription expired IPN.
612 612
  */
613
-function wpinv_process_paypal_subscr_eot( $ipn_data ) {
614
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
613
+function wpinv_process_paypal_subscr_eot($ipn_data) {
614
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
615 615
 
616
-    if( false === $subscription ) {
616
+    if (false === $subscription) {
617 617
         return;
618 618
     }
619 619
 
@@ -623,40 +623,40 @@  discard block
 block discarded – undo
623 623
 /**
624 624
  * Process the subscription payment failed IPN.
625 625
  */
626
-function wpinv_process_paypal_subscr_failed( $ipn_data ) {
627
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
626
+function wpinv_process_paypal_subscr_failed($ipn_data) {
627
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
628 628
 
629
-    if( false === $subscription ) {
629
+    if (false === $subscription) {
630 630
         return;
631 631
     }
632 632
 
633 633
     $subscription->failing();
634 634
 
635
-    do_action( 'wpinv_recurring_payment_failed', $subscription );
635
+    do_action('wpinv_recurring_payment_failed', $subscription);
636 636
 }
637 637
 
638 638
 /**
639 639
  * Retrieve the subscription this IPN notice is for.
640 640
  */
641
-function wpinv_get_paypal_subscription( $ipn_data = array() ) {
642
-    $parent_invoice_id = absint( $ipn_data['custom'] );
641
+function wpinv_get_paypal_subscription($ipn_data = array()) {
642
+    $parent_invoice_id = absint($ipn_data['custom']);
643 643
 
644
-    if( empty( $parent_invoice_id ) ) {
644
+    if (empty($parent_invoice_id)) {
645 645
         return false;
646 646
     }
647 647
 
648
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
649
-    if ( empty( $invoice ) ) {
648
+    $invoice = wpinv_get_invoice($parent_invoice_id);
649
+    if (empty($invoice)) {
650 650
         return false;
651 651
     }
652 652
 
653
-    $subscription = new WPInv_Subscription( $ipn_data['subscr_id'], true );
653
+    $subscription = new WPInv_Subscription($ipn_data['subscr_id'], true);
654 654
 
655
-    if ( ! ( ! empty( $subscription ) && $subscription->id > 0 ) ) {
656
-        $subscription = wpinv_get_subscription( $parent_invoice_id );
655
+    if (!(!empty($subscription) && $subscription->id > 0)) {
656
+        $subscription = wpinv_get_subscription($parent_invoice_id);
657 657
 
658
-        if ( ! empty( $subscription ) && $subscription->id > 0 ) {
659
-            $subscription->update( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) );
658
+        if (!empty($subscription) && $subscription->id > 0) {
659
+            $subscription->update(array('profile_id' => sanitize_text_field($ipn_data['subscr_id'])));
660 660
         } else {
661 661
             return false;
662 662
         }
@@ -666,152 +666,152 @@  discard block
 block discarded – undo
666 666
 
667 667
 }
668 668
 
669
-function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) {
669
+function wpinv_process_paypal_refund($data, $invoice_id = 0) {
670 670
 	// Collect payment details
671 671
 
672
-	if( empty( $invoice_id ) ) {
672
+	if (empty($invoice_id)) {
673 673
 		return;
674 674
 	}
675 675
 
676
-	if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
676
+	if (get_post_status($invoice_id) == 'wpi-refunded') {
677 677
 		return; // Only refund payments once
678 678
 	}
679 679
 
680
-	$payment_amount = wpinv_payment_total( $invoice_id );
680
+	$payment_amount = wpinv_payment_total($invoice_id);
681 681
 	$refund_amount  = $data['mc_gross'] * -1;
682 682
 
683
-	do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
683
+	do_action('wpinv_paypal_refund_request', $data, $invoice_id);
684 684
 
685
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
686
-		wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
685
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
686
+		wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing'), (float) $refund_amount . ' ' . $data['mc_currency'], $data['parent_txn_id'], $data['reason_code']), '', '', true);
687 687
 
688
-		do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
688
+		do_action('wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount);
689 689
 
690 690
 		return; // This is a partial refund
691 691
 	}
692 692
 
693
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
694
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
695
-	wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
693
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'invoicing'), $data['parent_txn_id'], $data['reason_code']), '', '', true);
694
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Refund Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
695
+	wpinv_update_payment_status($invoice_id, 'wpi-refunded');
696 696
 
697
-	do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
697
+	do_action('wpinv_paypal_invoice_fully_refunded', $data, $invoice_id);
698 698
 }
699 699
 
700
-function wpinv_get_paypal_redirect( $ssl_check = false ) {
701
-    return apply_filters( 'wpinv_paypal_uri', wpinv_is_test_mode( 'paypal' ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?' );
700
+function wpinv_get_paypal_redirect($ssl_check = false) {
701
+    return apply_filters('wpinv_paypal_uri', wpinv_is_test_mode('paypal') ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?');
702 702
 }
703 703
 
704
-function wpinv_paypal_success_page_content( $content ) {
704
+function wpinv_paypal_success_page_content($content) {
705 705
     global $wpi_invoice;
706 706
     
707 707
     $session = wpinv_get_checkout_session();
708 708
 
709
-    if ( empty( $_GET['invoice-id'] ) && empty( $session['invoice_key'] )  ) {
709
+    if (empty($_GET['invoice-id']) && empty($session['invoice_key'])) {
710 710
         return $content;
711 711
     }
712 712
 
713
-    $invoice_id = ! empty( $_GET['invoice-id'] ) ? absint( $_GET['invoice-id'] ) : wpinv_get_invoice_id_by_key( $session['invoice_key'] );
713
+    $invoice_id = !empty($_GET['invoice-id']) ? absint($_GET['invoice-id']) : wpinv_get_invoice_id_by_key($session['invoice_key']);
714 714
 
715
-    if ( empty(  $invoice_id ) ) {
715
+    if (empty($invoice_id)) {
716 716
         return $content;
717 717
     }
718 718
 
719
-    $wpi_invoice = wpinv_get_invoice( $invoice_id );
719
+    $wpi_invoice = wpinv_get_invoice($invoice_id);
720 720
     
721
-    if ( ! empty( $wpi_invoice ) && 'wpi-pending' == $wpi_invoice->status ) {
721
+    if (!empty($wpi_invoice) && 'wpi-pending' == $wpi_invoice->status) {
722 722
         // Payment is still pending so show processing indicator to fix the Race Condition, issue #
723 723
         ob_start();
724
-        wpinv_get_template_part( 'wpinv-payment-processing' );
724
+        wpinv_get_template_part('wpinv-payment-processing');
725 725
         $content = ob_get_clean();
726 726
     }
727 727
 
728 728
     return $content;
729 729
 }
730
-add_filter( 'wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content' );
730
+add_filter('wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content');
731 731
 
732
-function wpinv_paypal_get_transaction_id( $invoice_id ) {
732
+function wpinv_paypal_get_transaction_id($invoice_id) {
733 733
     $transaction_id = '';
734
-    $notes = wpinv_get_invoice_notes( $invoice_id );
734
+    $notes = wpinv_get_invoice_notes($invoice_id);
735 735
 
736
-    foreach ( $notes as $note ) {
737
-        if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
736
+    foreach ($notes as $note) {
737
+        if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
738 738
             $transaction_id = $match[1];
739 739
             continue;
740 740
         }
741 741
     }
742 742
 
743
-    return apply_filters( 'wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id );
743
+    return apply_filters('wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id);
744 744
 }
745
-add_filter( 'wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1 );
745
+add_filter('wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1);
746 746
 
747
-function wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice ) {
748
-    if ( $transaction_id == $invoice_id ) {
747
+function wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice) {
748
+    if ($transaction_id == $invoice_id) {
749 749
         $transaction_link = $transaction_id;
750 750
     } else {
751
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
751
+        if (!empty($invoice) && !empty($invoice->mode)) {
752 752
             $mode = $invoice->mode;
753 753
         } else {
754
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
754
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
755 755
         }
756 756
 
757 757
         $sandbox = $mode == 'test' ? '.sandbox' : '';
758 758
         $transaction_url = 'https://www' . $sandbox . '.paypal.com/webscr?cmd=_history-details-from-hub&id=' . $transaction_id;
759 759
 
760
-        $transaction_link = '<a href="' . esc_url( $transaction_url ) . '" target="_blank">' . $transaction_id . '</a>';
760
+        $transaction_link = '<a href="' . esc_url($transaction_url) . '" target="_blank">' . $transaction_id . '</a>';
761 761
     }
762 762
 
763
-    return apply_filters( 'wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice );
763
+    return apply_filters('wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice);
764 764
 }
765
-add_filter( 'wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3 );
765
+add_filter('wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3);
766 766
 
767
-function wpinv_paypal_profile_id_link( $profile_id, $subscription ) {
767
+function wpinv_paypal_profile_id_link($profile_id, $subscription) {
768 768
     $link = $profile_id;
769 769
 
770
-    if ( ! empty( $profile_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
771
-        $invoice = wpinv_get_invoice( $invoice_id );
770
+    if (!empty($profile_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
771
+        $invoice = wpinv_get_invoice($invoice_id);
772 772
 
773
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
773
+        if (!empty($invoice) && !empty($invoice->mode)) {
774 774
             $mode = $invoice->mode;
775 775
         } else {
776
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
776
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
777 777
         }
778 778
 
779 779
         $sandbox = $mode == 'test' ? '.sandbox' : '';
780 780
         $url = 'https://www' . $sandbox . '.paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=' . $profile_id;
781 781
 
782
-        $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $profile_id . '</a>';
782
+        $link = '<a href="' . esc_url($url) . '" target="_blank">' . $profile_id . '</a>';
783 783
     }
784 784
     
785
-    return apply_filters( 'wpinv_paypal_profile_id_link', $link, $profile_id, $subscription );
785
+    return apply_filters('wpinv_paypal_profile_id_link', $link, $profile_id, $subscription);
786 786
 }
787
-add_filter( 'wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2 );
787
+add_filter('wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2);
788 788
 
789
-function wpinv_paypal_transaction_id_link( $transaction_id, $subscription ) {
790
-    if ( ! empty( $transaction_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
791
-        $invoice = wpinv_get_invoice( $invoice_id );
789
+function wpinv_paypal_transaction_id_link($transaction_id, $subscription) {
790
+    if (!empty($transaction_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
791
+        $invoice = wpinv_get_invoice($invoice_id);
792 792
 
793
-        if ( ! empty( $invoice ) ) {
794
-            return wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice );
793
+        if (!empty($invoice)) {
794
+            return wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice);
795 795
         }        
796 796
     }
797 797
     
798 798
     return $transaction_id;
799 799
 }
800
-add_filter( 'wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2 );
800
+add_filter('wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2);
801 801
 
802 802
 function wpinv_is_paypal_valid_for_use() {
803
-    return in_array( wpinv_get_currency(), apply_filters( 'wpinv_paypal_supported_currencies', array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ) ) );
803
+    return in_array(wpinv_get_currency(), apply_filters('wpinv_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR')));
804 804
 }
805 805
 
806
-function wpinv_check_paypal_currency_support( $gateway_list ) {
807
-    if ( isset( $gateway_list['paypal'] ) && ! wpinv_is_paypal_valid_for_use() ) {
808
-        unset( $gateway_list['paypal'] );
806
+function wpinv_check_paypal_currency_support($gateway_list) {
807
+    if (isset($gateway_list['paypal']) && !wpinv_is_paypal_valid_for_use()) {
808
+        unset($gateway_list['paypal']);
809 809
     }
810 810
     return $gateway_list;
811 811
 }
812
-add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1 );
812
+add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1);
813 813
 
814
-function wpinv_gateway_paypal_button_label( $label ) {
815
-    return __( 'Proceed to PayPal', 'invoicing' );
814
+function wpinv_gateway_paypal_button_label($label) {
815
+    return __('Proceed to PayPal', 'invoicing');
816 816
 }
817
-add_filter( 'wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1 );
818 817
\ No newline at end of file
818
+add_filter('wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1);
819 819
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form-info.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Payment_Form_Info {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the form.
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 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
 
@@ -21,39 +21,39 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the form.
27
-        $form = new GetPaid_Payment_Form( $post );
27
+        $form = new GetPaid_Payment_Form($post);
28 28
 
29 29
         ?>
30 30
 
31 31
         <div class='bsui' style='padding-top: 10px;'>
32
-            <?php do_action( 'wpinv_payment_form_before_info_metabox', $form ); ?>
32
+            <?php do_action('wpinv_payment_form_before_info_metabox', $form); ?>
33 33
 
34 34
             <div class="wpinv_payment_form_shortcode form-group row">
35 35
                 <label for="wpinv_payment_form_shortcode" class="col-sm-12 col-form-label">
36
-                    <?php _e( 'Payment Form Shortcode', 'invoicing' );?>
37
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span>
36
+                    <?php _e('Payment Form Shortcode', 'invoicing'); ?>
37
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span>
38 38
                 </label>
39 39
 
40 40
                 <div class="col-sm-12">
41
-                    <input  onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?>]" style="width: 100%;" />
41
+                    <input  onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?>]" style="width: 100%;" />
42 42
                 </div>
43 43
             </div>
44 44
 
45 45
             <div class="wpinv_payment_form_buy_shortcode form-group row">
46 46
                 <label for="wpinv_payment_form_buy_shortcode" class="col-sm-12 col-form-label">
47
-                    <?php _e( 'Payment Button Shortcode', 'invoicing' );?>
48
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span>
47
+                    <?php _e('Payment Button Shortcode', 'invoicing'); ?>
48
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span>
49 49
                 </label>
50 50
 
51 51
                 <div class="col-sm-12">
52
-                    <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?> button='Buy Now']" style="width: 100%;" />
52
+                    <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?> button='Buy Now']" style="width: 100%;" />
53 53
                 </div>
54 54
             </div>
55 55
 
56
-            <?php do_action( 'wpinv_payment_form_info_metabox', $form ); ?>
56
+            <?php do_action('wpinv_payment_form_info_metabox', $form); ?>
57 57
         </div>
58 58
         <?php
59 59
 
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -1,68 +1,68 @@  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
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
 
28
-    add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
29
-    add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
28
+    add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
29
+    add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
30 30
    
31
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
32
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
33
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
31
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
32
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
33
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
34 34
     
35
-    if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
36
-        add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
35
+    if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) {
36
+        add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high');
37 37
     }
38 38
 
39 39
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
40 40
 }
41
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
41
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
42 42
 
43 43
 /**
44 44
  * Saves meta boxes.
45 45
  */
46
-function wpinv_save_meta_boxes( $post_id, $post ) {
47
-    remove_action( 'save_post', __FUNCTION__ );
46
+function wpinv_save_meta_boxes($post_id, $post) {
47
+    remove_action('save_post', __FUNCTION__);
48 48
 
49 49
     // $post_id and $post are required.
50
-    if ( empty( $post_id ) || empty( $post ) ) {
50
+    if (empty($post_id) || empty($post)) {
51 51
         return;
52 52
     }
53 53
 
54 54
     // Ensure that this user can edit the post.
55
-    if ( ! current_user_can( 'edit_post', $post_id ) ) {
55
+    if (!current_user_can('edit_post', $post_id)) {
56 56
         return;
57 57
     }
58 58
 
59 59
     // Dont' save meta boxes for revisions or autosaves
60
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
60
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
61 61
         return;
62 62
     }
63 63
 
64 64
     // Do not save for ajax requests.
65
-    if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
65
+    if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
66 66
         return;
67 67
     }
68 68
 
@@ -74,67 +74,67 @@  discard block
 block discarded – undo
74 74
     );
75 75
 
76 76
     // Is this our post type?
77
-    if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
77
+    if (empty($post->post_type) || !isset($post_types_map[$post->post_type])) {
78 78
         return;
79 79
     }
80 80
 
81 81
     // Save the post.
82
-    $class = $post_types_map[ $post->post_type ];
83
-    $class::save( $post_id, $_POST, $post );
82
+    $class = $post_types_map[$post->post_type];
83
+    $class::save($post_id, $_POST, $post);
84 84
 
85 85
 }
86
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
86
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
87 87
 
88 88
 function wpinv_register_item_meta_boxes() {    
89 89
     global $wpinv_euvat;
90 90
 
91 91
     // Item details metabox.
92
-    add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
92
+    add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
93 93
 
94 94
     // If taxes are enabled, register the tax metabox.
95
-    if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
96
-        add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
95
+    if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) {
96
+        add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
97 97
     }
98 98
 
99 99
     // Item info.
100
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
100
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
101 101
     
102 102
 }
103 103
 
104 104
 function wpinv_register_discount_meta_boxes() {
105
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
105
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
106 106
 }
107 107
 
108
-function wpinv_discount_metabox_details( $post ) {
108
+function wpinv_discount_metabox_details($post) {
109 109
     $discount_id    = $post->ID;
110
-    $discount       = wpinv_get_discount( $discount_id );
110
+    $discount       = wpinv_get_discount($discount_id);
111 111
     
112
-    $type               = wpinv_get_discount_type( $discount_id );
113
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
114
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
115
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
116
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
117
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
118
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
119
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
120
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
121
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
112
+    $type               = wpinv_get_discount_type($discount_id);
113
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
114
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
115
+    $min_total          = wpinv_get_discount_min_total($discount_id);
116
+    $max_total          = wpinv_get_discount_max_total($discount_id);
117
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
118
+    $single_use         = wpinv_discount_is_single_use($discount_id);
119
+    $recurring          = (bool) wpinv_discount_is_recurring($discount_id);
120
+    $start_date         = wpinv_get_discount_start_date($discount_id);
121
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
122 122
     
123
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
124
-        $start_time         = strtotime( $start_date );
125
-        $start_h            = date_i18n( 'H', $start_time );
126
-        $start_m            = date_i18n( 'i', $start_time );
127
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
123
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
124
+        $start_time         = strtotime($start_date);
125
+        $start_h            = date_i18n('H', $start_time);
126
+        $start_m            = date_i18n('i', $start_time);
127
+        $start_date         = date_i18n('Y-m-d', $start_time);
128 128
     } else {
129 129
         $start_h            = '00';
130 130
         $start_m            = '00';
131 131
     }
132 132
 
133
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
134
-        $expiration_time    = strtotime( $expiration_date );
135
-        $expiration_h       = date_i18n( 'H', $expiration_time );
136
-        $expiration_m       = date_i18n( 'i', $expiration_time );
137
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
133
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
134
+        $expiration_time    = strtotime($expiration_date);
135
+        $expiration_h       = date_i18n('H', $expiration_time);
136
+        $expiration_m       = date_i18n('i', $expiration_time);
137
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
138 138
     } else {
139 139
         $expiration_h       = '23';
140 140
         $expiration_m       = '59';
@@ -144,220 +144,220 @@  discard block
 block discarded – undo
144 144
     $max_total          = $max_total > 0 ? $max_total : '';
145 145
     $max_uses           = $max_uses > 0 ? $max_uses : '';
146 146
 ?>
147
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
148
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
147
+<?php do_action('wpinv_discount_form_top', $post); ?>
148
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
149 149
 <table class="form-table wpi-form-table">
150 150
     <tbody>
151
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
152
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
151
+        <?php do_action('wpinv_discount_form_first', $post); ?>
152
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
153 153
         <tr>
154 154
             <th valign="top" scope="row">
155
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
155
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
156 156
             </th>
157 157
             <td>
158
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
159
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
158
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
159
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
160 160
             </td>
161 161
         </tr>
162
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
162
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
163 163
         <tr>
164 164
             <th valign="top" scope="row">
165
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
165
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
166 166
             </th>
167 167
             <td>
168 168
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
169
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
170
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
169
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
170
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
171 171
                     <?php } ?>
172 172
                 </select>
173
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
173
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
174 174
             </td>
175 175
         </tr>
176
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
176
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
177 177
         <tr>
178 178
             <th valign="top" scope="row">
179
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
179
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
180 180
             </th>
181 181
             <td>
182
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
183
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
184
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
182
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
183
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
184
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
185 185
             </td>
186 186
         </tr>
187
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
187
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
188 188
         <tr>
189 189
             <th valign="top" scope="row">
190
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
190
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
191 191
             </th>
192 192
             <td>
193
-                <p><?php echo wpinv_item_dropdown( array(
193
+                <p><?php echo wpinv_item_dropdown(array(
194 194
                         'name'              => 'items[]',
195 195
                         'id'                => 'items',
196 196
                         'selected'          => $item_reqs,
197 197
                         'multiple'          => true,
198 198
                         'class'             => 'medium-text wpi_select2',
199
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
199
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
200 200
                         'show_recurring'    => true,
201
-                    ) ); ?>
201
+                    )); ?>
202 202
                 </p>
203
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
203
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
204 204
             </td>
205 205
         </tr>
206
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
206
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
207 207
         <tr>
208 208
             <th valign="top" scope="row">
209
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
209
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
210 210
             </th>
211 211
             <td>
212
-                <p><?php echo wpinv_item_dropdown( array(
212
+                <p><?php echo wpinv_item_dropdown(array(
213 213
                         'name'              => 'excluded_items[]',
214 214
                         'id'                => 'excluded_items',
215 215
                         'selected'          => $excluded_items,
216 216
                         'multiple'          => true,
217 217
                         'class'             => 'medium-text wpi_select2',
218
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
218
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
219 219
                         'show_recurring'    => true,
220
-                    ) ); ?>
220
+                    )); ?>
221 221
                 </p>
222
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
222
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
223 223
             </td>
224 224
         </tr>
225
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
225
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
226 226
         <tr>
227 227
             <th valign="top" scope="row">
228
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
228
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
229 229
             </th>
230 230
             <td>
231
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
232
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
233
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
231
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
232
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
233
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
234 234
                     <?php } ?>
235 235
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
236
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
237
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
236
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
237
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
238 238
                     <?php } ?>
239 239
                 </select>
240
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
240
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
241 241
             </td>
242 242
         </tr>
243
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
243
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
244 244
         <tr>
245 245
             <th valign="top" scope="row">
246
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
246
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
247 247
             </th>
248 248
             <td>
249
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
250
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
251
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
249
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
250
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
251
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
252 252
                     <?php } ?>
253 253
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
254
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
255
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
254
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
255
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
256 256
                     <?php } ?>
257 257
                 </select>
258
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
258
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
259 259
             </td>
260 260
         </tr>
261
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
261
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
262 262
         <tr>
263 263
             <th valign="top" scope="row">
264
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
264
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
265 265
             </th>
266 266
             <td>
267 267
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
268
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
268
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
269 269
             </td>
270 270
         </tr>
271
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
271
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
272 272
         <tr>
273 273
             <th valign="top" scope="row">
274
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
274
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
275 275
             </th>
276 276
             <td>
277 277
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
278
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
278
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
279 279
             </td>
280 280
         </tr>
281
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
281
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
282 282
         <tr>
283 283
             <th valign="top" scope="row">
284
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
284
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
285 285
             </th>
286 286
             <td>
287 287
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
288
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
289
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
288
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
289
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
290 290
                 </select>
291
-                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
291
+                <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
292 292
             </td>
293 293
         </tr>
294
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
294
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
295 295
         <tr>
296 296
             <th valign="top" scope="row">
297
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
297
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
298 298
             </th>
299 299
             <td>
300 300
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
301
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
301
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
302 302
             </td>
303 303
         </tr>
304
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
304
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
305 305
         <tr>
306 306
             <th valign="top" scope="row">
307
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
307
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
308 308
             </th>
309 309
             <td>
310
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
311
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
310
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
311
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
312 312
             </td>
313 313
         </tr>
314
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
314
+        <?php do_action('wpinv_discount_form_last', $post); ?>
315 315
     </tbody>
316 316
 </table>
317
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
317
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
318 318
     <?php
319 319
 }
320 320
 
321
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
322
-    $post_type = !empty( $post ) ? $post->post_type : '';
321
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
322
+    $post_type = !empty($post) ? $post->post_type : '';
323 323
     
324
-    if ( $post_type != 'wpi_discount' ) {
324
+    if ($post_type != 'wpi_discount') {
325 325
         return;
326 326
     }
327 327
     
328
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
328
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
329 329
         return;
330 330
     }
331 331
     
332
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
332
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
333 333
         return;
334 334
     }
335 335
     
336
-    if ( !current_user_can( wpinv_get_capability(), $post_id ) ) {
336
+    if (!current_user_can(wpinv_get_capability(), $post_id)) {
337 337
         return;
338 338
     }
339 339
     
340
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
340
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
341 341
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
342 342
     }
343 343
 
344
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
344
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
345 345
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
346 346
     }
347 347
     
348
-    return /** @scrutinizer ignore-call */ wpinv_store_discount( $post_id, $_POST, $post, $update );
348
+    return /** @scrutinizer ignore-call */ wpinv_store_discount($post_id, $_POST, $post, $update);
349 349
 }
350
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
350
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
351 351
 
352 352
 /**
353 353
  * Remove trash link from the default form.
354 354
  */
355
-function getpaid_remove_action_link( $actions, $post ) {
356
-    $post = get_post( $post );
357
-    if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
358
-        unset( $actions['trash'] );
359
-        unset( $actions['inline hide-if-no-js'] );
355
+function getpaid_remove_action_link($actions, $post) {
356
+    $post = get_post($post);
357
+    if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
358
+        unset($actions['trash']);
359
+        unset($actions['inline hide-if-no-js']);
360 360
     }
361 361
     return $actions;
362 362
 }
363
-add_filter( 'post_row_actions', 'getpaid_remove_action_link', 10, 2 );
363
+add_filter('post_row_actions', 'getpaid_remove_action_link', 10, 2);
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 2 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 
104 104
 function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105 105
     if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
107
-	}
106
+        extract( $args );
107
+    }
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
110
-	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
109
+    $located = wpinv_locate_template( $template_name, $template_path, $default_path );
110
+    // Allow 3rd party plugin filter template file from their plugin.
111
+    $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
112 112
 
113
-	if ( ! file_exists( $located ) ) {
113
+    if ( ! file_exists( $located ) ) {
114 114
         _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
115
-		return;
116
-	}
115
+        return;
116
+    }
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+    do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
119 119
 
120
-	include( $located );
120
+    include( $located );
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+    do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
123 123
 }
124 124
 
125 125
 function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
126
-	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
128
-	return ob_get_clean();
126
+    ob_start();
127
+    wpinv_get_template( $template_name, $args, $template_path, $default_path );
128
+    return ob_get_clean();
129 129
 }
130 130
 
131 131
 function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
@@ -155,126 +155,126 @@  discard block
 block discarded – undo
155 155
 }
156 156
 
157 157
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
158
+    do_action( 'get_template_part_' . $slug, $slug, $name );
159 159
 
160
-	// Setup possible parts
161
-	$templates = array();
162
-	if ( isset( $name ) )
163
-		$templates[] = $slug . '-' . $name . '.php';
164
-	$templates[] = $slug . '.php';
160
+    // Setup possible parts
161
+    $templates = array();
162
+    if ( isset( $name ) )
163
+        $templates[] = $slug . '-' . $name . '.php';
164
+    $templates[] = $slug . '.php';
165 165
 
166
-	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
166
+    // Allow template parts to be filtered
167
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
168 168
 
169
-	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
169
+    // Return the part that is found
170
+    return wpinv_locate_tmpl( $templates, $load, false );
171 171
 }
172 172
 
173 173
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
174
-	// No file found yet
175
-	$located = false;
174
+    // No file found yet
175
+    $located = false;
176 176
 
177
-	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
177
+    // Try to find a template file
178
+    foreach ( (array)$template_names as $template_name ) {
179 179
 
180
-		// Continue if template is empty
181
-		if ( empty( $template_name ) )
182
-			continue;
180
+        // Continue if template is empty
181
+        if ( empty( $template_name ) )
182
+            continue;
183 183
 
184
-		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
184
+        // Trim off any slashes from the template name
185
+        $template_name = ltrim( $template_name, '/' );
186 186
 
187
-		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
187
+        // try locating this template file by looping through the template paths
188
+        foreach( wpinv_get_theme_template_paths() as $template_path ) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
191
-				$located = $template_path . $template_name;
192
-				break;
193
-			}
194
-		}
190
+            if( file_exists( $template_path . $template_name ) ) {
191
+                $located = $template_path . $template_name;
192
+                break;
193
+            }
194
+        }
195 195
 
196
-		if( !empty( $located ) ) {
197
-			break;
198
-		}
199
-	}
196
+        if( !empty( $located ) ) {
197
+            break;
198
+        }
199
+    }
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+    if ( ( true == $load ) && ! empty( $located ) )
202
+        load_template( $located, $require_once );
203 203
 
204
-	return $located;
204
+    return $located;
205 205
 }
206 206
 
207 207
 function wpinv_get_theme_template_paths() {
208
-	$template_dir = wpinv_get_theme_template_dir_name();
208
+    $template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210
-	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
213
-		100 => wpinv_get_templates_dir()
214
-	);
210
+    $file_paths = array(
211
+        1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
+        10 => trailingslashit( get_template_directory() ) . $template_dir,
213
+        100 => wpinv_get_templates_dir()
214
+    );
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
217 217
 
218
-	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
218
+    // sort the file paths based on priority
219
+    ksort( $file_paths, SORT_NUMERIC );
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+    return array_map( 'trailingslashit', $file_paths );
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+    return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230
-	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
230
+    $pages   = array();
231
+    $pages[] = wpinv_get_option( 'success_page' );
232
+    $pages[] = wpinv_get_option( 'failure_page' );
233
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
234
+    $pages[] = wpinv_get_option( 'invoice_subscription_page' );
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
237
-		return;
238
-	}
236
+    if( !wpinv_is_checkout() && !is_page( $pages ) ) {
237
+        return;
238
+    }
239 239
 
240
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
240
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242 242
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
243 243
 
244 244
 function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
245
+    $classes = (array)$class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
248
-		$classes[] = 'wpinv-checkout';
249
-		$classes[] = 'wpinv-page';
250
-	}
247
+    if( wpinv_is_checkout() ) {
248
+        $classes[] = 'wpinv-checkout';
249
+        $classes[] = 'wpinv-page';
250
+    }
251 251
 
252
-	if( wpinv_is_success_page() ) {
253
-		$classes[] = 'wpinv-success';
254
-		$classes[] = 'wpinv-page';
255
-	}
252
+    if( wpinv_is_success_page() ) {
253
+        $classes[] = 'wpinv-success';
254
+        $classes[] = 'wpinv-page';
255
+    }
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
258
-		$classes[] = 'wpinv-failed-transaction';
259
-		$classes[] = 'wpinv-page';
260
-	}
257
+    if( wpinv_is_failed_transaction_page() ) {
258
+        $classes[] = 'wpinv-failed-transaction';
259
+        $classes[] = 'wpinv-page';
260
+    }
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
263
-		$classes[] = 'wpinv-history';
264
-		$classes[] = 'wpinv-page';
265
-	}
262
+    if( wpinv_is_invoice_history_page() ) {
263
+        $classes[] = 'wpinv-history';
264
+        $classes[] = 'wpinv-page';
265
+    }
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
268
-		$classes[] = 'wpinv-subscription';
269
-		$classes[] = 'wpinv-page';
270
-	}
267
+    if( wpinv_is_subscriptions_history_page() ) {
268
+        $classes[] = 'wpinv-subscription';
269
+        $classes[] = 'wpinv-page';
270
+    }
271 271
 
272
-	if( wpinv_is_test_mode() ) {
273
-		$classes[] = 'wpinv-test-mode';
274
-		$classes[] = 'wpinv-page';
275
-	}
272
+    if( wpinv_is_test_mode() ) {
273
+        $classes[] = 'wpinv-test-mode';
274
+        $classes[] = 'wpinv-page';
275
+    }
276 276
 
277
-	return array_unique( $classes );
277
+    return array_unique( $classes );
278 278
 }
279 279
 add_filter( 'body_class', 'wpinv_add_body_classes' );
280 280
 
@@ -958,21 +958,21 @@  discard block
 block discarded – undo
958 958
 
959 959
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
960 960
     
961
-	// Remove unavailable tags.
961
+    // Remove unavailable tags.
962 962
     $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
963 963
 
964 964
     // Clean up white space.
965
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
965
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
966 966
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
967 967
     
968 968
     // Break newlines apart and remove empty lines/trim commas and white space.
969
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
969
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
970 970
 
971 971
     // Add html breaks.
972
-	$formatted_address = implode( $separator, $formatted_address );
972
+    $formatted_address = implode( $separator, $formatted_address );
973 973
 
974
-	// We're done!
975
-	return $formatted_address;
974
+    // We're done!
975
+    return $formatted_address;
976 976
     
977 977
 }
978 978
 
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 
1060 1060
                     $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1061 1061
                     $summary    = '';
1062
-	                $item_name    = '';
1062
+                    $item_name    = '';
1063 1063
                     $cols       = 3;
1064 1064
                     if ( !empty($item) ) {
1065 1065
                         $item_name  = $item->get_name();
@@ -1416,13 +1416,13 @@  discard block
 block discarded – undo
1416 1416
     $payment_form    = wpinv_get_default_payment_form();
1417 1417
 
1418 1418
     ob_start();
1419
-	    do_action( 'wpinv_checkout_content_before' );
1419
+        do_action( 'wpinv_checkout_content_before' );
1420 1420
 
1421 1421
         if ( wpinv_get_cart_contents() ) {
1422 1422
 
1423 1423
             // Get the form elements and items.
1424
-	        $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1425
-	        $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1424
+            $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1425
+            $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1426 1426
             ?>
1427 1427
             <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST">
1428 1428
                 <?php do_action( 'wpinv_main_checkout_form_top' ); ?>
@@ -1446,10 +1446,10 @@  discard block
 block discarded – undo
1446 1446
             do_action( 'wpinv_cart_empty' );
1447 1447
         }
1448 1448
         echo '</div><!--end #wpinv_checkout_wrap-->';
1449
-	    do_action( 'wpinv_checkout_content_after' );
1449
+        do_action( 'wpinv_checkout_content_after' );
1450 1450
         $content = ob_get_clean();
1451 1451
 
1452
-		return str_replace( 'sr-only', '', $content );
1452
+        return str_replace( 'sr-only', '', $content );
1453 1453
 }
1454 1454
 
1455 1455
 function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
 add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1476 1476
 
1477 1477
 function wpinv_empty_cart_message() {
1478
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1478
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1479 1479
 }
1480 1480
 
1481 1481
 /**
@@ -2295,14 +2295,14 @@  discard block
 block discarded – undo
2295 2295
     global $invoicing;
2296 2296
 
2297 2297
     // Ensure that it is published.
2298
-	if ( 'publish' != get_post_status( $form ) ) {
2299
-		return aui()->alert(
2300
-			array(
2301
-				'type'    => 'warning',
2302
-				'content' => __( 'This payment form is no longer active', 'invoicing' ),
2303
-			)
2304
-		);
2305
-	}
2298
+    if ( 'publish' != get_post_status( $form ) ) {
2299
+        return aui()->alert(
2300
+            array(
2301
+                'type'    => 'warning',
2302
+                'content' => __( 'This payment form is no longer active', 'invoicing' ),
2303
+            )
2304
+        );
2305
+    }
2306 2306
 
2307 2307
     // Get the form.
2308 2308
     $form = new GetPaid_Payment_Form( $form );
@@ -2318,46 +2318,46 @@  discard block
 block discarded – undo
2318 2318
     global $invoicing;
2319 2319
 
2320 2320
     foreach ( array_keys( $items ) as $id ) {
2321
-	    if ( 'publish' != get_post_status( $id ) ) {
2322
-		    unset( $items[ $id ] );
2323
-	    }
2321
+        if ( 'publish' != get_post_status( $id ) ) {
2322
+            unset( $items[ $id ] );
2323
+        }
2324 2324
     }
2325 2325
 
2326 2326
     if ( empty( $items ) ) {
2327
-		return aui()->alert(
2328
-			array(
2329
-				'type'    => 'warning',
2330
-				'content' => __( 'No published items found', 'invoicing' ),
2331
-			)
2332
-		);
2327
+        return aui()->alert(
2328
+            array(
2329
+                'type'    => 'warning',
2330
+                'content' => __( 'No published items found', 'invoicing' ),
2331
+            )
2332
+        );
2333 2333
     }
2334 2334
 
2335 2335
     $item_key = getpaid_convert_items_to_string( $items );
2336 2336
 
2337 2337
     // Get the form elements and items.
2338 2338
     $form     = wpinv_get_default_payment_form();
2339
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2340
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
2339
+    $elements = $invoicing->form_elements->get_form_elements( $form );
2340
+    $items    = $invoicing->form_elements->convert_normal_items( $items );
2341 2341
 
2342
-	ob_start();
2343
-	echo "<form class='wpinv_payment_form'>";
2344
-	do_action( 'wpinv_payment_form_top' );
2342
+    ob_start();
2343
+    echo "<form class='wpinv_payment_form'>";
2344
+    do_action( 'wpinv_payment_form_top' );
2345 2345
     echo "<input type='hidden' name='form_id' value='$form'/>";
2346 2346
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
2347
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2348
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2347
+    wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2348
+    wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2349 2349
 
2350
-	foreach ( $elements as $element ) {
2351
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2352
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2353
-	}
2350
+    foreach ( $elements as $element ) {
2351
+        do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2352
+        do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2353
+    }
2354 2354
 
2355
-	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2356
-	do_action( 'wpinv_payment_form_bottom' );
2357
-	echo '</form>';
2355
+    echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2356
+    do_action( 'wpinv_payment_form_bottom' );
2357
+    echo '</form>';
2358 2358
 
2359
-	$content = ob_get_clean();
2360
-	return str_replace( 'sr-only', '', $content );
2359
+    $content = ob_get_clean();
2360
+    return str_replace( 'sr-only', '', $content );
2361 2361
 }
2362 2362
 
2363 2363
 /**
@@ -2369,47 +2369,47 @@  discard block
 block discarded – undo
2369 2369
     $invoice = wpinv_get_invoice( $invoice_id );
2370 2370
 
2371 2371
     if ( empty( $invoice ) ) {
2372
-		return aui()->alert(
2373
-			array(
2374
-				'type'    => 'warning',
2375
-				'content' => __( 'Invoice not found', 'invoicing' ),
2376
-			)
2377
-		);
2372
+        return aui()->alert(
2373
+            array(
2374
+                'type'    => 'warning',
2375
+                'content' => __( 'Invoice not found', 'invoicing' ),
2376
+            )
2377
+        );
2378 2378
     }
2379 2379
 
2380 2380
     if ( $invoice->is_paid() ) {
2381
-		return aui()->alert(
2382
-			array(
2383
-				'type'    => 'warning',
2384
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
2385
-			)
2386
-		);
2381
+        return aui()->alert(
2382
+            array(
2383
+                'type'    => 'warning',
2384
+                'content' => __( 'Invoice has already been paid', 'invoicing' ),
2385
+            )
2386
+        );
2387 2387
     }
2388 2388
 
2389 2389
     // Get the form elements and items.
2390 2390
     $form     = wpinv_get_default_payment_form();
2391
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2392
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
2391
+    $elements = $invoicing->form_elements->get_form_elements( $form );
2392
+    $items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
2393 2393
 
2394
-	ob_start();
2395
-	echo "<form class='wpinv_payment_form'>";
2396
-	do_action( 'wpinv_payment_form_top' );
2394
+    ob_start();
2395
+    echo "<form class='wpinv_payment_form'>";
2396
+    do_action( 'wpinv_payment_form_top' );
2397 2397
     echo "<input type='hidden' name='form_id' value='$form'/>";
2398 2398
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
2399
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2400
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2399
+    wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2400
+    wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2401 2401
 
2402
-	foreach ( $elements as $element ) {
2403
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2404
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2405
-	}
2402
+    foreach ( $elements as $element ) {
2403
+        do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2404
+        do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2405
+    }
2406 2406
 
2407
-	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2408
-	do_action( 'wpinv_payment_form_bottom' );
2409
-	echo '</form>';
2407
+    echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2408
+    do_action( 'wpinv_payment_form_bottom' );
2409
+    echo '</form>';
2410 2410
 
2411
-	$content = ob_get_clean();
2412
-	return str_replace( 'sr-only', '', $content );
2411
+    $content = ob_get_clean();
2412
+    return str_replace( 'sr-only', '', $content );
2413 2413
 }
2414 2414
 
2415 2415
 /**
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
2465 2465
     }
2466 2466
 	
2467
-	if ( ! empty( $items ) ) {
2467
+    if ( ! empty( $items ) ) {
2468 2468
         $items  = esc_attr( $items );
2469 2469
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
2470 2470
     }
Please login to merge, or discard this patch.
Spacing   +808 added lines, -808 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-if ( !is_admin() ) {
15
-    add_filter( 'template_include', 'wpinv_template', 10, 1 );
16
-    add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' );
17
-    add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' );
18
-    add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' );
14
+if (!is_admin()) {
15
+    add_filter('template_include', 'wpinv_template', 10, 1);
16
+    add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar');
17
+    add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions');
18
+    add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions');
19 19
 }
20 20
 
21 21
 function wpinv_template_path() {
22
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
22
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
23 23
 }
24 24
 
25
-function wpinv_display_invoice_top_bar( $invoice ) {
26
-    if ( empty( $invoice ) ) {
25
+function wpinv_display_invoice_top_bar($invoice) {
26
+    if (empty($invoice)) {
27 27
         return;
28 28
     }
29 29
     ?>
30 30
     <div class="row wpinv-top-bar no-print">
31 31
         <div class="container">
32 32
             <div class="col-xs-6">
33
-                <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?>
33
+                <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?>
34 34
             </div>
35 35
             <div class="col-xs-6 text-right">
36
-                <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?>
36
+                <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?>
37 37
             </div>
38 38
         </div>
39 39
     </div>
40 40
     <?php
41 41
 }
42 42
 
43
-function wpinv_invoice_display_left_actions( $invoice ) {
44
-    if ( empty( $invoice ) ) {
43
+function wpinv_invoice_display_left_actions($invoice) {
44
+    if (empty($invoice)) {
45 45
         return; // Exit if invoice is not set.
46 46
     }
47 47
     
48
-    if ( $invoice->post_type == 'wpi_invoice' ) {
49
-        if ( $invoice->needs_payment() ) {
50
-            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php
48
+    if ($invoice->post_type == 'wpi_invoice') {
49
+        if ($invoice->needs_payment()) {
50
+            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php
51 51
         }
52 52
     }
53 53
     do_action('wpinv_invoice_display_left_actions', $invoice);
54 54
 }
55 55
 
56
-function wpinv_invoice_display_right_actions( $invoice ) {
57
-    if ( empty( $invoice ) ) {
56
+function wpinv_invoice_display_right_actions($invoice) {
57
+    if (empty($invoice)) {
58 58
         return; // Exit if invoice is not set.
59 59
     }
60 60
 
61
-    if ( $invoice->post_type == 'wpi_invoice' ) { ?>
62
-        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a>
63
-        <?php if ( is_user_logged_in() ) { ?>
64
-        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a>
61
+    if ($invoice->post_type == 'wpi_invoice') { ?>
62
+        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a>
63
+        <?php if (is_user_logged_in()) { ?>
64
+        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a>
65 65
         <?php }
66 66
     }
67 67
     do_action('wpinv_invoice_display_right_actions', $invoice);
68 68
 }
69 69
 
70
-function wpinv_before_invoice_content( $content ) {
70
+function wpinv_before_invoice_content($content) {
71 71
     global $post;
72 72
 
73
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
73
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
74 74
         ob_start();
75
-        do_action( 'wpinv_before_invoice_content', $post->ID );
75
+        do_action('wpinv_before_invoice_content', $post->ID);
76 76
         $content = ob_get_clean() . $content;
77 77
     }
78 78
 
79 79
     return $content;
80 80
 }
81
-add_filter( 'the_content', 'wpinv_before_invoice_content' );
81
+add_filter('the_content', 'wpinv_before_invoice_content');
82 82
 
83
-function wpinv_after_invoice_content( $content ) {
83
+function wpinv_after_invoice_content($content) {
84 84
     global $post;
85 85
 
86
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
86
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
87 87
         ob_start();
88
-        do_action( 'wpinv_after_invoice_content', $post->ID );
88
+        do_action('wpinv_after_invoice_content', $post->ID);
89 89
         $content .= ob_get_clean();
90 90
     }
91 91
 
92 92
     return $content;
93 93
 }
94
-add_filter( 'the_content', 'wpinv_after_invoice_content' );
94
+add_filter('the_content', 'wpinv_after_invoice_content');
95 95
 
96 96
 function wpinv_get_templates_dir() {
97 97
     return WPINV_PLUGIN_DIR . 'templates';
@@ -101,105 +101,105 @@  discard block
 block discarded – undo
101 101
     return WPINV_PLUGIN_URL . 'templates';
102 102
 }
103 103
 
104
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105
-    if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
104
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
105
+    if (!empty($args) && is_array($args)) {
106
+		extract($args);
107 107
 	}
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
109
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
110 110
 	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
111
+	$located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path);
112 112
 
113
-	if ( ! file_exists( $located ) ) {
114
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
113
+	if (!file_exists($located)) {
114
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
115 115
 		return;
116 116
 	}
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
119 119
 
120
-	include( $located );
120
+	include($located);
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
123 123
 }
124 124
 
125
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
125
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
126 126
 	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
127
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
128 128
 	return ob_get_clean();
129 129
 }
130 130
 
131
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
132
-    if ( ! $template_path ) {
131
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
132
+    if (!$template_path) {
133 133
         $template_path = wpinv_template_path();
134 134
     }
135 135
 
136
-    if ( ! $default_path ) {
136
+    if (!$default_path) {
137 137
         $default_path = WPINV_PLUGIN_DIR . 'templates/';
138 138
     }
139 139
 
140 140
     // Look within passed path within the theme - this is priority.
141 141
     $template = locate_template(
142 142
         array(
143
-            trailingslashit( $template_path ) . $template_name,
143
+            trailingslashit($template_path) . $template_name,
144 144
             $template_name
145 145
         )
146 146
     );
147 147
 
148 148
     // Get default templates/
149
-    if ( !$template && $default_path ) {
150
-        $template = trailingslashit( $default_path ) . $template_name;
149
+    if (!$template && $default_path) {
150
+        $template = trailingslashit($default_path) . $template_name;
151 151
     }
152 152
 
153 153
     // Return what we found.
154
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path );
154
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path);
155 155
 }
156 156
 
157
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
157
+function wpinv_get_template_part($slug, $name = null, $load = true) {
158
+	do_action('get_template_part_' . $slug, $slug, $name);
159 159
 
160 160
 	// Setup possible parts
161 161
 	$templates = array();
162
-	if ( isset( $name ) )
162
+	if (isset($name))
163 163
 		$templates[] = $slug . '-' . $name . '.php';
164 164
 	$templates[] = $slug . '.php';
165 165
 
166 166
 	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
167
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
168 168
 
169 169
 	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
170
+	return wpinv_locate_tmpl($templates, $load, false);
171 171
 }
172 172
 
173
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
173
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
174 174
 	// No file found yet
175 175
 	$located = false;
176 176
 
177 177
 	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
178
+	foreach ((array) $template_names as $template_name) {
179 179
 
180 180
 		// Continue if template is empty
181
-		if ( empty( $template_name ) )
181
+		if (empty($template_name))
182 182
 			continue;
183 183
 
184 184
 		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
185
+		$template_name = ltrim($template_name, '/');
186 186
 
187 187
 		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
188
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
190
+			if (file_exists($template_path . $template_name)) {
191 191
 				$located = $template_path . $template_name;
192 192
 				break;
193 193
 			}
194 194
 		}
195 195
 
196
-		if( !empty( $located ) ) {
196
+		if (!empty($located)) {
197 197
 			break;
198 198
 		}
199 199
 	}
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+	if ((true == $load) && !empty($located))
202
+		load_template($located, $require_once);
203 203
 
204 204
 	return $located;
205 205
 }
@@ -208,159 +208,159 @@  discard block
 block discarded – undo
208 208
 	$template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210 210
 	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
211
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
212
+		10 => trailingslashit(get_template_directory()) . $template_dir,
213 213
 		100 => wpinv_get_templates_dir()
214 214
 	);
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
217 217
 
218 218
 	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
219
+	ksort($file_paths, SORT_NUMERIC);
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+	return array_map('trailingslashit', $file_paths);
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230 230
 	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234
+	$pages[] = wpinv_get_option('invoice_subscription_page');
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
236
+	if (!wpinv_is_checkout() && !is_page($pages)) {
237 237
 		return;
238 238
 	}
239 239
 
240 240
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
242
+add_action('wp_head', 'wpinv_checkout_meta_tags');
243 243
 
244
-function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
244
+function wpinv_add_body_classes($class) {
245
+	$classes = (array) $class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
247
+	if (wpinv_is_checkout()) {
248 248
 		$classes[] = 'wpinv-checkout';
249 249
 		$classes[] = 'wpinv-page';
250 250
 	}
251 251
 
252
-	if( wpinv_is_success_page() ) {
252
+	if (wpinv_is_success_page()) {
253 253
 		$classes[] = 'wpinv-success';
254 254
 		$classes[] = 'wpinv-page';
255 255
 	}
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
257
+	if (wpinv_is_failed_transaction_page()) {
258 258
 		$classes[] = 'wpinv-failed-transaction';
259 259
 		$classes[] = 'wpinv-page';
260 260
 	}
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
262
+	if (wpinv_is_invoice_history_page()) {
263 263
 		$classes[] = 'wpinv-history';
264 264
 		$classes[] = 'wpinv-page';
265 265
 	}
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
267
+	if (wpinv_is_subscriptions_history_page()) {
268 268
 		$classes[] = 'wpinv-subscription';
269 269
 		$classes[] = 'wpinv-page';
270 270
 	}
271 271
 
272
-	if( wpinv_is_test_mode() ) {
272
+	if (wpinv_is_test_mode()) {
273 273
 		$classes[] = 'wpinv-test-mode';
274 274
 		$classes[] = 'wpinv-page';
275 275
 	}
276 276
 
277
-	return array_unique( $classes );
277
+	return array_unique($classes);
278 278
 }
279
-add_filter( 'body_class', 'wpinv_add_body_classes' );
279
+add_filter('body_class', 'wpinv_add_body_classes');
280 280
 
281
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
282
-    $args = array( 'nopaging' => true );
281
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
282
+    $args = array('nopaging' => true);
283 283
 
284
-    if ( ! empty( $status ) )
284
+    if (!empty($status))
285 285
         $args['post_status'] = $status;
286 286
 
287
-    $discounts = wpinv_get_discounts( $args );
287
+    $discounts = wpinv_get_discounts($args);
288 288
     $options   = array();
289 289
 
290
-    if ( $discounts ) {
291
-        foreach ( $discounts as $discount ) {
292
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
290
+    if ($discounts) {
291
+        foreach ($discounts as $discount) {
292
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
293 293
         }
294 294
     } else {
295
-        $options[0] = __( 'No discounts found', 'invoicing' );
295
+        $options[0] = __('No discounts found', 'invoicing');
296 296
     }
297 297
 
298
-    $output = wpinv_html_select( array(
298
+    $output = wpinv_html_select(array(
299 299
         'name'             => $name,
300 300
         'selected'         => $selected,
301 301
         'options'          => $options,
302 302
         'show_option_all'  => false,
303 303
         'show_option_none' => false,
304
-    ) );
304
+    ));
305 305
 
306 306
     return $output;
307 307
 }
308 308
 
309
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
310
-    $current     = date( 'Y' );
311
-    $start_year  = $current - absint( $years_before );
312
-    $end_year    = $current + absint( $years_after );
313
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
309
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
310
+    $current     = date('Y');
311
+    $start_year  = $current - absint($years_before);
312
+    $end_year    = $current + absint($years_after);
313
+    $selected    = empty($selected) ? date('Y') : $selected;
314 314
     $options     = array();
315 315
 
316
-    while ( $start_year <= $end_year ) {
317
-        $options[ absint( $start_year ) ] = $start_year;
316
+    while ($start_year <= $end_year) {
317
+        $options[absint($start_year)] = $start_year;
318 318
         $start_year++;
319 319
     }
320 320
 
321
-    $output = wpinv_html_select( array(
321
+    $output = wpinv_html_select(array(
322 322
         'name'             => $name,
323 323
         'selected'         => $selected,
324 324
         'options'          => $options,
325 325
         'show_option_all'  => false,
326 326
         'show_option_none' => false
327
-    ) );
327
+    ));
328 328
 
329 329
     return $output;
330 330
 }
331 331
 
332
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
332
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
333 333
 
334 334
     $options = array(
335
-        '1'  => __( 'January', 'invoicing' ),
336
-        '2'  => __( 'February', 'invoicing' ),
337
-        '3'  => __( 'March', 'invoicing' ),
338
-        '4'  => __( 'April', 'invoicing' ),
339
-        '5'  => __( 'May', 'invoicing' ),
340
-        '6'  => __( 'June', 'invoicing' ),
341
-        '7'  => __( 'July', 'invoicing' ),
342
-        '8'  => __( 'August', 'invoicing' ),
343
-        '9'  => __( 'September', 'invoicing' ),
344
-        '10' => __( 'October', 'invoicing' ),
345
-        '11' => __( 'November', 'invoicing' ),
346
-        '12' => __( 'December', 'invoicing' ),
335
+        '1'  => __('January', 'invoicing'),
336
+        '2'  => __('February', 'invoicing'),
337
+        '3'  => __('March', 'invoicing'),
338
+        '4'  => __('April', 'invoicing'),
339
+        '5'  => __('May', 'invoicing'),
340
+        '6'  => __('June', 'invoicing'),
341
+        '7'  => __('July', 'invoicing'),
342
+        '8'  => __('August', 'invoicing'),
343
+        '9'  => __('September', 'invoicing'),
344
+        '10' => __('October', 'invoicing'),
345
+        '11' => __('November', 'invoicing'),
346
+        '12' => __('December', 'invoicing'),
347 347
     );
348 348
 
349 349
     // If no month is selected, default to the current month
350
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
350
+    $selected = empty($selected) ? date('n') : $selected;
351 351
 
352
-    $output = wpinv_html_select( array(
352
+    $output = wpinv_html_select(array(
353 353
         'name'             => $name,
354 354
         'selected'         => $selected,
355 355
         'options'          => $options,
356 356
         'show_option_all'  => false,
357 357
         'show_option_none' => false
358
-    ) );
358
+    ));
359 359
 
360 360
     return $output;
361 361
 }
362 362
 
363
-function wpinv_html_select( $args = array() ) {
363
+function wpinv_html_select($args = array()) {
364 364
     $defaults = array(
365 365
         'options'          => array(),
366 366
         'name'             => null,
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
         'selected'         => 0,
370 370
         'placeholder'      => null,
371 371
         'multiple'         => false,
372
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
373
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
372
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
373
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
374 374
         'data'             => array(),
375 375
         'onchange'         => null,
376 376
         'required'         => false,
@@ -378,74 +378,74 @@  discard block
 block discarded – undo
378 378
         'readonly'         => false,
379 379
     );
380 380
 
381
-    $args = wp_parse_args( $args, $defaults );
381
+    $args = wp_parse_args($args, $defaults);
382 382
 
383 383
     $data_elements = '';
384
-    foreach ( $args['data'] as $key => $value ) {
385
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
384
+    foreach ($args['data'] as $key => $value) {
385
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
386 386
     }
387 387
 
388
-    if( $args['multiple'] ) {
388
+    if ($args['multiple']) {
389 389
         $multiple = ' MULTIPLE';
390 390
     } else {
391 391
         $multiple = '';
392 392
     }
393 393
 
394
-    if( $args['placeholder'] ) {
394
+    if ($args['placeholder']) {
395 395
         $placeholder = $args['placeholder'];
396 396
     } else {
397 397
         $placeholder = '';
398 398
     }
399 399
     
400 400
     $options = '';
401
-    if( !empty( $args['onchange'] ) ) {
402
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
401
+    if (!empty($args['onchange'])) {
402
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
403 403
     }
404 404
     
405
-    if( !empty( $args['required'] ) ) {
405
+    if (!empty($args['required'])) {
406 406
         $options .= ' required="required"';
407 407
     }
408 408
     
409
-    if( !empty( $args['disabled'] ) ) {
409
+    if (!empty($args['disabled'])) {
410 410
         $options .= ' disabled';
411 411
     }
412 412
     
413
-    if( !empty( $args['readonly'] ) ) {
413
+    if (!empty($args['readonly'])) {
414 414
         $options .= ' readonly';
415 415
     }
416 416
 
417
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
418
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
417
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
418
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
419 419
 
420
-    if ( $args['show_option_all'] ) {
421
-        if( $args['multiple'] ) {
422
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
420
+    if ($args['show_option_all']) {
421
+        if ($args['multiple']) {
422
+            $selected = selected(true, in_array(0, $args['selected']), false);
423 423
         } else {
424
-            $selected = selected( $args['selected'], 0, false );
424
+            $selected = selected($args['selected'], 0, false);
425 425
         }
426
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
426
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
427 427
     }
428 428
 
429
-    if ( !empty( $args['options'] ) ) {
429
+    if (!empty($args['options'])) {
430 430
 
431
-        if ( $args['show_option_none'] ) {
432
-            if( $args['multiple'] ) {
433
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
431
+        if ($args['show_option_none']) {
432
+            if ($args['multiple']) {
433
+                $selected = selected(true, in_array("", $args['selected']), false);
434 434
             } else {
435
-                $selected = selected( $args['selected'] === "", true, false );
435
+                $selected = selected($args['selected'] === "", true, false);
436 436
             }
437
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
437
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
438 438
         }
439 439
 
440
-        foreach( $args['options'] as $key => $option ) {
440
+        foreach ($args['options'] as $key => $option) {
441 441
 
442
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
443
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
442
+            if ($args['multiple'] && is_array($args['selected'])) {
443
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
444 444
             } else {
445
-                $selected = selected( $args['selected'], $key, false );
445
+                $selected = selected($args['selected'], $key, false);
446 446
             }
447 447
 
448
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
448
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
449 449
         }
450 450
     }
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     return $output;
455 455
 }
456 456
 
457
-function wpinv_item_dropdown( $args = array() ) {
457
+function wpinv_item_dropdown($args = array()) {
458 458
     $defaults = array(
459 459
         'name'              => 'wpi_item',
460 460
         'id'                => 'wpi_item',
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         'multiple'          => false,
463 463
         'selected'          => 0,
464 464
         'number'            => 100,
465
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
466
-        'data'              => array( 'search-type' => 'item' ),
465
+        'placeholder'       => __('Choose a item', 'invoicing'),
466
+        'data'              => array('search-type' => 'item'),
467 467
         'show_option_all'   => false,
468 468
         'show_option_none'  => false,
469 469
         'show_recurring'    => false,
470 470
     );
471 471
 
472
-    $args = wp_parse_args( $args, $defaults );
472
+    $args = wp_parse_args($args, $defaults);
473 473
 
474 474
     $item_args = array(
475 475
         'post_type'      => 'wpi_item',
@@ -478,44 +478,44 @@  discard block
 block discarded – undo
478 478
         'posts_per_page' => $args['number']
479 479
     );
480 480
 
481
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
481
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
482 482
 
483
-    $items      = get_posts( $item_args );
483
+    $items      = get_posts($item_args);
484 484
     $options    = array();
485
-    if ( $items ) {
486
-        foreach ( $items as $item ) {
487
-            $title = esc_html( $item->post_title );
485
+    if ($items) {
486
+        foreach ($items as $item) {
487
+            $title = esc_html($item->post_title);
488 488
             
489
-            if ( !empty( $args['show_recurring'] ) ) {
490
-                $title .= wpinv_get_item_suffix( $item->ID, false );
489
+            if (!empty($args['show_recurring'])) {
490
+                $title .= wpinv_get_item_suffix($item->ID, false);
491 491
             }
492 492
             
493
-            $options[ absint( $item->ID ) ] = $title;
493
+            $options[absint($item->ID)] = $title;
494 494
         }
495 495
     }
496 496
 
497 497
     // This ensures that any selected items are included in the drop down
498
-    if( is_array( $args['selected'] ) ) {
499
-        foreach( $args['selected'] as $item ) {
500
-            if( ! in_array( $item, $options ) ) {
501
-                $title = get_the_title( $item );
502
-                if ( !empty( $args['show_recurring'] ) ) {
503
-                    $title .= wpinv_get_item_suffix( $item, false );
498
+    if (is_array($args['selected'])) {
499
+        foreach ($args['selected'] as $item) {
500
+            if (!in_array($item, $options)) {
501
+                $title = get_the_title($item);
502
+                if (!empty($args['show_recurring'])) {
503
+                    $title .= wpinv_get_item_suffix($item, false);
504 504
                 }
505 505
                 $options[$item] = $title;
506 506
             }
507 507
         }
508
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
509
-        if ( ! in_array( $args['selected'], $options ) ) {
510
-            $title = get_the_title( $args['selected'] );
511
-            if ( !empty( $args['show_recurring'] ) ) {
512
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
508
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
509
+        if (!in_array($args['selected'], $options)) {
510
+            $title = get_the_title($args['selected']);
511
+            if (!empty($args['show_recurring'])) {
512
+                $title .= wpinv_get_item_suffix($args['selected'], false);
513 513
             }
514
-            $options[$args['selected']] = get_the_title( $args['selected'] );
514
+            $options[$args['selected']] = get_the_title($args['selected']);
515 515
         }
516 516
     }
517 517
 
518
-    $output = wpinv_html_select( array(
518
+    $output = wpinv_html_select(array(
519 519
         'name'             => $args['name'],
520 520
         'selected'         => $args['selected'],
521 521
         'id'               => $args['id'],
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
         'show_option_all'  => $args['show_option_all'],
527 527
         'show_option_none' => $args['show_option_none'],
528 528
         'data'             => $args['data'],
529
-    ) );
529
+    ));
530 530
 
531 531
     return $output;
532 532
 }
533 533
 
534
-function wpinv_html_checkbox( $args = array() ) {
534
+function wpinv_html_checkbox($args = array()) {
535 535
     $defaults = array(
536 536
         'name'     => null,
537 537
         'current'  => null,
@@ -542,38 +542,38 @@  discard block
 block discarded – undo
542 542
         )
543 543
     );
544 544
 
545
-    $args = wp_parse_args( $args, $defaults );
545
+    $args = wp_parse_args($args, $defaults);
546 546
 
547
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
547
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
548 548
     $options = '';
549
-    if ( ! empty( $args['options']['disabled'] ) ) {
549
+    if (!empty($args['options']['disabled'])) {
550 550
         $options .= ' disabled="disabled"';
551
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
551
+    } elseif (!empty($args['options']['readonly'])) {
552 552
         $options .= ' readonly';
553 553
     }
554 554
 
555
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
555
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
556 556
 
557 557
     return $output;
558 558
 }
559 559
 
560
-function wpinv_html_text( $args = array() ) {
560
+function wpinv_html_text($args = array()) {
561 561
     // Backwards compatibility
562
-    if ( func_num_args() > 1 ) {
562
+    if (func_num_args() > 1) {
563 563
         $args = func_get_args();
564 564
 
565 565
         $name  = $args[0];
566
-        $value = isset( $args[1] ) ? $args[1] : '';
567
-        $label = isset( $args[2] ) ? $args[2] : '';
568
-        $desc  = isset( $args[3] ) ? $args[3] : '';
566
+        $value = isset($args[1]) ? $args[1] : '';
567
+        $label = isset($args[2]) ? $args[2] : '';
568
+        $desc  = isset($args[3]) ? $args[3] : '';
569 569
     }
570 570
 
571 571
     $defaults = array(
572 572
         'id'           => '',
573
-        'name'         => isset( $name )  ? $name  : 'text',
574
-        'value'        => isset( $value ) ? $value : null,
575
-        'label'        => isset( $label ) ? $label : null,
576
-        'desc'         => isset( $desc )  ? $desc  : null,
573
+        'name'         => isset($name) ? $name : 'text',
574
+        'value'        => isset($value) ? $value : null,
575
+        'label'        => isset($label) ? $label : null,
576
+        'desc'         => isset($desc) ? $desc : null,
577 577
         'placeholder'  => '',
578 578
         'class'        => 'regular-text',
579 579
         'disabled'     => false,
@@ -583,51 +583,51 @@  discard block
 block discarded – undo
583 583
         'data'         => false
584 584
     );
585 585
 
586
-    $args = wp_parse_args( $args, $defaults );
586
+    $args = wp_parse_args($args, $defaults);
587 587
 
588
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
588
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
589 589
     $options = '';
590
-    if( $args['required'] ) {
590
+    if ($args['required']) {
591 591
         $options .= ' required="required"';
592 592
     }
593
-    if( $args['readonly'] ) {
593
+    if ($args['readonly']) {
594 594
         $options .= ' readonly';
595 595
     }
596
-    if( $args['readonly'] ) {
596
+    if ($args['readonly']) {
597 597
         $options .= ' readonly';
598 598
     }
599 599
 
600 600
     $data = '';
601
-    if ( !empty( $args['data'] ) ) {
602
-        foreach ( $args['data'] as $key => $value ) {
603
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
601
+    if (!empty($args['data'])) {
602
+        foreach ($args['data'] as $key => $value) {
603
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
604 604
         }
605 605
     }
606 606
 
607
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
608
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
609
-    if ( ! empty( $args['desc'] ) ) {
610
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
607
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
608
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
609
+    if (!empty($args['desc'])) {
610
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
611 611
     }
612 612
 
613
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
613
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
614 614
 
615 615
     $output .= '</span>';
616 616
 
617 617
     return $output;
618 618
 }
619 619
 
620
-function wpinv_html_date_field( $args = array() ) {
621
-    if( empty( $args['class'] ) ) {
620
+function wpinv_html_date_field($args = array()) {
621
+    if (empty($args['class'])) {
622 622
         $args['class'] = 'wpiDatepicker';
623
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
623
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
624 624
         $args['class'] .= ' wpiDatepicker';
625 625
     }
626 626
 
627
-    return wpinv_html_text( $args );
627
+    return wpinv_html_text($args);
628 628
 }
629 629
 
630
-function wpinv_html_textarea( $args = array() ) {
630
+function wpinv_html_textarea($args = array()) {
631 631
     $defaults = array(
632 632
         'name'        => 'textarea',
633 633
         'value'       => null,
@@ -638,31 +638,31 @@  discard block
 block discarded – undo
638 638
         'placeholder' => '',
639 639
     );
640 640
 
641
-    $args = wp_parse_args( $args, $defaults );
641
+    $args = wp_parse_args($args, $defaults);
642 642
 
643
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
643
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
644 644
     $disabled = '';
645
-    if( $args['disabled'] ) {
645
+    if ($args['disabled']) {
646 646
         $disabled = ' disabled="disabled"';
647 647
     }
648 648
 
649
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
650
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
651
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
649
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
650
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
651
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
652 652
 
653
-    if ( ! empty( $args['desc'] ) ) {
654
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
653
+    if (!empty($args['desc'])) {
654
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
655 655
     }
656 656
     $output .= '</span>';
657 657
 
658 658
     return $output;
659 659
 }
660 660
 
661
-function wpinv_html_ajax_user_search( $args = array() ) {
661
+function wpinv_html_ajax_user_search($args = array()) {
662 662
     $defaults = array(
663 663
         'name'        => 'user_id',
664 664
         'value'       => null,
665
-        'placeholder' => __( 'Enter username', 'invoicing' ),
665
+        'placeholder' => __('Enter username', 'invoicing'),
666 666
         'label'       => null,
667 667
         'desc'        => null,
668 668
         'class'       => '',
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
         'data'        => false
672 672
     );
673 673
 
674
-    $args = wp_parse_args( $args, $defaults );
674
+    $args = wp_parse_args($args, $defaults);
675 675
 
676 676
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
677 677
 
678 678
     $output  = '<span class="wpinv_user_search_wrap">';
679
-        $output .= wpinv_html_text( $args );
680
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
679
+        $output .= wpinv_html_text($args);
680
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
681 681
     $output .= '</span>';
682 682
 
683 683
     return $output;
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 function wpinv_ip_geolocation() {
687 687
     global $wpinv_euvat;
688 688
     
689
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
689
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
690 690
     $content    = '';
691 691
     $iso        = '';
692 692
     $country    = '';
@@ -697,69 +697,69 @@  discard block
 block discarded – undo
697 697
     $credit     = '';
698 698
     $address    = '';
699 699
     
700
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
700
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
701 701
         try {
702 702
             $iso        = $geoip2_city->country->isoCode;
703 703
             $country    = $geoip2_city->country->name;
704
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
704
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
705 705
             $city       = $geoip2_city->city->name;
706 706
             $longitude  = $geoip2_city->location->longitude;
707 707
             $latitude   = $geoip2_city->location->latitude;
708
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
709
-        } catch( Exception $e ) { }
708
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
709
+        } catch (Exception $e) { }
710 710
     }
711 711
     
712
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
712
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
713 713
         try {
714
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
714
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
715 715
             
716
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
716
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
717 717
                 $iso        = $load_xml->geoplugin_countryCode;
718 718
                 $country    = $load_xml->geoplugin_countryName;
719
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
720
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
719
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
720
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
721 721
                 $longitude  = $load_xml->geoplugin_longitude;
722 722
                 $latitude   = $load_xml->geoplugin_latitude;
723 723
                 $credit     = $load_xml->geoplugin_credit;
724
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
724
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
725 725
             }
726
-        } catch( Exception $e ) { }
726
+        } catch (Exception $e) { }
727 727
     }
728 728
     
729
-    if ( $iso && $longitude && $latitude ) {
730
-        if ( $city ) {
729
+    if ($iso && $longitude && $latitude) {
730
+        if ($city) {
731 731
             $address .= $city . ', ';
732 732
         }
733 733
         
734
-        if ( $region ) {
734
+        if ($region) {
735 735
             $address .= $region . ', ';
736 736
         }
737 737
         
738 738
         $address .= $country . ' (' . $iso . ')';
739
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
740
-        $content .= '<p>'. $credit . '</p>';
739
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
740
+        $content .= '<p>' . $credit . '</p>';
741 741
     } else {
742
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
742
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
743 743
     }
744 744
     ?>
745 745
 <!DOCTYPE html>
746
-<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
746
+<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
747 747
 <body>
748
-    <?php if ( $latitude && $latitude ) { ?>
748
+    <?php if ($latitude && $latitude) { ?>
749 749
     <div id="map"></div>
750 750
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
751 751
         <script type="text/javascript">
752 752
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
753 753
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
754 754
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
755
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
755
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
756 756
 
757 757
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
758 758
 
759 759
         var marker = new L.Marker(latlng);
760 760
         map.addLayer(marker);
761 761
 
762
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
762
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
763 763
     </script>
764 764
     <?php } ?>
765 765
     <div style="height:100px"><?php echo $content; ?></div>
@@ -767,18 +767,18 @@  discard block
 block discarded – undo
767 767
 <?php
768 768
     exit;
769 769
 }
770
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
771
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
770
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
771
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
772 772
 
773 773
 // Set up the template for the invoice.
774
-function wpinv_template( $template ) {
774
+function wpinv_template($template) {
775 775
     global $post, $wp_query;
776 776
     
777
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
778
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
779
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
777
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
778
+        if (wpinv_user_can_view_invoice($post->ID)) {
779
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
780 780
         } else {
781
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
781
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
782 782
         }
783 783
     }
784 784
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 
788 788
 function wpinv_get_business_address() {
789 789
     $business_address   = wpinv_store_address();
790
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
790
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
791 791
     
792 792
     /*
793 793
     $default_country    = wpinv_get_default_country();
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
     
812 812
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
813 813
     
814
-    return apply_filters( 'wpinv_get_business_address', $business_address );
814
+    return apply_filters('wpinv_get_business_address', $business_address);
815 815
 }
816 816
 
817 817
 function wpinv_display_from_address() {
@@ -821,116 +821,116 @@  discard block
 block discarded – undo
821 821
     if (empty($from_name)) {
822 822
         $from_name = wpinv_get_business_name();
823 823
     }
824
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
824
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
825 825
     <div class="wrapper col-xs-10">
826
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
827
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
828
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
826
+        <div class="name"><?php echo esc_html($from_name); ?></div>
827
+        <?php if ($address = wpinv_get_business_address()) { ?>
828
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
829 829
         <?php } ?>
830
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
831
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
830
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
831
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
832 832
         <?php } ?>
833 833
     </div>
834 834
     <?php
835 835
 }
836 836
 
837
-function wpinv_watermark( $id = 0 ) {
838
-    $output = wpinv_get_watermark( $id );
837
+function wpinv_watermark($id = 0) {
838
+    $output = wpinv_get_watermark($id);
839 839
     
840
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
840
+    return apply_filters('wpinv_get_watermark', $output, $id);
841 841
 }
842 842
 
843
-function wpinv_get_watermark( $id ) {
844
-    if ( !$id > 0 ) {
843
+function wpinv_get_watermark($id) {
844
+    if (!$id > 0) {
845 845
         return NULL;
846 846
     }
847
-    $invoice = wpinv_get_invoice( $id );
847
+    $invoice = wpinv_get_invoice($id);
848 848
     
849
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
850
-        if ( $invoice->is_paid() ) {
851
-            return __( 'Paid', 'invoicing' );
849
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
850
+        if ($invoice->is_paid()) {
851
+            return __('Paid', 'invoicing');
852 852
         }
853
-        if ( $invoice->is_refunded() ) {
854
-            return __( 'Refunded', 'invoicing' );
853
+        if ($invoice->is_refunded()) {
854
+            return __('Refunded', 'invoicing');
855 855
         }
856
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
857
-            return __( 'Cancelled', 'invoicing' );
856
+        if ($invoice->has_status(array('wpi-cancelled'))) {
857
+            return __('Cancelled', 'invoicing');
858 858
         }
859 859
     }
860 860
     
861 861
     return NULL;
862 862
 }
863 863
 
864
-function wpinv_display_invoice_details( $invoice ) {
864
+function wpinv_display_invoice_details($invoice) {
865 865
     global $wpinv_euvat;
866 866
     
867 867
     $invoice_id = $invoice->ID;
868 868
     $vat_name   = $wpinv_euvat->get_vat_name();
869 869
     $use_taxes  = wpinv_use_taxes();
870 870
     
871
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
871
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
872 872
     ?>
873 873
     <table class="table table-bordered table-sm">
874
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
874
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
875 875
             <tr class="wpi-row-number">
876
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
877
-                <td><?php echo esc_html( $invoice_number ); ?></td>
876
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
877
+                <td><?php echo esc_html($invoice_number); ?></td>
878 878
             </tr>
879 879
         <?php } ?>
880 880
         <tr class="wpi-row-status">
881
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
882
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
881
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
882
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
883 883
         </tr>
884
-        <?php if ( $invoice->is_renewal() ) { ?>
884
+        <?php if ($invoice->is_renewal()) { ?>
885 885
         <tr class="wpi-row-parent">
886
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
887
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
886
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
887
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
888 888
         </tr>
889 889
         <?php } ?>
890
-        <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
890
+        <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
891 891
             <tr class="wpi-row-gateway">
892
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
892
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
893 893
                 <td><?php echo $gateway_name; ?></td>
894 894
             </tr>
895 895
         <?php } ?>
896
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
896
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
897 897
             <tr class="wpi-row-date">
898
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
898
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
899 899
                 <td><?php echo $invoice_date; ?></td>
900 900
             </tr>
901 901
         <?php } ?>
902
-        <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?>
903
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
902
+        <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?>
903
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
904 904
             <tr class="wpi-row-date">
905
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
905
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
906 906
                 <td><?php echo $due_date; ?></td>
907 907
             </tr>
908 908
         <?php } ?>
909
-        <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?>
910
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
909
+        <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?>
910
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
911 911
             <tr class="wpi-row-ovatno">
912
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
912
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
913 913
                 <td><?php echo $owner_vat_number; ?></td>
914 914
             </tr>
915 915
         <?php } ?>
916
-        <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?>
916
+        <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?>
917 917
             <tr class="wpi-row-uvatno">
918
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
918
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
919 919
                 <td><?php echo $user_vat_number; ?></td>
920 920
             </tr>
921 921
         <?php } ?>
922 922
         <tr class="table-active tr-total wpi-row-total">
923
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
924
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
923
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
924
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
925 925
         </tr>
926
-        <?php if ( $subscription = wpinv_get_subscription( $invoice_id ) ) { ?>
926
+        <?php if ($subscription = wpinv_get_subscription($invoice_id)) { ?>
927 927
         <tr class="table-active wpi-row-recurring-total">
928
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Recurring Amount', 'invoicing' ), $invoice ); ?></th>
929
-            <td><strong><?php echo wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ); ?></strong></td>
928
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Recurring Amount', 'invoicing'), $invoice); ?></th>
929
+            <td><strong><?php echo wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()); ?></strong></td>
930 930
         </tr>
931 931
         <tr class="wpi-row-expires">
932
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Renews On', 'invoicing' ), $invoice ); ?></th>
933
-            <td><?php echo sanitize_text_field( $subscription->expiration ); ?></td>
932
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Renews On', 'invoicing'), $invoice); ?></th>
933
+            <td><?php echo sanitize_text_field($subscription->expiration); ?></td>
934 934
         </tr>
935 935
         <?php } ?>
936 936
     </table>
@@ -947,84 +947,84 @@  discard block
 block discarded – undo
947 947
  * @param  string $separator How to separate address lines.
948 948
  * @return string
949 949
  */
950
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
950
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
951 951
 
952 952
     // Retrieve the address markup...
953
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
954
-    $format = wpinv_get_full_address_format( $country );
953
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
954
+    $format = wpinv_get_full_address_format($country);
955 955
 
956 956
     // ... and the replacements.
957
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
957
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
958 958
 
959
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
959
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
960 960
     
961 961
 	// Remove unavailable tags.
962
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
962
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
963 963
 
964 964
     // Clean up white space.
965
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
966
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
965
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
966
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
967 967
     
968 968
     // Break newlines apart and remove empty lines/trim commas and white space.
969
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
969
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
970 970
 
971 971
     // Add html breaks.
972
-	$formatted_address = implode( $separator, $formatted_address );
972
+	$formatted_address = implode($separator, $formatted_address);
973 973
 
974 974
 	// We're done!
975 975
 	return $formatted_address;
976 976
     
977 977
 }
978 978
 
979
-function wpinv_display_to_address( $invoice_id = 0 ) {
980
-    $invoice = wpinv_get_invoice( $invoice_id );
979
+function wpinv_display_to_address($invoice_id = 0) {
980
+    $invoice = wpinv_get_invoice($invoice_id);
981 981
     
982
-    if ( empty( $invoice ) ) {
982
+    if (empty($invoice)) {
983 983
         return NULL;
984 984
     }
985 985
     
986 986
     $billing_details = $invoice->get_user_info();
987
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
987
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
988 988
     $output .= '<div class="wrapper col-xs-10">';
989 989
     
990 990
     ob_start();
991
-    do_action( 'wpinv_display_to_address_top', $invoice );
991
+    do_action('wpinv_display_to_address_top', $invoice);
992 992
     $output .= ob_get_clean();
993 993
     
994
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
994
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
995 995
 
996
-    if ( $address_row ) {
996
+    if ($address_row) {
997 997
         $output .= '<div class="address">' . $address_row . '</div>';
998 998
     }
999 999
 
1000
-    if ( $phone = $invoice->get_phone() ) {
1001
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
1000
+    if ($phone = $invoice->get_phone()) {
1001
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
1002 1002
     }
1003
-    if ( $email = $invoice->get_email() ) {
1004
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
1003
+    if ($email = $invoice->get_email()) {
1004
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
1005 1005
     }
1006 1006
 
1007 1007
     ob_start();
1008
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
1008
+    do_action('wpinv_display_to_address_bottom', $invoice);
1009 1009
     $output .= ob_get_clean();
1010 1010
     
1011 1011
     $output .= '</div>';
1012
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
1012
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
1013 1013
 
1014 1014
     echo $output;
1015 1015
 }
1016 1016
 
1017
-function wpinv_display_line_items( $invoice_id = 0 ) {
1017
+function wpinv_display_line_items($invoice_id = 0) {
1018 1018
     global $wpinv_euvat, $ajax_cart_details;
1019
-    $invoice            = wpinv_get_invoice( $invoice_id );
1019
+    $invoice            = wpinv_get_invoice($invoice_id);
1020 1020
     $quantities_enabled = wpinv_item_quantities_enabled();
1021 1021
     $use_taxes          = wpinv_use_taxes();
1022
-    if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
1022
+    if (!$use_taxes && (float) $invoice->get_tax() > 0) {
1023 1023
         $use_taxes = true;
1024 1024
     }
1025
-    $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
1026
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
1027
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
1025
+    $zero_tax           = !(float) $invoice->get_tax() > 0 ? true : false;
1026
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
1027
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
1028 1028
 
1029 1029
     $cart_details       = $invoice->get_cart_details();
1030 1030
     $ajax_cart_details  = $cart_details;
@@ -1033,67 +1033,67 @@  discard block
 block discarded – undo
1033 1033
     <table class="table table-sm table-bordered">
1034 1034
         <thead>
1035 1035
             <tr>
1036
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1037
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1036
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1037
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1038 1038
                 <?php if ($quantities_enabled) { ?>
1039
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1039
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1040 1040
                 <?php } ?>
1041 1041
                 <?php if ($use_taxes && !$zero_tax) { ?>
1042 1042
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1043 1043
                 <?php } ?>
1044
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1044
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1045 1045
             </tr>
1046 1046
         </thead>
1047 1047
         <tbody>
1048 1048
         <?php 
1049
-            if ( !empty( $cart_details ) ) {
1050
-                do_action( 'wpinv_display_line_items_start', $invoice );
1049
+            if (!empty($cart_details)) {
1050
+                do_action('wpinv_display_line_items_start', $invoice);
1051 1051
 
1052 1052
                 $count = 0;
1053 1053
                 $cols  = 3;
1054
-                foreach ( $cart_details as $key => $cart_item ) {
1055
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1056
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1057
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1058
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1054
+                foreach ($cart_details as $key => $cart_item) {
1055
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1056
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1057
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1058
+                    $quantity   = !empty($cart_item['quantity']) && (int) $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1059 1059
 
1060
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1060
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1061 1061
                     $summary    = '';
1062
-	                $item_name    = '';
1062
+	                $item_name = '';
1063 1063
                     $cols       = 3;
1064
-                    if ( !empty($item) ) {
1064
+                    if (!empty($item)) {
1065 1065
                         $item_name  = $item->get_name();
1066 1066
                         $summary    = $item->get_summary();
1067 1067
                     }
1068
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1068
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1069 1069
 
1070
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1070
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1071 1071
 
1072 1072
                     $item_tax       = '';
1073 1073
                     $tax_rate       = '';
1074
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1075
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1076
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1077
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1074
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1075
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1076
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1077
+                        $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1078 1078
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1079 1079
                     }
1080 1080
 
1081 1081
                     $line_item_tax = $item_tax . $tax_rate;
1082 1082
 
1083
-                    if ( $line_item_tax === '' ) {
1083
+                    if ($line_item_tax === '') {
1084 1084
                         $line_item_tax = 0; // Zero tax
1085 1085
                     }
1086 1086
 
1087
-                    $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols );
1087
+                    $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols);
1088 1088
 
1089
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1090
-                        $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1091
-                        if ( $summary !== '' ) {
1092
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1089
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1090
+                        $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1091
+                        if ($summary !== '') {
1092
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1093 1093
                         }
1094 1094
                         $line_item .= '</td>';
1095 1095
 
1096
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1096
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1097 1097
                         if ($quantities_enabled) {
1098 1098
                             $cols++;
1099 1099
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1102,55 +1102,55 @@  discard block
 block discarded – undo
1102 1102
                             $cols++;
1103 1103
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1104 1104
                         }
1105
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1105
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1106 1106
                     $line_item .= '</tr>';
1107 1107
 
1108
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1108
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1109 1109
 
1110 1110
                     $count++;
1111 1111
                 }
1112 1112
 
1113
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1113
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1114 1114
                 ?>
1115 1115
                 <tr class="row-sub-total row_odd">
1116
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1117
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1116
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1117
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1118 1118
                 </tr>
1119 1119
                 <?php
1120
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1120
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1121 1121
                 
1122
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1123
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1122
+                if (wpinv_discount($invoice_id, false) > 0) {
1123
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1124 1124
                     ?>
1125 1125
                         <tr class="row-discount">
1126
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1127
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1126
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1127
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1128 1128
                         </tr>
1129 1129
                     <?php
1130
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1130
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1131 1131
                 }
1132 1132
 
1133
-                if ( $use_taxes ) {
1134
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1133
+                if ($use_taxes) {
1134
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1135 1135
                     ?>
1136 1136
                     <tr class="row-tax">
1137
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1138
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1137
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1138
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1139 1139
                     </tr>
1140 1140
                     <?php
1141
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1141
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1142 1142
                 }
1143 1143
 
1144
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1144
+                do_action('wpinv_display_before_total', $invoice, $cols);
1145 1145
                 ?>
1146 1146
                 <tr class="table-active row-total">
1147
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1148
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1147
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1148
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1149 1149
                 </tr>
1150 1150
                 <?php
1151
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1151
+                do_action('wpinv_display_after_total', $invoice, $cols);
1152 1152
 
1153
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1153
+                do_action('wpinv_display_line_end', $invoice, $cols);
1154 1154
             }
1155 1155
         ?>
1156 1156
         </tbody>
@@ -1162,56 +1162,56 @@  discard block
 block discarded – undo
1162 1162
 /**
1163 1163
  * @param WPInv_Invoice $invoice
1164 1164
  */
1165
-function wpinv_display_invoice_notes( $invoice ) {
1165
+function wpinv_display_invoice_notes($invoice) {
1166 1166
 
1167
-    $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' );
1167
+    $notes = wpinv_get_invoice_notes($invoice->ID, 'customer');
1168 1168
 
1169
-    if ( empty( $notes ) ) {
1169
+    if (empty($notes)) {
1170 1170
         return;
1171 1171
     }
1172 1172
 
1173 1173
     echo '<div class="wpi_invoice_notes_container">';
1174
-    echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>';
1174
+    echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>';
1175 1175
     echo '<ul class="wpi_invoice_notes">';
1176 1176
 
1177
-    foreach( $notes as $note ) {
1178
-        wpinv_get_invoice_note_line_item( $note );
1177
+    foreach ($notes as $note) {
1178
+        wpinv_get_invoice_note_line_item($note);
1179 1179
     }
1180 1180
 
1181 1181
     echo '</ul>';
1182 1182
     echo '</div>';
1183 1183
 }
1184
-add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' );
1184
+add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes');
1185 1185
 
1186
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {
1186
+function wpinv_display_invoice_totals($invoice_id = 0) {
1187 1187
     $use_taxes = wpinv_use_taxes();
1188 1188
 
1189
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1189
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1190 1190
     ?>
1191 1191
     <table class="table table-sm table-bordered table-responsive">
1192 1192
         <tbody>
1193
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1193
+            <?php do_action('wpinv_before_display_totals'); ?>
1194 1194
             <tr class="row-sub-total">
1195
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1196
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1195
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1196
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1197 1197
             </tr>
1198
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1199
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1198
+            <?php do_action('wpinv_after_display_totals'); ?>
1199
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1200 1200
                 <tr class="row-discount">
1201
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1202
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1201
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1202
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1203 1203
                 </tr>
1204
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1204
+            <?php do_action('wpinv_after_display_discount'); ?>
1205 1205
             <?php } ?>
1206
-            <?php if ( $use_taxes ) { ?>
1206
+            <?php if ($use_taxes) { ?>
1207 1207
             <tr class="row-tax">
1208
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1209
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1208
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1209
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1210 1210
             </tr>
1211
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1211
+            <?php do_action('wpinv_after_display_tax'); ?>
1212 1212
             <?php } ?>
1213
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1214
-                <?php foreach ( $fees as $fee ) { ?>
1213
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1214
+                <?php foreach ($fees as $fee) { ?>
1215 1215
                     <tr class="row-fee">
1216 1216
                         <td class="rate"><?php echo $fee['label']; ?></td>
1217 1217
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1219,82 +1219,82 @@  discard block
 block discarded – undo
1219 1219
                 <?php } ?>
1220 1220
             <?php } ?>
1221 1221
             <tr class="table-active row-total">
1222
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1223
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1222
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1223
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1224 1224
             </tr>
1225
-            <?php do_action( 'wpinv_after_totals' ); ?>
1225
+            <?php do_action('wpinv_after_totals'); ?>
1226 1226
         </tbody>
1227 1227
 
1228 1228
     </table>
1229 1229
 
1230
-    <?php do_action( 'wpinv_after_totals_table' );
1230
+    <?php do_action('wpinv_after_totals_table');
1231 1231
 }
1232 1232
 
1233
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1234
-    $invoice = wpinv_get_invoice( $invoice_id );
1233
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1234
+    $invoice = wpinv_get_invoice($invoice_id);
1235 1235
 
1236 1236
     ob_start();
1237
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1238
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1237
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1238
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1239 1239
         ?>
1240 1240
         <div class="wpi-payment-info">
1241
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1242
-            <?php if ( $gateway_title ) { ?>
1243
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1241
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1242
+            <?php if ($gateway_title) { ?>
1243
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1244 1244
             <?php } ?>
1245 1245
         </div>
1246 1246
         <?php
1247 1247
     }
1248
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1248
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1249 1249
     $outout = ob_get_clean();
1250 1250
 
1251
-    if ( $echo ) {
1251
+    if ($echo) {
1252 1252
         echo $outout;
1253 1253
     } else {
1254 1254
         return $outout;
1255 1255
     }
1256 1256
 }
1257 1257
 
1258
-function wpinv_display_style( $invoice ) {
1259
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1258
+function wpinv_display_style($invoice) {
1259
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1260 1260
 
1261
-    wp_print_styles( 'open-sans' );
1262
-    wp_print_styles( 'wpinv-single-style' );
1261
+    wp_print_styles('open-sans');
1262
+    wp_print_styles('wpinv-single-style');
1263 1263
 
1264 1264
     $custom_css = wpinv_get_option('template_custom_css');
1265
-    if(isset($custom_css) && !empty($custom_css)){
1266
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1267
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1265
+    if (isset($custom_css) && !empty($custom_css)) {
1266
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1267
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1268 1268
         echo '<style type="text/css">';
1269 1269
         echo $custom_css;
1270 1270
         echo '</style>';
1271 1271
     }
1272 1272
 }
1273
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1274
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1273
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1274
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1275 1275
 
1276 1276
 function wpinv_checkout_billing_details() {
1277
-    $invoice_id = (int)wpinv_get_invoice_cart_id();
1277
+    $invoice_id = (int) wpinv_get_invoice_cart_id();
1278 1278
     if (empty($invoice_id)) {
1279
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1279
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1280 1280
         return null;
1281 1281
     }
1282 1282
 
1283
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1283
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1284 1284
     if (empty($invoice)) {
1285
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1285
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1286 1286
         return null;
1287 1287
     }
1288 1288
     $user_id        = $invoice->get_user_id();
1289 1289
     $user_info      = $invoice->get_user_info();
1290
-    $address_info   = wpinv_get_user_address( $user_id );
1290
+    $address_info   = wpinv_get_user_address($user_id);
1291 1291
 
1292
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1292
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1293 1293
         $user_info['first_name'] = $user_info['first_name'];
1294 1294
         $user_info['last_name'] = $user_info['last_name'];
1295 1295
     }
1296 1296
 
1297
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1297
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1298 1298
         $user_info['country']   = $address_info['country'];
1299 1299
         $user_info['state']     = $address_info['state'];
1300 1300
         $user_info['city']      = $address_info['city'];
@@ -1310,99 +1310,99 @@  discard block
 block discarded – undo
1310 1310
         'address'
1311 1311
     );
1312 1312
 
1313
-    foreach ( $address_fields as $field ) {
1314
-        if ( empty( $user_info[$field] ) ) {
1313
+    foreach ($address_fields as $field) {
1314
+        if (empty($user_info[$field])) {
1315 1315
             $user_info[$field] = $address_info[$field];
1316 1316
         }
1317 1317
     }
1318 1318
 
1319
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1319
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1320 1320
 }
1321 1321
 
1322 1322
 function wpinv_admin_get_line_items($invoice = array()) {
1323 1323
     $item_quantities    = wpinv_item_quantities_enabled();
1324 1324
     $use_taxes          = wpinv_use_taxes();
1325 1325
 
1326
-    if ( empty( $invoice ) ) {
1326
+    if (empty($invoice)) {
1327 1327
         return NULL;
1328 1328
     }
1329 1329
 
1330 1330
     $cart_items = $invoice->get_cart_details();
1331
-    if ( empty( $cart_items ) ) {
1331
+    if (empty($cart_items)) {
1332 1332
         return NULL;
1333 1333
     }
1334 1334
 
1335 1335
     ob_start();
1336 1336
 
1337
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1337
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1338 1338
 
1339 1339
     $count = 0;
1340
-    foreach ( $cart_items as $key => $cart_item ) {
1340
+    foreach ($cart_items as $key => $cart_item) {
1341 1341
         $item_id    = $cart_item['id'];
1342
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1342
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1343 1343
 
1344 1344
         if (empty($wpi_item)) {
1345 1345
             continue;
1346 1346
         }
1347 1347
 
1348
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1349
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1350
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1348
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1349
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1350
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1351 1351
         $can_remove     = true;
1352 1352
 
1353
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1353
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1354 1354
 
1355 1355
         $item_tax       = '';
1356 1356
         $tax_rate       = '';
1357
-        if ( $invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1358
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1359
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1360
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1357
+        if ($invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1358
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1359
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1360
+            $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1361 1361
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1362 1362
         }
1363 1363
         $line_item_tax = $item_tax . $tax_rate;
1364 1364
 
1365
-        if ( $line_item_tax === '' ) {
1365
+        if ($line_item_tax === '') {
1366 1366
             $line_item_tax = 0; // Zero tax
1367 1367
         }
1368 1368
 
1369
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1369
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1370 1370
             $line_item .= '<td class="id">' . $item_id . '</td>';
1371
-            $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item );
1372
-            if ( $summary !== '' ) {
1373
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1371
+            $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item);
1372
+            if ($summary !== '') {
1373
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1374 1374
             }
1375 1375
             $line_item .= '</td>';
1376 1376
             $line_item .= '<td class="price">' . $item_price . '</td>';
1377 1377
             
1378
-            if ( $item_quantities ) {
1379
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1378
+            if ($item_quantities) {
1379
+                if (count($cart_items) == 1 && $quantity <= 1) {
1380 1380
                     $can_remove = false;
1381 1381
                 }
1382 1382
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1383 1383
             } else {
1384
-                if ( count( $cart_items ) == 1 ) {
1384
+                if (count($cart_items) == 1) {
1385 1385
                     $can_remove = false;
1386 1386
                 }
1387 1387
             }
1388 1388
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1389 1389
             
1390
-            if ( $use_taxes ) {
1390
+            if ($use_taxes) {
1391 1391
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1392 1392
             }
1393 1393
             $line_item .= '<td class="action">';
1394
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
1394
+            if (!$invoice->is_paid() && !$invoice->is_refunded()) {
1395 1395
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1396 1396
             }
1397 1397
             $line_item .= '</td>';
1398 1398
         $line_item .= '</tr>';
1399 1399
 
1400
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1400
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1401 1401
 
1402 1402
         $count++;
1403 1403
     } 
1404 1404
 
1405
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1405
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1406 1406
 
1407 1407
     return ob_get_clean();
1408 1408
 }
@@ -1412,70 +1412,70 @@  discard block
 block discarded – undo
1412 1412
 
1413 1413
     // Set current invoice id.
1414 1414
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1415
-    $form_action     = esc_url( wpinv_get_checkout_uri() );
1415
+    $form_action     = esc_url(wpinv_get_checkout_uri());
1416 1416
     $payment_form    = wpinv_get_default_payment_form();
1417 1417
 
1418 1418
     ob_start();
1419
-	    do_action( 'wpinv_checkout_content_before' );
1419
+	    do_action('wpinv_checkout_content_before');
1420 1420
 
1421
-        if ( wpinv_get_cart_contents() ) {
1421
+        if (wpinv_get_cart_contents()) {
1422 1422
 
1423 1423
             // Get the form elements and items.
1424
-	        $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1425
-	        $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1424
+	        $elements = $invoicing->form_elements->get_form_elements($payment_form);
1425
+	        $items    = $invoicing->form_elements->convert_checkout_items(wpinv_get_cart_contents(), wpinv_get_invoice_cart());
1426 1426
             ?>
1427 1427
             <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST">
1428
-                <?php do_action( 'wpinv_main_checkout_form_top' ); ?>
1429
-                <input type='hidden' name='form_id' value='<?php echo esc_attr( $payment_form ); ?>'/>
1430
-                <input type='hidden' name='invoice_id' value='<?php echo esc_attr( $wpi_checkout_id ); ?>'/>
1428
+                <?php do_action('wpinv_main_checkout_form_top'); ?>
1429
+                <input type='hidden' name='form_id' value='<?php echo esc_attr($payment_form); ?>'/>
1430
+                <input type='hidden' name='invoice_id' value='<?php echo esc_attr($wpi_checkout_id); ?>'/>
1431 1431
                     <?php
1432
-                        wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1433
-                        wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1432
+                        wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1433
+                        wp_nonce_field('vat_validation', '_wpi_nonce');
1434 1434
 
1435
-                        foreach ( $elements as $element ) {
1436
-                            do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $payment_form );
1437
-                            do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form );
1435
+                        foreach ($elements as $element) {
1436
+                            do_action('wpinv_frontend_render_payment_form_element', $element, $items, $payment_form);
1437
+                            do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form);
1438 1438
                         }
1439 1439
                     ?>
1440 1440
                 <div class='wpinv_payment_form_errors alert alert-danger d-none'></div>
1441
-                <?php do_action( 'wpinv_main_checkout_form_bottom' ); ?>
1441
+                <?php do_action('wpinv_main_checkout_form_bottom'); ?>
1442 1442
             </form>
1443 1443
         <?php
1444 1444
 
1445 1445
         } else {
1446
-            do_action( 'wpinv_cart_empty' );
1446
+            do_action('wpinv_cart_empty');
1447 1447
         }
1448 1448
         echo '</div><!--end #wpinv_checkout_wrap-->';
1449
-	    do_action( 'wpinv_checkout_content_after' );
1449
+	    do_action('wpinv_checkout_content_after');
1450 1450
         $content = ob_get_clean();
1451 1451
 
1452
-		return str_replace( 'sr-only', '', $content );
1452
+		return str_replace('sr-only', '', $content);
1453 1453
 }
1454 1454
 
1455
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1455
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1456 1456
     global $ajax_cart_details;
1457 1457
     $ajax_cart_details = $cart_details;
1458 1458
 
1459 1459
     ob_start();
1460
-    do_action( 'wpinv_before_checkout_cart' );
1460
+    do_action('wpinv_before_checkout_cart');
1461 1461
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1462 1462
         echo '<div id="wpinv_checkout_cart_wrap">';
1463
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1463
+            wpinv_get_template_part('wpinv-checkout-cart');
1464 1464
         echo '</div>';
1465 1465
     echo '</div>';
1466
-    do_action( 'wpinv_after_checkout_cart' );
1466
+    do_action('wpinv_after_checkout_cart');
1467 1467
     $content = ob_get_clean();
1468 1468
 
1469
-    if ( $echo ) {
1469
+    if ($echo) {
1470 1470
         echo $content;
1471 1471
     } else {
1472 1472
         return $content;
1473 1473
     }
1474 1474
 }
1475
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1475
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1476 1476
 
1477 1477
 function wpinv_empty_cart_message() {
1478
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1478
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1479 1479
 }
1480 1480
 
1481 1481
 /**
@@ -1492,83 +1492,83 @@  discard block
 block discarded – undo
1492 1492
         )
1493 1493
     );
1494 1494
 }
1495
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1495
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1496 1496
 
1497 1497
 function wpinv_update_cart_button() {
1498
-    if ( !wpinv_item_quantities_enabled() )
1498
+    if (!wpinv_item_quantities_enabled())
1499 1499
         return;
1500 1500
 ?>
1501
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1501
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1502 1502
     <input type="hidden" name="wpi_action" value="update_cart"/>
1503 1503
 <?php
1504 1504
 }
1505 1505
 
1506 1506
 function wpinv_checkout_cart_columns() {
1507 1507
     $default = 3;
1508
-    if ( wpinv_item_quantities_enabled() ) {
1508
+    if (wpinv_item_quantities_enabled()) {
1509 1509
         $default++;
1510 1510
     }
1511 1511
     
1512
-    if ( wpinv_use_taxes() ) {
1512
+    if (wpinv_use_taxes()) {
1513 1513
         $default++;
1514 1514
     }
1515 1515
 
1516
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1516
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1517 1517
 }
1518 1518
 
1519 1519
 function wpinv_display_cart_messages() {
1520 1520
     global $wpi_session;
1521 1521
 
1522
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1522
+    $messages = $wpi_session->get('wpinv_cart_messages');
1523 1523
 
1524
-    if ( $messages ) {
1525
-        foreach ( $messages as $message_id => $message ) {
1524
+    if ($messages) {
1525
+        foreach ($messages as $message_id => $message) {
1526 1526
             // Try and detect what type of message this is
1527
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1527
+            if (strpos(strtolower($message), 'error')) {
1528 1528
                 $type = 'error';
1529
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1529
+            } elseif (strpos(strtolower($message), 'success')) {
1530 1530
                 $type = 'success';
1531 1531
             } else {
1532 1532
                 $type = 'info';
1533 1533
             }
1534 1534
 
1535
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1535
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1536 1536
 
1537
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1537
+            echo '<div class="' . implode(' ', $classes) . '">';
1538 1538
                 // Loop message codes and display messages
1539 1539
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1540 1540
             echo '</div>';
1541 1541
         }
1542 1542
 
1543 1543
         // Remove all of the cart saving messages
1544
-        $wpi_session->set( 'wpinv_cart_messages', null );
1544
+        $wpi_session->set('wpinv_cart_messages', null);
1545 1545
     }
1546 1546
 }
1547
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1547
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1548 1548
 
1549 1549
 function wpinv_discount_field() {
1550
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1550
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1551 1551
         return; // Only show before a payment method has been selected if ajax is disabled
1552 1552
     }
1553 1553
 
1554
-    if ( !wpinv_is_checkout() ) {
1554
+    if (!wpinv_is_checkout()) {
1555 1555
         return;
1556 1556
     }
1557 1557
 
1558
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1558
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1559 1559
     ?>
1560 1560
     <div id="wpinv-discount-field" class="panel panel-default">
1561 1561
         <div class="panel-body">
1562 1562
             <p>
1563
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1564
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1563
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1564
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1565 1565
             </p>
1566 1566
             <div class="form-group row">
1567 1567
                 <div class="col-sm-4">
1568
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1568
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1569 1569
                 </div>
1570 1570
                 <div class="col-sm-3">
1571
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1571
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1572 1572
                 </div>
1573 1573
                 <div style="clear:both"></div>
1574 1574
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1581,10 +1581,10 @@  discard block
 block discarded – undo
1581 1581
 <?php
1582 1582
     }
1583 1583
 }
1584
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1584
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1585 1585
 
1586 1586
 function wpinv_agree_to_terms_js() {
1587
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1587
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1588 1588
 ?>
1589 1589
 <script type="text/javascript">
1590 1590
     jQuery(document).ready(function($){
@@ -1599,127 +1599,127 @@  discard block
 block discarded – undo
1599 1599
 <?php
1600 1600
     }
1601 1601
 }
1602
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1602
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1603 1603
 
1604 1604
 function wpinv_payment_mode_select() {
1605
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1606
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1607
-    $invoice = wpinv_get_invoice( 0, true );
1605
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1606
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1607
+    $invoice = wpinv_get_invoice(0, true);
1608 1608
 
1609 1609
     do_action('wpinv_payment_mode_top');
1610
-    $invoice_id = $invoice ? (int)$invoice->ID : 0;
1611
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1610
+    $invoice_id = $invoice ? (int) $invoice->ID : 0;
1611
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1612 1612
     ?>
1613
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( ( $invoice && $invoice->is_free() ) ? 'style="display:none;" data-free="1"' : '' ); ?>>
1614
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1613
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo (($invoice && $invoice->is_free()) ? 'style="display:none;" data-free="1"' : ''); ?>>
1614
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1615 1615
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1616 1616
                 <div class="panel-heading wpi-payment_methods_title">
1617
-                    <h3 class="panel-title"><?php _e( 'Pay Via', 'invoicing' ); ?></h3>
1617
+                    <h3 class="panel-title"><?php _e('Pay Via', 'invoicing'); ?></h3>
1618 1618
                 </div>
1619 1619
                 <div class="panel-body wpi-payment_methods">
1620 1620
                     <?php
1621
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1622
-
1623
-                    if ( !empty( $gateways ) ) {
1624
-                        foreach ( $gateways as $gateway_id => $gateway ) {
1625
-                            $checked       = checked( $gateway_id, $chosen_gateway, false );
1626
-                            $button_label  = wpinv_get_gateway_button_label( $gateway_id );
1627
-                            $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id );
1628
-                            $description   = wpinv_get_gateway_description( $gateway_id );
1621
+                    do_action('wpinv_payment_mode_before_gateways');
1622
+
1623
+                    if (!empty($gateways)) {
1624
+                        foreach ($gateways as $gateway_id => $gateway) {
1625
+                            $checked       = checked($gateway_id, $chosen_gateway, false);
1626
+                            $button_label  = wpinv_get_gateway_button_label($gateway_id);
1627
+                            $gateway_label = wpinv_get_gateway_checkout_label($gateway_id);
1628
+                            $description   = wpinv_get_gateway_description($gateway_id);
1629 1629
                             ?>
1630 1630
                             <div class="pt-2 pb-2">
1631 1631
                                 <div class="radio">
1632
-                                    <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label>
1632
+                                    <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label>
1633 1633
                                 </div>
1634
-                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1635
-                                    <?php if ( !empty( $description ) ) { ?>
1636
-                                        <div class="wpi-gateway-desc"><?php _e( $description, 'invoicing' ); ?></div>
1634
+                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1635
+                                    <?php if (!empty($description)) { ?>
1636
+                                        <div class="wpi-gateway-desc"><?php _e($description, 'invoicing'); ?></div>
1637 1637
                                     <?php } ?>
1638
-                                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1638
+                                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1639 1639
                                 </div>
1640 1640
                             </div>
1641 1641
                             <?php
1642 1642
                         }
1643 1643
                     } else {
1644
-                        echo '<div class="alert alert-danger">'. __( 'No payment gateway active', 'invoicing' ) .'</div>';
1644
+                        echo '<div class="alert alert-danger">' . __('No payment gateway active', 'invoicing') . '</div>';
1645 1645
                     }
1646 1646
 
1647
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1647
+                    do_action('wpinv_payment_mode_after_gateways');
1648 1648
                     ?>
1649 1649
                 </div>
1650 1650
             </div>
1651
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1651
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1652 1652
     </div>
1653 1653
     <?php
1654 1654
     do_action('wpinv_payment_mode_bottom');
1655 1655
 }
1656
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1656
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1657 1657
 
1658 1658
 function wpinv_checkout_billing_info() {
1659
-    if ( wpinv_is_checkout() ) {
1659
+    if (wpinv_is_checkout()) {
1660 1660
         $billing_details    = wpinv_checkout_billing_details();
1661
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1661
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1662 1662
         ?>
1663 1663
         <div id="wpinv-fields" class="clearfix">
1664 1664
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1665
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1665
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1666 1666
                 <div id="wpinv-fields-box" class="panel-body">
1667
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1667
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1668 1668
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1669
-                        <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1669
+                        <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1670 1670
                         <?php
1671
-                        echo wpinv_html_text( array(
1671
+                        echo wpinv_html_text(array(
1672 1672
                                 'id'            => 'wpinv_first_name',
1673 1673
                                 'name'          => 'wpinv_first_name',
1674 1674
                                 'value'         => $billing_details['first_name'],
1675 1675
                                 'class'         => 'wpi-input form-control',
1676
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1677
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1678
-                            ) );
1676
+                                'placeholder'   => __('First name', 'invoicing'),
1677
+                                'required'      => (bool) wpinv_get_option('fname_mandatory'),
1678
+                            ));
1679 1679
                         ?>
1680 1680
                     </p>
1681 1681
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1682
-                        <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1682
+                        <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1683 1683
                         <?php
1684
-                        echo wpinv_html_text( array(
1684
+                        echo wpinv_html_text(array(
1685 1685
                                 'id'            => 'wpinv_last_name',
1686 1686
                                 'name'          => 'wpinv_last_name',
1687 1687
                                 'value'         => $billing_details['last_name'],
1688 1688
                                 'class'         => 'wpi-input form-control',
1689
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1690
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1691
-                            ) );
1689
+                                'placeholder'   => __('Last name', 'invoicing'),
1690
+                                'required'      => (bool) wpinv_get_option('lname_mandatory'),
1691
+                            ));
1692 1692
                         ?>
1693 1693
                     </p>
1694 1694
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1695
-                        <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1695
+                        <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1696 1696
                         <?php
1697
-                        echo wpinv_html_text( array(
1697
+                        echo wpinv_html_text(array(
1698 1698
                                 'id'            => 'wpinv_address',
1699 1699
                                 'name'          => 'wpinv_address',
1700 1700
                                 'value'         => $billing_details['address'],
1701 1701
                                 'class'         => 'wpi-input form-control',
1702
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1703
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1704
-                            ) );
1702
+                                'placeholder'   => __('Address', 'invoicing'),
1703
+                                'required'      => (bool) wpinv_get_option('address_mandatory'),
1704
+                            ));
1705 1705
                         ?>
1706 1706
                     </p>
1707 1707
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1708
-                        <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1708
+                        <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1709 1709
                         <?php
1710
-                        echo wpinv_html_text( array(
1710
+                        echo wpinv_html_text(array(
1711 1711
                                 'id'            => 'wpinv_city',
1712 1712
                                 'name'          => 'wpinv_city',
1713 1713
                                 'value'         => $billing_details['city'],
1714 1714
                                 'class'         => 'wpi-input form-control',
1715
-                                'placeholder'   => __( 'City', 'invoicing' ),
1716
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1717
-                            ) );
1715
+                                'placeholder'   => __('City', 'invoicing'),
1716
+                                'required'      => (bool) wpinv_get_option('city_mandatory'),
1717
+                            ));
1718 1718
                         ?>
1719 1719
                     </p>
1720 1720
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1721
-                        <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1722
-                        <?php echo wpinv_html_select( array(
1721
+                        <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1722
+                        <?php echo wpinv_html_select(array(
1723 1723
                             'options'          => wpinv_get_country_list(),
1724 1724
                             'name'             => 'wpinv_country',
1725 1725
                             'id'               => 'wpinv_country',
@@ -1727,16 +1727,16 @@  discard block
 block discarded – undo
1727 1727
                             'show_option_all'  => false,
1728 1728
                             'show_option_none' => false,
1729 1729
                             'class'            => 'wpi-input form-control wpi_select2',
1730
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1731
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1732
-                        ) ); ?>
1730
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1731
+                            'required'         => (bool) wpinv_get_option('country_mandatory'),
1732
+                        )); ?>
1733 1733
                     </p>
1734 1734
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1735
-                        <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1735
+                        <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1736 1736
                         <?php
1737
-                        $states = wpinv_get_country_states( $selected_country );
1738
-                        if( !empty( $states ) ) {
1739
-                            echo wpinv_html_select( array(
1737
+                        $states = wpinv_get_country_states($selected_country);
1738
+                        if (!empty($states)) {
1739
+                            echo wpinv_html_select(array(
1740 1740
                                 'options'          => $states,
1741 1741
                                 'name'             => 'wpinv_state',
1742 1742
                                 'id'               => 'wpinv_state',
@@ -1744,61 +1744,61 @@  discard block
 block discarded – undo
1744 1744
                                 'show_option_all'  => false,
1745 1745
                                 'show_option_none' => false,
1746 1746
                                 'class'            => 'wpi-input form-control wpi_select2',
1747
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1748
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1749
-                            ) );
1747
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1748
+                                'required'         => (bool) wpinv_get_option('state_mandatory'),
1749
+                            ));
1750 1750
                         } else {
1751
-                            echo wpinv_html_text( array(
1751
+                            echo wpinv_html_text(array(
1752 1752
                                 'name'          => 'wpinv_state',
1753 1753
                                 'value'         => $billing_details['state'],
1754 1754
                                 'id'            => 'wpinv_state',
1755 1755
                                 'class'         => 'wpi-input form-control',
1756
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1757
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1758
-                            ) );
1756
+                                'placeholder'   => __('State / Province', 'invoicing'),
1757
+                                'required'      => (bool) wpinv_get_option('state_mandatory'),
1758
+                            ));
1759 1759
                         }
1760 1760
                         ?>
1761 1761
                     </p>
1762 1762
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1763
-                        <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1763
+                        <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1764 1764
                         <?php
1765
-                        echo wpinv_html_text( array(
1765
+                        echo wpinv_html_text(array(
1766 1766
                                 'name'          => 'wpinv_zip',
1767 1767
                                 'value'         => $billing_details['zip'],
1768 1768
                                 'id'            => 'wpinv_zip',
1769 1769
                                 'class'         => 'wpi-input form-control',
1770
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1771
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1772
-                            ) );
1770
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1771
+                                'required'      => (bool) wpinv_get_option('zip_mandatory'),
1772
+                            ));
1773 1773
                         ?>
1774 1774
                     </p>
1775 1775
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1776
-                        <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1776
+                        <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1777 1777
                         <?php
1778
-                        echo wpinv_html_text( array(
1778
+                        echo wpinv_html_text(array(
1779 1779
                                 'id'            => 'wpinv_phone',
1780 1780
                                 'name'          => 'wpinv_phone',
1781 1781
                                 'value'         => $billing_details['phone'],
1782 1782
                                 'class'         => 'wpi-input form-control',
1783
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1784
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1785
-                            ) );
1783
+                                'placeholder'   => __('Phone', 'invoicing'),
1784
+                                'required'      => (bool) wpinv_get_option('phone_mandatory'),
1785
+                            ));
1786 1786
                         ?>
1787 1787
                     </p>
1788
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1788
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1789 1789
                     <div class="clearfix"></div>
1790 1790
                 </div>
1791 1791
             </div>
1792
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1792
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1793 1793
         </div>
1794 1794
         <?php
1795 1795
     }
1796 1796
 }
1797
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1797
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1798 1798
 
1799 1799
 function wpinv_checkout_hidden_fields() {
1800 1800
 ?>
1801
-    <?php if ( is_user_logged_in() ) { ?>
1801
+    <?php if (is_user_logged_in()) { ?>
1802 1802
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1803 1803
     <?php } ?>
1804 1804
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1808,9 +1808,9 @@  discard block
 block discarded – undo
1808 1808
 function wpinv_checkout_button_purchase() {
1809 1809
     ob_start();
1810 1810
 ?>
1811
-    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/>
1811
+    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/>
1812 1812
 <?php
1813
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1813
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1814 1814
 }
1815 1815
 
1816 1816
 function wpinv_checkout_total() {
@@ -1819,64 +1819,64 @@  discard block
 block discarded – undo
1819 1819
 <div id="wpinv_checkout_total" class="panel panel-info">
1820 1820
     <div class="panel-body">
1821 1821
     <?php
1822
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1822
+    do_action('wpinv_purchase_form_before_checkout_total');
1823 1823
     ?>
1824
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1824
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1825 1825
     <?php
1826
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1826
+    do_action('wpinv_purchase_form_after_checkout_total');
1827 1827
     ?>
1828 1828
     </div>
1829 1829
 </div>
1830 1830
 <?php
1831 1831
 }
1832
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1832
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1833 1833
 
1834 1834
 function wpinv_checkout_submit() {
1835 1835
 ?>
1836 1836
 <div id="wpinv_purchase_submit" class="panel panel-success">
1837 1837
     <div class="panel-body text-center">
1838 1838
     <?php
1839
-    do_action( 'wpinv_purchase_form_before_submit' );
1839
+    do_action('wpinv_purchase_form_before_submit');
1840 1840
     wpinv_checkout_hidden_fields();
1841 1841
     echo wpinv_checkout_button_purchase();
1842
-    do_action( 'wpinv_purchase_form_after_submit' );
1842
+    do_action('wpinv_purchase_form_after_submit');
1843 1843
     ?>
1844 1844
     </div>
1845 1845
 </div>
1846 1846
 <?php
1847 1847
 }
1848
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1848
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1849 1849
 
1850
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1851
-    $invoice = wpinv_get_invoice( $invoice_id );
1850
+function wpinv_receipt_billing_address($invoice_id = 0) {
1851
+    $invoice = wpinv_get_invoice($invoice_id);
1852 1852
 
1853
-    if ( empty( $invoice ) ) {
1853
+    if (empty($invoice)) {
1854 1854
         return NULL;
1855 1855
     }
1856 1856
 
1857 1857
     $billing_details = $invoice->get_user_info();
1858
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1858
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1859 1859
 
1860 1860
     ob_start();
1861 1861
     ?>
1862 1862
     <table class="table table-bordered table-sm wpi-billing-details">
1863 1863
         <tbody>
1864 1864
             <tr class="wpi-receipt-name">
1865
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1866
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1865
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1866
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1867 1867
             </tr>
1868 1868
             <tr class="wpi-receipt-email">
1869
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1870
-                <td><?php echo $billing_details['email'] ;?></td>
1869
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1870
+                <td><?php echo $billing_details['email']; ?></td>
1871 1871
             </tr>
1872 1872
             <tr class="wpi-receipt-address">
1873
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1874
-                <td><?php echo $address_row ;?></td>
1873
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1874
+                <td><?php echo $address_row; ?></td>
1875 1875
             </tr>
1876
-            <?php if ( $billing_details['phone'] ) { ?>
1876
+            <?php if ($billing_details['phone']) { ?>
1877 1877
             <tr class="wpi-receipt-phone">
1878
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1879
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1878
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1879
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1880 1880
             </tr>
1881 1881
             <?php } ?>
1882 1882
         </tbody>
@@ -1884,74 +1884,74 @@  discard block
 block discarded – undo
1884 1884
     <?php
1885 1885
     $output = ob_get_clean();
1886 1886
     
1887
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1887
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1888 1888
 
1889 1889
     echo $output;
1890 1890
 }
1891 1891
 
1892
-function wpinv_filter_success_page_content( $content ) {
1893
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1894
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1895
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1892
+function wpinv_filter_success_page_content($content) {
1893
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1894
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1895
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1896 1896
         }
1897 1897
     }
1898 1898
 
1899 1899
     return $content;
1900 1900
 }
1901
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1901
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1902 1902
 
1903
-function wpinv_receipt_actions( $invoice ) {
1904
-    if ( !empty( $invoice ) ) {
1903
+function wpinv_receipt_actions($invoice) {
1904
+    if (!empty($invoice)) {
1905 1905
         $actions = array();
1906 1906
 
1907
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1908
-            $actions['print']   = array(
1909
-                'url'  => $invoice->get_view_url( true ),
1910
-                'name' => __( 'Print Invoice', 'invoicing' ),
1907
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1908
+            $actions['print'] = array(
1909
+                'url'  => $invoice->get_view_url(true),
1910
+                'name' => __('Print Invoice', 'invoicing'),
1911 1911
                 'class' => 'btn-primary',
1912 1912
             );
1913 1913
         }
1914 1914
 
1915
-        if ( is_user_logged_in() ) {
1915
+        if (is_user_logged_in()) {
1916 1916
             $actions['history'] = array(
1917 1917
                 'url'  => wpinv_get_history_page_uri(),
1918
-                'name' => __( 'Invoice History', 'invoicing' ),
1918
+                'name' => __('Invoice History', 'invoicing'),
1919 1919
                 'class' => 'btn-warning',
1920 1920
             );
1921 1921
         }
1922 1922
 
1923
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1923
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1924 1924
 
1925
-        if ( !empty( $actions ) ) {
1925
+        if (!empty($actions)) {
1926 1926
         ?>
1927 1927
         <div class="wpinv-receipt-actions text-right">
1928
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1929
-            <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a>
1928
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1929
+            <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a>
1930 1930
             <?php } ?>
1931 1931
         </div>
1932 1932
         <?php
1933 1933
         }
1934 1934
     }
1935 1935
 }
1936
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1936
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1937 1937
 
1938
-function wpinv_invoice_link( $invoice_id ) {
1939
-    $invoice = wpinv_get_invoice( $invoice_id );
1938
+function wpinv_invoice_link($invoice_id) {
1939
+    $invoice = wpinv_get_invoice($invoice_id);
1940 1940
 
1941
-    if ( empty( $invoice ) ) {
1941
+    if (empty($invoice)) {
1942 1942
         return NULL;
1943 1943
     }
1944 1944
 
1945
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1945
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1946 1946
 
1947
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1947
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1948 1948
 }
1949 1949
 
1950
-function wpinv_invoice_subscription_details( $invoice ) {
1951
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1952
-        $subscription = wpinv_get_subscription( $invoice, true );
1950
+function wpinv_invoice_subscription_details($invoice) {
1951
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1952
+        $subscription = wpinv_get_subscription($invoice, true);
1953 1953
 
1954
-        if ( empty( $subscription ) ) {
1954
+        if (empty($subscription)) {
1955 1955
             return;
1956 1956
         }
1957 1957
 
@@ -1962,15 +1962,15 @@  discard block
 block discarded – undo
1962 1962
         $payments = $subscription->get_child_payments();
1963 1963
         ?>
1964 1964
         <div class="wpinv-subscriptions-details">
1965
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1965
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1966 1966
             <table class="table">
1967 1967
                 <thead>
1968 1968
                     <tr>
1969
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1970
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1971
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1972
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1973
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1969
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1970
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1971
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1972
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1973
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1974 1974
                     </tr>
1975 1975
                 </thead>
1976 1976
                 <tbody>
@@ -1984,29 +1984,29 @@  discard block
 block discarded – undo
1984 1984
                 </tbody>
1985 1985
             </table>
1986 1986
         </div>
1987
-        <?php if ( !empty( $payments ) ) { ?>
1987
+        <?php if (!empty($payments)) { ?>
1988 1988
         <div class="wpinv-renewal-payments">
1989
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1989
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1990 1990
             <table class="table">
1991 1991
                 <thead>
1992 1992
                     <tr>
1993 1993
                         <th>#</th>
1994
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1995
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1996
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1994
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1995
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1996
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1997 1997
                     </tr>
1998 1998
                 </thead>
1999 1999
                 <tbody>
2000 2000
                     <?php
2001 2001
                         $i = 1;
2002
-                        foreach ( $payments as $payment ) {
2002
+                        foreach ($payments as $payment) {
2003 2003
                             $invoice_id = $payment->ID;
2004 2004
                     ?>
2005 2005
                     <tr>
2006
-                        <th scope="row"><?php echo $i;?></th>
2007
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
2008
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
2009
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
2006
+                        <th scope="row"><?php echo $i; ?></th>
2007
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
2008
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
2009
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
2010 2010
                     </tr>
2011 2011
                     <?php $i++; } ?>
2012 2012
                 </tbody>
@@ -2017,52 +2017,52 @@  discard block
 block discarded – undo
2017 2017
     }
2018 2018
 }
2019 2019
 
2020
-function wpinv_cart_total_label( $label, $invoice ) {
2021
-    if ( empty( $invoice ) ) {
2020
+function wpinv_cart_total_label($label, $invoice) {
2021
+    if (empty($invoice)) {
2022 2022
         return $label;
2023 2023
     }
2024 2024
 
2025 2025
     $prefix_label = '';
2026
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
2027
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2028
-    } else if ( $invoice->is_renewal() ) {
2029
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
2026
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
2027
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2028
+    } else if ($invoice->is_renewal()) {
2029
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2030 2030
     }
2031 2031
 
2032
-    if ( $prefix_label != '' ) {
2033
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2032
+    if ($prefix_label != '') {
2033
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2034 2034
     }
2035 2035
 
2036 2036
     return $label;
2037 2037
 }
2038
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2039
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2040
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2038
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2039
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2040
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2041 2041
 
2042
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2042
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2043 2043
 
2044
-function wpinv_invoice_print_description( $invoice ) {
2045
-    if ( empty( $invoice ) ) {
2044
+function wpinv_invoice_print_description($invoice) {
2045
+    if (empty($invoice)) {
2046 2046
         return NULL;
2047 2047
     }
2048
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2048
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2049 2049
         ?>
2050 2050
         <div class="row wpinv-lower">
2051 2051
             <div class="col-sm-12 wpinv-description">
2052
-                <?php echo wpautop( $description ); ?>
2052
+                <?php echo wpautop($description); ?>
2053 2053
             </div>
2054 2054
         </div>
2055 2055
         <?php
2056 2056
     }
2057 2057
 }
2058
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2058
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2059 2059
 
2060
-function wpinv_invoice_print_payment_info( $invoice ) {
2061
-    if ( empty( $invoice ) ) {
2060
+function wpinv_invoice_print_payment_info($invoice) {
2061
+    if (empty($invoice)) {
2062 2062
         return NULL;
2063 2063
     }
2064 2064
 
2065
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2065
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2066 2066
         ?>
2067 2067
         <div class="row wpinv-payments">
2068 2068
             <div class="col-sm-12">
@@ -2074,43 +2074,43 @@  discard block
 block discarded – undo
2074 2074
 }
2075 2075
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2076 2076
 
2077
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2078
-    if ( empty( $note ) ) {
2077
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2078
+    if (empty($note)) {
2079 2079
         return NULL;
2080 2080
     }
2081 2081
 
2082
-    if ( is_int( $note ) ) {
2083
-        $note = get_comment( $note );
2082
+    if (is_int($note)) {
2083
+        $note = get_comment($note);
2084 2084
     }
2085 2085
 
2086
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2086
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2087 2087
         return NULL;
2088 2088
     }
2089 2089
 
2090
-    $note_classes   = array( 'note' );
2091
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2090
+    $note_classes   = array('note');
2091
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2092 2092
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
2093
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2094
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2093
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2094
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2095 2095
 
2096 2096
     ob_start();
2097 2097
     ?>
2098
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2098
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2099 2099
         <div class="note_content">
2100
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2100
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2101 2101
         </div>
2102 2102
         <p class="meta">
2103
-            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
2104
-            <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?>
2105
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2103
+            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
2104
+            <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?>
2105
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2106 2106
             <?php } ?>
2107 2107
         </p>
2108 2108
     </li>
2109 2109
     <?php
2110 2110
     $note_content = ob_get_clean();
2111
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2111
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2112 2112
 
2113
-    if ( $echo ) {
2113
+    if ($echo) {
2114 2114
         echo $note_content;
2115 2115
     } else {
2116 2116
         return $note_content;
@@ -2120,43 +2120,43 @@  discard block
 block discarded – undo
2120 2120
 function wpinv_invalid_invoice_content() {
2121 2121
     global $post;
2122 2122
 
2123
-    $invoice = wpinv_get_invoice( $post->ID );
2123
+    $invoice = wpinv_get_invoice($post->ID);
2124 2124
 
2125
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
2126
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2127
-        if ( is_user_logged_in() ) {
2128
-            if ( wpinv_require_login_to_checkout() ) {
2129
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2130
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2125
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
2126
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2127
+        if (is_user_logged_in()) {
2128
+            if (wpinv_require_login_to_checkout()) {
2129
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2130
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2131 2131
                 }
2132 2132
             }
2133 2133
         } else {
2134
-            if ( wpinv_require_login_to_checkout() ) {
2135
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2136
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2134
+            if (wpinv_require_login_to_checkout()) {
2135
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2136
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2137 2137
                 }
2138 2138
             }
2139 2139
         }
2140 2140
     } else {
2141
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2141
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2142 2142
     }
2143 2143
     ?>
2144 2144
     <div class="row wpinv-row-invalid">
2145 2145
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2146
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2146
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2147 2147
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2148 2148
         </div>
2149 2149
     </div>
2150 2150
     <?php
2151 2151
 }
2152
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2152
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2153 2153
 
2154
-add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2155
-function wpinv_force_company_name_field(){
2154
+add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2155
+function wpinv_force_company_name_field() {
2156 2156
     $invoice = wpinv_get_invoice_cart();
2157
-    $user_id = wpinv_get_user_id( $invoice->ID );
2158
-    $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
2159
-    if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) {
2157
+    $user_id = wpinv_get_user_id($invoice->ID);
2158
+    $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
2159
+    if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) {
2160 2160
         ?>
2161 2161
         <p class="wpi-cart-field wpi-col2 wpi-colf">
2162 2162
             <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
@@ -2182,21 +2182,21 @@  discard block
 block discarded – undo
2182 2182
  * @return string
2183 2183
  */
2184 2184
 function wpinv_get_policy_text() {
2185
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
2185
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
2186 2186
 
2187
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
2187
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
2188 2188
 
2189
-    if(!$privacy_page_id){
2190
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
2189
+    if (!$privacy_page_id) {
2190
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
2191 2191
     }
2192 2192
 
2193
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
2193
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
2194 2194
 
2195 2195
     $find_replace = array(
2196 2196
         '[wpinv_privacy_policy]' => $privacy_link,
2197 2197
     );
2198 2198
 
2199
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
2199
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
2200 2200
 
2201 2201
     return wp_kses_post(wpautop($privacy_text));
2202 2202
 }
@@ -2205,25 +2205,25 @@  discard block
 block discarded – undo
2205 2205
 /**
2206 2206
  * Allows the user to set their own price for an invoice item
2207 2207
  */
2208
-function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) {
2208
+function wpinv_checkout_cart_item_name_your_price($cart_item, $key) {
2209 2209
     
2210 2210
     //Ensure we have an item id
2211
-    if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) {
2211
+    if (!is_array($cart_item) || empty($cart_item['id'])) {
2212 2212
         return;
2213 2213
     }
2214 2214
 
2215 2215
     //Fetch the item
2216 2216
     $item_id = $cart_item['id'];
2217
-    $item    = new WPInv_Item( $item_id );
2217
+    $item    = new WPInv_Item($item_id);
2218 2218
     
2219
-    if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) {
2219
+    if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) {
2220 2220
         return;
2221 2221
     }
2222 2222
 
2223 2223
     //Fetch the dynamic pricing "strings"
2224
-    $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) );
2225
-    $minimum_price_text   = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) );
2226
-    $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) );
2224
+    $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing')));
2225
+    $minimum_price_text   = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing')));
2226
+    $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing')));
2227 2227
 
2228 2228
     //Display a "name_your_price" button
2229 2229
     echo " &mdash; <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>";
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
     echo '<div class="name-your-price-miniform">';
2233 2233
     
2234 2234
     //Maybe display the recommended price
2235
-    if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) {
2235
+    if ($item->get_price() > 0 && !empty($suggested_price_text)) {
2236 2236
         $suggested_price = $item->get_the_price();
2237 2237
         echo "<div>$suggested_price_text &mdash; $suggested_price</div>";
2238 2238
     }
@@ -2240,198 +2240,198 @@  discard block
 block discarded – undo
2240 2240
     //Display the update price form
2241 2241
     $symbol         = wpinv_currency_symbol();
2242 2242
     $position       = wpinv_currency_position();
2243
-    $minimum        = esc_attr( $item->get_minimum_price() );
2244
-    $price          = esc_attr( $cart_item['item_price'] );
2245
-    $update         = esc_attr__( "Update", 'invoicing' );
2243
+    $minimum        = esc_attr($item->get_minimum_price());
2244
+    $price          = esc_attr($cart_item['item_price']);
2245
+    $update         = esc_attr__("Update", 'invoicing');
2246 2246
 
2247 2247
     //Ensure it supports dynamic prici
2248
-    if( $price < $minimum ) {
2248
+    if ($price < $minimum) {
2249 2249
         $price = $minimum;
2250 2250
     }
2251 2251
 
2252 2252
     echo '<label>';
2253 2253
     echo $position != 'right' ? $symbol . '&nbsp;' : '';
2254 2254
     echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />";
2255
-    echo $position == 'right' ? '&nbsp;' . $symbol : '' ;
2255
+    echo $position == 'right' ? '&nbsp;' . $symbol : '';
2256 2256
     echo "</label>";
2257 2257
     echo "<input type='hidden' value='$item_id' class='wpi-field-item' />";
2258 2258
     echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>";
2259 2259
 
2260 2260
     //Maybe display the minimum price
2261
-    if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) {
2262
-        $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) );
2261
+    if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) {
2262
+        $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price()));
2263 2263
         echo "<div>$minimum_price_text &mdash; $minimum_price</div>";
2264 2264
     }
2265 2265
 
2266 2266
     echo "</div>";
2267 2267
 
2268 2268
 }
2269
-add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 );
2269
+add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2);
2270 2270
 
2271 2271
 function wpinv_oxygen_fix_conflict() {
2272 2272
     global $ct_ignore_post_types;
2273 2273
 
2274
-    if ( ! is_array( $ct_ignore_post_types ) ) {
2274
+    if (!is_array($ct_ignore_post_types)) {
2275 2275
         $ct_ignore_post_types = array();
2276 2276
     }
2277 2277
 
2278
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
2278
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
2279 2279
 
2280
-    foreach ( $post_types as $post_type ) {
2280
+    foreach ($post_types as $post_type) {
2281 2281
         $ct_ignore_post_types[] = $post_type;
2282 2282
 
2283 2283
         // Ignore post type
2284
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
2284
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
2285 2285
     }
2286 2286
 
2287
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
2288
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
2287
+    remove_filter('template_include', 'wpinv_template', 10, 1);
2288
+    add_filter('template_include', 'wpinv_template', 999, 1);
2289 2289
 }
2290 2290
 
2291 2291
 /**
2292 2292
  * Helper function to display a payment form on the frontend.
2293 2293
  */
2294
-function getpaid_display_payment_form( $form ) {
2294
+function getpaid_display_payment_form($form) {
2295 2295
     global $invoicing;
2296 2296
 
2297 2297
     // Ensure that it is published.
2298
-	if ( 'publish' != get_post_status( $form ) ) {
2298
+	if ('publish' != get_post_status($form)) {
2299 2299
 		return aui()->alert(
2300 2300
 			array(
2301 2301
 				'type'    => 'warning',
2302
-				'content' => __( 'This payment form is no longer active', 'invoicing' ),
2302
+				'content' => __('This payment form is no longer active', 'invoicing'),
2303 2303
 			)
2304 2304
 		);
2305 2305
 	}
2306 2306
 
2307 2307
     // Get the form.
2308
-    $form = new GetPaid_Payment_Form( $form );
2309
-    $html = wpinv_get_template_html( 'payment-forms/form.php', compact( 'form' ) );
2310
-    return str_replace( 'sr-only', '', $html );
2308
+    $form = new GetPaid_Payment_Form($form);
2309
+    $html = wpinv_get_template_html('payment-forms/form.php', compact('form'));
2310
+    return str_replace('sr-only', '', $html);
2311 2311
 
2312 2312
 }
2313 2313
 
2314 2314
 /**
2315 2315
  * Helper function to display a item payment form on the frontend.
2316 2316
  */
2317
-function getpaid_display_item_payment_form( $items ) {
2317
+function getpaid_display_item_payment_form($items) {
2318 2318
     global $invoicing;
2319 2319
 
2320
-    foreach ( array_keys( $items ) as $id ) {
2321
-	    if ( 'publish' != get_post_status( $id ) ) {
2322
-		    unset( $items[ $id ] );
2320
+    foreach (array_keys($items) as $id) {
2321
+	    if ('publish' != get_post_status($id)) {
2322
+		    unset($items[$id]);
2323 2323
 	    }
2324 2324
     }
2325 2325
 
2326
-    if ( empty( $items ) ) {
2326
+    if (empty($items)) {
2327 2327
 		return aui()->alert(
2328 2328
 			array(
2329 2329
 				'type'    => 'warning',
2330
-				'content' => __( 'No published items found', 'invoicing' ),
2330
+				'content' => __('No published items found', 'invoicing'),
2331 2331
 			)
2332 2332
 		);
2333 2333
     }
2334 2334
 
2335
-    $item_key = getpaid_convert_items_to_string( $items );
2335
+    $item_key = getpaid_convert_items_to_string($items);
2336 2336
 
2337 2337
     // Get the form elements and items.
2338 2338
     $form     = wpinv_get_default_payment_form();
2339
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2340
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
2339
+	$elements = $invoicing->form_elements->get_form_elements($form);
2340
+	$items    = $invoicing->form_elements->convert_normal_items($items);
2341 2341
 
2342 2342
 	ob_start();
2343 2343
 	echo "<form class='wpinv_payment_form'>";
2344
-	do_action( 'wpinv_payment_form_top' );
2344
+	do_action('wpinv_payment_form_top');
2345 2345
     echo "<input type='hidden' name='form_id' value='$form'/>";
2346 2346
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
2347
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2348
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2347
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
2348
+	wp_nonce_field('vat_validation', '_wpi_nonce');
2349 2349
 
2350
-	foreach ( $elements as $element ) {
2351
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2352
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2350
+	foreach ($elements as $element) {
2351
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
2352
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
2353 2353
 	}
2354 2354
 
2355 2355
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2356
-	do_action( 'wpinv_payment_form_bottom' );
2356
+	do_action('wpinv_payment_form_bottom');
2357 2357
 	echo '</form>';
2358 2358
 
2359 2359
 	$content = ob_get_clean();
2360
-	return str_replace( 'sr-only', '', $content );
2360
+	return str_replace('sr-only', '', $content);
2361 2361
 }
2362 2362
 
2363 2363
 /**
2364 2364
  * Helper function to display an invoice payment form on the frontend.
2365 2365
  */
2366
-function getpaid_display_invoice_payment_form( $invoice_id ) {
2366
+function getpaid_display_invoice_payment_form($invoice_id) {
2367 2367
     global $invoicing;
2368 2368
 
2369
-    $invoice = wpinv_get_invoice( $invoice_id );
2369
+    $invoice = wpinv_get_invoice($invoice_id);
2370 2370
 
2371
-    if ( empty( $invoice ) ) {
2371
+    if (empty($invoice)) {
2372 2372
 		return aui()->alert(
2373 2373
 			array(
2374 2374
 				'type'    => 'warning',
2375
-				'content' => __( 'Invoice not found', 'invoicing' ),
2375
+				'content' => __('Invoice not found', 'invoicing'),
2376 2376
 			)
2377 2377
 		);
2378 2378
     }
2379 2379
 
2380
-    if ( $invoice->is_paid() ) {
2380
+    if ($invoice->is_paid()) {
2381 2381
 		return aui()->alert(
2382 2382
 			array(
2383 2383
 				'type'    => 'warning',
2384
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
2384
+				'content' => __('Invoice has already been paid', 'invoicing'),
2385 2385
 			)
2386 2386
 		);
2387 2387
     }
2388 2388
 
2389 2389
     // Get the form elements and items.
2390
-    $form     = wpinv_get_default_payment_form();
2391
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2392
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
2390
+    $form = wpinv_get_default_payment_form();
2391
+	$elements = $invoicing->form_elements->get_form_elements($form);
2392
+	$items    = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
2393 2393
 
2394 2394
 	ob_start();
2395 2395
 	echo "<form class='wpinv_payment_form'>";
2396
-	do_action( 'wpinv_payment_form_top' );
2396
+	do_action('wpinv_payment_form_top');
2397 2397
     echo "<input type='hidden' name='form_id' value='$form'/>";
2398 2398
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
2399
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2400
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2399
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
2400
+	wp_nonce_field('vat_validation', '_wpi_nonce');
2401 2401
 
2402
-	foreach ( $elements as $element ) {
2403
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2404
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2402
+	foreach ($elements as $element) {
2403
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
2404
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
2405 2405
 	}
2406 2406
 
2407 2407
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2408
-	do_action( 'wpinv_payment_form_bottom' );
2408
+	do_action('wpinv_payment_form_bottom');
2409 2409
 	echo '</form>';
2410 2410
 
2411 2411
 	$content = ob_get_clean();
2412
-	return str_replace( 'sr-only', '', $content );
2412
+	return str_replace('sr-only', '', $content);
2413 2413
 }
2414 2414
 
2415 2415
 /**
2416 2416
  * Helper function to convert item string to array.
2417 2417
  */
2418
-function getpaid_convert_items_to_array( $items ) {
2419
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
2418
+function getpaid_convert_items_to_array($items) {
2419
+    $items    = array_filter(array_map('trim', explode(',', $items)));
2420 2420
     $prepared = array();
2421 2421
 
2422
-    foreach ( $items as $item ) {
2423
-        $data = array_map( 'trim', explode( '|', $item ) );
2422
+    foreach ($items as $item) {
2423
+        $data = array_map('trim', explode('|', $item));
2424 2424
 
2425
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
2425
+        if (empty($data[0]) || !is_numeric($data[0])) {
2426 2426
             continue;
2427 2427
         }
2428 2428
 
2429 2429
         $quantity = 1;
2430
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
2430
+        if (isset($data[1]) && is_numeric($data[1])) {
2431 2431
             $quantity = $data[1];
2432 2432
         }
2433 2433
 
2434
-        $prepared[ $data[0] ] = $quantity;
2434
+        $prepared[$data[0]] = $quantity;
2435 2435
 
2436 2436
     }
2437 2437
 
@@ -2441,13 +2441,13 @@  discard block
 block discarded – undo
2441 2441
 /**
2442 2442
  * Helper function to convert item array to string.
2443 2443
  */
2444
-function getpaid_convert_items_to_string( $items ) {
2444
+function getpaid_convert_items_to_string($items) {
2445 2445
     $prepared = array();
2446 2446
 
2447
-    foreach ( $items as $item => $quantity ) {
2447
+    foreach ($items as $item => $quantity) {
2448 2448
         $prepared[] = "$item|$quantity";
2449 2449
     }
2450
-    return implode( ',', $prepared );
2450
+    return implode(',', $prepared);
2451 2451
 }
2452 2452
 
2453 2453
 /**
@@ -2455,22 +2455,22 @@  discard block
 block discarded – undo
2455 2455
  * 
2456 2456
  * Provide a label and one of $form, $items or $invoice.
2457 2457
  */
2458
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
2459
-    $label = sanitize_text_field( $label );
2458
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
2459
+    $label = sanitize_text_field($label);
2460 2460
     $nonce = wp_create_nonce('getpaid_ajax_form');
2461 2461
 
2462
-    if ( ! empty( $form ) ) {
2463
-        $form  = esc_attr( $form );
2462
+    if (!empty($form)) {
2463
+        $form = esc_attr($form);
2464 2464
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
2465 2465
     }
2466 2466
 	
2467
-	if ( ! empty( $items ) ) {
2468
-        $items  = esc_attr( $items );
2467
+	if (!empty($items)) {
2468
+        $items = esc_attr($items);
2469 2469
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
2470 2470
     }
2471 2471
     
2472
-    if ( ! empty( $invoice ) ) {
2473
-        $invoice  = esc_attr( $invoice );
2472
+    if (!empty($invoice)) {
2473
+        $invoice = esc_attr($invoice);
2474 2474
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
2475 2475
     }
2476 2476
 
@@ -2481,15 +2481,15 @@  discard block
 block discarded – undo
2481 2481
  *
2482 2482
  * @param WPInv_Invoice $invoice
2483 2483
  */
2484
-function getpaid_the_invoice_description( $invoice ) {
2485
-    if ( empty( $invoice->description ) ) {
2484
+function getpaid_the_invoice_description($invoice) {
2485
+    if (empty($invoice->description)) {
2486 2486
         return;
2487 2487
     }
2488 2488
 
2489
-    $description = wp_kses_post( $invoice->description );
2489
+    $description = wp_kses_post($invoice->description);
2490 2490
     echo "<div style='color: #616161; font-size: 90%; margin-bottom: 20px;'><em>$description</em></div>";
2491 2491
 }
2492
-add_action( 'wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description' );
2492
+add_action('wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description');
2493 2493
 
2494 2494
 /**
2495 2495
  * Render element on a form.
@@ -2497,38 +2497,38 @@  discard block
 block discarded – undo
2497 2497
  * @param array $element
2498 2498
  * @param GetPaid_Payment_Form $form
2499 2499
  */
2500
-function getpaid_payment_form_element( $element, $form ) {
2500
+function getpaid_payment_form_element($element, $form) {
2501 2501
 
2502 2502
     // Set up the args.
2503
-    $element_type    = trim( $element['type'] );
2503
+    $element_type    = trim($element['type']);
2504 2504
     $element['form'] = $form;
2505
-    extract( $element );
2505
+    extract($element);
2506 2506
 
2507 2507
     // Try to locate the appropriate template.
2508
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
2508
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
2509 2509
     
2510 2510
     // Abort if this is not our element.
2511
-    if ( empty( $located ) || ! file_exists( $located ) ) {
2511
+    if (empty($located) || !file_exists($located)) {
2512 2512
         return;
2513 2513
     }
2514 2514
 
2515 2515
     // Generate the class and id of the element.
2516
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
2517
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
2516
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
2517
+    $id            = isset($id) ? $id : uniqid('gp');
2518 2518
 
2519 2519
     // Echo the opening wrapper.
2520 2520
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
2521 2521
 
2522 2522
     // Fires before displaying a given element type's content.
2523
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
2523
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
2524 2524
 
2525 2525
     // Include the template for the element.
2526 2526
     include $located;
2527 2527
 
2528 2528
     // Fires after displaying a given element type's content.
2529
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
2529
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
2530 2530
 
2531 2531
     // Echo the closing wrapper.
2532 2532
     echo '</div>';
2533 2533
 }
2534
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
2534
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
Please login to merge, or discard this patch.
includes/data/payment-form-elements.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@  discard block
 block discarded – undo
9 9
  * @version 1.0.19
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 return array(
15 15
 
16 16
     array(
17 17
         'type'     => 'heading',
18
-        'name'     => __( 'Heading', 'invoicing' ),
18
+        'name'     => __('Heading', 'invoicing'),
19 19
         'defaults' => array(
20 20
             'level' => 'h2',
21
-            'text'  => __( 'Heading', 'invoicing' ),
21
+            'text'  => __('Heading', 'invoicing'),
22 22
         )
23 23
     ),
24 24
 
25 25
     array(
26 26
         'type' => 'paragraph',
27
-        'name' => __( 'Paragraph', 'invoicing' ),
27
+        'name' => __('Paragraph', 'invoicing'),
28 28
         'defaults'  => array(
29
-            'text'  => __( 'Paragraph text', 'invoicing' ),
29
+            'text'  => __('Paragraph text', 'invoicing'),
30 30
         )
31 31
     ),
32 32
 
33 33
     array( 
34 34
         'type' => 'alert',
35
-        'name' => __( 'Alert', 'invoicing' ),
35
+        'name' => __('Alert', 'invoicing'),
36 36
         'defaults'  => array(
37 37
             'value'        => '',
38 38
             'class'        => 'alert-warning',
39
-            'text'         => __( 'Alert', 'invoicing' ),
39
+            'text'         => __('Alert', 'invoicing'),
40 40
             'dismissible'  => false,
41 41
         )
42 42
     ),
43 43
 
44 44
     array( 
45 45
         'type' => 'separator',
46
-        'name' => __( 'Separator', 'invoicing' ),
46
+        'name' => __('Separator', 'invoicing'),
47 47
         'defaults'  => array(
48 48
             'value'        => '',
49 49
         ),
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 
52 52
     array(
53 53
         'type' => 'text',
54
-        'name' => __( 'Text Input', 'invoicing' ),
54
+        'name' => __('Text Input', 'invoicing'),
55 55
         'defaults'  => array(
56
-            'placeholder'  => __( 'Enter some text', 'invoicing' ),
56
+            'placeholder'  => __('Enter some text', 'invoicing'),
57 57
             'value'        => '',
58
-            'label'        => __( 'Field Label', 'invoicing' ),
58
+            'label'        => __('Field Label', 'invoicing'),
59 59
             'description'  => '',
60 60
             'required'     => false,
61 61
         )
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 
64 64
     array(
65 65
         'type' => 'textarea',
66
-        'name' => __( 'Textarea', 'invoicing' ),
66
+        'name' => __('Textarea', 'invoicing'),
67 67
         'defaults'         => array(
68
-            'placeholder'  => __( 'Enter your text hear', 'invoicing' ),
68
+            'placeholder'  => __('Enter your text hear', 'invoicing'),
69 69
             'value'        => '',
70
-            'label'        => __( 'Textarea Label', 'invoicing' ),
70
+            'label'        => __('Textarea Label', 'invoicing'),
71 71
             'description'  => '',
72 72
             'required'     => false,
73 73
         )
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 
76 76
     array(
77 77
         'type' => 'select',
78
-        'name' => __( 'Dropdown', 'invoicing' ),
78
+        'name' => __('Dropdown', 'invoicing'),
79 79
         'defaults'         => array(
80
-            'placeholder'  => __( 'Select a value', 'invoicing' ),
80
+            'placeholder'  => __('Select a value', 'invoicing'),
81 81
             'value'        => '',
82
-            'label'        => __( 'Dropdown Label', 'invoicing' ),
82
+            'label'        => __('Dropdown Label', 'invoicing'),
83 83
             'description'  => '',
84 84
             'required'     => false,
85 85
             'options'      => array(
86
-                esc_attr__( 'Option One', 'invoicing' ),
87
-                esc_attr__( 'Option Two', 'invoicing' ),
88
-                esc_attr__( 'Option Three', 'invoicing' )
86
+                esc_attr__('Option One', 'invoicing'),
87
+                esc_attr__('Option Two', 'invoicing'),
88
+                esc_attr__('Option Three', 'invoicing')
89 89
             ),
90 90
         )
91 91
     ),
92 92
 
93 93
     array(
94 94
         'type' => 'checkbox',
95
-        'name' => __( 'Checkbox', 'invoicing' ),
95
+        'name' => __('Checkbox', 'invoicing'),
96 96
         'defaults'         => array(
97 97
             'value'        => '',
98
-            'label'        => __( 'Checkbox Label', 'invoicing' ),
98
+            'label'        => __('Checkbox Label', 'invoicing'),
99 99
             'description'  => '',
100 100
             'required'     => false,
101 101
         )
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
 
104 104
     array( 
105 105
         'type' => 'radio',
106
-        'name' => __( 'Multiple Choice', 'invoicing' ),
106
+        'name' => __('Multiple Choice', 'invoicing'),
107 107
         'defaults'     => array(
108
-            'label'    => __( 'Select one choice', 'invoicing' ),
108
+            'label'    => __('Select one choice', 'invoicing'),
109 109
             'options'  => array(
110
-                esc_attr__( 'Choice One', 'invoicing' ),
111
-                esc_attr__( 'Choice Two', 'invoicing' ),
112
-                esc_attr__( 'Choice Three', 'invoicing' )
110
+                esc_attr__('Choice One', 'invoicing'),
111
+                esc_attr__('Choice Two', 'invoicing'),
112
+                esc_attr__('Choice Three', 'invoicing')
113 113
             ),
114 114
         )
115 115
     ),
116 116
 
117 117
     array( 
118 118
         'type' => 'date',
119
-        'name' => __( 'Date', 'invoicing' ),
119
+        'name' => __('Date', 'invoicing'),
120 120
         'defaults' => array(
121 121
             'value'        => '',
122
-            'label'        => __( 'Date', 'invoicing' ),
122
+            'label'        => __('Date', 'invoicing'),
123 123
             'description'  => '',
124 124
             'required'     => false,
125 125
         )
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 
128 128
     array( 
129 129
         'type' => 'time',
130
-        'name' => __( 'Time', 'invoicing' ),
130
+        'name' => __('Time', 'invoicing'),
131 131
         'defaults' => array(
132 132
             'value'        => '',
133
-            'label'        => __( 'Time', 'invoicing' ),
133
+            'label'        => __('Time', 'invoicing'),
134 134
             'description'  => '',
135 135
             'required'     => false,
136 136
         )
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 
139 139
     array( 
140 140
         'type' => 'number',
141
-        'name' => __( 'Number', 'invoicing' ),
141
+        'name' => __('Number', 'invoicing'),
142 142
         'defaults' => array(
143 143
             'placeholder'  => '',
144 144
             'value'        => '',
145
-            'label'        => __( 'Number', 'invoicing' ),
145
+            'label'        => __('Number', 'invoicing'),
146 146
             'description'  => '',
147 147
             'required'     => false,
148 148
         )
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 
151 151
     array( 
152 152
         'type' => 'website',
153
-        'name' => __( 'Website', 'invoicing' ),
153
+        'name' => __('Website', 'invoicing'),
154 154
         'defaults' => array(
155 155
             'placeholder'  => 'http://example.com',
156 156
             'value'        => '',
157
-            'label'        => __( 'Website', 'invoicing' ),
157
+            'label'        => __('Website', 'invoicing'),
158 158
             'description'  => '',
159 159
             'required'     => false,
160 160
         )
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
     array( 
164 164
         'type' => 'email',
165
-        'name' => __( 'Email', 'invoicing' ),
165
+        'name' => __('Email', 'invoicing'),
166 166
         'defaults'  => array(
167 167
             'placeholder'  => '[email protected]',
168 168
             'value'        => '',
169
-            'label'        => __( 'Email Address', 'invoicing' ),
169
+            'label'        => __('Email Address', 'invoicing'),
170 170
             'description'  => '',
171 171
             'required'     => false,
172 172
         )
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 
175 175
     array( 
176 176
         'type' => 'address',
177
-        'name' => __( 'Address', 'invoicing' ),
177
+        'name' => __('Address', 'invoicing'),
178 178
         'defaults'  => array(
179 179
 
180 180
             'fields' => array(
181 181
                 array(
182 182
                     'placeholder'  => 'Jon',
183 183
                     'value'        => '',
184
-                    'label'        => __( 'First Name', 'invoicing' ),
184
+                    'label'        => __('First Name', 'invoicing'),
185 185
                     'description'  => '',
186 186
                     'required'     => false,
187 187
                     'visible'      => true,
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                 array(
192 192
                     'placeholder'  => 'Snow',
193 193
                     'value'        => '',
194
-                    'label'        => __( 'Last Name', 'invoicing' ),
194
+                    'label'        => __('Last Name', 'invoicing'),
195 195
                     'description'  => '',
196 196
                     'required'     => false,
197 197
                     'visible'      => true,
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                 array(
202 202
                     'placeholder'  => '',
203 203
                     'value'        => '',
204
-                    'label'        => __( 'Address', 'invoicing' ),
204
+                    'label'        => __('Address', 'invoicing'),
205 205
                     'description'  => '',
206 206
                     'required'     => false,
207 207
                     'visible'      => true,
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 array(
212 212
                     'placeholder'  => '',
213 213
                     'value'        => '',
214
-                    'label'        => __( 'City', 'invoicing' ),
214
+                    'label'        => __('City', 'invoicing'),
215 215
                     'description'  => '',
216 216
                     'required'     => false,
217 217
                     'visible'      => true,
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
                 ),
220 220
 
221 221
                 array(
222
-                    'placeholder'  => __( 'Select your country' ),
222
+                    'placeholder'  => __('Select your country'),
223 223
                     'value'        => '',
224
-                    'label'        => __( 'Country', 'invoicing' ),
224
+                    'label'        => __('Country', 'invoicing'),
225 225
                     'description'  => '',
226 226
                     'required'     => false,
227 227
                     'visible'      => true,
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
                 ),
230 230
 
231 231
                 array(
232
-                    'placeholder'  => __( 'Choose a state', 'invoicing' ),
232
+                    'placeholder'  => __('Choose a state', 'invoicing'),
233 233
                     'value'        => '',
234
-                    'label'        => __( 'State / Province', 'invoicing' ),
234
+                    'label'        => __('State / Province', 'invoicing'),
235 235
                     'description'  => '',
236 236
                     'required'     => false,
237 237
                     'visible'      => true,
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                 array(
242 242
                     'placeholder'  => '',
243 243
                     'value'        => '',
244
-                    'label'        => __( 'ZIP / Postcode', 'invoicing' ),
244
+                    'label'        => __('ZIP / Postcode', 'invoicing'),
245 245
                     'description'  => '',
246 246
                     'required'     => false,
247 247
                     'visible'      => true,
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                 array(
252 252
                     'placeholder'  => '',
253 253
                     'value'        => '',
254
-                    'label'        => __( 'Phone', 'invoicing' ),
254
+                    'label'        => __('Phone', 'invoicing'),
255 255
                     'description'  => '',
256 256
                     'required'     => false,
257 257
                     'visible'      => true,
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 array(
262 262
                     'placeholder'  => '',
263 263
                     'value'        => '',
264
-                    'label'        => __( 'Company', 'invoicing' ),
264
+                    'label'        => __('Company', 'invoicing'),
265 265
                     'description'  => '',
266 266
                     'required'     => false,
267 267
                     'visible'      => false,
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                 array(
272 272
                     'placeholder'  => '',
273 273
                     'value'        => '',
274
-                    'label'        => __( 'VAT Number', 'invoicing' ),
274
+                    'label'        => __('VAT Number', 'invoicing'),
275 275
                     'description'  => '',
276 276
                     'required'     => false,
277 277
                     'visible'      => false,
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 
284 284
     array( 
285 285
         'type' => 'billing_email',
286
-        'name' => __( 'Billing Email', 'invoicing' ),
286
+        'name' => __('Billing Email', 'invoicing'),
287 287
         'defaults'  => array(
288 288
             'placeholder'  => '[email protected]',
289 289
             'value'        => '',
290
-            'label'        => __( 'Billing Email', 'invoicing' ),
290
+            'label'        => __('Billing Email', 'invoicing'),
291 291
             'description'  => '',
292 292
             'premade'      => true,
293 293
         )
@@ -295,18 +295,18 @@  discard block
 block discarded – undo
295 295
 
296 296
     array( 
297 297
         'type' => 'discount',
298
-        'name' => __( 'Discount Input', 'invoicing' ),
298
+        'name' => __('Discount Input', 'invoicing'),
299 299
         'defaults'  => array(
300 300
             'value'        => '',
301
-            'input_label'  => __( 'Coupon Code', 'invoicing' ),
302
-            'button_label' => __( 'Apply Coupon', 'invoicing' ),
303
-            'description'  => __( 'Have a discount code? Enter it above.', 'invoicing' ),
301
+            'input_label'  => __('Coupon Code', 'invoicing'),
302
+            'button_label' => __('Apply Coupon', 'invoicing'),
303
+            'description'  => __('Have a discount code? Enter it above.', 'invoicing'),
304 304
         )
305 305
     ),
306 306
 
307 307
     array( 
308 308
         'type' => 'items',
309
-        'name' => __( 'Items', 'invoicing' ),
309
+        'name' => __('Items', 'invoicing'),
310 310
         'defaults'  => array(
311 311
             'value'        => '',
312 312
             'items_type'   => 'total',
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 
318 318
     array( 
319 319
         'type'       => 'pay_button',
320
-        'name'       => __( 'Payment Button', 'invoicing' ),
320
+        'name'       => __('Payment Button', 'invoicing'),
321 321
         'defaults'   => array(
322 322
             'value'        => '',
323 323
             'class'        => 'btn-primary',
324
-            'label'        => __( 'Pay Now »', 'invoicing' ),
325
-            'description'  => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
324
+            'label'        => __('Pay Now »', 'invoicing'),
325
+            'description'  => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
326 326
             'premade'      => true,
327 327
         )
328 328
     )
Please login to merge, or discard this patch.