Passed
Push — master ( 11ea61...3d88bf )
by Brian
05:49
created
includes/class-wpinv-invoice.php 1 patch
Indentation   +2332 added lines, -2332 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'remote_subscription_id' => null,
84
-		'is_viewed'            => false,
85
-		'email_cc'             => '',
86
-		'template'             => 'quantity', // hours, amount only
87
-		'created_via'          => null,
82
+        'subscription_id'      => null,
83
+        'remote_subscription_id' => null,
84
+        'is_viewed'            => false,
85
+        'email_cc'             => '',
86
+        'template'             => 'quantity', // hours, amount only
87
+        'created_via'          => null,
88 88
     );
89 89
 
90 90
     /**
91
-	 * Stores meta in cache for future reads.
92
-	 *
93
-	 * A group must be set to to enable caching.
94
-	 *
95
-	 * @var string
96
-	 */
97
-	protected $cache_group = 'getpaid_invoices';
91
+     * Stores meta in cache for future reads.
92
+     *
93
+     * A group must be set to to enable caching.
94
+     *
95
+     * @var string
96
+     */
97
+    protected $cache_group = 'getpaid_invoices';
98 98
 
99 99
     /**
100 100
      * Stores a reference to the original WP_Post object
@@ -108,104 +108,104 @@  discard block
 block discarded – undo
108 108
      *
109 109
      * @var int
110 110
      */
111
-	protected $recurring_item = null;
111
+    protected $recurring_item = null;
112 112
 
113
-	/**
113
+    /**
114 114
      * Stores an array of item totals.
115
-	 *
116
-	 * e.g $totals['discount'] = array(
117
-	 * 		'initial'   => 10,
118
-	 * 		'recurring' => 10,
119
-	 * )
115
+     *
116
+     * e.g $totals['discount'] = array(
117
+     * 		'initial'   => 10,
118
+     * 		'recurring' => 10,
119
+     * )
120 120
      *
121 121
      * @var array
122 122
      */
123
-	protected $totals = array();
123
+    protected $totals = array();
124 124
 
125
-	/**
126
-	 * Stores the status transition information.
127
-	 *
128
-	 * @since 1.0.19
129
-	 * @var bool
130
-	 */
131
-	protected $status_transition = false;
125
+    /**
126
+     * Stores the status transition information.
127
+     *
128
+     * @since 1.0.19
129
+     * @var bool
130
+     */
131
+    protected $status_transition = false;
132 132
 
133 133
     /**
134
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
135
-	 *
136
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137
-	 */
134
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
135
+     *
136
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137
+     */
138 138
     public function __construct( $invoice = false ) {
139 139
 
140 140
         parent::__construct( $invoice );
141 141
 
142
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
143
-			$this->set_id( $invoice );
144
-		} elseif ( $invoice instanceof self ) {
145
-			$this->set_id( $invoice->get_id() );
146
-		} elseif ( ! empty( $invoice->ID ) ) {
147
-			$this->set_id( $invoice->ID );
148
-		} elseif ( is_array( $invoice ) ) {
149
-			$this->set_props( $invoice );
150
-
151
-			if ( isset( $invoice['ID'] ) ) {
152
-				$this->set_id( $invoice['ID'] );
153
-			}
154
-
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
-			$this->set_id( $invoice_id );
161
-		}else {
162
-			$this->set_object_read( true );
163
-		}
142
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
143
+            $this->set_id( $invoice );
144
+        } elseif ( $invoice instanceof self ) {
145
+            $this->set_id( $invoice->get_id() );
146
+        } elseif ( ! empty( $invoice->ID ) ) {
147
+            $this->set_id( $invoice->ID );
148
+        } elseif ( is_array( $invoice ) ) {
149
+            $this->set_props( $invoice );
150
+
151
+            if ( isset( $invoice['ID'] ) ) {
152
+                $this->set_id( $invoice['ID'] );
153
+            }
154
+
155
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
+            $this->set_id( $invoice_id );
157
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
+            $this->set_id( $invoice_id );
159
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
+            $this->set_id( $invoice_id );
161
+        }else {
162
+            $this->set_object_read( true );
163
+        }
164 164
 
165 165
         // Load the datastore.
166
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
167 167
 
168
-		if ( $this->get_id() > 0 ) {
168
+        if ( $this->get_id() > 0 ) {
169 169
             $this->post = get_post( $this->get_id() );
170 170
             $this->ID   = $this->get_id();
171
-			$this->data_store->read( $this );
171
+            $this->data_store->read( $this );
172 172
         }
173 173
 
174 174
     }
175 175
 
176 176
     /**
177
-	 * Given an invoice key/number, it returns its id.
178
-	 *
179
-	 *
180
-	 * @static
181
-	 * @param string $value The invoice key or number
182
-	 * @param string $field Either key, transaction_id or number.
183
-	 * @since 1.0.15
184
-	 * @return int
185
-	 */
186
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
177
+     * Given an invoice key/number, it returns its id.
178
+     *
179
+     *
180
+     * @static
181
+     * @param string $value The invoice key or number
182
+     * @param string $field Either key, transaction_id or number.
183
+     * @since 1.0.15
184
+     * @return int
185
+     */
186
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
187 187
         global $wpdb;
188 188
 
189
-		// Trim the value.
190
-		$value = trim( $value );
189
+        // Trim the value.
190
+        $value = trim( $value );
191 191
 
192
-		if ( empty( $value ) ) {
193
-			return 0;
194
-		}
192
+        if ( empty( $value ) ) {
193
+            return 0;
194
+        }
195 195
 
196 196
         // Valid fields.
197 197
         $fields = array( 'key', 'number', 'transaction_id' );
198 198
 
199
-		// Ensure a field has been passed.
200
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
201
-			return 0;
202
-		}
199
+        // Ensure a field has been passed.
200
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
201
+            return 0;
202
+        }
203 203
 
204
-		// Maybe retrieve from the cache.
205
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
-		if ( false !== $invoice_id ) {
207
-			return $invoice_id;
208
-		}
204
+        // Maybe retrieve from the cache.
205
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
+        if ( false !== $invoice_id ) {
207
+            return $invoice_id;
208
+        }
209 209
 
210 210
         // Fetch from the db.
211 211
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
214 214
         );
215 215
 
216
-		// Update the cache with our data
217
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+        // Update the cache with our data
217
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
218 218
 
219
-		return $invoice_id;
219
+        return $invoice_id;
220 220
     }
221 221
 
222 222
     /**
@@ -242,80 +242,80 @@  discard block
 block discarded – undo
242 242
     */
243 243
 
244 244
     /**
245
-	 * Get parent invoice ID.
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return int
250
-	 */
251
-	public function get_parent_id( $context = 'view' ) {
252
-		return (int) $this->get_prop( 'parent_id', $context );
245
+     * Get parent invoice ID.
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return int
250
+     */
251
+    public function get_parent_id( $context = 'view' ) {
252
+        return (int) $this->get_prop( 'parent_id', $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Get parent invoice.
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @return WPInv_Invoice
260
-	 */
256
+     * Get parent invoice.
257
+     *
258
+     * @since 1.0.19
259
+     * @return WPInv_Invoice
260
+     */
261 261
     public function get_parent_payment() {
262 262
         return new WPInv_Invoice( $this->get_parent_id() );
263 263
     }
264 264
 
265 265
     /**
266
-	 * Alias for self::get_parent_payment().
267
-	 *
268
-	 * @since 1.0.19
269
-	 * @return WPInv_Invoice
270
-	 */
266
+     * Alias for self::get_parent_payment().
267
+     *
268
+     * @since 1.0.19
269
+     * @return WPInv_Invoice
270
+     */
271 271
     public function get_parent() {
272 272
         return $this->get_parent_payment();
273 273
     }
274 274
 
275 275
     /**
276
-	 * Get invoice status.
277
-	 *
278
-	 * @since 1.0.19
279
-	 * @param  string $context View or edit context.
280
-	 * @return string
281
-	 */
282
-	public function get_status( $context = 'view' ) {
283
-		return $this->get_prop( 'status', $context );
284
-	}
276
+     * Get invoice status.
277
+     *
278
+     * @since 1.0.19
279
+     * @param  string $context View or edit context.
280
+     * @return string
281
+     */
282
+    public function get_status( $context = 'view' ) {
283
+        return $this->get_prop( 'status', $context );
284
+    }
285 285
 	
286
-	/**
287
-	 * Retrieves an array of possible invoice statuses.
288
-	 *
289
-	 * @since 1.0.19
290
-	 * @return array
291
-	 */
292
-	public function get_all_statuses() {
293
-
294
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
295
-
296
-		// For backwards compatibility.
297
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
286
+    /**
287
+     * Retrieves an array of possible invoice statuses.
288
+     *
289
+     * @since 1.0.19
290
+     * @return array
291
+     */
292
+    public function get_all_statuses() {
293
+
294
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
295
+
296
+        // For backwards compatibility.
297
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
298 298
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
299
-		}
299
+        }
300 300
 
301
-		return $statuses;
301
+        return $statuses;
302 302
     }
303 303
 
304 304
     /**
305
-	 * Get invoice status nice name.
306
-	 *
307
-	 * @since 1.0.19
308
-	 * @return string
309
-	 */
305
+     * Get invoice status nice name.
306
+     *
307
+     * @since 1.0.19
308
+     * @return string
309
+     */
310 310
     public function get_status_nicename() {
311
-		$statuses = $this->get_all_statuses();
311
+        $statuses = $this->get_all_statuses();
312 312
 
313 313
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
314 314
 
315 315
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
316 316
     }
317 317
 
318
-	/**
318
+    /**
319 319
      * Retrieves the invoice status label html
320 320
      *
321 321
      * @since  1.0.0
@@ -323,262 +323,262 @@  discard block
 block discarded – undo
323 323
      */
324 324
     public function get_status_label_html() {
325 325
 
326
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
327
-		$status       = sanitize_html_class( $this->get_status() );
326
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
327
+        $status       = sanitize_html_class( $this->get_status() );
328 328
 
329
-		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
330
-	}
329
+        return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
330
+    }
331 331
 
332 332
     /**
333
-	 * Get plugin version when the invoice was created.
334
-	 *
335
-	 * @since 1.0.19
336
-	 * @param  string $context View or edit context.
337
-	 * @return string
338
-	 */
339
-	public function get_version( $context = 'view' ) {
340
-		return $this->get_prop( 'version', $context );
341
-	}
333
+     * Get plugin version when the invoice was created.
334
+     *
335
+     * @since 1.0.19
336
+     * @param  string $context View or edit context.
337
+     * @return string
338
+     */
339
+    public function get_version( $context = 'view' ) {
340
+        return $this->get_prop( 'version', $context );
341
+    }
342 342
 
343
-	/**
344
-	 * @deprecated
345
-	 */
346
-	public function get_invoice_date( $format = true ) {
347
-		$date      = getpaid_format_date( $this->get_date_completed() );
348
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
349
-		$formatted = getpaid_format_date( $date );
343
+    /**
344
+     * @deprecated
345
+     */
346
+    public function get_invoice_date( $format = true ) {
347
+        $date      = getpaid_format_date( $this->get_date_completed() );
348
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
349
+        $formatted = getpaid_format_date( $date );
350 350
 
351
-		if ( $format ) {
352
-			return $formatted;
353
-		}
351
+        if ( $format ) {
352
+            return $formatted;
353
+        }
354 354
 
355
-		return empty( $formatted ) ? '' : $date;
355
+        return empty( $formatted ) ? '' : $date;
356 356
 
357 357
     }
358 358
 
359 359
     /**
360
-	 * Get date when the invoice was created.
361
-	 *
362
-	 * @since 1.0.19
363
-	 * @param  string $context View or edit context.
364
-	 * @return string
365
-	 */
366
-	public function get_date_created( $context = 'view' ) {
367
-		return $this->get_prop( 'date_created', $context );
368
-	}
360
+     * Get date when the invoice was created.
361
+     *
362
+     * @since 1.0.19
363
+     * @param  string $context View or edit context.
364
+     * @return string
365
+     */
366
+    public function get_date_created( $context = 'view' ) {
367
+        return $this->get_prop( 'date_created', $context );
368
+    }
369 369
 	
370
-	/**
371
-	 * Alias for self::get_date_created().
372
-	 *
373
-	 * @since 1.0.19
374
-	 * @param  string $context View or edit context.
375
-	 * @return string
376
-	 */
377
-	public function get_created_date( $context = 'view' ) {
378
-		return $this->get_date_created( $context );
379
-    }
380
-
381
-    /**
382
-	 * Get GMT date when the invoice was created.
383
-	 *
384
-	 * @since 1.0.19
385
-	 * @param  string $context View or edit context.
386
-	 * @return string
387
-	 */
388
-	public function get_date_created_gmt( $context = 'view' ) {
370
+    /**
371
+     * Alias for self::get_date_created().
372
+     *
373
+     * @since 1.0.19
374
+     * @param  string $context View or edit context.
375
+     * @return string
376
+     */
377
+    public function get_created_date( $context = 'view' ) {
378
+        return $this->get_date_created( $context );
379
+    }
380
+
381
+    /**
382
+     * Get GMT date when the invoice was created.
383
+     *
384
+     * @since 1.0.19
385
+     * @param  string $context View or edit context.
386
+     * @return string
387
+     */
388
+    public function get_date_created_gmt( $context = 'view' ) {
389 389
         $date = $this->get_date_created( $context );
390 390
 
391 391
         if ( $date ) {
392 392
             $date = get_gmt_from_date( $date );
393 393
         }
394
-		return $date;
394
+        return $date;
395 395
     }
396 396
 
397 397
     /**
398
-	 * Get date when the invoice was last modified.
399
-	 *
400
-	 * @since 1.0.19
401
-	 * @param  string $context View or edit context.
402
-	 * @return string
403
-	 */
404
-	public function get_date_modified( $context = 'view' ) {
405
-		return $this->get_prop( 'date_modified', $context );
406
-	}
398
+     * Get date when the invoice was last modified.
399
+     *
400
+     * @since 1.0.19
401
+     * @param  string $context View or edit context.
402
+     * @return string
403
+     */
404
+    public function get_date_modified( $context = 'view' ) {
405
+        return $this->get_prop( 'date_modified', $context );
406
+    }
407 407
 
408
-	/**
409
-	 * Alias for self::get_date_modified().
410
-	 *
411
-	 * @since 1.0.19
412
-	 * @param  string $context View or edit context.
413
-	 * @return string
414
-	 */
415
-	public function get_modified_date( $context = 'view' ) {
416
-		return $this->get_date_modified( $context );
408
+    /**
409
+     * Alias for self::get_date_modified().
410
+     *
411
+     * @since 1.0.19
412
+     * @param  string $context View or edit context.
413
+     * @return string
414
+     */
415
+    public function get_modified_date( $context = 'view' ) {
416
+        return $this->get_date_modified( $context );
417 417
     }
418 418
 
419 419
     /**
420
-	 * Get GMT date when the invoice was last modified.
421
-	 *
422
-	 * @since 1.0.19
423
-	 * @param  string $context View or edit context.
424
-	 * @return string
425
-	 */
426
-	public function get_date_modified_gmt( $context = 'view' ) {
420
+     * Get GMT date when the invoice was last modified.
421
+     *
422
+     * @since 1.0.19
423
+     * @param  string $context View or edit context.
424
+     * @return string
425
+     */
426
+    public function get_date_modified_gmt( $context = 'view' ) {
427 427
         $date = $this->get_date_modified( $context );
428 428
 
429 429
         if ( $date ) {
430 430
             $date = get_gmt_from_date( $date );
431 431
         }
432
-		return $date;
432
+        return $date;
433 433
     }
434 434
 
435 435
     /**
436
-	 * Get the invoice due date.
437
-	 *
438
-	 * @since 1.0.19
439
-	 * @param  string $context View or edit context.
440
-	 * @return string
441
-	 */
442
-	public function get_due_date( $context = 'view' ) {
443
-		return $this->get_prop( 'due_date', $context );
436
+     * Get the invoice due date.
437
+     *
438
+     * @since 1.0.19
439
+     * @param  string $context View or edit context.
440
+     * @return string
441
+     */
442
+    public function get_due_date( $context = 'view' ) {
443
+        return $this->get_prop( 'due_date', $context );
444 444
     }
445 445
 
446 446
     /**
447
-	 * Alias for self::get_due_date().
448
-	 *
449
-	 * @since 1.0.19
450
-	 * @param  string $context View or edit context.
451
-	 * @return string
452
-	 */
453
-	public function get_date_due( $context = 'view' ) {
454
-		return $this->get_due_date( $context );
447
+     * Alias for self::get_due_date().
448
+     *
449
+     * @since 1.0.19
450
+     * @param  string $context View or edit context.
451
+     * @return string
452
+     */
453
+    public function get_date_due( $context = 'view' ) {
454
+        return $this->get_due_date( $context );
455 455
     }
456 456
 
457 457
     /**
458
-	 * Get the invoice GMT due date.
459
-	 *
460
-	 * @since 1.0.19
461
-	 * @param  string $context View or edit context.
462
-	 * @return string
463
-	 */
464
-	public function get_due_date_gmt( $context = 'view' ) {
458
+     * Get the invoice GMT due date.
459
+     *
460
+     * @since 1.0.19
461
+     * @param  string $context View or edit context.
462
+     * @return string
463
+     */
464
+    public function get_due_date_gmt( $context = 'view' ) {
465 465
         $date = $this->get_due_date( $context );
466 466
 
467 467
         if ( $date ) {
468 468
             $date = get_gmt_from_date( $date );
469 469
         }
470
-		return $date;
470
+        return $date;
471 471
     }
472 472
 
473 473
     /**
474
-	 * Alias for self::get_due_date_gmt().
475
-	 *
476
-	 * @since 1.0.19
477
-	 * @param  string $context View or edit context.
478
-	 * @return string
479
-	 */
480
-	public function get_gmt_date_due( $context = 'view' ) {
481
-		return $this->get_due_date_gmt( $context );
474
+     * Alias for self::get_due_date_gmt().
475
+     *
476
+     * @since 1.0.19
477
+     * @param  string $context View or edit context.
478
+     * @return string
479
+     */
480
+    public function get_gmt_date_due( $context = 'view' ) {
481
+        return $this->get_due_date_gmt( $context );
482 482
     }
483 483
 
484 484
     /**
485
-	 * Get date when the invoice was completed.
486
-	 *
487
-	 * @since 1.0.19
488
-	 * @param  string $context View or edit context.
489
-	 * @return string
490
-	 */
491
-	public function get_completed_date( $context = 'view' ) {
492
-		return $this->get_prop( 'completed_date', $context );
485
+     * Get date when the invoice was completed.
486
+     *
487
+     * @since 1.0.19
488
+     * @param  string $context View or edit context.
489
+     * @return string
490
+     */
491
+    public function get_completed_date( $context = 'view' ) {
492
+        return $this->get_prop( 'completed_date', $context );
493 493
     }
494 494
 
495 495
     /**
496
-	 * Alias for self::get_completed_date().
497
-	 *
498
-	 * @since 1.0.19
499
-	 * @param  string $context View or edit context.
500
-	 * @return string
501
-	 */
502
-	public function get_date_completed( $context = 'view' ) {
503
-		return $this->get_completed_date( $context );
496
+     * Alias for self::get_completed_date().
497
+     *
498
+     * @since 1.0.19
499
+     * @param  string $context View or edit context.
500
+     * @return string
501
+     */
502
+    public function get_date_completed( $context = 'view' ) {
503
+        return $this->get_completed_date( $context );
504 504
     }
505 505
 
506 506
     /**
507
-	 * Get GMT date when the invoice was was completed.
508
-	 *
509
-	 * @since 1.0.19
510
-	 * @param  string $context View or edit context.
511
-	 * @return string
512
-	 */
513
-	public function get_completed_date_gmt( $context = 'view' ) {
507
+     * Get GMT date when the invoice was was completed.
508
+     *
509
+     * @since 1.0.19
510
+     * @param  string $context View or edit context.
511
+     * @return string
512
+     */
513
+    public function get_completed_date_gmt( $context = 'view' ) {
514 514
         $date = $this->get_completed_date( $context );
515 515
 
516 516
         if ( $date ) {
517 517
             $date = get_gmt_from_date( $date );
518 518
         }
519
-		return $date;
519
+        return $date;
520 520
     }
521 521
 
522 522
     /**
523
-	 * Alias for self::get_completed_date_gmt().
524
-	 *
525
-	 * @since 1.0.19
526
-	 * @param  string $context View or edit context.
527
-	 * @return string
528
-	 */
529
-	public function get_gmt_completed_date( $context = 'view' ) {
530
-		return $this->get_completed_date_gmt( $context );
523
+     * Alias for self::get_completed_date_gmt().
524
+     *
525
+     * @since 1.0.19
526
+     * @param  string $context View or edit context.
527
+     * @return string
528
+     */
529
+    public function get_gmt_completed_date( $context = 'view' ) {
530
+        return $this->get_completed_date_gmt( $context );
531 531
     }
532 532
 
533 533
     /**
534
-	 * Get the invoice number.
535
-	 *
536
-	 * @since 1.0.19
537
-	 * @param  string $context View or edit context.
538
-	 * @return string
539
-	 */
540
-	public function get_number( $context = 'view' ) {
541
-		$number = $this->get_prop( 'number', $context );
534
+     * Get the invoice number.
535
+     *
536
+     * @since 1.0.19
537
+     * @param  string $context View or edit context.
538
+     * @return string
539
+     */
540
+    public function get_number( $context = 'view' ) {
541
+        $number = $this->get_prop( 'number', $context );
542 542
 
543
-		if ( empty( $number ) ) {
544
-			$number = $this->generate_number();
545
-			$this->set_number( $this->generate_number() );
546
-		}
543
+        if ( empty( $number ) ) {
544
+            $number = $this->generate_number();
545
+            $this->set_number( $this->generate_number() );
546
+        }
547 547
 
548
-		return $number;
548
+        return $number;
549 549
     }
550 550
 
551
-	/**
552
-	 * Set the invoice number.
553
-	 *
554
-	 * @since 1.0.19
555
-	 */
556
-	public function maybe_set_number() {
551
+    /**
552
+     * Set the invoice number.
553
+     *
554
+     * @since 1.0.19
555
+     */
556
+    public function maybe_set_number() {
557 557
         $number = $this->get_number();
558 558
 
559 559
         if ( empty( $number ) || $this->get_id() == $number ) {
560
-			$this->set_number( $this->generate_number() );
560
+            $this->set_number( $this->generate_number() );
561 561
         }
562 562
 
563
-	}
563
+    }
564 564
 
565 565
     /**
566
-	 * Get the invoice key.
567
-	 *
568
-	 * @since 1.0.19
569
-	 * @param  string $context View or edit context.
570
-	 * @return string
571
-	 */
572
-	public function get_key( $context = 'view' ) {
566
+     * Get the invoice key.
567
+     *
568
+     * @since 1.0.19
569
+     * @param  string $context View or edit context.
570
+     * @return string
571
+     */
572
+    public function get_key( $context = 'view' ) {
573 573
         return $this->get_prop( 'key', $context );
574
-	}
575
-
576
-	/**
577
-	 * Set the invoice key.
578
-	 *
579
-	 * @since 1.0.19
580
-	 */
581
-	public function maybe_set_key() {
574
+    }
575
+
576
+    /**
577
+     * Set the invoice key.
578
+     *
579
+     * @since 1.0.19
580
+     */
581
+    public function maybe_set_key() {
582 582
         $key = $this->get_key();
583 583
 
584 584
         if ( empty( $key ) ) {
@@ -589,126 +589,126 @@  discard block
 block discarded – undo
589 589
     }
590 590
 
591 591
     /**
592
-	 * Get the invoice type.
593
-	 *
594
-	 * @since 1.0.19
595
-	 * @param  string $context View or edit context.
596
-	 * @return string
597
-	 */
598
-	public function get_type( $context = 'view' ) {
592
+     * Get the invoice type.
593
+     *
594
+     * @since 1.0.19
595
+     * @param  string $context View or edit context.
596
+     * @return string
597
+     */
598
+    public function get_type( $context = 'view' ) {
599 599
         return $this->get_prop( 'type', $context );
600
-	}
600
+    }
601 601
 
602
-	/**
603
-	 * @deprecated
604
-	 */
605
-	public function get_invoice_quote_type() {
602
+    /**
603
+     * @deprecated
604
+     */
605
+    public function get_invoice_quote_type() {
606 606
         ucfirst( $this->get_type() );
607 607
     }
608 608
 
609 609
     /**
610
-	 * Get the invoice post type.
611
-	 *
612
-	 * @since 1.0.19
613
-	 * @param  string $context View or edit context.
614
-	 * @return string
615
-	 */
616
-	public function get_post_type( $context = 'view' ) {
610
+     * Get the invoice post type.
611
+     *
612
+     * @since 1.0.19
613
+     * @param  string $context View or edit context.
614
+     * @return string
615
+     */
616
+    public function get_post_type( $context = 'view' ) {
617 617
         return $this->get_prop( 'post_type', $context );
618 618
     }
619 619
 
620 620
     /**
621
-	 * Get the invoice mode.
622
-	 *
623
-	 * @since 1.0.19
624
-	 * @param  string $context View or edit context.
625
-	 * @return string
626
-	 */
627
-	public function get_mode( $context = 'view' ) {
621
+     * Get the invoice mode.
622
+     *
623
+     * @since 1.0.19
624
+     * @param  string $context View or edit context.
625
+     * @return string
626
+     */
627
+    public function get_mode( $context = 'view' ) {
628 628
         return $this->get_prop( 'mode', $context );
629 629
     }
630 630
 
631 631
     /**
632
-	 * Get the invoice path.
633
-	 *
634
-	 * @since 1.0.19
635
-	 * @param  string $context View or edit context.
636
-	 * @return string
637
-	 */
638
-	public function get_path( $context = 'view' ) {
632
+     * Get the invoice path.
633
+     *
634
+     * @since 1.0.19
635
+     * @param  string $context View or edit context.
636
+     * @return string
637
+     */
638
+    public function get_path( $context = 'view' ) {
639 639
         $path   = $this->get_prop( 'path', $context );
640
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
640
+        $prefix = wpinv_post_name_prefix( $this->get_post_type() );
641 641
 
642
-		if ( 0 !== strpos( $path, $prefix ) ) {
643
-			$path = sanitize_title(  $prefix . $this->get_id()  );
644
-			$this->set_path( $path );
645
-		}
642
+        if ( 0 !== strpos( $path, $prefix ) ) {
643
+            $path = sanitize_title(  $prefix . $this->get_id()  );
644
+            $this->set_path( $path );
645
+        }
646 646
 
647
-		return $path;
647
+        return $path;
648 648
     }
649 649
 
650 650
     /**
651
-	 * Get the invoice name/title.
652
-	 *
653
-	 * @since 1.0.19
654
-	 * @param  string $context View or edit context.
655
-	 * @return string
656
-	 */
657
-	public function get_name( $context = 'view' ) {
651
+     * Get the invoice name/title.
652
+     *
653
+     * @since 1.0.19
654
+     * @param  string $context View or edit context.
655
+     * @return string
656
+     */
657
+    public function get_name( $context = 'view' ) {
658 658
         return $this->get_prop( 'title', $context );
659 659
     }
660 660
 
661 661
     /**
662
-	 * Alias of self::get_name().
663
-	 *
664
-	 * @since 1.0.19
665
-	 * @param  string $context View or edit context.
666
-	 * @return string
667
-	 */
668
-	public function get_title( $context = 'view' ) {
669
-		return $this->get_name( $context );
662
+     * Alias of self::get_name().
663
+     *
664
+     * @since 1.0.19
665
+     * @param  string $context View or edit context.
666
+     * @return string
667
+     */
668
+    public function get_title( $context = 'view' ) {
669
+        return $this->get_name( $context );
670 670
     }
671 671
 
672 672
     /**
673
-	 * Get the invoice description.
674
-	 *
675
-	 * @since 1.0.19
676
-	 * @param  string $context View or edit context.
677
-	 * @return string
678
-	 */
679
-	public function get_description( $context = 'view' ) {
680
-		return $this->get_prop( 'description', $context );
673
+     * Get the invoice description.
674
+     *
675
+     * @since 1.0.19
676
+     * @param  string $context View or edit context.
677
+     * @return string
678
+     */
679
+    public function get_description( $context = 'view' ) {
680
+        return $this->get_prop( 'description', $context );
681 681
     }
682 682
 
683 683
     /**
684
-	 * Alias of self::get_description().
685
-	 *
686
-	 * @since 1.0.19
687
-	 * @param  string $context View or edit context.
688
-	 * @return string
689
-	 */
690
-	public function get_excerpt( $context = 'view' ) {
691
-		return $this->get_description( $context );
684
+     * Alias of self::get_description().
685
+     *
686
+     * @since 1.0.19
687
+     * @param  string $context View or edit context.
688
+     * @return string
689
+     */
690
+    public function get_excerpt( $context = 'view' ) {
691
+        return $this->get_description( $context );
692 692
     }
693 693
 
694 694
     /**
695
-	 * Alias of self::get_description().
696
-	 *
697
-	 * @since 1.0.19
698
-	 * @param  string $context View or edit context.
699
-	 * @return string
700
-	 */
701
-	public function get_summary( $context = 'view' ) {
702
-		return $this->get_description( $context );
695
+     * Alias of self::get_description().
696
+     *
697
+     * @since 1.0.19
698
+     * @param  string $context View or edit context.
699
+     * @return string
700
+     */
701
+    public function get_summary( $context = 'view' ) {
702
+        return $this->get_description( $context );
703 703
     }
704 704
 
705 705
     /**
706
-	 * Returns the user info.
707
-	 *
708
-	 * @since 1.0.19
706
+     * Returns the user info.
707
+     *
708
+     * @since 1.0.19
709 709
      * @param  string $context View or edit context.
710
-	 * @return array
711
-	 */
710
+     * @return array
711
+     */
712 712
     public function get_user_info( $context = 'view' ) {
713 713
 
714 714
         $user_info = array(
@@ -725,616 +725,616 @@  discard block
 block discarded – undo
725 725
             'company'    => $this->get_company( $context ),
726 726
             'vat_number' => $this->get_vat_number( $context ),
727 727
             'discount'   => $this->get_discount_code( $context ),
728
-		);
728
+        );
729
+
730
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
731
+
732
+    }
733
+
734
+    /**
735
+     * Get the customer id.
736
+     *
737
+     * @since 1.0.19
738
+     * @param  string $context View or edit context.
739
+     * @return int
740
+     */
741
+    public function get_author( $context = 'view' ) {
742
+        return (int) $this->get_prop( 'author', $context );
743
+    }
744
+
745
+    /**
746
+     * Alias of self::get_author().
747
+     *
748
+     * @since 1.0.19
749
+     * @param  string $context View or edit context.
750
+     * @return int
751
+     */
752
+    public function get_user_id( $context = 'view' ) {
753
+        return $this->get_author( $context );
754
+    }
755
+
756
+        /**
757
+         * Alias of self::get_author().
758
+         *
759
+         * @since 1.0.19
760
+         * @param  string $context View or edit context.
761
+         * @return int
762
+         */
763
+    public function get_customer_id( $context = 'view' ) {
764
+        return $this->get_author( $context );
765
+    }
729 766
 
730
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
767
+    /**
768
+     * Get the customer's ip.
769
+     *
770
+     * @since 1.0.19
771
+     * @param  string $context View or edit context.
772
+     * @return string
773
+     */
774
+    public function get_ip( $context = 'view' ) {
775
+        return $this->get_prop( 'user_ip', $context );
776
+    }
731 777
 
778
+    /**
779
+     * Alias of self::get_ip().
780
+     *
781
+     * @since 1.0.19
782
+     * @param  string $context View or edit context.
783
+     * @return string
784
+     */
785
+    public function get_user_ip( $context = 'view' ) {
786
+        return $this->get_ip( $context );
787
+    }
788
+
789
+        /**
790
+         * Alias of self::get_ip().
791
+         *
792
+         * @since 1.0.19
793
+         * @param  string $context View or edit context.
794
+         * @return string
795
+         */
796
+    public function get_customer_ip( $context = 'view' ) {
797
+        return $this->get_ip( $context );
732 798
     }
733 799
 
734 800
     /**
735
-	 * Get the customer id.
736
-	 *
737
-	 * @since 1.0.19
738
-	 * @param  string $context View or edit context.
739
-	 * @return int
740
-	 */
741
-	public function get_author( $context = 'view' ) {
742
-		return (int) $this->get_prop( 'author', $context );
801
+     * Get the customer's first name.
802
+     *
803
+     * @since 1.0.19
804
+     * @param  string $context View or edit context.
805
+     * @return string
806
+     */
807
+    public function get_first_name( $context = 'view' ) {
808
+        return $this->get_prop( 'first_name', $context );
743 809
     }
744 810
 
745 811
     /**
746
-	 * Alias of self::get_author().
747
-	 *
748
-	 * @since 1.0.19
749
-	 * @param  string $context View or edit context.
750
-	 * @return int
751
-	 */
752
-	public function get_user_id( $context = 'view' ) {
753
-		return $this->get_author( $context );
812
+     * Alias of self::get_first_name().
813
+     *
814
+     * @since 1.0.19
815
+     * @param  string $context View or edit context.
816
+     * @return int
817
+     */
818
+    public function get_user_first_name( $context = 'view' ) {
819
+        return $this->get_first_name( $context );
754 820
     }
755 821
 
756
-     /**
757
-	 * Alias of self::get_author().
758
-	 *
759
-	 * @since 1.0.19
760
-	 * @param  string $context View or edit context.
761
-	 * @return int
762
-	 */
763
-	public function get_customer_id( $context = 'view' ) {
764
-		return $this->get_author( $context );
822
+        /**
823
+         * Alias of self::get_first_name().
824
+         *
825
+         * @since 1.0.19
826
+         * @param  string $context View or edit context.
827
+         * @return int
828
+         */
829
+    public function get_customer_first_name( $context = 'view' ) {
830
+        return $this->get_first_name( $context );
765 831
     }
766 832
 
767 833
     /**
768
-	 * Get the customer's ip.
769
-	 *
770
-	 * @since 1.0.19
771
-	 * @param  string $context View or edit context.
772
-	 * @return string
773
-	 */
774
-	public function get_ip( $context = 'view' ) {
775
-		return $this->get_prop( 'user_ip', $context );
834
+     * Get the customer's last name.
835
+     *
836
+     * @since 1.0.19
837
+     * @param  string $context View or edit context.
838
+     * @return string
839
+     */
840
+    public function get_last_name( $context = 'view' ) {
841
+        return $this->get_prop( 'last_name', $context );
776 842
     }
777 843
 
778 844
     /**
779
-	 * Alias of self::get_ip().
780
-	 *
781
-	 * @since 1.0.19
782
-	 * @param  string $context View or edit context.
783
-	 * @return string
784
-	 */
785
-	public function get_user_ip( $context = 'view' ) {
786
-		return $this->get_ip( $context );
845
+     * Alias of self::get_last_name().
846
+     *
847
+     * @since 1.0.19
848
+     * @param  string $context View or edit context.
849
+     * @return int
850
+     */
851
+    public function get_user_last_name( $context = 'view' ) {
852
+        return $this->get_last_name( $context );
787 853
     }
788 854
 
789
-     /**
790
-	 * Alias of self::get_ip().
791
-	 *
792
-	 * @since 1.0.19
793
-	 * @param  string $context View or edit context.
794
-	 * @return string
795
-	 */
796
-	public function get_customer_ip( $context = 'view' ) {
797
-		return $this->get_ip( $context );
855
+    /**
856
+     * Alias of self::get_last_name().
857
+     *
858
+     * @since 1.0.19
859
+     * @param  string $context View or edit context.
860
+     * @return int
861
+     */
862
+    public function get_customer_last_name( $context = 'view' ) {
863
+        return $this->get_last_name( $context );
798 864
     }
799 865
 
800 866
     /**
801
-	 * Get the customer's first name.
802
-	 *
803
-	 * @since 1.0.19
804
-	 * @param  string $context View or edit context.
805
-	 * @return string
806
-	 */
807
-	public function get_first_name( $context = 'view' ) {
808
-		return $this->get_prop( 'first_name', $context );
867
+     * Get the customer's full name.
868
+     *
869
+     * @since 1.0.19
870
+     * @param  string $context View or edit context.
871
+     * @return string
872
+     */
873
+    public function get_full_name( $context = 'view' ) {
874
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
809 875
     }
810 876
 
811 877
     /**
812
-	 * Alias of self::get_first_name().
813
-	 *
814
-	 * @since 1.0.19
815
-	 * @param  string $context View or edit context.
816
-	 * @return int
817
-	 */
818
-	public function get_user_first_name( $context = 'view' ) {
819
-		return $this->get_first_name( $context );
878
+     * Alias of self::get_full_name().
879
+     *
880
+     * @since 1.0.19
881
+     * @param  string $context View or edit context.
882
+     * @return int
883
+     */
884
+    public function get_user_full_name( $context = 'view' ) {
885
+        return $this->get_full_name( $context );
820 886
     }
821 887
 
822
-     /**
823
-	 * Alias of self::get_first_name().
824
-	 *
825
-	 * @since 1.0.19
826
-	 * @param  string $context View or edit context.
827
-	 * @return int
828
-	 */
829
-	public function get_customer_first_name( $context = 'view' ) {
830
-		return $this->get_first_name( $context );
888
+    /**
889
+     * Alias of self::get_full_name().
890
+     *
891
+     * @since 1.0.19
892
+     * @param  string $context View or edit context.
893
+     * @return int
894
+     */
895
+    public function get_customer_full_name( $context = 'view' ) {
896
+        return $this->get_full_name( $context );
831 897
     }
832 898
 
833 899
     /**
834
-	 * Get the customer's last name.
835
-	 *
836
-	 * @since 1.0.19
837
-	 * @param  string $context View or edit context.
838
-	 * @return string
839
-	 */
840
-	public function get_last_name( $context = 'view' ) {
841
-		return $this->get_prop( 'last_name', $context );
900
+     * Get the customer's phone number.
901
+     *
902
+     * @since 1.0.19
903
+     * @param  string $context View or edit context.
904
+     * @return string
905
+     */
906
+    public function get_phone( $context = 'view' ) {
907
+        return $this->get_prop( 'phone', $context );
842 908
     }
843 909
 
844 910
     /**
845
-	 * Alias of self::get_last_name().
846
-	 *
847
-	 * @since 1.0.19
848
-	 * @param  string $context View or edit context.
849
-	 * @return int
850
-	 */
851
-	public function get_user_last_name( $context = 'view' ) {
852
-		return $this->get_last_name( $context );
911
+     * Alias of self::get_phone().
912
+     *
913
+     * @since 1.0.19
914
+     * @param  string $context View or edit context.
915
+     * @return int
916
+     */
917
+    public function get_phone_number( $context = 'view' ) {
918
+        return $this->get_phone( $context );
853 919
     }
854 920
 
855 921
     /**
856
-	 * Alias of self::get_last_name().
857
-	 *
858
-	 * @since 1.0.19
859
-	 * @param  string $context View or edit context.
860
-	 * @return int
861
-	 */
862
-	public function get_customer_last_name( $context = 'view' ) {
863
-		return $this->get_last_name( $context );
922
+     * Alias of self::get_phone().
923
+     *
924
+     * @since 1.0.19
925
+     * @param  string $context View or edit context.
926
+     * @return int
927
+     */
928
+    public function get_user_phone( $context = 'view' ) {
929
+        return $this->get_phone( $context );
864 930
     }
865 931
 
866 932
     /**
867
-	 * Get the customer's full name.
868
-	 *
869
-	 * @since 1.0.19
870
-	 * @param  string $context View or edit context.
871
-	 * @return string
872
-	 */
873
-	public function get_full_name( $context = 'view' ) {
874
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
933
+     * Alias of self::get_phone().
934
+     *
935
+     * @since 1.0.19
936
+     * @param  string $context View or edit context.
937
+     * @return int
938
+     */
939
+    public function get_customer_phone( $context = 'view' ) {
940
+        return $this->get_phone( $context );
941
+    }
942
+
943
+    /**
944
+     * Get the customer's email address.
945
+     *
946
+     * @since 1.0.19
947
+     * @param  string $context View or edit context.
948
+     * @return string
949
+     */
950
+    public function get_email( $context = 'view' ) {
951
+        return $this->get_prop( 'email', $context );
952
+    }
953
+
954
+    /**
955
+     * Alias of self::get_email().
956
+     *
957
+     * @since 1.0.19
958
+     * @param  string $context View or edit context.
959
+     * @return string
960
+     */
961
+    public function get_email_address( $context = 'view' ) {
962
+        return $this->get_email( $context );
963
+    }
964
+
965
+    /**
966
+     * Alias of self::get_email().
967
+     *
968
+     * @since 1.0.19
969
+     * @param  string $context View or edit context.
970
+     * @return int
971
+     */
972
+    public function get_user_email( $context = 'view' ) {
973
+        return $this->get_email( $context );
974
+    }
975
+
976
+    /**
977
+     * Alias of self::get_email().
978
+     *
979
+     * @since 1.0.19
980
+     * @param  string $context View or edit context.
981
+     * @return int
982
+     */
983
+    public function get_customer_email( $context = 'view' ) {
984
+        return $this->get_email( $context );
985
+    }
986
+
987
+    /**
988
+     * Get the customer's country.
989
+     *
990
+     * @since 1.0.19
991
+     * @param  string $context View or edit context.
992
+     * @return string
993
+     */
994
+    public function get_country( $context = 'view' ) {
995
+        $country = $this->get_prop( 'country', $context );
996
+        return empty( $country ) ? wpinv_get_default_country() : $country;
997
+    }
998
+
999
+    /**
1000
+     * Alias of self::get_country().
1001
+     *
1002
+     * @since 1.0.19
1003
+     * @param  string $context View or edit context.
1004
+     * @return int
1005
+     */
1006
+    public function get_user_country( $context = 'view' ) {
1007
+        return $this->get_country( $context );
1008
+    }
1009
+
1010
+    /**
1011
+     * Alias of self::get_country().
1012
+     *
1013
+     * @since 1.0.19
1014
+     * @param  string $context View or edit context.
1015
+     * @return int
1016
+     */
1017
+    public function get_customer_country( $context = 'view' ) {
1018
+        return $this->get_country( $context );
875 1019
     }
876 1020
 
877 1021
     /**
878
-	 * Alias of self::get_full_name().
879
-	 *
880
-	 * @since 1.0.19
881
-	 * @param  string $context View or edit context.
882
-	 * @return int
883
-	 */
884
-	public function get_user_full_name( $context = 'view' ) {
885
-		return $this->get_full_name( $context );
1022
+     * Get the customer's state.
1023
+     *
1024
+     * @since 1.0.19
1025
+     * @param  string $context View or edit context.
1026
+     * @return string
1027
+     */
1028
+    public function get_state( $context = 'view' ) {
1029
+        $state = $this->get_prop( 'state', $context );
1030
+        return empty( $state ) ? wpinv_get_default_state() : $state;
886 1031
     }
887 1032
 
888 1033
     /**
889
-	 * Alias of self::get_full_name().
890
-	 *
891
-	 * @since 1.0.19
892
-	 * @param  string $context View or edit context.
893
-	 * @return int
894
-	 */
895
-	public function get_customer_full_name( $context = 'view' ) {
896
-		return $this->get_full_name( $context );
1034
+     * Alias of self::get_state().
1035
+     *
1036
+     * @since 1.0.19
1037
+     * @param  string $context View or edit context.
1038
+     * @return int
1039
+     */
1040
+    public function get_user_state( $context = 'view' ) {
1041
+        return $this->get_state( $context );
897 1042
     }
898 1043
 
899 1044
     /**
900
-	 * Get the customer's phone number.
901
-	 *
902
-	 * @since 1.0.19
903
-	 * @param  string $context View or edit context.
904
-	 * @return string
905
-	 */
906
-	public function get_phone( $context = 'view' ) {
907
-		return $this->get_prop( 'phone', $context );
1045
+     * Alias of self::get_state().
1046
+     *
1047
+     * @since 1.0.19
1048
+     * @param  string $context View or edit context.
1049
+     * @return int
1050
+     */
1051
+    public function get_customer_state( $context = 'view' ) {
1052
+        return $this->get_state( $context );
908 1053
     }
909 1054
 
910 1055
     /**
911
-	 * Alias of self::get_phone().
912
-	 *
913
-	 * @since 1.0.19
914
-	 * @param  string $context View or edit context.
915
-	 * @return int
916
-	 */
917
-	public function get_phone_number( $context = 'view' ) {
918
-		return $this->get_phone( $context );
1056
+     * Get the customer's city.
1057
+     *
1058
+     * @since 1.0.19
1059
+     * @param  string $context View or edit context.
1060
+     * @return string
1061
+     */
1062
+    public function get_city( $context = 'view' ) {
1063
+        return $this->get_prop( 'city', $context );
919 1064
     }
920 1065
 
921 1066
     /**
922
-	 * Alias of self::get_phone().
923
-	 *
924
-	 * @since 1.0.19
925
-	 * @param  string $context View or edit context.
926
-	 * @return int
927
-	 */
928
-	public function get_user_phone( $context = 'view' ) {
929
-		return $this->get_phone( $context );
1067
+     * Alias of self::get_city().
1068
+     *
1069
+     * @since 1.0.19
1070
+     * @param  string $context View or edit context.
1071
+     * @return string
1072
+     */
1073
+    public function get_user_city( $context = 'view' ) {
1074
+        return $this->get_city( $context );
930 1075
     }
931 1076
 
932 1077
     /**
933
-	 * Alias of self::get_phone().
934
-	 *
935
-	 * @since 1.0.19
936
-	 * @param  string $context View or edit context.
937
-	 * @return int
938
-	 */
939
-	public function get_customer_phone( $context = 'view' ) {
940
-		return $this->get_phone( $context );
1078
+     * Alias of self::get_city().
1079
+     *
1080
+     * @since 1.0.19
1081
+     * @param  string $context View or edit context.
1082
+     * @return string
1083
+     */
1084
+    public function get_customer_city( $context = 'view' ) {
1085
+        return $this->get_city( $context );
941 1086
     }
942 1087
 
943 1088
     /**
944
-	 * Get the customer's email address.
945
-	 *
946
-	 * @since 1.0.19
947
-	 * @param  string $context View or edit context.
948
-	 * @return string
949
-	 */
950
-	public function get_email( $context = 'view' ) {
951
-		return $this->get_prop( 'email', $context );
1089
+     * Get the customer's zip.
1090
+     *
1091
+     * @since 1.0.19
1092
+     * @param  string $context View or edit context.
1093
+     * @return string
1094
+     */
1095
+    public function get_zip( $context = 'view' ) {
1096
+        return $this->get_prop( 'zip', $context );
952 1097
     }
953 1098
 
954 1099
     /**
955
-	 * Alias of self::get_email().
956
-	 *
957
-	 * @since 1.0.19
958
-	 * @param  string $context View or edit context.
959
-	 * @return string
960
-	 */
961
-	public function get_email_address( $context = 'view' ) {
962
-		return $this->get_email( $context );
1100
+     * Alias of self::get_zip().
1101
+     *
1102
+     * @since 1.0.19
1103
+     * @param  string $context View or edit context.
1104
+     * @return string
1105
+     */
1106
+    public function get_user_zip( $context = 'view' ) {
1107
+        return $this->get_zip( $context );
963 1108
     }
964 1109
 
965 1110
     /**
966
-	 * Alias of self::get_email().
967
-	 *
968
-	 * @since 1.0.19
969
-	 * @param  string $context View or edit context.
970
-	 * @return int
971
-	 */
972
-	public function get_user_email( $context = 'view' ) {
973
-		return $this->get_email( $context );
1111
+     * Alias of self::get_zip().
1112
+     *
1113
+     * @since 1.0.19
1114
+     * @param  string $context View or edit context.
1115
+     * @return string
1116
+     */
1117
+    public function get_customer_zip( $context = 'view' ) {
1118
+        return $this->get_zip( $context );
974 1119
     }
975 1120
 
976 1121
     /**
977
-	 * Alias of self::get_email().
978
-	 *
979
-	 * @since 1.0.19
980
-	 * @param  string $context View or edit context.
981
-	 * @return int
982
-	 */
983
-	public function get_customer_email( $context = 'view' ) {
984
-		return $this->get_email( $context );
1122
+     * Get the customer's company.
1123
+     *
1124
+     * @since 1.0.19
1125
+     * @param  string $context View or edit context.
1126
+     * @return string
1127
+     */
1128
+    public function get_company( $context = 'view' ) {
1129
+        return $this->get_prop( 'company', $context );
985 1130
     }
986 1131
 
987 1132
     /**
988
-	 * Get the customer's country.
989
-	 *
990
-	 * @since 1.0.19
991
-	 * @param  string $context View or edit context.
992
-	 * @return string
993
-	 */
994
-	public function get_country( $context = 'view' ) {
995
-		$country = $this->get_prop( 'country', $context );
996
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1133
+     * Alias of self::get_company().
1134
+     *
1135
+     * @since 1.0.19
1136
+     * @param  string $context View or edit context.
1137
+     * @return string
1138
+     */
1139
+    public function get_user_company( $context = 'view' ) {
1140
+        return $this->get_company( $context );
997 1141
     }
998 1142
 
999 1143
     /**
1000
-	 * Alias of self::get_country().
1001
-	 *
1002
-	 * @since 1.0.19
1003
-	 * @param  string $context View or edit context.
1004
-	 * @return int
1005
-	 */
1006
-	public function get_user_country( $context = 'view' ) {
1007
-		return $this->get_country( $context );
1144
+     * Alias of self::get_company().
1145
+     *
1146
+     * @since 1.0.19
1147
+     * @param  string $context View or edit context.
1148
+     * @return string
1149
+     */
1150
+    public function get_customer_company( $context = 'view' ) {
1151
+        return $this->get_company( $context );
1008 1152
     }
1009 1153
 
1010 1154
     /**
1011
-	 * Alias of self::get_country().
1012
-	 *
1013
-	 * @since 1.0.19
1014
-	 * @param  string $context View or edit context.
1015
-	 * @return int
1016
-	 */
1017
-	public function get_customer_country( $context = 'view' ) {
1018
-		return $this->get_country( $context );
1155
+     * Get the customer's vat number.
1156
+     *
1157
+     * @since 1.0.19
1158
+     * @param  string $context View or edit context.
1159
+     * @return string
1160
+     */
1161
+    public function get_vat_number( $context = 'view' ) {
1162
+        return $this->get_prop( 'vat_number', $context );
1019 1163
     }
1020 1164
 
1021 1165
     /**
1022
-	 * Get the customer's state.
1023
-	 *
1024
-	 * @since 1.0.19
1025
-	 * @param  string $context View or edit context.
1026
-	 * @return string
1027
-	 */
1028
-	public function get_state( $context = 'view' ) {
1029
-		$state = $this->get_prop( 'state', $context );
1030
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1166
+     * Alias of self::get_vat_number().
1167
+     *
1168
+     * @since 1.0.19
1169
+     * @param  string $context View or edit context.
1170
+     * @return string
1171
+     */
1172
+    public function get_user_vat_number( $context = 'view' ) {
1173
+        return $this->get_vat_number( $context );
1031 1174
     }
1032 1175
 
1033 1176
     /**
1034
-	 * Alias of self::get_state().
1035
-	 *
1036
-	 * @since 1.0.19
1037
-	 * @param  string $context View or edit context.
1038
-	 * @return int
1039
-	 */
1040
-	public function get_user_state( $context = 'view' ) {
1041
-		return $this->get_state( $context );
1177
+     * Alias of self::get_vat_number().
1178
+     *
1179
+     * @since 1.0.19
1180
+     * @param  string $context View or edit context.
1181
+     * @return string
1182
+     */
1183
+    public function get_customer_vat_number( $context = 'view' ) {
1184
+        return $this->get_vat_number( $context );
1042 1185
     }
1043 1186
 
1044 1187
     /**
1045
-	 * Alias of self::get_state().
1046
-	 *
1047
-	 * @since 1.0.19
1048
-	 * @param  string $context View or edit context.
1049
-	 * @return int
1050
-	 */
1051
-	public function get_customer_state( $context = 'view' ) {
1052
-		return $this->get_state( $context );
1188
+     * Get the customer's vat rate.
1189
+     *
1190
+     * @since 1.0.19
1191
+     * @param  string $context View or edit context.
1192
+     * @return string
1193
+     */
1194
+    public function get_vat_rate( $context = 'view' ) {
1195
+        return $this->get_prop( 'vat_rate', $context );
1053 1196
     }
1054 1197
 
1055 1198
     /**
1056
-	 * Get the customer's city.
1057
-	 *
1058
-	 * @since 1.0.19
1059
-	 * @param  string $context View or edit context.
1060
-	 * @return string
1061
-	 */
1062
-	public function get_city( $context = 'view' ) {
1063
-		return $this->get_prop( 'city', $context );
1199
+     * Alias of self::get_vat_rate().
1200
+     *
1201
+     * @since 1.0.19
1202
+     * @param  string $context View or edit context.
1203
+     * @return string
1204
+     */
1205
+    public function get_user_vat_rate( $context = 'view' ) {
1206
+        return $this->get_vat_rate( $context );
1064 1207
     }
1065 1208
 
1066 1209
     /**
1067
-	 * Alias of self::get_city().
1068
-	 *
1069
-	 * @since 1.0.19
1070
-	 * @param  string $context View or edit context.
1071
-	 * @return string
1072
-	 */
1073
-	public function get_user_city( $context = 'view' ) {
1074
-		return $this->get_city( $context );
1210
+     * Alias of self::get_vat_rate().
1211
+     *
1212
+     * @since 1.0.19
1213
+     * @param  string $context View or edit context.
1214
+     * @return string
1215
+     */
1216
+    public function get_customer_vat_rate( $context = 'view' ) {
1217
+        return $this->get_vat_rate( $context );
1075 1218
     }
1076 1219
 
1077 1220
     /**
1078
-	 * Alias of self::get_city().
1079
-	 *
1080
-	 * @since 1.0.19
1081
-	 * @param  string $context View or edit context.
1082
-	 * @return string
1083
-	 */
1084
-	public function get_customer_city( $context = 'view' ) {
1085
-		return $this->get_city( $context );
1221
+     * Get the customer's address.
1222
+     *
1223
+     * @since 1.0.19
1224
+     * @param  string $context View or edit context.
1225
+     * @return string
1226
+     */
1227
+    public function get_address( $context = 'view' ) {
1228
+        return $this->get_prop( 'address', $context );
1086 1229
     }
1087 1230
 
1088 1231
     /**
1089
-	 * Get the customer's zip.
1090
-	 *
1091
-	 * @since 1.0.19
1092
-	 * @param  string $context View or edit context.
1093
-	 * @return string
1094
-	 */
1095
-	public function get_zip( $context = 'view' ) {
1096
-		return $this->get_prop( 'zip', $context );
1232
+     * Alias of self::get_address().
1233
+     *
1234
+     * @since 1.0.19
1235
+     * @param  string $context View or edit context.
1236
+     * @return string
1237
+     */
1238
+    public function get_user_address( $context = 'view' ) {
1239
+        return $this->get_address( $context );
1097 1240
     }
1098 1241
 
1099 1242
     /**
1100
-	 * Alias of self::get_zip().
1101
-	 *
1102
-	 * @since 1.0.19
1103
-	 * @param  string $context View or edit context.
1104
-	 * @return string
1105
-	 */
1106
-	public function get_user_zip( $context = 'view' ) {
1107
-		return $this->get_zip( $context );
1243
+     * Alias of self::get_address().
1244
+     *
1245
+     * @since 1.0.19
1246
+     * @param  string $context View or edit context.
1247
+     * @return string
1248
+     */
1249
+    public function get_customer_address( $context = 'view' ) {
1250
+        return $this->get_address( $context );
1108 1251
     }
1109 1252
 
1110 1253
     /**
1111
-	 * Alias of self::get_zip().
1112
-	 *
1113
-	 * @since 1.0.19
1114
-	 * @param  string $context View or edit context.
1115
-	 * @return string
1116
-	 */
1117
-	public function get_customer_zip( $context = 'view' ) {
1118
-		return $this->get_zip( $context );
1254
+     * Get whether the customer has viewed the invoice or not.
1255
+     *
1256
+     * @since 1.0.19
1257
+     * @param  string $context View or edit context.
1258
+     * @return bool
1259
+     */
1260
+    public function get_is_viewed( $context = 'view' ) {
1261
+        return (bool) $this->get_prop( 'is_viewed', $context );
1119 1262
     }
1120 1263
 
1121 1264
     /**
1122
-	 * Get the customer's company.
1123
-	 *
1124
-	 * @since 1.0.19
1125
-	 * @param  string $context View or edit context.
1126
-	 * @return string
1127
-	 */
1128
-	public function get_company( $context = 'view' ) {
1129
-		return $this->get_prop( 'company', $context );
1265
+     * Get other recipients for invoice communications.
1266
+     *
1267
+     * @since 1.0.19
1268
+     * @param  string $context View or edit context.
1269
+     * @return bool
1270
+     */
1271
+    public function get_email_cc( $context = 'view' ) {
1272
+        return $this->get_prop( 'email_cc', $context );
1130 1273
     }
1131 1274
 
1132 1275
     /**
1133
-	 * Alias of self::get_company().
1134
-	 *
1135
-	 * @since 1.0.19
1136
-	 * @param  string $context View or edit context.
1137
-	 * @return string
1138
-	 */
1139
-	public function get_user_company( $context = 'view' ) {
1140
-		return $this->get_company( $context );
1276
+     * Get invoice template.
1277
+     *
1278
+     * @since 1.0.19
1279
+     * @param  string $context View or edit context.
1280
+     * @return bool
1281
+     */
1282
+    public function get_template( $context = 'view' ) {
1283
+        return $this->get_prop( 'template', $context );
1141 1284
     }
1142 1285
 
1143 1286
     /**
1144
-	 * Alias of self::get_company().
1145
-	 *
1146
-	 * @since 1.0.19
1147
-	 * @param  string $context View or edit context.
1148
-	 * @return string
1149
-	 */
1150
-	public function get_customer_company( $context = 'view' ) {
1151
-		return $this->get_company( $context );
1287
+     * Get invoice source.
1288
+     *
1289
+     * @since 1.0.19
1290
+     * @param  string $context View or edit context.
1291
+     * @return bool
1292
+     */
1293
+    public function get_created_via( $context = 'view' ) {
1294
+        return $this->get_prop( 'created_via', $context );
1152 1295
     }
1153 1296
 
1154 1297
     /**
1155
-	 * Get the customer's vat number.
1156
-	 *
1157
-	 * @since 1.0.19
1158
-	 * @param  string $context View or edit context.
1159
-	 * @return string
1160
-	 */
1161
-	public function get_vat_number( $context = 'view' ) {
1162
-		return $this->get_prop( 'vat_number', $context );
1298
+     * Get whether the customer has confirmed their address.
1299
+     *
1300
+     * @since 1.0.19
1301
+     * @param  string $context View or edit context.
1302
+     * @return bool
1303
+     */
1304
+    public function get_address_confirmed( $context = 'view' ) {
1305
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1163 1306
     }
1164 1307
 
1165 1308
     /**
1166
-	 * Alias of self::get_vat_number().
1167
-	 *
1168
-	 * @since 1.0.19
1169
-	 * @param  string $context View or edit context.
1170
-	 * @return string
1171
-	 */
1172
-	public function get_user_vat_number( $context = 'view' ) {
1173
-		return $this->get_vat_number( $context );
1309
+     * Alias of self::get_address_confirmed().
1310
+     *
1311
+     * @since 1.0.19
1312
+     * @param  string $context View or edit context.
1313
+     * @return bool
1314
+     */
1315
+    public function get_user_address_confirmed( $context = 'view' ) {
1316
+        return $this->get_address_confirmed( $context );
1174 1317
     }
1175 1318
 
1176 1319
     /**
1177
-	 * Alias of self::get_vat_number().
1178
-	 *
1179
-	 * @since 1.0.19
1180
-	 * @param  string $context View or edit context.
1181
-	 * @return string
1182
-	 */
1183
-	public function get_customer_vat_number( $context = 'view' ) {
1184
-		return $this->get_vat_number( $context );
1320
+     * Alias of self::get_address().
1321
+     *
1322
+     * @since 1.0.19
1323
+     * @param  string $context View or edit context.
1324
+     * @return bool
1325
+     */
1326
+    public function get_customer_address_confirmed( $context = 'view' ) {
1327
+        return $this->get_address_confirmed( $context );
1185 1328
     }
1186 1329
 
1187 1330
     /**
1188
-	 * Get the customer's vat rate.
1189
-	 *
1190
-	 * @since 1.0.19
1191
-	 * @param  string $context View or edit context.
1192
-	 * @return string
1193
-	 */
1194
-	public function get_vat_rate( $context = 'view' ) {
1195
-		return $this->get_prop( 'vat_rate', $context );
1196
-    }
1197
-
1198
-    /**
1199
-	 * Alias of self::get_vat_rate().
1200
-	 *
1201
-	 * @since 1.0.19
1202
-	 * @param  string $context View or edit context.
1203
-	 * @return string
1204
-	 */
1205
-	public function get_user_vat_rate( $context = 'view' ) {
1206
-		return $this->get_vat_rate( $context );
1207
-    }
1208
-
1209
-    /**
1210
-	 * Alias of self::get_vat_rate().
1211
-	 *
1212
-	 * @since 1.0.19
1213
-	 * @param  string $context View or edit context.
1214
-	 * @return string
1215
-	 */
1216
-	public function get_customer_vat_rate( $context = 'view' ) {
1217
-		return $this->get_vat_rate( $context );
1218
-    }
1219
-
1220
-    /**
1221
-	 * Get the customer's address.
1222
-	 *
1223
-	 * @since 1.0.19
1224
-	 * @param  string $context View or edit context.
1225
-	 * @return string
1226
-	 */
1227
-	public function get_address( $context = 'view' ) {
1228
-		return $this->get_prop( 'address', $context );
1229
-    }
1230
-
1231
-    /**
1232
-	 * Alias of self::get_address().
1233
-	 *
1234
-	 * @since 1.0.19
1235
-	 * @param  string $context View or edit context.
1236
-	 * @return string
1237
-	 */
1238
-	public function get_user_address( $context = 'view' ) {
1239
-		return $this->get_address( $context );
1240
-    }
1241
-
1242
-    /**
1243
-	 * Alias of self::get_address().
1244
-	 *
1245
-	 * @since 1.0.19
1246
-	 * @param  string $context View or edit context.
1247
-	 * @return string
1248
-	 */
1249
-	public function get_customer_address( $context = 'view' ) {
1250
-		return $this->get_address( $context );
1251
-    }
1252
-
1253
-    /**
1254
-	 * Get whether the customer has viewed the invoice or not.
1255
-	 *
1256
-	 * @since 1.0.19
1257
-	 * @param  string $context View or edit context.
1258
-	 * @return bool
1259
-	 */
1260
-	public function get_is_viewed( $context = 'view' ) {
1261
-		return (bool) $this->get_prop( 'is_viewed', $context );
1262
-	}
1263
-
1264
-	/**
1265
-	 * Get other recipients for invoice communications.
1266
-	 *
1267
-	 * @since 1.0.19
1268
-	 * @param  string $context View or edit context.
1269
-	 * @return bool
1270
-	 */
1271
-	public function get_email_cc( $context = 'view' ) {
1272
-		return $this->get_prop( 'email_cc', $context );
1273
-	}
1274
-
1275
-	/**
1276
-	 * Get invoice template.
1277
-	 *
1278
-	 * @since 1.0.19
1279
-	 * @param  string $context View or edit context.
1280
-	 * @return bool
1281
-	 */
1282
-	public function get_template( $context = 'view' ) {
1283
-		return $this->get_prop( 'template', $context );
1284
-	}
1285
-
1286
-	/**
1287
-	 * Get invoice source.
1288
-	 *
1289
-	 * @since 1.0.19
1290
-	 * @param  string $context View or edit context.
1291
-	 * @return bool
1292
-	 */
1293
-	public function get_created_via( $context = 'view' ) {
1294
-		return $this->get_prop( 'created_via', $context );
1295
-	}
1296
-
1297
-	/**
1298
-	 * Get whether the customer has confirmed their address.
1299
-	 *
1300
-	 * @since 1.0.19
1301
-	 * @param  string $context View or edit context.
1302
-	 * @return bool
1303
-	 */
1304
-	public function get_address_confirmed( $context = 'view' ) {
1305
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1306
-    }
1307
-
1308
-    /**
1309
-	 * Alias of self::get_address_confirmed().
1310
-	 *
1311
-	 * @since 1.0.19
1312
-	 * @param  string $context View or edit context.
1313
-	 * @return bool
1314
-	 */
1315
-	public function get_user_address_confirmed( $context = 'view' ) {
1316
-		return $this->get_address_confirmed( $context );
1317
-    }
1318
-
1319
-    /**
1320
-	 * Alias of self::get_address().
1321
-	 *
1322
-	 * @since 1.0.19
1323
-	 * @param  string $context View or edit context.
1324
-	 * @return bool
1325
-	 */
1326
-	public function get_customer_address_confirmed( $context = 'view' ) {
1327
-		return $this->get_address_confirmed( $context );
1328
-    }
1329
-
1330
-    /**
1331
-	 * Get the invoice subtotal.
1332
-	 *
1333
-	 * @since 1.0.19
1334
-	 * @param  string $context View or edit context.
1335
-	 * @return float
1336
-	 */
1337
-	public function get_subtotal( $context = 'view' ) {
1331
+     * Get the invoice subtotal.
1332
+     *
1333
+     * @since 1.0.19
1334
+     * @param  string $context View or edit context.
1335
+     * @return float
1336
+     */
1337
+    public function get_subtotal( $context = 'view' ) {
1338 1338
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1339 1339
 
1340 1340
         // Backwards compatibility.
@@ -1346,165 +1346,165 @@  discard block
 block discarded – undo
1346 1346
     }
1347 1347
 
1348 1348
     /**
1349
-	 * Get the invoice discount total.
1350
-	 *
1351
-	 * @since 1.0.19
1352
-	 * @param  string $context View or edit context.
1353
-	 * @return float
1354
-	 */
1355
-	public function get_total_discount( $context = 'view' ) {
1356
-		return (float) $this->get_prop( 'total_discount', $context );
1349
+     * Get the invoice discount total.
1350
+     *
1351
+     * @since 1.0.19
1352
+     * @param  string $context View or edit context.
1353
+     * @return float
1354
+     */
1355
+    public function get_total_discount( $context = 'view' ) {
1356
+        return (float) $this->get_prop( 'total_discount', $context );
1357 1357
     }
1358 1358
 
1359 1359
     /**
1360
-	 * Get the invoice tax total.
1361
-	 *
1362
-	 * @since 1.0.19
1363
-	 * @param  string $context View or edit context.
1364
-	 * @return float
1365
-	 */
1366
-	public function get_total_tax( $context = 'view' ) {
1367
-		return (float) $this->get_prop( 'total_tax', $context );
1368
-	}
1360
+     * Get the invoice tax total.
1361
+     *
1362
+     * @since 1.0.19
1363
+     * @param  string $context View or edit context.
1364
+     * @return float
1365
+     */
1366
+    public function get_total_tax( $context = 'view' ) {
1367
+        return (float) $this->get_prop( 'total_tax', $context );
1368
+    }
1369 1369
 
1370
-	/**
1371
-	 * @deprecated
1372
-	 */
1373
-	public function get_final_tax( $currency = false ) {
1374
-		$tax = $this->get_total_tax();
1370
+    /**
1371
+     * @deprecated
1372
+     */
1373
+    public function get_final_tax( $currency = false ) {
1374
+        $tax = $this->get_total_tax();
1375 1375
 
1376 1376
         if ( $currency ) {
1377
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1377
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1378 1378
         }
1379 1379
 
1380 1380
         return $tax;
1381 1381
     }
1382 1382
 
1383 1383
     /**
1384
-	 * Get the invoice fees total.
1385
-	 *
1386
-	 * @since 1.0.19
1387
-	 * @param  string $context View or edit context.
1388
-	 * @return float
1389
-	 */
1390
-	public function get_total_fees( $context = 'view' ) {
1391
-		return (float) $this->get_prop( 'total_fees', $context );
1384
+     * Get the invoice fees total.
1385
+     *
1386
+     * @since 1.0.19
1387
+     * @param  string $context View or edit context.
1388
+     * @return float
1389
+     */
1390
+    public function get_total_fees( $context = 'view' ) {
1391
+        return (float) $this->get_prop( 'total_fees', $context );
1392 1392
     }
1393 1393
 
1394 1394
     /**
1395
-	 * Alias for self::get_total_fees().
1396
-	 *
1397
-	 * @since 1.0.19
1398
-	 * @param  string $context View or edit context.
1399
-	 * @return float
1400
-	 */
1401
-	public function get_fees_total( $context = 'view' ) {
1402
-		return $this->get_total_fees( $context );
1395
+     * Alias for self::get_total_fees().
1396
+     *
1397
+     * @since 1.0.19
1398
+     * @param  string $context View or edit context.
1399
+     * @return float
1400
+     */
1401
+    public function get_fees_total( $context = 'view' ) {
1402
+        return $this->get_total_fees( $context );
1403 1403
     }
1404 1404
 
1405 1405
     /**
1406
-	 * Get the invoice total.
1407
-	 *
1408
-	 * @since 1.0.19
1406
+     * Get the invoice total.
1407
+     *
1408
+     * @since 1.0.19
1409 1409
      * @return float
1410
-	 */
1411
-	public function get_total() {
1412
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1413
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1414
-	}
1410
+     */
1411
+    public function get_total() {
1412
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1413
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1414
+    }
1415 1415
 	
1416
-	/**
1417
-	 * Get the invoice totals.
1418
-	 *
1419
-	 * @since 1.0.19
1416
+    /**
1417
+     * Get the invoice totals.
1418
+     *
1419
+     * @since 1.0.19
1420 1420
      * @return float
1421
-	 */
1422
-	public function get_totals() {
1423
-		return $this->totals;
1421
+     */
1422
+    public function get_totals() {
1423
+        return $this->totals;
1424 1424
     }
1425 1425
 
1426 1426
     /**
1427
-	 * Get the initial invoice total.
1428
-	 *
1429
-	 * @since 1.0.19
1427
+     * Get the initial invoice total.
1428
+     *
1429
+     * @since 1.0.19
1430 1430
      * @param  string $context View or edit context.
1431 1431
      * @return float
1432
-	 */
1432
+     */
1433 1433
     public function get_initial_total() {
1434 1434
 
1435
-		if ( empty( $this->totals ) ) {
1436
-			$this->recalculate_total();
1437
-		}
1435
+        if ( empty( $this->totals ) ) {
1436
+            $this->recalculate_total();
1437
+        }
1438 1438
 
1439
-		$tax      = $this->totals['tax']['initial'];
1440
-		$fee      = $this->totals['fee']['initial'];
1441
-		$discount = $this->totals['discount']['initial'];
1442
-		$subtotal = $this->totals['subtotal']['initial'];
1443
-		$total    = $tax + $fee - $discount + $subtotal;
1439
+        $tax      = $this->totals['tax']['initial'];
1440
+        $fee      = $this->totals['fee']['initial'];
1441
+        $discount = $this->totals['discount']['initial'];
1442
+        $subtotal = $this->totals['subtotal']['initial'];
1443
+        $total    = $tax + $fee - $discount + $subtotal;
1444 1444
 
1445
-		if ( 0 > $total ) {
1446
-			$total = 0;
1447
-		}
1445
+        if ( 0 > $total ) {
1446
+            $total = 0;
1447
+        }
1448 1448
 
1449 1449
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1450
-	}
1450
+    }
1451 1451
 
1452
-	/**
1453
-	 * Get the recurring invoice total.
1454
-	 *
1455
-	 * @since 1.0.19
1452
+    /**
1453
+     * Get the recurring invoice total.
1454
+     *
1455
+     * @since 1.0.19
1456 1456
      * @param  string $context View or edit context.
1457 1457
      * @return float
1458
-	 */
1458
+     */
1459 1459
     public function get_recurring_total() {
1460 1460
 
1461
-		if ( empty( $this->totals ) ) {
1462
-			$this->recalculate_total();
1463
-		}
1461
+        if ( empty( $this->totals ) ) {
1462
+            $this->recalculate_total();
1463
+        }
1464 1464
 
1465
-		$tax      = $this->totals['tax']['recurring'];
1466
-		$fee      = $this->totals['fee']['recurring'];
1467
-		$discount = $this->totals['discount']['recurring'];
1468
-		$subtotal = $this->totals['subtotal']['recurring'];
1469
-		$total    = $tax + $fee - $discount + $subtotal;
1465
+        $tax      = $this->totals['tax']['recurring'];
1466
+        $fee      = $this->totals['fee']['recurring'];
1467
+        $discount = $this->totals['discount']['recurring'];
1468
+        $subtotal = $this->totals['subtotal']['recurring'];
1469
+        $total    = $tax + $fee - $discount + $subtotal;
1470 1470
 
1471
-		if ( 0 > $total ) {
1472
-			$total = 0;
1473
-		}
1471
+        if ( 0 > $total ) {
1472
+            $total = 0;
1473
+        }
1474 1474
 
1475 1475
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1476
-	}
1476
+    }
1477 1477
 
1478
-	/**
1479
-	 * Returns recurring payment details.
1480
-	 *
1481
-	 * @since 1.0.19
1478
+    /**
1479
+     * Returns recurring payment details.
1480
+     *
1481
+     * @since 1.0.19
1482 1482
      * @param  string $field Optionally provide a field to return.
1483
-	 * @param string $currency Whether to include the currency.
1483
+     * @param string $currency Whether to include the currency.
1484 1484
      * @return float
1485
-	 */
1485
+     */
1486 1486
     public function get_recurring_details( $field = '', $currency = false ) {
1487 1487
 
1488
-		// Maybe recalculate totals.
1489
-		if ( empty( $this->totals ) ) {
1490
-			$this->recalculate_total();
1491
-		}
1488
+        // Maybe recalculate totals.
1489
+        if ( empty( $this->totals ) ) {
1490
+            $this->recalculate_total();
1491
+        }
1492 1492
 
1493
-		// Prepare recurring totals.
1493
+        // Prepare recurring totals.
1494 1494
         $data = apply_filters(
1495
-			'wpinv_get_invoice_recurring_details',
1496
-			array(
1497
-				'cart_details' => $this->get_cart_details(),
1498
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1499
-				'discount'     => $this->totals['discount']['recurring'],
1500
-				'tax'          => $this->totals['tax']['recurring'],
1501
-				'fee'          => $this->totals['fee']['recurring'],
1502
-				'total'        => $this->get_recurring_total(),
1503
-			),
1504
-			$this,
1505
-			$field,
1506
-			$currency
1507
-		);
1495
+            'wpinv_get_invoice_recurring_details',
1496
+            array(
1497
+                'cart_details' => $this->get_cart_details(),
1498
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1499
+                'discount'     => $this->totals['discount']['recurring'],
1500
+                'tax'          => $this->totals['tax']['recurring'],
1501
+                'fee'          => $this->totals['fee']['recurring'],
1502
+                'total'        => $this->get_recurring_total(),
1503
+            ),
1504
+            $this,
1505
+            $field,
1506
+            $currency
1507
+        );
1508 1508
 
1509 1509
         if ( isset( $data[$field] ) ) {
1510 1510
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1514,156 +1514,156 @@  discard block
 block discarded – undo
1514 1514
     }
1515 1515
 
1516 1516
     /**
1517
-	 * Get the invoice fees.
1518
-	 *
1519
-	 * @since 1.0.19
1520
-	 * @param  string $context View or edit context.
1521
-	 * @return array
1522
-	 */
1523
-	public function get_fees( $context = 'view' ) {
1524
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1517
+     * Get the invoice fees.
1518
+     *
1519
+     * @since 1.0.19
1520
+     * @param  string $context View or edit context.
1521
+     * @return array
1522
+     */
1523
+    public function get_fees( $context = 'view' ) {
1524
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1525 1525
     }
1526 1526
 
1527 1527
     /**
1528
-	 * Get the invoice discounts.
1529
-	 *
1530
-	 * @since 1.0.19
1531
-	 * @param  string $context View or edit context.
1532
-	 * @return array
1533
-	 */
1534
-	public function get_discounts( $context = 'view' ) {
1535
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1528
+     * Get the invoice discounts.
1529
+     *
1530
+     * @since 1.0.19
1531
+     * @param  string $context View or edit context.
1532
+     * @return array
1533
+     */
1534
+    public function get_discounts( $context = 'view' ) {
1535
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1536 1536
     }
1537 1537
 
1538 1538
     /**
1539
-	 * Get the invoice taxes.
1540
-	 *
1541
-	 * @since 1.0.19
1542
-	 * @param  string $context View or edit context.
1543
-	 * @return array
1544
-	 */
1545
-	public function get_taxes( $context = 'view' ) {
1546
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1539
+     * Get the invoice taxes.
1540
+     *
1541
+     * @since 1.0.19
1542
+     * @param  string $context View or edit context.
1543
+     * @return array
1544
+     */
1545
+    public function get_taxes( $context = 'view' ) {
1546
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1547 1547
     }
1548 1548
 
1549 1549
     /**
1550
-	 * Get the invoice items.
1551
-	 *
1552
-	 * @since 1.0.19
1553
-	 * @param  string $context View or edit context.
1554
-	 * @return GetPaid_Form_Item[]
1555
-	 */
1556
-	public function get_items( $context = 'view' ) {
1550
+     * Get the invoice items.
1551
+     *
1552
+     * @since 1.0.19
1553
+     * @param  string $context View or edit context.
1554
+     * @return GetPaid_Form_Item[]
1555
+     */
1556
+    public function get_items( $context = 'view' ) {
1557 1557
         return $this->get_prop( 'items', $context );
1558 1558
     }
1559 1559
 
1560 1560
     /**
1561
-	 * Get the invoice's payment form.
1562
-	 *
1563
-	 * @since 1.0.19
1564
-	 * @param  string $context View or edit context.
1565
-	 * @return int
1566
-	 */
1567
-	public function get_payment_form( $context = 'view' ) {
1568
-		return intval( $this->get_prop( 'payment_form', $context ) );
1561
+     * Get the invoice's payment form.
1562
+     *
1563
+     * @since 1.0.19
1564
+     * @param  string $context View or edit context.
1565
+     * @return int
1566
+     */
1567
+    public function get_payment_form( $context = 'view' ) {
1568
+        return intval( $this->get_prop( 'payment_form', $context ) );
1569 1569
     }
1570 1570
 
1571 1571
     /**
1572
-	 * Get the invoice's submission id.
1573
-	 *
1574
-	 * @since 1.0.19
1575
-	 * @param  string $context View or edit context.
1576
-	 * @return string
1577
-	 */
1578
-	public function get_submission_id( $context = 'view' ) {
1579
-		return $this->get_prop( 'submission_id', $context );
1572
+     * Get the invoice's submission id.
1573
+     *
1574
+     * @since 1.0.19
1575
+     * @param  string $context View or edit context.
1576
+     * @return string
1577
+     */
1578
+    public function get_submission_id( $context = 'view' ) {
1579
+        return $this->get_prop( 'submission_id', $context );
1580 1580
     }
1581 1581
 
1582 1582
     /**
1583
-	 * Get the invoice's discount code.
1584
-	 *
1585
-	 * @since 1.0.19
1586
-	 * @param  string $context View or edit context.
1587
-	 * @return string
1588
-	 */
1589
-	public function get_discount_code( $context = 'view' ) {
1590
-		return $this->get_prop( 'discount_code', $context );
1583
+     * Get the invoice's discount code.
1584
+     *
1585
+     * @since 1.0.19
1586
+     * @param  string $context View or edit context.
1587
+     * @return string
1588
+     */
1589
+    public function get_discount_code( $context = 'view' ) {
1590
+        return $this->get_prop( 'discount_code', $context );
1591 1591
     }
1592 1592
 
1593 1593
     /**
1594
-	 * Get the invoice's gateway.
1595
-	 *
1596
-	 * @since 1.0.19
1597
-	 * @param  string $context View or edit context.
1598
-	 * @return string
1599
-	 */
1600
-	public function get_gateway( $context = 'view' ) {
1601
-		return $this->get_prop( 'gateway', $context );
1594
+     * Get the invoice's gateway.
1595
+     *
1596
+     * @since 1.0.19
1597
+     * @param  string $context View or edit context.
1598
+     * @return string
1599
+     */
1600
+    public function get_gateway( $context = 'view' ) {
1601
+        return $this->get_prop( 'gateway', $context );
1602 1602
     }
1603 1603
 
1604 1604
     /**
1605
-	 * Get the invoice's gateway display title.
1606
-	 *
1607
-	 * @since 1.0.19
1608
-	 * @return string
1609
-	 */
1605
+     * Get the invoice's gateway display title.
1606
+     *
1607
+     * @since 1.0.19
1608
+     * @return string
1609
+     */
1610 1610
     public function get_gateway_title() {
1611 1611
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1612 1612
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1613 1613
     }
1614 1614
 
1615 1615
     /**
1616
-	 * Get the invoice's transaction id.
1617
-	 *
1618
-	 * @since 1.0.19
1619
-	 * @param  string $context View or edit context.
1620
-	 * @return string
1621
-	 */
1622
-	public function get_transaction_id( $context = 'view' ) {
1623
-		return $this->get_prop( 'transaction_id', $context );
1616
+     * Get the invoice's transaction id.
1617
+     *
1618
+     * @since 1.0.19
1619
+     * @param  string $context View or edit context.
1620
+     * @return string
1621
+     */
1622
+    public function get_transaction_id( $context = 'view' ) {
1623
+        return $this->get_prop( 'transaction_id', $context );
1624 1624
     }
1625 1625
 
1626 1626
     /**
1627
-	 * Get the invoice's currency.
1628
-	 *
1629
-	 * @since 1.0.19
1630
-	 * @param  string $context View or edit context.
1631
-	 * @return string
1632
-	 */
1633
-	public function get_currency( $context = 'view' ) {
1627
+     * Get the invoice's currency.
1628
+     *
1629
+     * @since 1.0.19
1630
+     * @param  string $context View or edit context.
1631
+     * @return string
1632
+     */
1633
+    public function get_currency( $context = 'view' ) {
1634 1634
         $currency = $this->get_prop( 'currency', $context );
1635 1635
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1636 1636
     }
1637 1637
 
1638 1638
     /**
1639
-	 * Checks if we are charging taxes for this invoice.
1640
-	 *
1641
-	 * @since 1.0.19
1642
-	 * @param  string $context View or edit context.
1643
-	 * @return bool
1644
-	 */
1645
-	public function get_disable_taxes( $context = 'view' ) {
1639
+     * Checks if we are charging taxes for this invoice.
1640
+     *
1641
+     * @since 1.0.19
1642
+     * @param  string $context View or edit context.
1643
+     * @return bool
1644
+     */
1645
+    public function get_disable_taxes( $context = 'view' ) {
1646 1646
         return (bool) $this->get_prop( 'disable_taxes', $context );
1647 1647
     }
1648 1648
 
1649 1649
     /**
1650
-	 * Retrieves the subscription id for an invoice.
1651
-	 *
1652
-	 * @since 1.0.19
1653
-	 * @param  string $context View or edit context.
1654
-	 * @return int
1655
-	 */
1650
+     * Retrieves the subscription id for an invoice.
1651
+     *
1652
+     * @since 1.0.19
1653
+     * @param  string $context View or edit context.
1654
+     * @return int
1655
+     */
1656 1656
     public function get_subscription_id( $context = 'view' ) {
1657
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1658
-	}
1659
-
1660
-	/**
1661
-	 * Retrieves the remote subscription id for an invoice.
1662
-	 *
1663
-	 * @since 1.0.19
1664
-	 * @param  string $context View or edit context.
1665
-	 * @return int
1666
-	 */
1657
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1658
+    }
1659
+
1660
+    /**
1661
+     * Retrieves the remote subscription id for an invoice.
1662
+     *
1663
+     * @since 1.0.19
1664
+     * @param  string $context View or edit context.
1665
+     * @return int
1666
+     */
1667 1667
     public function get_remote_subscription_id( $context = 'view' ) {
1668 1668
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1669 1669
 
@@ -1676,12 +1676,12 @@  discard block
 block discarded – undo
1676 1676
     }
1677 1677
 
1678 1678
     /**
1679
-	 * Retrieves the payment meta for an invoice.
1680
-	 *
1681
-	 * @since 1.0.19
1682
-	 * @param  string $context View or edit context.
1683
-	 * @return array
1684
-	 */
1679
+     * Retrieves the payment meta for an invoice.
1680
+     *
1681
+     * @since 1.0.19
1682
+     * @param  string $context View or edit context.
1683
+     * @return array
1684
+     */
1685 1685
     public function get_payment_meta( $context = 'view' ) {
1686 1686
 
1687 1687
         return array(
@@ -1701,31 +1701,31 @@  discard block
 block discarded – undo
1701 1701
     }
1702 1702
 
1703 1703
     /**
1704
-	 * Retrieves the cart details for an invoice.
1705
-	 *
1706
-	 * @since 1.0.19
1707
-	 * @return array
1708
-	 */
1704
+     * Retrieves the cart details for an invoice.
1705
+     *
1706
+     * @since 1.0.19
1707
+     * @return array
1708
+     */
1709 1709
     public function get_cart_details() {
1710 1710
         $items        = $this->get_items();
1711 1711
         $cart_details = array();
1712 1712
 
1713 1713
         foreach ( $items as $item_id => $item ) {
1714
-			$item->invoice_id = $this->get_id();
1714
+            $item->invoice_id = $this->get_id();
1715 1715
             $cart_details[]   = $item->prepare_data_for_saving();
1716 1716
         }
1717 1717
 
1718 1718
         return $cart_details;
1719
-	}
1719
+    }
1720 1720
 
1721
-	/**
1722
-	 * Retrieves the recurring item.
1723
-	 *
1724
-	 * @return null|GetPaid_Form_Item|int
1725
-	 */
1726
-	public function get_recurring( $object = false ) {
1721
+    /**
1722
+     * Retrieves the recurring item.
1723
+     *
1724
+     * @return null|GetPaid_Form_Item|int
1725
+     */
1726
+    public function get_recurring( $object = false ) {
1727 1727
 
1728
-		// Are we returning an object?
1728
+        // Are we returning an object?
1729 1729
         if ( $object ) {
1730 1730
             return $this->get_item( $this->recurring_item );
1731 1731
         }
@@ -1733,100 +1733,100 @@  discard block
 block discarded – undo
1733 1733
         return $this->recurring_item;
1734 1734
     }
1735 1735
 
1736
-	/**
1737
-	 * Retrieves the subscription name.
1738
-	 *
1739
-	 * @since 1.0.19
1740
-	 * @return string
1741
-	 */
1742
-	public function get_subscription_name() {
1736
+    /**
1737
+     * Retrieves the subscription name.
1738
+     *
1739
+     * @since 1.0.19
1740
+     * @return string
1741
+     */
1742
+    public function get_subscription_name() {
1743 1743
 
1744
-		// Retrieve the recurring name
1744
+        // Retrieve the recurring name
1745 1745
         $item = $this->get_recurring( true );
1746 1746
 
1747
-		// Abort if it does not exist.
1747
+        // Abort if it does not exist.
1748 1748
         if ( empty( $item ) ) {
1749 1749
             return '';
1750 1750
         }
1751 1751
 
1752
-		// Return the item name.
1752
+        // Return the item name.
1753 1753
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1754
-	}
1755
-
1756
-	/**
1757
-	 * Retrieves the view url.
1758
-	 *
1759
-	 * @since 1.0.19
1760
-	 * @return string
1761
-	 */
1762
-	public function get_view_url() {
1754
+    }
1755
+
1756
+    /**
1757
+     * Retrieves the view url.
1758
+     *
1759
+     * @since 1.0.19
1760
+     * @return string
1761
+     */
1762
+    public function get_view_url() {
1763 1763
         $invoice_url = get_permalink( $this->get_id() );
1764
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1764
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1765 1765
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1766
-	}
1766
+    }
1767 1767
 
1768
-	/**
1769
-	 * Retrieves the payment url.
1770
-	 *
1771
-	 * @since 1.0.19
1772
-	 * @return string
1773
-	 */
1774
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1768
+    /**
1769
+     * Retrieves the payment url.
1770
+     *
1771
+     * @since 1.0.19
1772
+     * @return string
1773
+     */
1774
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1775 1775
 
1776
-		// Retrieve the checkout url.
1776
+        // Retrieve the checkout url.
1777 1777
         $pay_url = wpinv_get_checkout_uri();
1778 1778
 
1779
-		// Maybe force ssl.
1779
+        // Maybe force ssl.
1780 1780
         if ( is_ssl() ) {
1781 1781
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1782 1782
         }
1783 1783
 
1784
-		// Add the invoice key.
1785
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1784
+        // Add the invoice key.
1785
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1786 1786
 
1787
-		// (Maybe?) add a secret
1787
+        // (Maybe?) add a secret
1788 1788
         if ( $secret ) {
1789 1789
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1790 1790
         }
1791 1791
 
1792 1792
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1793
-	}
1793
+    }
1794 1794
 	
1795
-	/**
1796
-	 * Retrieves the receipt url.
1797
-	 *
1798
-	 * @since 1.0.19
1799
-	 * @return string
1800
-	 */
1801
-	public function get_receipt_url() {
1802
-
1803
-		// Retrieve the checkout url.
1795
+    /**
1796
+     * Retrieves the receipt url.
1797
+     *
1798
+     * @since 1.0.19
1799
+     * @return string
1800
+     */
1801
+    public function get_receipt_url() {
1802
+
1803
+        // Retrieve the checkout url.
1804 1804
         $receipt_url = wpinv_get_success_page_uri();
1805 1805
 
1806
-		// Maybe force ssl.
1806
+        // Maybe force ssl.
1807 1807
         if ( is_ssl() ) {
1808 1808
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1809 1809
         }
1810 1810
 
1811
-		// Add the invoice key.
1812
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1811
+        // Add the invoice key.
1812
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1813 1813
 
1814 1814
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1815 1815
     }
1816 1816
 
1817 1817
     /**
1818
-	 * Magic method for accessing invoice properties.
1819
-	 *
1820
-	 * @since 1.0.15
1821
-	 * @access public
1822
-	 *
1823
-	 * @param string $key Discount data to retrieve
1824
-	 * @param  string $context View or edit context.
1825
-	 * @return mixed Value of the given invoice property (if set).
1826
-	 */
1827
-	public function get( $key, $context = 'view' ) {
1818
+     * Magic method for accessing invoice properties.
1819
+     *
1820
+     * @since 1.0.15
1821
+     * @access public
1822
+     *
1823
+     * @param string $key Discount data to retrieve
1824
+     * @param  string $context View or edit context.
1825
+     * @return mixed Value of the given invoice property (if set).
1826
+     */
1827
+    public function get( $key, $context = 'view' ) {
1828 1828
         return $this->get_prop( $key, $context );
1829
-	}
1829
+    }
1830 1830
 
1831 1831
     /*
1832 1832
 	|--------------------------------------------------------------------------
@@ -1839,130 +1839,130 @@  discard block
 block discarded – undo
1839 1839
     */
1840 1840
 
1841 1841
     /**
1842
-	 * Magic method for setting invoice properties.
1843
-	 *
1844
-	 * @since 1.0.19
1845
-	 * @access public
1846
-	 *
1847
-	 * @param string $key Discount data to retrieve
1848
-	 * @param  mixed $value new value.
1849
-	 * @return mixed Value of the given invoice property (if set).
1850
-	 */
1851
-	public function set( $key, $value ) {
1842
+     * Magic method for setting invoice properties.
1843
+     *
1844
+     * @since 1.0.19
1845
+     * @access public
1846
+     *
1847
+     * @param string $key Discount data to retrieve
1848
+     * @param  mixed $value new value.
1849
+     * @return mixed Value of the given invoice property (if set).
1850
+     */
1851
+    public function set( $key, $value ) {
1852 1852
 
1853 1853
         $setter = "set_$key";
1854 1854
         if ( is_callable( array( $this, $setter ) ) ) {
1855 1855
             $this->{$setter}( $value );
1856 1856
         }
1857 1857
 
1858
-	}
1858
+    }
1859 1859
 
1860
-	/**
1861
-	 * Sets item status.
1862
-	 *
1863
-	 * @since 1.0.19
1864
-	 * @param string $new_status    New status.
1865
-	 * @param string $note          Optional note to add.
1866
-	 * @param bool   $manual_update Is this a manual status change?.
1867
-	 * @return array details of change.
1868
-	 */
1869
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1870
-		$old_status = $this->get_status();
1860
+    /**
1861
+     * Sets item status.
1862
+     *
1863
+     * @since 1.0.19
1864
+     * @param string $new_status    New status.
1865
+     * @param string $note          Optional note to add.
1866
+     * @param bool   $manual_update Is this a manual status change?.
1867
+     * @return array details of change.
1868
+     */
1869
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1870
+        $old_status = $this->get_status();
1871 1871
 
1872
-		$statuses = $this->get_all_statuses();
1872
+        $statuses = $this->get_all_statuses();
1873 1873
 
1874
-		if ( isset( $statuses[ 'draft' ] ) ) {
1875
-			unset( $statuses[ 'draft' ] );
1876
-		}
1874
+        if ( isset( $statuses[ 'draft' ] ) ) {
1875
+            unset( $statuses[ 'draft' ] );
1876
+        }
1877 1877
 
1878
-		$this->set_prop( 'status', $new_status );
1878
+        $this->set_prop( 'status', $new_status );
1879 1879
 
1880
-		// If setting the status, ensure it's set to a valid status.
1881
-		if ( true === $this->object_read ) {
1880
+        // If setting the status, ensure it's set to a valid status.
1881
+        if ( true === $this->object_read ) {
1882 1882
 
1883
-			// Only allow valid new status.
1884
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1885
-				$new_status = 'wpi-pending';
1886
-			}
1883
+            // Only allow valid new status.
1884
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1885
+                $new_status = 'wpi-pending';
1886
+            }
1887 1887
 
1888
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1889
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1890
-				$old_status = 'wpi-pending';
1891
-			}
1888
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1889
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1890
+                $old_status = 'wpi-pending';
1891
+            }
1892 1892
 
1893
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1894
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1895
-				$old_status = 'wpi-pending';
1896
-			}
1893
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1894
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1895
+                $old_status = 'wpi-pending';
1896
+            }
1897 1897
 
1898
-		}
1898
+        }
1899 1899
 
1900
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1901
-			$this->status_transition = array(
1902
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1903
-				'to'     => $new_status,
1904
-				'note'   => $note,
1905
-				'manual' => (bool) $manual_update,
1906
-			);
1900
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1901
+            $this->status_transition = array(
1902
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1903
+                'to'     => $new_status,
1904
+                'note'   => $note,
1905
+                'manual' => (bool) $manual_update,
1906
+            );
1907 1907
 
1908
-			if ( $manual_update ) {
1909
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1910
-			}
1908
+            if ( $manual_update ) {
1909
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1910
+            }
1911 1911
 
1912
-			$this->maybe_set_date_paid();
1912
+            $this->maybe_set_date_paid();
1913 1913
 
1914
-		}
1914
+        }
1915 1915
 
1916
-		return array(
1917
-			'from' => $old_status,
1918
-			'to'   => $new_status,
1919
-		);
1920
-	}
1916
+        return array(
1917
+            'from' => $old_status,
1918
+            'to'   => $new_status,
1919
+        );
1920
+    }
1921 1921
 
1922
-	/**
1923
-	 * Maybe set date paid.
1924
-	 *
1925
-	 * Sets the date paid variable when transitioning to the payment complete
1926
-	 * order status.
1927
-	 *
1928
-	 * @since 1.0.19
1929
-	 */
1930
-	public function maybe_set_date_paid() {
1922
+    /**
1923
+     * Maybe set date paid.
1924
+     *
1925
+     * Sets the date paid variable when transitioning to the payment complete
1926
+     * order status.
1927
+     *
1928
+     * @since 1.0.19
1929
+     */
1930
+    public function maybe_set_date_paid() {
1931 1931
 
1932
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1933
-			$this->set_date_completed( current_time( 'mysql' ) );
1934
-		}
1935
-	}
1932
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1933
+            $this->set_date_completed( current_time( 'mysql' ) );
1934
+        }
1935
+    }
1936 1936
 
1937 1937
     /**
1938
-	 * Set parent invoice ID.
1939
-	 *
1940
-	 * @since 1.0.19
1941
-	 */
1942
-	public function set_parent_id( $value ) {
1943
-		if ( $value && ( $value === $this->get_id() ) ) {
1944
-			return;
1945
-		}
1946
-		$this->set_prop( 'parent_id', absint( $value ) );
1938
+     * Set parent invoice ID.
1939
+     *
1940
+     * @since 1.0.19
1941
+     */
1942
+    public function set_parent_id( $value ) {
1943
+        if ( $value && ( $value === $this->get_id() ) ) {
1944
+            return;
1945
+        }
1946
+        $this->set_prop( 'parent_id', absint( $value ) );
1947 1947
     }
1948 1948
 
1949 1949
     /**
1950
-	 * Set plugin version when the invoice was created.
1951
-	 *
1952
-	 * @since 1.0.19
1953
-	 */
1954
-	public function set_version( $value ) {
1955
-		$this->set_prop( 'version', $value );
1950
+     * Set plugin version when the invoice was created.
1951
+     *
1952
+     * @since 1.0.19
1953
+     */
1954
+    public function set_version( $value ) {
1955
+        $this->set_prop( 'version', $value );
1956 1956
     }
1957
-
1958
-    /**
1959
-	 * Set date when the invoice was created.
1960
-	 *
1961
-	 * @since 1.0.19
1962
-	 * @param string $value Value to set.
1957
+
1958
+    /**
1959
+     * Set date when the invoice was created.
1960
+     *
1961
+     * @since 1.0.19
1962
+     * @param string $value Value to set.
1963 1963
      * @return bool Whether or not the date was set.
1964
-	 */
1965
-	public function set_date_created( $value ) {
1964
+     */
1965
+    public function set_date_created( $value ) {
1966 1966
         $date = strtotime( $value );
1967 1967
 
1968 1968
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1975,13 +1975,13 @@  discard block
 block discarded – undo
1975 1975
     }
1976 1976
 
1977 1977
     /**
1978
-	 * Set date invoice due date.
1979
-	 *
1980
-	 * @since 1.0.19
1981
-	 * @param string $value Value to set.
1978
+     * Set date invoice due date.
1979
+     *
1980
+     * @since 1.0.19
1981
+     * @param string $value Value to set.
1982 1982
      * @return bool Whether or not the date was set.
1983
-	 */
1984
-	public function set_due_date( $value ) {
1983
+     */
1984
+    public function set_due_date( $value ) {
1985 1985
         $date = strtotime( $value );
1986 1986
 
1987 1987
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1989,29 +1989,29 @@  discard block
 block discarded – undo
1989 1989
             return true;
1990 1990
         }
1991 1991
 
1992
-		$this->set_prop( 'due_date', '' );
1992
+        $this->set_prop( 'due_date', '' );
1993 1993
         return false;
1994 1994
 
1995 1995
     }
1996 1996
 
1997 1997
     /**
1998
-	 * Alias of self::set_due_date().
1999
-	 *
2000
-	 * @since 1.0.19
2001
-	 * @param  string $value New name.
2002
-	 */
2003
-	public function set_date_due( $value ) {
2004
-		$this->set_due_date( $value );
1998
+     * Alias of self::set_due_date().
1999
+     *
2000
+     * @since 1.0.19
2001
+     * @param  string $value New name.
2002
+     */
2003
+    public function set_date_due( $value ) {
2004
+        $this->set_due_date( $value );
2005 2005
     }
2006 2006
 
2007 2007
     /**
2008
-	 * Set date invoice was completed.
2009
-	 *
2010
-	 * @since 1.0.19
2011
-	 * @param string $value Value to set.
2008
+     * Set date invoice was completed.
2009
+     *
2010
+     * @since 1.0.19
2011
+     * @param string $value Value to set.
2012 2012
      * @return bool Whether or not the date was set.
2013
-	 */
2014
-	public function set_completed_date( $value ) {
2013
+     */
2014
+    public function set_completed_date( $value ) {
2015 2015
         $date = strtotime( $value );
2016 2016
 
2017 2017
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2019,29 +2019,29 @@  discard block
 block discarded – undo
2019 2019
             return true;
2020 2020
         }
2021 2021
 
2022
-		$this->set_prop( 'completed_date', '' );
2022
+        $this->set_prop( 'completed_date', '' );
2023 2023
         return false;
2024 2024
 
2025 2025
     }
2026 2026
 
2027 2027
     /**
2028
-	 * Alias of self::set_completed_date().
2029
-	 *
2030
-	 * @since 1.0.19
2031
-	 * @param  string $value New name.
2032
-	 */
2033
-	public function set_date_completed( $value ) {
2034
-		$this->set_completed_date( $value );
2028
+     * Alias of self::set_completed_date().
2029
+     *
2030
+     * @since 1.0.19
2031
+     * @param  string $value New name.
2032
+     */
2033
+    public function set_date_completed( $value ) {
2034
+        $this->set_completed_date( $value );
2035 2035
     }
2036 2036
 
2037 2037
     /**
2038
-	 * Set date when the invoice was last modified.
2039
-	 *
2040
-	 * @since 1.0.19
2041
-	 * @param string $value Value to set.
2038
+     * Set date when the invoice was last modified.
2039
+     *
2040
+     * @since 1.0.19
2041
+     * @param string $value Value to set.
2042 2042
      * @return bool Whether or not the date was set.
2043
-	 */
2044
-	public function set_date_modified( $value ) {
2043
+     */
2044
+    public function set_date_modified( $value ) {
2045 2045
         $date = strtotime( $value );
2046 2046
 
2047 2047
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2049,763 +2049,763 @@  discard block
 block discarded – undo
2049 2049
             return true;
2050 2050
         }
2051 2051
 
2052
-		$this->set_prop( 'date_modified', '' );
2052
+        $this->set_prop( 'date_modified', '' );
2053 2053
         return false;
2054 2054
 
2055 2055
     }
2056 2056
 
2057 2057
     /**
2058
-	 * Set the invoice number.
2059
-	 *
2060
-	 * @since 1.0.19
2061
-	 * @param  string $value New number.
2062
-	 */
2063
-	public function set_number( $value ) {
2058
+     * Set the invoice number.
2059
+     *
2060
+     * @since 1.0.19
2061
+     * @param  string $value New number.
2062
+     */
2063
+    public function set_number( $value ) {
2064 2064
         $number = sanitize_text_field( $value );
2065
-		$this->set_prop( 'number', $number );
2065
+        $this->set_prop( 'number', $number );
2066 2066
     }
2067 2067
 
2068 2068
     /**
2069
-	 * Set the invoice type.
2070
-	 *
2071
-	 * @since 1.0.19
2072
-	 * @param  string $value Type.
2073
-	 */
2074
-	public function set_type( $value ) {
2069
+     * Set the invoice type.
2070
+     *
2071
+     * @since 1.0.19
2072
+     * @param  string $value Type.
2073
+     */
2074
+    public function set_type( $value ) {
2075 2075
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2076
-		$this->set_prop( 'type', $type );
2077
-	}
2076
+        $this->set_prop( 'type', $type );
2077
+    }
2078 2078
 
2079 2079
     /**
2080
-	 * Set the invoice post type.
2081
-	 *
2082
-	 * @since 1.0.19
2083
-	 * @param  string $value Post type.
2084
-	 */
2085
-	public function set_post_type( $value ) {
2080
+     * Set the invoice post type.
2081
+     *
2082
+     * @since 1.0.19
2083
+     * @param  string $value Post type.
2084
+     */
2085
+    public function set_post_type( $value ) {
2086 2086
         if ( getpaid_is_invoice_post_type( $value ) ) {
2087
-			$this->set_type( $value );
2087
+            $this->set_type( $value );
2088 2088
             $this->set_prop( 'post_type', $value );
2089 2089
         }
2090 2090
     }
2091 2091
 
2092 2092
     /**
2093
-	 * Set the invoice key.
2094
-	 *
2095
-	 * @since 1.0.19
2096
-	 * @param  string $value New key.
2097
-	 */
2098
-	public function set_key( $value ) {
2093
+     * Set the invoice key.
2094
+     *
2095
+     * @since 1.0.19
2096
+     * @param  string $value New key.
2097
+     */
2098
+    public function set_key( $value ) {
2099 2099
         $key = sanitize_text_field( $value );
2100
-		$this->set_prop( 'key', $key );
2100
+        $this->set_prop( 'key', $key );
2101 2101
     }
2102 2102
 
2103 2103
     /**
2104
-	 * Set the invoice mode.
2105
-	 *
2106
-	 * @since 1.0.19
2107
-	 * @param  string $value mode.
2108
-	 */
2109
-	public function set_mode( $value ) {
2104
+     * Set the invoice mode.
2105
+     *
2106
+     * @since 1.0.19
2107
+     * @param  string $value mode.
2108
+     */
2109
+    public function set_mode( $value ) {
2110 2110
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2111 2111
             $this->set_prop( 'value', $value );
2112 2112
         }
2113 2113
     }
2114 2114
 
2115 2115
     /**
2116
-	 * Set the invoice path.
2117
-	 *
2118
-	 * @since 1.0.19
2119
-	 * @param  string $value path.
2120
-	 */
2121
-	public function set_path( $value ) {
2116
+     * Set the invoice path.
2117
+     *
2118
+     * @since 1.0.19
2119
+     * @param  string $value path.
2120
+     */
2121
+    public function set_path( $value ) {
2122 2122
         $this->set_prop( 'path', $value );
2123 2123
     }
2124 2124
 
2125 2125
     /**
2126
-	 * Set the invoice name.
2127
-	 *
2128
-	 * @since 1.0.19
2129
-	 * @param  string $value New name.
2130
-	 */
2131
-	public function set_name( $value ) {
2126
+     * Set the invoice name.
2127
+     *
2128
+     * @since 1.0.19
2129
+     * @param  string $value New name.
2130
+     */
2131
+    public function set_name( $value ) {
2132 2132
         $name = sanitize_text_field( $value );
2133
-		$this->set_prop( 'name', $name );
2133
+        $this->set_prop( 'name', $name );
2134 2134
     }
2135 2135
 
2136 2136
     /**
2137
-	 * Alias of self::set_name().
2138
-	 *
2139
-	 * @since 1.0.19
2140
-	 * @param  string $value New name.
2141
-	 */
2142
-	public function set_title( $value ) {
2143
-		$this->set_name( $value );
2137
+     * Alias of self::set_name().
2138
+     *
2139
+     * @since 1.0.19
2140
+     * @param  string $value New name.
2141
+     */
2142
+    public function set_title( $value ) {
2143
+        $this->set_name( $value );
2144 2144
     }
2145 2145
 
2146 2146
     /**
2147
-	 * Set the invoice description.
2148
-	 *
2149
-	 * @since 1.0.19
2150
-	 * @param  string $value New description.
2151
-	 */
2152
-	public function set_description( $value ) {
2147
+     * Set the invoice description.
2148
+     *
2149
+     * @since 1.0.19
2150
+     * @param  string $value New description.
2151
+     */
2152
+    public function set_description( $value ) {
2153 2153
         $description = wp_kses_post( $value );
2154
-		return $this->set_prop( 'description', $description );
2154
+        return $this->set_prop( 'description', $description );
2155
+    }
2156
+
2157
+    /**
2158
+     * Alias of self::set_description().
2159
+     *
2160
+     * @since 1.0.19
2161
+     * @param  string $value New description.
2162
+     */
2163
+    public function set_excerpt( $value ) {
2164
+        $this->set_description( $value );
2165
+    }
2166
+
2167
+    /**
2168
+     * Alias of self::set_description().
2169
+     *
2170
+     * @since 1.0.19
2171
+     * @param  string $value New description.
2172
+     */
2173
+    public function set_summary( $value ) {
2174
+        $this->set_description( $value );
2155 2175
     }
2156 2176
 
2157 2177
     /**
2158
-	 * Alias of self::set_description().
2159
-	 *
2160
-	 * @since 1.0.19
2161
-	 * @param  string $value New description.
2162
-	 */
2163
-	public function set_excerpt( $value ) {
2164
-		$this->set_description( $value );
2178
+     * Set the receiver of the invoice.
2179
+     *
2180
+     * @since 1.0.19
2181
+     * @param  int $value New author.
2182
+     */
2183
+    public function set_author( $value ) {
2184
+        $user = get_user_by( 'id', (int) $value );
2185
+
2186
+        if ( $user && $user->ID ) {
2187
+            $this->set_prop( 'author', $user->ID );
2188
+            $this->set_prop( 'email', $user->user_email );
2189
+        }
2190
+
2165 2191
     }
2166 2192
 
2167 2193
     /**
2168
-	 * Alias of self::set_description().
2169
-	 *
2170
-	 * @since 1.0.19
2171
-	 * @param  string $value New description.
2172
-	 */
2173
-	public function set_summary( $value ) {
2174
-		$this->set_description( $value );
2194
+     * Alias of self::set_author().
2195
+     *
2196
+     * @since 1.0.19
2197
+     * @param  int $value New user id.
2198
+     */
2199
+    public function set_user_id( $value ) {
2200
+        $this->set_author( $value );
2175 2201
     }
2176 2202
 
2177 2203
     /**
2178
-	 * Set the receiver of the invoice.
2179
-	 *
2180
-	 * @since 1.0.19
2181
-	 * @param  int $value New author.
2182
-	 */
2183
-	public function set_author( $value ) {
2184
-		$user = get_user_by( 'id', (int) $value );
2204
+     * Alias of self::set_author().
2205
+     *
2206
+     * @since 1.0.19
2207
+     * @param  int $value New user id.
2208
+     */
2209
+    public function set_customer_id( $value ) {
2210
+        $this->set_author( $value );
2211
+    }
2185 2212
 
2186
-		if ( $user && $user->ID ) {
2187
-			$this->set_prop( 'author', $user->ID );
2188
-			$this->set_prop( 'email', $user->user_email );
2189
-		}
2213
+    /**
2214
+     * Set the customer's ip.
2215
+     *
2216
+     * @since 1.0.19
2217
+     * @param  string $value ip address.
2218
+     */
2219
+    public function set_ip( $value ) {
2220
+        $this->set_prop( 'ip', $value );
2221
+    }
2190 2222
 
2223
+    /**
2224
+     * Alias of self::set_ip().
2225
+     *
2226
+     * @since 1.0.19
2227
+     * @param  string $value ip address.
2228
+     */
2229
+    public function set_user_ip( $value ) {
2230
+        $this->set_ip( $value );
2191 2231
     }
2192 2232
 
2193 2233
     /**
2194
-	 * Alias of self::set_author().
2195
-	 *
2196
-	 * @since 1.0.19
2197
-	 * @param  int $value New user id.
2198
-	 */
2199
-	public function set_user_id( $value ) {
2200
-		$this->set_author( $value );
2234
+     * Set the customer's first name.
2235
+     *
2236
+     * @since 1.0.19
2237
+     * @param  string $value first name.
2238
+     */
2239
+    public function set_first_name( $value ) {
2240
+        $this->set_prop( 'first_name', $value );
2201 2241
     }
2202 2242
 
2203 2243
     /**
2204
-	 * Alias of self::set_author().
2205
-	 *
2206
-	 * @since 1.0.19
2207
-	 * @param  int $value New user id.
2208
-	 */
2209
-	public function set_customer_id( $value ) {
2210
-		$this->set_author( $value );
2244
+     * Alias of self::set_first_name().
2245
+     *
2246
+     * @since 1.0.19
2247
+     * @param  string $value first name.
2248
+     */
2249
+    public function set_user_first_name( $value ) {
2250
+        $this->set_first_name( $value );
2211 2251
     }
2212 2252
 
2213 2253
     /**
2214
-	 * Set the customer's ip.
2215
-	 *
2216
-	 * @since 1.0.19
2217
-	 * @param  string $value ip address.
2218
-	 */
2219
-	public function set_ip( $value ) {
2220
-		$this->set_prop( 'ip', $value );
2254
+     * Alias of self::set_first_name().
2255
+     *
2256
+     * @since 1.0.19
2257
+     * @param  string $value first name.
2258
+     */
2259
+    public function set_customer_first_name( $value ) {
2260
+        $this->set_first_name( $value );
2221 2261
     }
2222 2262
 
2223 2263
     /**
2224
-	 * Alias of self::set_ip().
2225
-	 *
2226
-	 * @since 1.0.19
2227
-	 * @param  string $value ip address.
2228
-	 */
2229
-	public function set_user_ip( $value ) {
2230
-		$this->set_ip( $value );
2264
+     * Set the customer's last name.
2265
+     *
2266
+     * @since 1.0.19
2267
+     * @param  string $value last name.
2268
+     */
2269
+    public function set_last_name( $value ) {
2270
+        $this->set_prop( 'last_name', $value );
2231 2271
     }
2232 2272
 
2233 2273
     /**
2234
-	 * Set the customer's first name.
2235
-	 *
2236
-	 * @since 1.0.19
2237
-	 * @param  string $value first name.
2238
-	 */
2239
-	public function set_first_name( $value ) {
2240
-		$this->set_prop( 'first_name', $value );
2274
+     * Alias of self::set_last_name().
2275
+     *
2276
+     * @since 1.0.19
2277
+     * @param  string $value last name.
2278
+     */
2279
+    public function set_user_last_name( $value ) {
2280
+        $this->set_last_name( $value );
2241 2281
     }
2242 2282
 
2243 2283
     /**
2244
-	 * Alias of self::set_first_name().
2245
-	 *
2246
-	 * @since 1.0.19
2247
-	 * @param  string $value first name.
2248
-	 */
2249
-	public function set_user_first_name( $value ) {
2250
-		$this->set_first_name( $value );
2284
+     * Alias of self::set_last_name().
2285
+     *
2286
+     * @since 1.0.19
2287
+     * @param  string $value last name.
2288
+     */
2289
+    public function set_customer_last_name( $value ) {
2290
+        $this->set_last_name( $value );
2251 2291
     }
2252 2292
 
2253 2293
     /**
2254
-	 * Alias of self::set_first_name().
2255
-	 *
2256
-	 * @since 1.0.19
2257
-	 * @param  string $value first name.
2258
-	 */
2259
-	public function set_customer_first_name( $value ) {
2260
-		$this->set_first_name( $value );
2294
+     * Set the customer's phone number.
2295
+     *
2296
+     * @since 1.0.19
2297
+     * @param  string $value phone.
2298
+     */
2299
+    public function set_phone( $value ) {
2300
+        $this->set_prop( 'phone', $value );
2261 2301
     }
2262 2302
 
2263 2303
     /**
2264
-	 * Set the customer's last name.
2265
-	 *
2266
-	 * @since 1.0.19
2267
-	 * @param  string $value last name.
2268
-	 */
2269
-	public function set_last_name( $value ) {
2270
-		$this->set_prop( 'last_name', $value );
2304
+     * Alias of self::set_phone().
2305
+     *
2306
+     * @since 1.0.19
2307
+     * @param  string $value phone.
2308
+     */
2309
+    public function set_user_phone( $value ) {
2310
+        $this->set_phone( $value );
2271 2311
     }
2272 2312
 
2273 2313
     /**
2274
-	 * Alias of self::set_last_name().
2275
-	 *
2276
-	 * @since 1.0.19
2277
-	 * @param  string $value last name.
2278
-	 */
2279
-	public function set_user_last_name( $value ) {
2280
-		$this->set_last_name( $value );
2314
+     * Alias of self::set_phone().
2315
+     *
2316
+     * @since 1.0.19
2317
+     * @param  string $value phone.
2318
+     */
2319
+    public function set_customer_phone( $value ) {
2320
+        $this->set_phone( $value );
2281 2321
     }
2282 2322
 
2283 2323
     /**
2284
-	 * Alias of self::set_last_name().
2285
-	 *
2286
-	 * @since 1.0.19
2287
-	 * @param  string $value last name.
2288
-	 */
2289
-	public function set_customer_last_name( $value ) {
2290
-		$this->set_last_name( $value );
2324
+     * Alias of self::set_phone().
2325
+     *
2326
+     * @since 1.0.19
2327
+     * @param  string $value phone.
2328
+     */
2329
+    public function set_phone_number( $value ) {
2330
+        $this->set_phone( $value );
2291 2331
     }
2292 2332
 
2293 2333
     /**
2294
-	 * Set the customer's phone number.
2295
-	 *
2296
-	 * @since 1.0.19
2297
-	 * @param  string $value phone.
2298
-	 */
2299
-	public function set_phone( $value ) {
2300
-		$this->set_prop( 'phone', $value );
2334
+     * Set the customer's email address.
2335
+     *
2336
+     * @since 1.0.19
2337
+     * @param  string $value email address.
2338
+     */
2339
+    public function set_email( $value ) {
2340
+        $this->set_prop( 'email', $value );
2301 2341
     }
2302 2342
 
2303 2343
     /**
2304
-	 * Alias of self::set_phone().
2305
-	 *
2306
-	 * @since 1.0.19
2307
-	 * @param  string $value phone.
2308
-	 */
2309
-	public function set_user_phone( $value ) {
2310
-		$this->set_phone( $value );
2344
+     * Alias of self::set_email().
2345
+     *
2346
+     * @since 1.0.19
2347
+     * @param  string $value email address.
2348
+     */
2349
+    public function set_user_email( $value ) {
2350
+        $this->set_email( $value );
2311 2351
     }
2312 2352
 
2313 2353
     /**
2314
-	 * Alias of self::set_phone().
2315
-	 *
2316
-	 * @since 1.0.19
2317
-	 * @param  string $value phone.
2318
-	 */
2319
-	public function set_customer_phone( $value ) {
2320
-		$this->set_phone( $value );
2354
+     * Alias of self::set_email().
2355
+     *
2356
+     * @since 1.0.19
2357
+     * @param  string $value email address.
2358
+     */
2359
+    public function set_email_address( $value ) {
2360
+        $this->set_email( $value );
2321 2361
     }
2322 2362
 
2323 2363
     /**
2324
-	 * Alias of self::set_phone().
2325
-	 *
2326
-	 * @since 1.0.19
2327
-	 * @param  string $value phone.
2328
-	 */
2329
-	public function set_phone_number( $value ) {
2330
-		$this->set_phone( $value );
2364
+     * Alias of self::set_email().
2365
+     *
2366
+     * @since 1.0.19
2367
+     * @param  string $value email address.
2368
+     */
2369
+    public function set_customer_email( $value ) {
2370
+        $this->set_email( $value );
2331 2371
     }
2332 2372
 
2333 2373
     /**
2334
-	 * Set the customer's email address.
2335
-	 *
2336
-	 * @since 1.0.19
2337
-	 * @param  string $value email address.
2338
-	 */
2339
-	public function set_email( $value ) {
2340
-		$this->set_prop( 'email', $value );
2374
+     * Set the customer's country.
2375
+     *
2376
+     * @since 1.0.19
2377
+     * @param  string $value country.
2378
+     */
2379
+    public function set_country( $value ) {
2380
+        $this->set_prop( 'country', $value );
2341 2381
     }
2342 2382
 
2343 2383
     /**
2344
-	 * Alias of self::set_email().
2345
-	 *
2346
-	 * @since 1.0.19
2347
-	 * @param  string $value email address.
2348
-	 */
2349
-	public function set_user_email( $value ) {
2350
-		$this->set_email( $value );
2384
+     * Alias of self::set_country().
2385
+     *
2386
+     * @since 1.0.19
2387
+     * @param  string $value country.
2388
+     */
2389
+    public function set_user_country( $value ) {
2390
+        $this->set_country( $value );
2351 2391
     }
2352 2392
 
2353 2393
     /**
2354
-	 * Alias of self::set_email().
2355
-	 *
2356
-	 * @since 1.0.19
2357
-	 * @param  string $value email address.
2358
-	 */
2359
-	public function set_email_address( $value ) {
2360
-		$this->set_email( $value );
2394
+     * Alias of self::set_country().
2395
+     *
2396
+     * @since 1.0.19
2397
+     * @param  string $value country.
2398
+     */
2399
+    public function set_customer_country( $value ) {
2400
+        $this->set_country( $value );
2361 2401
     }
2362 2402
 
2363 2403
     /**
2364
-	 * Alias of self::set_email().
2365
-	 *
2366
-	 * @since 1.0.19
2367
-	 * @param  string $value email address.
2368
-	 */
2369
-	public function set_customer_email( $value ) {
2370
-		$this->set_email( $value );
2404
+     * Set the customer's state.
2405
+     *
2406
+     * @since 1.0.19
2407
+     * @param  string $value state.
2408
+     */
2409
+    public function set_state( $value ) {
2410
+        $this->set_prop( 'state', $value );
2371 2411
     }
2372 2412
 
2373 2413
     /**
2374
-	 * Set the customer's country.
2375
-	 *
2376
-	 * @since 1.0.19
2377
-	 * @param  string $value country.
2378
-	 */
2379
-	public function set_country( $value ) {
2380
-		$this->set_prop( 'country', $value );
2414
+     * Alias of self::set_state().
2415
+     *
2416
+     * @since 1.0.19
2417
+     * @param  string $value state.
2418
+     */
2419
+    public function set_user_state( $value ) {
2420
+        $this->set_state( $value );
2381 2421
     }
2382 2422
 
2383 2423
     /**
2384
-	 * Alias of self::set_country().
2385
-	 *
2386
-	 * @since 1.0.19
2387
-	 * @param  string $value country.
2388
-	 */
2389
-	public function set_user_country( $value ) {
2390
-		$this->set_country( $value );
2424
+     * Alias of self::set_state().
2425
+     *
2426
+     * @since 1.0.19
2427
+     * @param  string $value state.
2428
+     */
2429
+    public function set_customer_state( $value ) {
2430
+        $this->set_state( $value );
2391 2431
     }
2392 2432
 
2393 2433
     /**
2394
-	 * Alias of self::set_country().
2395
-	 *
2396
-	 * @since 1.0.19
2397
-	 * @param  string $value country.
2398
-	 */
2399
-	public function set_customer_country( $value ) {
2400
-		$this->set_country( $value );
2434
+     * Set the customer's city.
2435
+     *
2436
+     * @since 1.0.19
2437
+     * @param  string $value city.
2438
+     */
2439
+    public function set_city( $value ) {
2440
+        $this->set_prop( 'city', $value );
2401 2441
     }
2402 2442
 
2403 2443
     /**
2404
-	 * Set the customer's state.
2405
-	 *
2406
-	 * @since 1.0.19
2407
-	 * @param  string $value state.
2408
-	 */
2409
-	public function set_state( $value ) {
2410
-		$this->set_prop( 'state', $value );
2444
+     * Alias of self::set_city().
2445
+     *
2446
+     * @since 1.0.19
2447
+     * @param  string $value city.
2448
+     */
2449
+    public function set_user_city( $value ) {
2450
+        $this->set_city( $value );
2411 2451
     }
2412 2452
 
2413 2453
     /**
2414
-	 * Alias of self::set_state().
2415
-	 *
2416
-	 * @since 1.0.19
2417
-	 * @param  string $value state.
2418
-	 */
2419
-	public function set_user_state( $value ) {
2420
-		$this->set_state( $value );
2454
+     * Alias of self::set_city().
2455
+     *
2456
+     * @since 1.0.19
2457
+     * @param  string $value city.
2458
+     */
2459
+    public function set_customer_city( $value ) {
2460
+        $this->set_city( $value );
2421 2461
     }
2422 2462
 
2423 2463
     /**
2424
-	 * Alias of self::set_state().
2425
-	 *
2426
-	 * @since 1.0.19
2427
-	 * @param  string $value state.
2428
-	 */
2429
-	public function set_customer_state( $value ) {
2430
-		$this->set_state( $value );
2464
+     * Set the customer's zip code.
2465
+     *
2466
+     * @since 1.0.19
2467
+     * @param  string $value zip.
2468
+     */
2469
+    public function set_zip( $value ) {
2470
+        $this->set_prop( 'zip', $value );
2431 2471
     }
2432 2472
 
2433 2473
     /**
2434
-	 * Set the customer's city.
2435
-	 *
2436
-	 * @since 1.0.19
2437
-	 * @param  string $value city.
2438
-	 */
2439
-	public function set_city( $value ) {
2440
-		$this->set_prop( 'city', $value );
2474
+     * Alias of self::set_zip().
2475
+     *
2476
+     * @since 1.0.19
2477
+     * @param  string $value zip.
2478
+     */
2479
+    public function set_user_zip( $value ) {
2480
+        $this->set_zip( $value );
2441 2481
     }
2442 2482
 
2443 2483
     /**
2444
-	 * Alias of self::set_city().
2445
-	 *
2446
-	 * @since 1.0.19
2447
-	 * @param  string $value city.
2448
-	 */
2449
-	public function set_user_city( $value ) {
2450
-		$this->set_city( $value );
2484
+     * Alias of self::set_zip().
2485
+     *
2486
+     * @since 1.0.19
2487
+     * @param  string $value zip.
2488
+     */
2489
+    public function set_customer_zip( $value ) {
2490
+        $this->set_zip( $value );
2451 2491
     }
2452 2492
 
2453 2493
     /**
2454
-	 * Alias of self::set_city().
2455
-	 *
2456
-	 * @since 1.0.19
2457
-	 * @param  string $value city.
2458
-	 */
2459
-	public function set_customer_city( $value ) {
2460
-		$this->set_city( $value );
2494
+     * Set the customer's company.
2495
+     *
2496
+     * @since 1.0.19
2497
+     * @param  string $value company.
2498
+     */
2499
+    public function set_company( $value ) {
2500
+        $this->set_prop( 'company', $value );
2461 2501
     }
2462 2502
 
2463 2503
     /**
2464
-	 * Set the customer's zip code.
2465
-	 *
2466
-	 * @since 1.0.19
2467
-	 * @param  string $value zip.
2468
-	 */
2469
-	public function set_zip( $value ) {
2470
-		$this->set_prop( 'zip', $value );
2504
+     * Alias of self::set_company().
2505
+     *
2506
+     * @since 1.0.19
2507
+     * @param  string $value company.
2508
+     */
2509
+    public function set_user_company( $value ) {
2510
+        $this->set_company( $value );
2471 2511
     }
2472 2512
 
2473 2513
     /**
2474
-	 * Alias of self::set_zip().
2475
-	 *
2476
-	 * @since 1.0.19
2477
-	 * @param  string $value zip.
2478
-	 */
2479
-	public function set_user_zip( $value ) {
2480
-		$this->set_zip( $value );
2514
+     * Alias of self::set_company().
2515
+     *
2516
+     * @since 1.0.19
2517
+     * @param  string $value company.
2518
+     */
2519
+    public function set_customer_company( $value ) {
2520
+        $this->set_company( $value );
2481 2521
     }
2482 2522
 
2483 2523
     /**
2484
-	 * Alias of self::set_zip().
2485
-	 *
2486
-	 * @since 1.0.19
2487
-	 * @param  string $value zip.
2488
-	 */
2489
-	public function set_customer_zip( $value ) {
2490
-		$this->set_zip( $value );
2524
+     * Set the customer's var number.
2525
+     *
2526
+     * @since 1.0.19
2527
+     * @param  string $value var number.
2528
+     */
2529
+    public function set_vat_number( $value ) {
2530
+        $this->set_prop( 'vat_number', $value );
2491 2531
     }
2492 2532
 
2493 2533
     /**
2494
-	 * Set the customer's company.
2495
-	 *
2496
-	 * @since 1.0.19
2497
-	 * @param  string $value company.
2498
-	 */
2499
-	public function set_company( $value ) {
2500
-		$this->set_prop( 'company', $value );
2534
+     * Alias of self::set_vat_number().
2535
+     *
2536
+     * @since 1.0.19
2537
+     * @param  string $value var number.
2538
+     */
2539
+    public function set_user_vat_number( $value ) {
2540
+        $this->set_vat_number( $value );
2501 2541
     }
2502 2542
 
2503 2543
     /**
2504
-	 * Alias of self::set_company().
2505
-	 *
2506
-	 * @since 1.0.19
2507
-	 * @param  string $value company.
2508
-	 */
2509
-	public function set_user_company( $value ) {
2510
-		$this->set_company( $value );
2544
+     * Alias of self::set_vat_number().
2545
+     *
2546
+     * @since 1.0.19
2547
+     * @param  string $value var number.
2548
+     */
2549
+    public function set_customer_vat_number( $value ) {
2550
+        $this->set_vat_number( $value );
2511 2551
     }
2512 2552
 
2513 2553
     /**
2514
-	 * Alias of self::set_company().
2515
-	 *
2516
-	 * @since 1.0.19
2517
-	 * @param  string $value company.
2518
-	 */
2519
-	public function set_customer_company( $value ) {
2520
-		$this->set_company( $value );
2554
+     * Set the customer's vat rate.
2555
+     *
2556
+     * @since 1.0.19
2557
+     * @param  string $value var rate.
2558
+     */
2559
+    public function set_vat_rate( $value ) {
2560
+        $this->set_prop( 'vat_rate', $value );
2521 2561
     }
2522 2562
 
2523 2563
     /**
2524
-	 * Set the customer's var number.
2525
-	 *
2526
-	 * @since 1.0.19
2527
-	 * @param  string $value var number.
2528
-	 */
2529
-	public function set_vat_number( $value ) {
2530
-		$this->set_prop( 'vat_number', $value );
2564
+     * Alias of self::set_vat_rate().
2565
+     *
2566
+     * @since 1.0.19
2567
+     * @param  string $value var number.
2568
+     */
2569
+    public function set_user_vat_rate( $value ) {
2570
+        $this->set_vat_rate( $value );
2531 2571
     }
2532 2572
 
2533 2573
     /**
2534
-	 * Alias of self::set_vat_number().
2535
-	 *
2536
-	 * @since 1.0.19
2537
-	 * @param  string $value var number.
2538
-	 */
2539
-	public function set_user_vat_number( $value ) {
2540
-		$this->set_vat_number( $value );
2574
+     * Alias of self::set_vat_rate().
2575
+     *
2576
+     * @since 1.0.19
2577
+     * @param  string $value var number.
2578
+     */
2579
+    public function set_customer_vat_rate( $value ) {
2580
+        $this->set_vat_rate( $value );
2541 2581
     }
2542 2582
 
2543 2583
     /**
2544
-	 * Alias of self::set_vat_number().
2545
-	 *
2546
-	 * @since 1.0.19
2547
-	 * @param  string $value var number.
2548
-	 */
2549
-	public function set_customer_vat_number( $value ) {
2550
-		$this->set_vat_number( $value );
2584
+     * Set the customer's address.
2585
+     *
2586
+     * @since 1.0.19
2587
+     * @param  string $value address.
2588
+     */
2589
+    public function set_address( $value ) {
2590
+        $this->set_prop( 'address', $value );
2551 2591
     }
2552 2592
 
2553 2593
     /**
2554
-	 * Set the customer's vat rate.
2555
-	 *
2556
-	 * @since 1.0.19
2557
-	 * @param  string $value var rate.
2558
-	 */
2559
-	public function set_vat_rate( $value ) {
2560
-		$this->set_prop( 'vat_rate', $value );
2594
+     * Alias of self::set_address().
2595
+     *
2596
+     * @since 1.0.19
2597
+     * @param  string $value address.
2598
+     */
2599
+    public function set_user_address( $value ) {
2600
+        $this->set_address( $value );
2561 2601
     }
2562 2602
 
2563 2603
     /**
2564
-	 * Alias of self::set_vat_rate().
2565
-	 *
2566
-	 * @since 1.0.19
2567
-	 * @param  string $value var number.
2568
-	 */
2569
-	public function set_user_vat_rate( $value ) {
2570
-		$this->set_vat_rate( $value );
2604
+     * Alias of self::set_address().
2605
+     *
2606
+     * @since 1.0.19
2607
+     * @param  string $value address.
2608
+     */
2609
+    public function set_customer_address( $value ) {
2610
+        $this->set_address( $value );
2571 2611
     }
2572 2612
 
2573 2613
     /**
2574
-	 * Alias of self::set_vat_rate().
2575
-	 *
2576
-	 * @since 1.0.19
2577
-	 * @param  string $value var number.
2578
-	 */
2579
-	public function set_customer_vat_rate( $value ) {
2580
-		$this->set_vat_rate( $value );
2614
+     * Set whether the customer has viewed the invoice or not.
2615
+     *
2616
+     * @since 1.0.19
2617
+     * @param  int|bool $value confirmed.
2618
+     */
2619
+    public function set_is_viewed( $value ) {
2620
+        $this->set_prop( 'is_viewed', $value );
2581 2621
     }
2582 2622
 
2583 2623
     /**
2584
-	 * Set the customer's address.
2585
-	 *
2586
-	 * @since 1.0.19
2587
-	 * @param  string $value address.
2588
-	 */
2589
-	public function set_address( $value ) {
2590
-		$this->set_prop( 'address', $value );
2624
+     * Set extra email recipients.
2625
+     *
2626
+     * @since 1.0.19
2627
+     * @param  string $value email recipients.
2628
+     */
2629
+    public function set_email_cc( $value ) {
2630
+        $this->set_prop( 'email_cc', $value );
2591 2631
     }
2592 2632
 
2593 2633
     /**
2594
-	 * Alias of self::set_address().
2595
-	 *
2596
-	 * @since 1.0.19
2597
-	 * @param  string $value address.
2598
-	 */
2599
-	public function set_user_address( $value ) {
2600
-		$this->set_address( $value );
2634
+     * Set the invoice template.
2635
+     *
2636
+     * @since 1.0.19
2637
+     * @param  string $value template.
2638
+     */
2639
+    public function set_template( $value ) {
2640
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2641
+            $this->set_prop( 'template', $value );
2642
+        }
2601 2643
     }
2602 2644
 
2603 2645
     /**
2604
-	 * Alias of self::set_address().
2605
-	 *
2606
-	 * @since 1.0.19
2607
-	 * @param  string $value address.
2608
-	 */
2609
-	public function set_customer_address( $value ) {
2610
-		$this->set_address( $value );
2646
+     * Set the invoice source.
2647
+     *
2648
+     * @since 1.0.19
2649
+     * @param  string $value email recipients.
2650
+     */
2651
+    public function created_via( $value ) {
2652
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2611 2653
     }
2612 2654
 
2613 2655
     /**
2614
-	 * Set whether the customer has viewed the invoice or not.
2615
-	 *
2616
-	 * @since 1.0.19
2617
-	 * @param  int|bool $value confirmed.
2618
-	 */
2619
-	public function set_is_viewed( $value ) {
2620
-		$this->set_prop( 'is_viewed', $value );
2621
-	}
2622
-
2623
-	/**
2624
-	 * Set extra email recipients.
2625
-	 *
2626
-	 * @since 1.0.19
2627
-	 * @param  string $value email recipients.
2628
-	 */
2629
-	public function set_email_cc( $value ) {
2630
-		$this->set_prop( 'email_cc', $value );
2631
-	}
2632
-
2633
-	/**
2634
-	 * Set the invoice template.
2635
-	 *
2636
-	 * @since 1.0.19
2637
-	 * @param  string $value template.
2638
-	 */
2639
-	public function set_template( $value ) {
2640
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2641
-			$this->set_prop( 'template', $value );
2642
-		}
2643
-	}
2644
-
2645
-	/**
2646
-	 * Set the invoice source.
2647
-	 *
2648
-	 * @since 1.0.19
2649
-	 * @param  string $value email recipients.
2650
-	 */
2651
-	public function created_via( $value ) {
2652
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2653
-	}
2654
-
2655
-	/**
2656
-	 * Set the customer's address confirmed status.
2657
-	 *
2658
-	 * @since 1.0.19
2659
-	 * @param  int|bool $value confirmed.
2660
-	 */
2661
-	public function set_address_confirmed( $value ) {
2662
-		$this->set_prop( 'address_confirmed', $value );
2656
+     * Set the customer's address confirmed status.
2657
+     *
2658
+     * @since 1.0.19
2659
+     * @param  int|bool $value confirmed.
2660
+     */
2661
+    public function set_address_confirmed( $value ) {
2662
+        $this->set_prop( 'address_confirmed', $value );
2663 2663
     }
2664 2664
 
2665 2665
     /**
2666
-	 * Alias of self::set_address_confirmed().
2667
-	 *
2668
-	 * @since 1.0.19
2669
-	 * @param  int|bool $value confirmed.
2670
-	 */
2671
-	public function set_user_address_confirmed( $value ) {
2672
-		$this->set_address_confirmed( $value );
2666
+     * Alias of self::set_address_confirmed().
2667
+     *
2668
+     * @since 1.0.19
2669
+     * @param  int|bool $value confirmed.
2670
+     */
2671
+    public function set_user_address_confirmed( $value ) {
2672
+        $this->set_address_confirmed( $value );
2673 2673
     }
2674 2674
 
2675 2675
     /**
2676
-	 * Alias of self::set_address_confirmed().
2677
-	 *
2678
-	 * @since 1.0.19
2679
-	 * @param  int|bool $value confirmed.
2680
-	 */
2681
-	public function set_customer_address_confirmed( $value ) {
2682
-		$this->set_address_confirmed( $value );
2676
+     * Alias of self::set_address_confirmed().
2677
+     *
2678
+     * @since 1.0.19
2679
+     * @param  int|bool $value confirmed.
2680
+     */
2681
+    public function set_customer_address_confirmed( $value ) {
2682
+        $this->set_address_confirmed( $value );
2683 2683
     }
2684 2684
 
2685 2685
     /**
2686
-	 * Set the invoice sub total.
2687
-	 *
2688
-	 * @since 1.0.19
2689
-	 * @param  float $value sub total.
2690
-	 */
2691
-	public function set_subtotal( $value ) {
2692
-		$this->set_prop( 'subtotal', $value );
2686
+     * Set the invoice sub total.
2687
+     *
2688
+     * @since 1.0.19
2689
+     * @param  float $value sub total.
2690
+     */
2691
+    public function set_subtotal( $value ) {
2692
+        $this->set_prop( 'subtotal', $value );
2693 2693
     }
2694 2694
 
2695 2695
     /**
2696
-	 * Set the invoice discount amount.
2697
-	 *
2698
-	 * @since 1.0.19
2699
-	 * @param  float $value discount total.
2700
-	 */
2701
-	public function set_total_discount( $value ) {
2702
-		$this->set_prop( 'total_discount', $value );
2696
+     * Set the invoice discount amount.
2697
+     *
2698
+     * @since 1.0.19
2699
+     * @param  float $value discount total.
2700
+     */
2701
+    public function set_total_discount( $value ) {
2702
+        $this->set_prop( 'total_discount', $value );
2703 2703
     }
2704 2704
 
2705 2705
     /**
2706
-	 * Alias of self::set_total_discount().
2707
-	 *
2708
-	 * @since 1.0.19
2709
-	 * @param  float $value discount total.
2710
-	 */
2711
-	public function set_discount( $value ) {
2712
-		$this->set_total_discount( $value );
2706
+     * Alias of self::set_total_discount().
2707
+     *
2708
+     * @since 1.0.19
2709
+     * @param  float $value discount total.
2710
+     */
2711
+    public function set_discount( $value ) {
2712
+        $this->set_total_discount( $value );
2713 2713
     }
2714 2714
 
2715 2715
     /**
2716
-	 * Set the invoice tax amount.
2717
-	 *
2718
-	 * @since 1.0.19
2719
-	 * @param  float $value tax total.
2720
-	 */
2721
-	public function set_total_tax( $value ) {
2722
-		$this->set_prop( 'total_tax', $value );
2716
+     * Set the invoice tax amount.
2717
+     *
2718
+     * @since 1.0.19
2719
+     * @param  float $value tax total.
2720
+     */
2721
+    public function set_total_tax( $value ) {
2722
+        $this->set_prop( 'total_tax', $value );
2723 2723
     }
2724 2724
 
2725 2725
     /**
2726
-	 * Alias of self::set_total_tax().
2727
-	 *
2728
-	 * @since 1.0.19
2729
-	 * @param  float $value tax total.
2730
-	 */
2731
-	public function set_tax_total( $value ) {
2732
-		$this->set_total_tax( $value );
2726
+     * Alias of self::set_total_tax().
2727
+     *
2728
+     * @since 1.0.19
2729
+     * @param  float $value tax total.
2730
+     */
2731
+    public function set_tax_total( $value ) {
2732
+        $this->set_total_tax( $value );
2733 2733
     }
2734 2734
 
2735 2735
     /**
2736
-	 * Set the invoice fees amount.
2737
-	 *
2738
-	 * @since 1.0.19
2739
-	 * @param  float $value fees total.
2740
-	 */
2741
-	public function set_total_fees( $value ) {
2742
-		$this->set_prop( 'total_fees', $value );
2736
+     * Set the invoice fees amount.
2737
+     *
2738
+     * @since 1.0.19
2739
+     * @param  float $value fees total.
2740
+     */
2741
+    public function set_total_fees( $value ) {
2742
+        $this->set_prop( 'total_fees', $value );
2743 2743
     }
2744 2744
 
2745 2745
     /**
2746
-	 * Alias of self::set_total_fees().
2747
-	 *
2748
-	 * @since 1.0.19
2749
-	 * @param  float $value fees total.
2750
-	 */
2751
-	public function set_fees_total( $value ) {
2752
-		$this->set_total_fees( $value );
2746
+     * Alias of self::set_total_fees().
2747
+     *
2748
+     * @since 1.0.19
2749
+     * @param  float $value fees total.
2750
+     */
2751
+    public function set_fees_total( $value ) {
2752
+        $this->set_total_fees( $value );
2753 2753
     }
2754 2754
 
2755 2755
     /**
2756
-	 * Set the invoice fees.
2757
-	 *
2758
-	 * @since 1.0.19
2759
-	 * @param  array $value fees.
2760
-	 */
2761
-	public function set_fees( $value ) {
2756
+     * Set the invoice fees.
2757
+     *
2758
+     * @since 1.0.19
2759
+     * @param  array $value fees.
2760
+     */
2761
+    public function set_fees( $value ) {
2762 2762
 
2763
-		if ( ! is_array( $value ) ) {
2764
-			$value = array();
2765
-		}
2763
+        if ( ! is_array( $value ) ) {
2764
+            $value = array();
2765
+        }
2766 2766
 
2767
-		$this->set_prop( 'fees', $value );
2767
+        $this->set_prop( 'fees', $value );
2768 2768
 
2769 2769
     }
2770 2770
 
2771 2771
     /**
2772
-	 * Set the invoice taxes.
2773
-	 *
2774
-	 * @since 1.0.19
2775
-	 * @param  array $value taxes.
2776
-	 */
2777
-	public function set_taxes( $value ) {
2772
+     * Set the invoice taxes.
2773
+     *
2774
+     * @since 1.0.19
2775
+     * @param  array $value taxes.
2776
+     */
2777
+    public function set_taxes( $value ) {
2778 2778
 
2779
-		if ( ! is_array( $value ) ) {
2780
-			$value = array();
2781
-		}
2779
+        if ( ! is_array( $value ) ) {
2780
+            $value = array();
2781
+        }
2782 2782
 
2783
-		$this->set_prop( 'taxes', $value );
2783
+        $this->set_prop( 'taxes', $value );
2784 2784
 
2785 2785
     }
2786 2786
 
2787 2787
     /**
2788
-	 * Set the invoice discounts.
2789
-	 *
2790
-	 * @since 1.0.19
2791
-	 * @param  array $value discounts.
2792
-	 */
2793
-	public function set_discounts( $value ) {
2788
+     * Set the invoice discounts.
2789
+     *
2790
+     * @since 1.0.19
2791
+     * @param  array $value discounts.
2792
+     */
2793
+    public function set_discounts( $value ) {
2794 2794
 
2795
-		if ( ! is_array( $value ) ) {
2796
-			$value = array();
2797
-		}
2795
+        if ( ! is_array( $value ) ) {
2796
+            $value = array();
2797
+        }
2798 2798
 
2799
-		$this->set_prop( 'discounts', $value );
2799
+        $this->set_prop( 'discounts', $value );
2800 2800
     }
2801 2801
 
2802 2802
     /**
2803
-	 * Set the invoice items.
2804
-	 *
2805
-	 * @since 1.0.19
2806
-	 * @param  GetPaid_Form_Item[] $value items.
2807
-	 */
2808
-	public function set_items( $value ) {
2803
+     * Set the invoice items.
2804
+     *
2805
+     * @since 1.0.19
2806
+     * @param  GetPaid_Form_Item[] $value items.
2807
+     */
2808
+    public function set_items( $value ) {
2809 2809
 
2810 2810
         // Remove existing items.
2811 2811
         $this->set_prop( 'items', array() );
@@ -2822,95 +2822,95 @@  discard block
 block discarded – undo
2822 2822
     }
2823 2823
 
2824 2824
     /**
2825
-	 * Set the payment form.
2826
-	 *
2827
-	 * @since 1.0.19
2828
-	 * @param  int $value payment form.
2829
-	 */
2830
-	public function set_payment_form( $value ) {
2831
-		$this->set_prop( 'payment_form', $value );
2825
+     * Set the payment form.
2826
+     *
2827
+     * @since 1.0.19
2828
+     * @param  int $value payment form.
2829
+     */
2830
+    public function set_payment_form( $value ) {
2831
+        $this->set_prop( 'payment_form', $value );
2832 2832
     }
2833 2833
 
2834 2834
     /**
2835
-	 * Set the submission id.
2836
-	 *
2837
-	 * @since 1.0.19
2838
-	 * @param  string $value submission id.
2839
-	 */
2840
-	public function set_submission_id( $value ) {
2841
-		$this->set_prop( 'submission_id', $value );
2835
+     * Set the submission id.
2836
+     *
2837
+     * @since 1.0.19
2838
+     * @param  string $value submission id.
2839
+     */
2840
+    public function set_submission_id( $value ) {
2841
+        $this->set_prop( 'submission_id', $value );
2842 2842
     }
2843 2843
 
2844 2844
     /**
2845
-	 * Set the discount code.
2846
-	 *
2847
-	 * @since 1.0.19
2848
-	 * @param  string $value discount code.
2849
-	 */
2850
-	public function set_discount_code( $value ) {
2851
-		$this->set_prop( 'discount_code', $value );
2845
+     * Set the discount code.
2846
+     *
2847
+     * @since 1.0.19
2848
+     * @param  string $value discount code.
2849
+     */
2850
+    public function set_discount_code( $value ) {
2851
+        $this->set_prop( 'discount_code', $value );
2852 2852
     }
2853 2853
 
2854 2854
     /**
2855
-	 * Set the gateway.
2856
-	 *
2857
-	 * @since 1.0.19
2858
-	 * @param  string $value gateway.
2859
-	 */
2860
-	public function set_gateway( $value ) {
2861
-		$this->set_prop( 'gateway', $value );
2855
+     * Set the gateway.
2856
+     *
2857
+     * @since 1.0.19
2858
+     * @param  string $value gateway.
2859
+     */
2860
+    public function set_gateway( $value ) {
2861
+        $this->set_prop( 'gateway', $value );
2862 2862
     }
2863 2863
 
2864 2864
     /**
2865
-	 * Set the transaction id.
2866
-	 *
2867
-	 * @since 1.0.19
2868
-	 * @param  string $value transaction id.
2869
-	 */
2870
-	public function set_transaction_id( $value ) {
2871
-		if ( ! empty( $value ) ) {
2872
-			$this->set_prop( 'transaction_id', $value );
2873
-		}
2865
+     * Set the transaction id.
2866
+     *
2867
+     * @since 1.0.19
2868
+     * @param  string $value transaction id.
2869
+     */
2870
+    public function set_transaction_id( $value ) {
2871
+        if ( ! empty( $value ) ) {
2872
+            $this->set_prop( 'transaction_id', $value );
2873
+        }
2874 2874
     }
2875 2875
 
2876 2876
     /**
2877
-	 * Set the currency id.
2878
-	 *
2879
-	 * @since 1.0.19
2880
-	 * @param  string $value currency id.
2881
-	 */
2882
-	public function set_currency( $value ) {
2883
-		$this->set_prop( 'currency', $value );
2877
+     * Set the currency id.
2878
+     *
2879
+     * @since 1.0.19
2880
+     * @param  string $value currency id.
2881
+     */
2882
+    public function set_currency( $value ) {
2883
+        $this->set_prop( 'currency', $value );
2884 2884
     }
2885 2885
 
2886
-	/**
2887
-	 * Set whether to disable taxes.
2888
-	 *
2889
-	 * @since 1.0.19
2890
-	 * @param  bool $value value.
2891
-	 */
2892
-	public function set_disable_taxes( $value ) {
2893
-		$this->set_prop( 'disable_taxes', (bool) $value );
2894
-	}
2886
+    /**
2887
+     * Set whether to disable taxes.
2888
+     *
2889
+     * @since 1.0.19
2890
+     * @param  bool $value value.
2891
+     */
2892
+    public function set_disable_taxes( $value ) {
2893
+        $this->set_prop( 'disable_taxes', (bool) $value );
2894
+    }
2895 2895
 
2896 2896
     /**
2897
-	 * Set the subscription id.
2898
-	 *
2899
-	 * @since 1.0.19
2900
-	 * @param  string $value subscription id.
2901
-	 */
2902
-	public function set_subscription_id( $value ) {
2903
-		$this->set_prop( 'subscription_id', $value );
2904
-	}
2897
+     * Set the subscription id.
2898
+     *
2899
+     * @since 1.0.19
2900
+     * @param  string $value subscription id.
2901
+     */
2902
+    public function set_subscription_id( $value ) {
2903
+        $this->set_prop( 'subscription_id', $value );
2904
+    }
2905 2905
 	
2906
-	/**
2907
-	 * Set the remote subscription id.
2908
-	 *
2909
-	 * @since 1.0.19
2910
-	 * @param  string $value subscription id.
2911
-	 */
2912
-	public function set_remote_subscription_id( $value ) {
2913
-		$this->set_prop( 'remote_subscription_id', $value );
2906
+    /**
2907
+     * Set the remote subscription id.
2908
+     *
2909
+     * @since 1.0.19
2910
+     * @param  string $value subscription id.
2911
+     */
2912
+    public function set_remote_subscription_id( $value ) {
2913
+        $this->set_prop( 'remote_subscription_id', $value );
2914 2914
     }
2915 2915
 
2916 2916
     /*
@@ -2949,12 +2949,12 @@  discard block
 block discarded – undo
2949 2949
      */
2950 2950
     public function is_taxable() {
2951 2951
         return ! $this->get_disable_taxes();
2952
-	}
2952
+    }
2953 2953
 
2954
-	/**
2955
-	 * @deprecated
2956
-	 */
2957
-	public function has_vat() {
2954
+    /**
2955
+     * @deprecated
2956
+     */
2957
+    public function has_vat() {
2958 2958
         global $wpinv_euvat, $wpi_country;
2959 2959
 
2960 2960
         $requires_vat = false;
@@ -2965,17 +2965,17 @@  discard block
 block discarded – undo
2965 2965
         }
2966 2966
 
2967 2967
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2968
-	}
2968
+    }
2969 2969
 
2970
-	/**
2971
-	 * Checks to see if the invoice requires payment.
2972
-	 */
2973
-	public function is_free() {
2970
+    /**
2971
+     * Checks to see if the invoice requires payment.
2972
+     */
2973
+    public function is_free() {
2974 2974
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2975 2975
 
2976
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2977
-			$is_free = false;
2978
-		}
2976
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2977
+            $is_free = false;
2978
+        }
2979 2979
 
2980 2980
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2981 2981
     }
@@ -2986,46 +2986,46 @@  discard block
 block discarded – undo
2986 2986
     public function is_paid() {
2987 2987
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2988 2988
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2989
-	}
2989
+    }
2990 2990
 
2991
-	/**
2991
+    /**
2992 2992
      * Checks if the invoice needs payment.
2993 2993
      */
2994
-	public function needs_payment() {
2995
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2994
+    public function needs_payment() {
2995
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2996 2996
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2997 2997
     }
2998 2998
   
2999
-	/**
2999
+    /**
3000 3000
      * Checks if the invoice is refunded.
3001 3001
      */
3002
-	public function is_refunded() {
3002
+    public function is_refunded() {
3003 3003
         $is_refunded = $this->has_status( 'wpi-refunded' );
3004 3004
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3005
-	}
3005
+    }
3006 3006
 
3007
-	/**
3007
+    /**
3008 3008
      * Checks if the invoice is held.
3009 3009
      */
3010
-	public function is_held() {
3010
+    public function is_held() {
3011 3011
         $is_held = $this->has_status( 'wpi-onhold' );
3012 3012
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3013
-	}
3013
+    }
3014 3014
 
3015
-	/**
3015
+    /**
3016 3016
      * Checks if the invoice is due.
3017 3017
      */
3018
-	public function is_due() {
3019
-		$due_date = $this->get_due_date();
3020
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3021
-	}
3018
+    public function is_due() {
3019
+        $due_date = $this->get_due_date();
3020
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3021
+    }
3022 3022
 
3023
-	/**
3023
+    /**
3024 3024
      * Checks if the invoice is draft.
3025 3025
      */
3026
-	public function is_draft() {
3026
+    public function is_draft() {
3027 3027
         return $this->has_status( 'draft, auto-draft' );
3028
-	}
3028
+    }
3029 3029
 
3030 3030
     /**
3031 3031
      * Checks if the invoice has a given status.
@@ -3033,9 +3033,9 @@  discard block
 block discarded – undo
3033 3033
     public function has_status( $status ) {
3034 3034
         $status = wpinv_parse_list( $status );
3035 3035
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3036
-	}
3036
+    }
3037 3037
 
3038
-	/**
3038
+    /**
3039 3039
      * Checks if the invoice is of a given type.
3040 3040
      */
3041 3041
     public function is_type( $type ) {
@@ -3058,25 +3058,25 @@  discard block
 block discarded – undo
3058 3058
      */
3059 3059
     public function has_free_trial() {
3060 3060
         return $this->is_recurring() && 0 == $this->get_initial_total();
3061
-	}
3061
+    }
3062 3062
 
3063
-	/**
3063
+    /**
3064 3064
      * @deprecated
3065 3065
      */
3066 3066
     public function is_free_trial() {
3067 3067
         $this->has_free_trial();
3068 3068
     }
3069 3069
 
3070
-	/**
3070
+    /**
3071 3071
      * Check if the initial payment if 0.
3072 3072
      *
3073 3073
      */
3074
-	public function is_initial_free() {
3074
+    public function is_initial_free() {
3075 3075
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3076 3076
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3077 3077
     }
3078 3078
 	
3079
-	/**
3079
+    /**
3080 3080
      * Check if the recurring item has a free trial.
3081 3081
      *
3082 3082
      */
@@ -3089,21 +3089,21 @@  discard block
 block discarded – undo
3089 3089
 
3090 3090
         $item = $this->get_recurring( true );
3091 3091
         return $item->has_free_trial();
3092
-	}
3092
+    }
3093 3093
 
3094
-	/**
3094
+    /**
3095 3095
      * Check if the free trial is a result of a discount.
3096 3096
      */
3097 3097
     public function is_free_trial_from_discount() {
3098
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3099
-	}
3098
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3099
+    }
3100 3100
 	
3101
-	/**
3101
+    /**
3102 3102
      * @deprecated
3103 3103
      */
3104 3104
     public function discount_first_payment_only() {
3105 3105
 
3106
-		$discount_code = $this->get_discount_code();
3106
+        $discount_code = $this->get_discount_code();
3107 3107
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3108 3108
             return true;
3109 3109
         }
@@ -3134,28 +3134,28 @@  discard block
 block discarded – undo
3134 3134
      */
3135 3135
     public function add_item( $item ) {
3136 3136
 
3137
-		if ( is_array( $item ) ) {
3138
-			$item = $this->process_array_item( $item );
3139
-		}
3137
+        if ( is_array( $item ) ) {
3138
+            $item = $this->process_array_item( $item );
3139
+        }
3140 3140
 
3141
-		if ( is_numeric( $item ) ) {
3142
-			$item = new GetPaid_Form_Item( $item );
3143
-		}
3141
+        if ( is_numeric( $item ) ) {
3142
+            $item = new GetPaid_Form_Item( $item );
3143
+        }
3144 3144
 
3145 3145
         // Make sure that it is available for purchase.
3146
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3147
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3146
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3147
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3148 3148
         }
3149 3149
 
3150 3150
         // Do we have a recurring item?
3151
-		if ( $item->is_recurring() ) {
3151
+        if ( $item->is_recurring() ) {
3152 3152
 
3153
-			// An invoice can only contain one recurring item.
3154
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3155
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3156
-			}
3153
+            // An invoice can only contain one recurring item.
3154
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3155
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3156
+            }
3157 3157
 
3158
-			$this->recurring_item = $item->get_id();
3158
+            $this->recurring_item = $item->get_id();
3159 3159
         }
3160 3160
 
3161 3161
         // Invoice id.
@@ -3166,60 +3166,60 @@  discard block
 block discarded – undo
3166 3166
         $items[ (int) $item->get_id() ] = $item;
3167 3167
 
3168 3168
         $this->set_prop( 'items', $items );
3169
-		return true;
3170
-	}
3169
+        return true;
3170
+    }
3171 3171
 
3172
-	/**
3173
-	 * Converts an array to an item.
3174
-	 *
3175
-	 * @since 1.0.19
3176
-	 * @return GetPaid_Form_Item
3177
-	 */
3178
-	protected function process_array_item( $array ) {
3172
+    /**
3173
+     * Converts an array to an item.
3174
+     *
3175
+     * @since 1.0.19
3176
+     * @return GetPaid_Form_Item
3177
+     */
3178
+    protected function process_array_item( $array ) {
3179 3179
 
3180
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3181
-		$item    = new GetPaid_Form_Item( $item_id );
3180
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3181
+        $item    = new GetPaid_Form_Item( $item_id );
3182 3182
 
3183
-		// Set item data.
3184
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3185
-			if ( isset( $array[ "item_$key" ] ) ) {
3186
-				$method = "set_$key";
3187
-				$item->$method( $array[ "item_$key" ] );
3188
-			}
3189
-		}
3183
+        // Set item data.
3184
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3185
+            if ( isset( $array[ "item_$key" ] ) ) {
3186
+                $method = "set_$key";
3187
+                $item->$method( $array[ "item_$key" ] );
3188
+            }
3189
+        }
3190 3190
 
3191
-		if ( isset( $array['quantity'] ) ) {
3192
-			$item->set_quantity( $array['quantity'] );
3193
-		}
3191
+        if ( isset( $array['quantity'] ) ) {
3192
+            $item->set_quantity( $array['quantity'] );
3193
+        }
3194 3194
 
3195
-		// Set item meta.
3196
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3197
-			$item->set_item_meta( $array['meta'] );
3198
-		}
3195
+        // Set item meta.
3196
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3197
+            $item->set_item_meta( $array['meta'] );
3198
+        }
3199 3199
 
3200
-		return $item;
3200
+        return $item;
3201 3201
 
3202
-	}
3202
+    }
3203 3203
 
3204 3204
     /**
3205
-	 * Retrieves a specific item.
3206
-	 *
3207
-	 * @since 1.0.19
3208
-	 */
3209
-	public function get_item( $item_id ) {
3210
-		$items   = $this->get_items();
3211
-		$item_id = (int) $item_id;
3212
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3205
+     * Retrieves a specific item.
3206
+     *
3207
+     * @since 1.0.19
3208
+     */
3209
+    public function get_item( $item_id ) {
3210
+        $items   = $this->get_items();
3211
+        $item_id = (int) $item_id;
3212
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3213 3213
     }
3214 3214
 
3215 3215
     /**
3216
-	 * Removes a specific item.
3217
-	 *
3218
-	 * @since 1.0.19
3219
-	 */
3220
-	public function remove_item( $item_id ) {
3221
-		$items   = $this->get_items();
3222
-		$item_id = (int) $item_id;
3216
+     * Removes a specific item.
3217
+     *
3218
+     * @since 1.0.19
3219
+     */
3220
+    public function remove_item( $item_id ) {
3221
+        $items   = $this->get_items();
3222
+        $item_id = (int) $item_id;
3223 3223
 
3224 3224
         if ( $item_id == $this->recurring_item ) {
3225 3225
             $this->recurring_item = null;
@@ -3232,35 +3232,35 @@  discard block
 block discarded – undo
3232 3232
     }
3233 3233
 
3234 3234
     /**
3235
-	 * Adds a fee to the invoice.
3236
-	 *
3237
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3238
-	 * @since 1.0.19
3239
-	 */
3235
+     * Adds a fee to the invoice.
3236
+     *
3237
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3238
+     * @since 1.0.19
3239
+     */
3240 3240
     public function add_fee( $fee ) {
3241 3241
 
3242
-		$fees                 = $this->get_fees();
3243
-		$fees[ $fee['name'] ] = $fee;
3244
-		$this->set_prop( 'fees', $fees );
3242
+        $fees                 = $this->get_fees();
3243
+        $fees[ $fee['name'] ] = $fee;
3244
+        $this->set_prop( 'fees', $fees );
3245 3245
 
3246 3246
     }
3247 3247
 
3248 3248
     /**
3249
-	 * Retrieves a specific fee.
3250
-	 *
3251
-	 * @since 1.0.19
3252
-	 */
3253
-	public function get_fee( $fee ) {
3249
+     * Retrieves a specific fee.
3250
+     *
3251
+     * @since 1.0.19
3252
+     */
3253
+    public function get_fee( $fee ) {
3254 3254
         $fees = $this->get_fees();
3255
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3255
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3256 3256
     }
3257 3257
 
3258 3258
     /**
3259
-	 * Removes a specific fee.
3260
-	 *
3261
-	 * @since 1.0.19
3262
-	 */
3263
-	public function remove_fee( $fee ) {
3259
+     * Removes a specific fee.
3260
+     *
3261
+     * @since 1.0.19
3262
+     */
3263
+    public function remove_fee( $fee ) {
3264 3264
         $fees = $this->get_fees();
3265 3265
         if ( isset( $fees[ $fee ] ) ) {
3266 3266
             unset( $fees[ $fee ] );
@@ -3268,43 +3268,43 @@  discard block
 block discarded – undo
3268 3268
         }
3269 3269
     }
3270 3270
 
3271
-	/**
3272
-	 * Adds a discount to the invoice.
3273
-	 *
3274
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3275
-	 * @since 1.0.19
3276
-	 */
3277
-	public function add_discount( $discount ) {
3271
+    /**
3272
+     * Adds a discount to the invoice.
3273
+     *
3274
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3275
+     * @since 1.0.19
3276
+     */
3277
+    public function add_discount( $discount ) {
3278 3278
 
3279
-		$discounts = $this->get_discounts();
3280
-		$discounts[ $discount['name'] ] = $discount;
3281
-		$this->set_prop( 'discounts', $discounts );
3279
+        $discounts = $this->get_discounts();
3280
+        $discounts[ $discount['name'] ] = $discount;
3281
+        $this->set_prop( 'discounts', $discounts );
3282 3282
 
3283
-	}
3283
+    }
3284 3284
 
3285 3285
     /**
3286
-	 * Retrieves a specific discount.
3287
-	 *
3288
-	 * @since 1.0.19
3289
-	 * @return float
3290
-	 */
3291
-	public function get_discount( $discount = false ) {
3286
+     * Retrieves a specific discount.
3287
+     *
3288
+     * @since 1.0.19
3289
+     * @return float
3290
+     */
3291
+    public function get_discount( $discount = false ) {
3292 3292
 
3293
-		// Backwards compatibilty.
3294
-		if ( empty( $discount ) ) {
3295
-			return $this->get_total_discount();
3296
-		}
3293
+        // Backwards compatibilty.
3294
+        if ( empty( $discount ) ) {
3295
+            return $this->get_total_discount();
3296
+        }
3297 3297
 
3298 3298
         $discounts = $this->get_discounts();
3299
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3299
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3300 3300
     }
3301 3301
 
3302 3302
     /**
3303
-	 * Removes a specific discount.
3304
-	 *
3305
-	 * @since 1.0.19
3306
-	 */
3307
-	public function remove_discount( $discount ) {
3303
+     * Removes a specific discount.
3304
+     *
3305
+     * @since 1.0.19
3306
+     */
3307
+    public function remove_discount( $discount ) {
3308 3308
         $discounts = $this->get_discounts();
3309 3309
         if ( isset( $discounts[ $discount ] ) ) {
3310 3310
             unset( $discounts[ $discount ] );
@@ -3321,34 +3321,34 @@  discard block
 block discarded – undo
3321 3321
         if ( $this->is_taxable() ) {
3322 3322
 
3323 3323
             $taxes                 = $this->get_taxes();
3324
-			$taxes[ $tax['name'] ] = $tax;
3325
-			$this->set_prop( 'taxes', $tax );
3324
+            $taxes[ $tax['name'] ] = $tax;
3325
+            $this->set_prop( 'taxes', $tax );
3326 3326
 
3327 3327
         }
3328 3328
     }
3329 3329
 
3330 3330
     /**
3331
-	 * Retrieves a specific tax.
3332
-	 *
3333
-	 * @since 1.0.19
3334
-	 */
3335
-	public function get_tax( $tax = null ) {
3331
+     * Retrieves a specific tax.
3332
+     *
3333
+     * @since 1.0.19
3334
+     */
3335
+    public function get_tax( $tax = null ) {
3336 3336
 
3337
-		// Backwards compatility.
3338
-		if ( empty( $tax ) ) {
3339
-			return $this->get_total_tax();
3340
-		}
3337
+        // Backwards compatility.
3338
+        if ( empty( $tax ) ) {
3339
+            return $this->get_total_tax();
3340
+        }
3341 3341
 
3342 3342
         $taxes = $this->get_taxes();
3343
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3343
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3344 3344
     }
3345 3345
 
3346 3346
     /**
3347
-	 * Removes a specific tax.
3348
-	 *
3349
-	 * @since 1.0.19
3350
-	 */
3351
-	public function remove_tax( $tax ) {
3347
+     * Removes a specific tax.
3348
+     *
3349
+     * @since 1.0.19
3350
+     */
3351
+    public function remove_tax( $tax ) {
3352 3352
         $taxes = $this->get_taxes();
3353 3353
         if ( isset( $taxes[ $tax ] ) ) {
3354 3354
             unset( $taxes[ $tax ] );
@@ -3357,134 +3357,134 @@  discard block
 block discarded – undo
3357 3357
     }
3358 3358
 
3359 3359
     /**
3360
-	 * Recalculates the invoice subtotal.
3361
-	 *
3362
-	 * @since 1.0.19
3363
-	 * @return float The recalculated subtotal
3364
-	 */
3365
-	public function recalculate_subtotal() {
3360
+     * Recalculates the invoice subtotal.
3361
+     *
3362
+     * @since 1.0.19
3363
+     * @return float The recalculated subtotal
3364
+     */
3365
+    public function recalculate_subtotal() {
3366 3366
         $items     = $this->get_items();
3367
-		$subtotal  = 0;
3368
-		$recurring = 0;
3367
+        $subtotal  = 0;
3368
+        $recurring = 0;
3369 3369
 
3370 3370
         foreach ( $items as $item ) {
3371
-			$subtotal  += $item->get_sub_total();
3372
-			$recurring += $item->get_recurring_sub_total();
3371
+            $subtotal  += $item->get_sub_total();
3372
+            $recurring += $item->get_recurring_sub_total();
3373 3373
         }
3374 3374
 
3375
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3376
-		$this->set_subtotal( $current );
3375
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3376
+        $this->set_subtotal( $current );
3377 3377
 
3378
-		$this->totals['subtotal'] = array(
3379
-			'initial'   => $subtotal,
3380
-			'recurring' => $recurring,
3381
-		);
3378
+        $this->totals['subtotal'] = array(
3379
+            'initial'   => $subtotal,
3380
+            'recurring' => $recurring,
3381
+        );
3382 3382
 
3383 3383
         return $current;
3384 3384
     }
3385 3385
 
3386 3386
     /**
3387
-	 * Recalculates the invoice discount total.
3388
-	 *
3389
-	 * @since 1.0.19
3390
-	 * @return float The recalculated discount
3391
-	 */
3392
-	public function recalculate_total_discount() {
3387
+     * Recalculates the invoice discount total.
3388
+     *
3389
+     * @since 1.0.19
3390
+     * @return float The recalculated discount
3391
+     */
3392
+    public function recalculate_total_discount() {
3393 3393
         $discounts = $this->get_discounts();
3394
-		$discount  = 0;
3395
-		$recurring = 0;
3394
+        $discount  = 0;
3395
+        $recurring = 0;
3396 3396
 
3397 3397
         foreach ( $discounts as $data ) {
3398
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3399
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3400
-		}
3398
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3399
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3400
+        }
3401 3401
 
3402
-		$current = $this->is_renewal() ? $recurring : $discount;
3402
+        $current = $this->is_renewal() ? $recurring : $discount;
3403 3403
 
3404
-		$this->set_total_discount( $current );
3404
+        $this->set_total_discount( $current );
3405 3405
 
3406
-		$this->totals['discount'] = array(
3407
-			'initial'   => $discount,
3408
-			'recurring' => $recurring,
3409
-		);
3406
+        $this->totals['discount'] = array(
3407
+            'initial'   => $discount,
3408
+            'recurring' => $recurring,
3409
+        );
3410 3410
 
3411
-		return $current;
3411
+        return $current;
3412 3412
 
3413 3413
     }
3414 3414
 
3415 3415
     /**
3416
-	 * Recalculates the invoice tax total.
3417
-	 *
3418
-	 * @since 1.0.19
3419
-	 * @return float The recalculated tax
3420
-	 */
3421
-	public function recalculate_total_tax() {
3416
+     * Recalculates the invoice tax total.
3417
+     *
3418
+     * @since 1.0.19
3419
+     * @return float The recalculated tax
3420
+     */
3421
+    public function recalculate_total_tax() {
3422 3422
         $taxes     = $this->get_taxes();
3423
-		$tax       = 0;
3424
-		$recurring = 0;
3423
+        $tax       = 0;
3424
+        $recurring = 0;
3425 3425
 
3426 3426
         foreach ( $taxes as $data ) {
3427
-			$tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3428
-			$recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3429
-		}
3427
+            $tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3428
+            $recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3429
+        }
3430 3430
 
3431
-		$current = $this->is_renewal() ? $recurring : $tax;
3432
-		$this->set_total_tax( $current );
3431
+        $current = $this->is_renewal() ? $recurring : $tax;
3432
+        $this->set_total_tax( $current );
3433 3433
 
3434
-		$this->totals['tax'] = array(
3435
-			'initial'   => $tax,
3436
-			'recurring' => $recurring,
3437
-		);
3434
+        $this->totals['tax'] = array(
3435
+            'initial'   => $tax,
3436
+            'recurring' => $recurring,
3437
+        );
3438 3438
 
3439
-		return $current;
3439
+        return $current;
3440 3440
 
3441 3441
     }
3442 3442
 
3443 3443
     /**
3444
-	 * Recalculates the invoice fees total.
3445
-	 *
3446
-	 * @since 1.0.19
3447
-	 * @return float The recalculated fee
3448
-	 */
3449
-	public function recalculate_total_fees() {
3450
-		$fees      = $this->get_fees();
3451
-		$fee       = 0;
3452
-		$recurring = 0;
3444
+     * Recalculates the invoice fees total.
3445
+     *
3446
+     * @since 1.0.19
3447
+     * @return float The recalculated fee
3448
+     */
3449
+    public function recalculate_total_fees() {
3450
+        $fees      = $this->get_fees();
3451
+        $fee       = 0;
3452
+        $recurring = 0;
3453 3453
 
3454 3454
         foreach ( $fees as $data ) {
3455
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3456
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3457
-		}
3455
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3456
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3457
+        }
3458 3458
 
3459
-		$current = $this->is_renewal() ? $recurring : $fee;
3460
-		$this->set_total_fees( $current );
3459
+        $current = $this->is_renewal() ? $recurring : $fee;
3460
+        $this->set_total_fees( $current );
3461 3461
 
3462
-		$this->totals['fee'] = array(
3463
-			'initial'   => $fee,
3464
-			'recurring' => $recurring,
3465
-		);
3462
+        $this->totals['fee'] = array(
3463
+            'initial'   => $fee,
3464
+            'recurring' => $recurring,
3465
+        );
3466 3466
 
3467 3467
         $this->set_total_fees( $fee );
3468 3468
         return $current;
3469 3469
     }
3470 3470
 
3471 3471
     /**
3472
-	 * Recalculates the invoice total.
3473
-	 *
3474
-	 * @since 1.0.19
3472
+     * Recalculates the invoice total.
3473
+     *
3474
+     * @since 1.0.19
3475 3475
      * @return float The invoice total
3476
-	 */
3477
-	public function recalculate_total() {
3476
+     */
3477
+    public function recalculate_total() {
3478 3478
         $this->recalculate_subtotal();
3479 3479
         $this->recalculate_total_fees();
3480 3480
         $this->recalculate_total_discount();
3481 3481
         $this->recalculate_total_tax();
3482
-		return $this->get_total();
3483
-	}
3482
+        return $this->get_total();
3483
+    }
3484 3484
 
3485
-	/**
3486
-	 * @deprecated
3487
-	 */
3485
+    /**
3486
+     * @deprecated
3487
+     */
3488 3488
     public function recalculate_totals( $temp = false ) {
3489 3489
         $this->update_items( $temp );
3490 3490
         $this->save( true );
@@ -3502,7 +3502,7 @@  discard block
 block discarded – undo
3502 3502
      * Adds a note to an invoice.
3503 3503
      *
3504 3504
      * @param string $note The note being added.
3505
-	 * @return int|false The new note's ID on success, false on failure.
3505
+     * @return int|false The new note's ID on success, false on failure.
3506 3506
      *
3507 3507
      */
3508 3508
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3512,21 +3512,21 @@  discard block
 block discarded – undo
3512 3512
             return false;
3513 3513
         }
3514 3514
 
3515
-		$author       = 'System';
3516
-		$author_email = '[email protected]';
3515
+        $author       = 'System';
3516
+        $author_email = '[email protected]';
3517 3517
 
3518
-		// If this is an admin comment or it has been added by the user.
3519
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3520
-			$user         = get_user_by( 'id', get_current_user_id() );
3518
+        // If this is an admin comment or it has been added by the user.
3519
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3520
+            $user         = get_user_by( 'id', get_current_user_id() );
3521 3521
             $author       = $user->display_name;
3522 3522
             $author_email = $user->user_email;
3523
-		}
3523
+        }
3524 3524
 
3525
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3525
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3526 3526
 
3527
-	}
3527
+    }
3528 3528
 
3529
-	/**
3529
+    /**
3530 3530
      * Generates a unique key for the invoice.
3531 3531
      */
3532 3532
     public function generate_key( $string = '' ) {
@@ -3546,113 +3546,113 @@  discard block
 block discarded – undo
3546 3546
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3547 3547
         }
3548 3548
 
3549
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3550
-
3551
-	}
3552
-
3553
-	/**
3554
-	 * Handle the status transition.
3555
-	 */
3556
-	protected function status_transition() {
3557
-		$status_transition = $this->status_transition;
3558
-
3559
-		// Reset status transition variable.
3560
-		$this->status_transition = false;
3561
-
3562
-		if ( $status_transition ) {
3563
-			try {
3549
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3564 3550
 
3565
-				// Fire a hook for the status change.
3566
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3567
-
3568
-				// @deprecated this is deprecated and will be removed in the future.
3569
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3570
-
3571
-				if ( ! empty( $status_transition['from'] ) ) {
3572
-
3573
-					/* translators: 1: old invoice status 2: new invoice status */
3574
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3575
-
3576
-					// Fire another hook.
3577
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3578
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3579
-
3580
-					// @deprecated this is deprecated and will be removed in the future.
3581
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3582
-
3583
-					// Note the transition occurred.
3584
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3585
-
3586
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3587
-					if (
3588
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3589
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3590
-					) {
3591
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3592
-					}
3593
-
3594
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3595
-					if (
3596
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3597
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3598
-					) {
3599
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3600
-					}
3601
-				} else {
3602
-					/* translators: %s: new invoice status */
3603
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3604
-
3605
-					// Note the transition occurred.
3606
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3551
+    }
3607 3552
 
3608
-				}
3609
-			} catch ( Exception $e ) {
3610
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3611
-			}
3612
-		}
3613
-	}
3553
+    /**
3554
+     * Handle the status transition.
3555
+     */
3556
+    protected function status_transition() {
3557
+        $status_transition = $this->status_transition;
3558
+
3559
+        // Reset status transition variable.
3560
+        $this->status_transition = false;
3561
+
3562
+        if ( $status_transition ) {
3563
+            try {
3564
+
3565
+                // Fire a hook for the status change.
3566
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3567
+
3568
+                // @deprecated this is deprecated and will be removed in the future.
3569
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3570
+
3571
+                if ( ! empty( $status_transition['from'] ) ) {
3572
+
3573
+                    /* translators: 1: old invoice status 2: new invoice status */
3574
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3575
+
3576
+                    // Fire another hook.
3577
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3578
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3579
+
3580
+                    // @deprecated this is deprecated and will be removed in the future.
3581
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3582
+
3583
+                    // Note the transition occurred.
3584
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3585
+
3586
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3587
+                    if (
3588
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3589
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3590
+                    ) {
3591
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3592
+                    }
3593
+
3594
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3595
+                    if (
3596
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3597
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3598
+                    ) {
3599
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3600
+                    }
3601
+                } else {
3602
+                    /* translators: %s: new invoice status */
3603
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3604
+
3605
+                    // Note the transition occurred.
3606
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3607
+
3608
+                }
3609
+            } catch ( Exception $e ) {
3610
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3611
+            }
3612
+        }
3613
+    }
3614 3614
 
3615
-	/**
3616
-	 * Updates an invoice status.
3617
-	 */
3618
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3615
+    /**
3616
+     * Updates an invoice status.
3617
+     */
3618
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3619 3619
 
3620
-		// Fires before updating a status.
3621
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3620
+        // Fires before updating a status.
3621
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3622 3622
 
3623
-		// Update the status.
3624
-		$this->set_status( $new_status, $note, $manual );
3623
+        // Update the status.
3624
+        $this->set_status( $new_status, $note, $manual );
3625 3625
 
3626
-		// Save the order.
3627
-		return $this->save();
3626
+        // Save the order.
3627
+        return $this->save();
3628 3628
 
3629
-	}
3629
+    }
3630 3630
 
3631
-	/**
3632
-	 * @deprecated
3633
-	 */
3634
-	public function refresh_item_ids() {
3631
+    /**
3632
+     * @deprecated
3633
+     */
3634
+    public function refresh_item_ids() {
3635 3635
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3636 3636
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3637
-	}
3637
+    }
3638 3638
 
3639
-	/**
3640
-	 * @deprecated
3641
-	 */
3642
-	public function update_items( $temp = false ) {
3639
+    /**
3640
+     * @deprecated
3641
+     */
3642
+    public function update_items( $temp = false ) {
3643 3643
 
3644
-		$this->set_items( $this->get_items() );
3644
+        $this->set_items( $this->get_items() );
3645 3645
 
3646
-		if ( ! $temp ) {
3647
-			$this->save();
3648
-		}
3646
+        if ( ! $temp ) {
3647
+            $this->save();
3648
+        }
3649 3649
 
3650 3650
         return $this;
3651
-	}
3651
+    }
3652 3652
 
3653
-	/**
3654
-	 * @deprecated
3655
-	 */
3653
+    /**
3654
+     * @deprecated
3655
+     */
3656 3656
     public function validate_discount() {
3657 3657
 
3658 3658
         $discount_code = $this->get_discount_code();
@@ -3668,97 +3668,97 @@  discard block
 block discarded – undo
3668 3668
 
3669 3669
     }
3670 3670
 
3671
-	/**
3672
-	 * Refunds an invoice.
3673
-	 */
3671
+    /**
3672
+     * Refunds an invoice.
3673
+     */
3674 3674
     public function refund() {
3675
-		$this->set_status( 'wpi-refunded' );
3675
+        $this->set_status( 'wpi-refunded' );
3676 3676
         $this->save();
3677
-	}
3677
+    }
3678 3678
 
3679
-	/**
3680
-	 * Marks an invoice as paid.
3681
-	 * 
3682
-	 * @param string $transaction_id
3683
-	 */
3679
+    /**
3680
+     * Marks an invoice as paid.
3681
+     * 
3682
+     * @param string $transaction_id
3683
+     */
3684 3684
     public function mark_paid( $transaction_id = null, $note = '' ) {
3685 3685
 
3686
-		// Set the transaction id.
3687
-		if ( empty( $transaction_id ) ) {
3688
-			$transaction_id = $this->generate_key('trans_');
3689
-		}
3686
+        // Set the transaction id.
3687
+        if ( empty( $transaction_id ) ) {
3688
+            $transaction_id = $this->generate_key('trans_');
3689
+        }
3690 3690
 
3691
-		if ( ! $this->get_transaction_id() ) {
3692
-			$this->set_transaction_id( $transaction_id );
3693
-		}
3691
+        if ( ! $this->get_transaction_id() ) {
3692
+            $this->set_transaction_id( $transaction_id );
3693
+        }
3694 3694
 
3695
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3696
-			return $this->save();
3697
-		}
3695
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3696
+            return $this->save();
3697
+        }
3698 3698
 
3699
-		// Set the completed date.
3700
-		$this->set_date_completed( current_time( 'mysql' ) );
3699
+        // Set the completed date.
3700
+        $this->set_date_completed( current_time( 'mysql' ) );
3701 3701
 
3702
-		// Set the new status.
3703
-		if ( $this->is_renewal() ) {
3702
+        // Set the new status.
3703
+        if ( $this->is_renewal() ) {
3704 3704
 
3705
-			$_note = sprintf(
3706
-				__( 'Renewed via %s', 'invoicing' ),
3707
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3708
-			);
3705
+            $_note = sprintf(
3706
+                __( 'Renewed via %s', 'invoicing' ),
3707
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3708
+            );
3709 3709
 
3710
-			if ( 'none' == $this->get_gateway() ) {
3711
-				$_note = $note;
3712
-			}
3710
+            if ( 'none' == $this->get_gateway() ) {
3711
+                $_note = $note;
3712
+            }
3713 3713
 
3714
-			$this->set_status( 'wpi-renewal', $_note );
3714
+            $this->set_status( 'wpi-renewal', $_note );
3715 3715
 
3716
-		} else {
3716
+        } else {
3717 3717
 
3718
-			$_note = sprintf(
3719
-				__( 'Paid via %s', 'invoicing' ),
3720
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3721
-			);
3718
+            $_note = sprintf(
3719
+                __( 'Paid via %s', 'invoicing' ),
3720
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3721
+            );
3722 3722
 
3723
-			if ( 'none' == $this->get_gateway() ) {
3724
-				$_note = $note;
3725
-			}
3723
+            if ( 'none' == $this->get_gateway() ) {
3724
+                $_note = $note;
3725
+            }
3726 3726
 
3727
-			$this->set_status( 'publish',$_note );
3727
+            $this->set_status( 'publish',$_note );
3728 3728
 
3729
-		}
3729
+        }
3730 3730
 
3731
-		// Set checkout mode.
3732
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3733
-		$this->set_mode( $mode );
3731
+        // Set checkout mode.
3732
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3733
+        $this->set_mode( $mode );
3734 3734
 
3735
-		// Save the invoice.
3735
+        // Save the invoice.
3736 3736
         $this->save();
3737
-	}
3738
-
3739
-
3740
-	/**
3741
-	 * Save data to the database.
3742
-	 *
3743
-	 * @since 1.0.19
3744
-	 * @return int invoice ID
3745
-	 */
3746
-	public function save() {
3747
-		$this->maybe_set_date_paid();
3748
-		$this->maybe_set_key();
3749
-		parent::save();
3750
-		$this->clear_cache();
3751
-		$this->status_transition();
3752
-		return $this->get_id();
3753
-	}
3754
-
3755
-	/**
3737
+    }
3738
+
3739
+
3740
+    /**
3741
+     * Save data to the database.
3742
+     *
3743
+     * @since 1.0.19
3744
+     * @return int invoice ID
3745
+     */
3746
+    public function save() {
3747
+        $this->maybe_set_date_paid();
3748
+        $this->maybe_set_key();
3749
+        parent::save();
3750
+        $this->clear_cache();
3751
+        $this->status_transition();
3752
+        return $this->get_id();
3753
+    }
3754
+
3755
+    /**
3756 3756
      * Clears the subscription's cache.
3757 3757
      */
3758 3758
     public function clear_cache() {
3759
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3760
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3761
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3762
-	}
3759
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3760
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3761
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3762
+    }
3763 3763
 
3764 3764
 }
Please login to merge, or discard this patch.
includes/class-getpaid-notification-email-sender.php 1 patch
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Notification_Email_Sender {
14 14
 
15 15
     /**
16
-	 * Whether or not we should inline CSS into the email.
17
-	 */
18
-	public $inline_css = true;
16
+     * Whether or not we should inline CSS into the email.
17
+     */
18
+    public $inline_css = true;
19 19
 
20 20
     /**
21
-	 * The wp_mail() data.
22
-	 */
21
+     * The wp_mail() data.
22
+     */
23 23
     public $wp_mail_data = null;
24 24
 
25 25
     /**
26
-	 * Sends a new email.
26
+     * Sends a new email.
27 27
      * 
28 28
      * @param string|array $to The recipients email or an array of recipient emails.
29 29
      * @param string $subject The email's subject.
@@ -31,49 +31,49 @@  discard block
 block discarded – undo
31 31
      * @param array $attachments The email attachments.
32 32
      * 
33 33
      * @return bool
34
-	 */
35
-	public function send( $to, $subject, $email, $attachments = array() ) {
34
+     */
35
+    public function send( $to, $subject, $email, $attachments = array() ) {
36 36
 
37
-		/*
37
+        /*
38 38
 		 * Allow to filter data on per-email basis.
39 39
 		 */
40
-		$data = apply_filters(
41
-			'getpaid_email_data',
42
-			array(
43
-				'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
44
-				'subject'     => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ),
45
-				'email'       => $email,
46
-				'headers'     => $this->get_headers(),
47
-				'attachments' => $attachments,
48
-			),
49
-			$this
50
-		);
40
+        $data = apply_filters(
41
+            'getpaid_email_data',
42
+            array(
43
+                'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
44
+                'subject'     => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ),
45
+                'email'       => $email,
46
+                'headers'     => $this->get_headers(),
47
+                'attachments' => $attachments,
48
+            ),
49
+            $this
50
+        );
51 51
 
52 52
         // Remove slashes.
53 53
         $data               = (array) wp_unslash( $data );
54 54
 
55 55
         // Cache it.
56
-		$this->wp_mail_data = $data;
56
+        $this->wp_mail_data = $data;
57 57
 
58
-		// Attach our own hooks.
59
-		$this->before_sending();
58
+        // Attach our own hooks.
59
+        $this->before_sending();
60 60
 
61 61
         $result = false;
62 62
 
63 63
         foreach ( $this->wp_mail_data['to'] as $to ) {
64
-			$result = $this->_send( $to, $data );
64
+            $result = $this->_send( $to, $data );
65 65
         }
66 66
 
67
-		// Remove our hooks.
68
-		$this->after_sending();		
67
+        // Remove our hooks.
68
+        $this->after_sending();		
69 69
 
70
-		$this->wp_mail_data = null;
70
+        $this->wp_mail_data = null;
71 71
 
72
-		return $result;
73
-	}
72
+        return $result;
73
+    }
74 74
 
75
-	/**
76
-	 * Does the actual sending.
75
+    /**
76
+     * Does the actual sending.
77 77
      * 
78 78
      * @param string $to The recipient's email.
79 79
      * @param array $data The email's data.
@@ -81,81 +81,81 @@  discard block
 block discarded – undo
81 81
      * @param array $attachments The email attachments.
82 82
      * 
83 83
      * @return bool
84
-	 */
85
-	protected function _send( $to, $data ) {
86
-
87
-		// Prepare the sending function.
88
-		$sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
89
-
90
-		// Send the actual email.
91
-		$result = call_user_func(
92
-			$sending_function,
93
-			$to,
94
-			html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
95
-			$data['email'],
96
-			$data['headers'],
97
-			$data['attachments']
98
-		);
99
-
100
-		if ( ! $result ) {
101
-			$log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
-			wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
103
-		}
104
-
105
-		return $result;
106
-	}
84
+     */
85
+    protected function _send( $to, $data ) {
86
+
87
+        // Prepare the sending function.
88
+        $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
89
+
90
+        // Send the actual email.
91
+        $result = call_user_func(
92
+            $sending_function,
93
+            $to,
94
+            html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
95
+            $data['email'],
96
+            $data['headers'],
97
+            $data['attachments']
98
+        );
99
+
100
+        if ( ! $result ) {
101
+            $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
+            wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
103
+        }
104
+
105
+        return $result;
106
+    }
107 107
     
108 108
     /**
109
-	 * Retrieves email headers.
110
-	 */
111
-	public function get_headers() {
109
+     * Retrieves email headers.
110
+     */
111
+    public function get_headers() {
112 112
 
113
-		$name       = $this->get_from_name();
114
-		$reply_to   = $this->get_reply_to();
115
-		$headers    = array( "Reply-To:$name <$reply_to>" );
113
+        $name       = $this->get_from_name();
114
+        $reply_to   = $this->get_reply_to();
115
+        $headers    = array( "Reply-To:$name <$reply_to>" );
116 116
 
117
-		return apply_filters( 'getpaid_email_headers',  $headers, $this );
117
+        return apply_filters( 'getpaid_email_headers',  $headers, $this );
118 118
 
119
-	}
119
+    }
120 120
 
121 121
     /**
122
-	 * Fires before an email is sent
123
-	 *
124
-	 * @since 1.0.0
125
-	 */
126
-	public function before_sending() {
122
+     * Fires before an email is sent
123
+     *
124
+     * @since 1.0.0
125
+     */
126
+    public function before_sending() {
127 127
 
128 128
         do_action( 'getpaid_before_send_email', $this );
129
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
-		add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 );
129
+        add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
+        add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
+        add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
+        add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 );
133 133
 
134
-	}
134
+    }
135 135
 
136 136
     /**
137
-	 * Returns the from name.
138
-	 */
139
-	public function get_from_name() {
137
+     * Returns the from name.
138
+     */
139
+    public function get_from_name() {
140 140
 
141 141
         $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) );
142 142
 
143
-		if ( empty( $from_name ) ) {
144
-			$from_name =  get_bloginfo( 'name' );
143
+        if ( empty( $from_name ) ) {
144
+            $from_name =  get_bloginfo( 'name' );
145 145
         }
146 146
 
147
-		return wp_specialchars_decode( $from_name, ENT_QUOTES );
147
+        return wp_specialchars_decode( $from_name, ENT_QUOTES );
148 148
     }
149 149
 
150 150
     /**
151
-	 * Returns the from email.
152
-	 */
153
-	public function get_from_address() {
151
+     * Returns the from email.
152
+     */
153
+    public function get_from_address() {
154 154
 
155 155
         $from_address = wpinv_get_option( 'email_from', $this->default_from_address() );
156 156
 
157
-		if ( ! is_email( $from_address ) ) {
158
-			$from_address =  $this->default_from_address();
157
+        if ( ! is_email( $from_address ) ) {
158
+            $from_address =  $this->default_from_address();
159 159
         }
160 160
         
161 161
         return $from_address;
@@ -163,75 +163,75 @@  discard block
 block discarded – undo
163 163
     }
164 164
 
165 165
     /**
166
-	 * The default emails from address.
167
-	 * 
168
-	 * Defaults to wordpress@$sitename
169
-	 * Some hosts will block outgoing mail from this address if it doesn't exist,
170
-	 * but there's no easy alternative. Defaulting to admin_email might appear to be
171
-	 * another option, but some hosts may refuse to relay mail from an unknown domain.
172
-	 *
173
-	 */
174
-	public function default_from_address() {
175
-
176
-		// Get the site domain and get rid of www.
177
-		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
-		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
-			$sitename = substr( $sitename, 4 );
180
-		}
181
-
182
-		$from_email = 'wordpress@' . $sitename;
183
-
184
-		return apply_filters( 'getpaid_default_from_address', $from_email );
166
+     * The default emails from address.
167
+     * 
168
+     * Defaults to wordpress@$sitename
169
+     * Some hosts will block outgoing mail from this address if it doesn't exist,
170
+     * but there's no easy alternative. Defaulting to admin_email might appear to be
171
+     * another option, but some hosts may refuse to relay mail from an unknown domain.
172
+     *
173
+     */
174
+    public function default_from_address() {
175
+
176
+        // Get the site domain and get rid of www.
177
+        $sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
+        if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
+            $sitename = substr( $sitename, 4 );
180
+        }
181
+
182
+        $from_email = 'wordpress@' . $sitename;
183
+
184
+        return apply_filters( 'getpaid_default_from_address', $from_email );
185 185
 
186 186
     }
187 187
     
188 188
     /**
189
-	 * Get the email reply-to.
190
-	 *
191
-	 *
192
-	 * @return string The email reply-to address.
193
-	 */
194
-	public function get_reply_to() {
189
+     * Get the email reply-to.
190
+     *
191
+     *
192
+     * @return string The email reply-to address.
193
+     */
194
+    public function get_reply_to() {
195 195
 
196
-		$reply_to = wpinv_get_admin_email();
196
+        $reply_to = wpinv_get_admin_email();
197 197
 
198
-		if ( ! is_email( $reply_to ) ) {
199
-			$reply_to =  get_option( 'admin_email' );
200
-		}
198
+        if ( ! is_email( $reply_to ) ) {
199
+            $reply_to =  get_option( 'admin_email' );
200
+        }
201 201
 
202
-		return $reply_to;
202
+        return $reply_to;
203 203
     }
204 204
     
205 205
     /**
206
-	 * Get the email content type.
207
-	 *
208
-	 */
209
-	public function get_content_type() {
210
-		return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
206
+     * Get the email content type.
207
+     *
208
+     */
209
+    public function get_content_type() {
210
+        return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
211 211
     }
212 212
     
213 213
     /**
214
-	 * Ensures that our email messages are not messed up by template plugins.
215
-	 *
216
-	 * @return array wp_mail_data.
217
-	 */
218
-	public function ensure_email_content( $args ) {
219
-		$args['message'] = $this->wp_mail_data['email'];
220
-		return $args;
214
+     * Ensures that our email messages are not messed up by template plugins.
215
+     *
216
+     * @return array wp_mail_data.
217
+     */
218
+    public function ensure_email_content( $args ) {
219
+        $args['message'] = $this->wp_mail_data['email'];
220
+        return $args;
221 221
     }
222 222
     
223 223
     /**
224
-	 * A little house keeping after an email is sent.
225
-	 *
226
- 	 */
227
-	public function after_sending() {
224
+     * A little house keeping after an email is sent.
225
+     *
226
+     */
227
+    public function after_sending() {
228 228
 
229 229
         do_action( 'getpaid_after_send_email', $this->wp_mail_data );
230
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
-		remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
230
+        remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
+        remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
+        remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
+        remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
234 234
 
235
-	}
235
+    }
236 236
 
237 237
 }
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Indentation   +338 added lines, -338 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = esc_attr( $option['desc'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = esc_attr( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -425,333 +425,333 @@  discard block
 block discarded – undo
425 425
 }
426 426
 
427 427
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
428
-	$pages_options = array();
428
+    $pages_options = array();
429 429
 
430
-	if( $default_label !== NULL && $default_label !== false ) {
431
-		$pages_options = array( '' => $default_label ); // Blank option
432
-	}
430
+    if( $default_label !== NULL && $default_label !== false ) {
431
+        $pages_options = array( '' => $default_label ); // Blank option
432
+    }
433 433
 
434
-	$pages = get_pages();
435
-	if ( $pages ) {
436
-		foreach ( $pages as $page ) {
437
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
434
+    $pages = get_pages();
435
+    if ( $pages ) {
436
+        foreach ( $pages as $page ) {
437
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
438 438
             $pages_options[ $page->ID ] = $title;
439
-		}
440
-	}
439
+        }
440
+    }
441 441
 
442
-	return $pages_options;
442
+    return $pages_options;
443 443
 }
444 444
 
445 445
 function wpinv_header_callback( $args ) {
446
-	if ( !empty( $args['desc'] ) ) {
446
+    if ( !empty( $args['desc'] ) ) {
447 447
         echo $args['desc'];
448 448
     }
449 449
 }
450 450
 
451 451
 function wpinv_hidden_callback( $args ) {
452
-	global $wpinv_options;
453
-
454
-	if ( isset( $args['set_value'] ) ) {
455
-		$value = $args['set_value'];
456
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
457
-		$value = $wpinv_options[ $args['id'] ];
458
-	} else {
459
-		$value = isset( $args['std'] ) ? $args['std'] : '';
460
-	}
461
-
462
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
463
-		$args['readonly'] = true;
464
-		$value = isset( $args['std'] ) ? $args['std'] : '';
465
-		$name  = '';
466
-	} else {
467
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
468
-	}
469
-
470
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
452
+    global $wpinv_options;
453
+
454
+    if ( isset( $args['set_value'] ) ) {
455
+        $value = $args['set_value'];
456
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
457
+        $value = $wpinv_options[ $args['id'] ];
458
+    } else {
459
+        $value = isset( $args['std'] ) ? $args['std'] : '';
460
+    }
461
+
462
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
463
+        $args['readonly'] = true;
464
+        $value = isset( $args['std'] ) ? $args['std'] : '';
465
+        $name  = '';
466
+    } else {
467
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
468
+    }
469
+
470
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
471 471
     
472
-	echo $html;
472
+    echo $html;
473 473
 }
474 474
 
475 475
 function wpinv_checkbox_callback( $args ) {
476
-	global $wpinv_options;
476
+    global $wpinv_options;
477 477
     
478 478
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
479 479
 
480
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
481
-		$name = '';
482
-	} else {
483
-		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
484
-	}
480
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
481
+        $name = '';
482
+    } else {
483
+        $name = 'name="wpinv_settings[' . $sanitize_id . ']"';
484
+    }
485 485
 
486
-	$std     = isset( $args['std'] ) ? $args['std'] : 0;
487
-	$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
488
-	$checked = checked( empty( $value ), false, false );
486
+    $std     = isset( $args['std'] ) ? $args['std'] : 0;
487
+    $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
488
+    $checked = checked( empty( $value ), false, false );
489 489
 
490
-	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
491
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
490
+    $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
491
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
492 492
 
493
-	echo $html;
493
+    echo $html;
494 494
 }
495 495
 
496 496
 function wpinv_multicheck_callback( $args ) {
497
-	global $wpinv_options;
497
+    global $wpinv_options;
498 498
 
499
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
500
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
499
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
500
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
501 501
 
502
-	if ( ! empty( $args['options'] ) ) {
502
+    if ( ! empty( $args['options'] ) ) {
503 503
 
504
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
505
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
504
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
505
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
506 506
 
507
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
507
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
508 508
         foreach( $args['options'] as $key => $option ):
509
-			$sanitize_key = wpinv_sanitize_key( $key );
510
-			if ( in_array( $sanitize_key, $value ) ) { 
511
-				$enabled = $sanitize_key;
512
-			} else { 
513
-				$enabled = NULL; 
514
-			}
515
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
516
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
517
-		endforeach;
518
-		echo '</div>';
519
-		echo '<p class="description">' . $args['desc'] . '</p>';
520
-	}
509
+            $sanitize_key = wpinv_sanitize_key( $key );
510
+            if ( in_array( $sanitize_key, $value ) ) { 
511
+                $enabled = $sanitize_key;
512
+            } else { 
513
+                $enabled = NULL; 
514
+            }
515
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
516
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
517
+        endforeach;
518
+        echo '</div>';
519
+        echo '<p class="description">' . $args['desc'] . '</p>';
520
+    }
521 521
 }
522 522
 
523 523
 function wpinv_payment_icons_callback( $args ) {
524
-	global $wpinv_options;
524
+    global $wpinv_options;
525 525
     
526 526
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
527 527
 
528
-	if ( ! empty( $args['options'] ) ) {
529
-		foreach( $args['options'] as $key => $option ) {
528
+    if ( ! empty( $args['options'] ) ) {
529
+        foreach( $args['options'] as $key => $option ) {
530 530
             $sanitize_key = wpinv_sanitize_key( $key );
531 531
             
532
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
533
-				$enabled = $option;
534
-			} else {
535
-				$enabled = NULL;
536
-			}
537
-
538
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
539
-
540
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
541
-
542
-				if ( wpinv_string_is_image_url( $key ) ) {
543
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
544
-				} else {
545
-					$card = strtolower( str_replace( ' ', '', $option ) );
546
-
547
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
548
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
549
-					} else {
550
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
551
-						$content_dir = WP_CONTENT_DIR;
552
-
553
-						if ( function_exists( 'wp_normalize_path' ) ) {
554
-							// Replaces backslashes with forward slashes for Windows systems
555
-							$image = wp_normalize_path( $image );
556
-							$content_dir = wp_normalize_path( $content_dir );
557
-						}
558
-
559
-						$image = str_replace( $content_dir, content_url(), $image );
560
-					}
561
-
562
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
-				}
564
-			echo $option . '</label>';
565
-		}
566
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
567
-	}
532
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
533
+                $enabled = $option;
534
+            } else {
535
+                $enabled = NULL;
536
+            }
537
+
538
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
539
+
540
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
541
+
542
+                if ( wpinv_string_is_image_url( $key ) ) {
543
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
544
+                } else {
545
+                    $card = strtolower( str_replace( ' ', '', $option ) );
546
+
547
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
548
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
549
+                    } else {
550
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
551
+                        $content_dir = WP_CONTENT_DIR;
552
+
553
+                        if ( function_exists( 'wp_normalize_path' ) ) {
554
+                            // Replaces backslashes with forward slashes for Windows systems
555
+                            $image = wp_normalize_path( $image );
556
+                            $content_dir = wp_normalize_path( $content_dir );
557
+                        }
558
+
559
+                        $image = str_replace( $content_dir, content_url(), $image );
560
+                    }
561
+
562
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
+                }
564
+            echo $option . '</label>';
565
+        }
566
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
567
+    }
568 568
 }
569 569
 
570 570
 function wpinv_radio_callback( $args ) {
571
-	global $wpinv_options;
571
+    global $wpinv_options;
572 572
     
573 573
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
574 574
     
575 575
     foreach ( $args['options'] as $key => $option ) :
576
-		$sanitize_key = wpinv_sanitize_key( $key );
576
+        $sanitize_key = wpinv_sanitize_key( $key );
577 577
         
578 578
         $checked = false;
579 579
 
580
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
581
-			$checked = true;
582
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
583
-			$checked = true;
580
+        if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
581
+            $checked = true;
582
+        elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
583
+            $checked = true;
584 584
 
585
-		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
586
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
587
-	endforeach;
585
+        echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
586
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
587
+    endforeach;
588 588
 
589
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
589
+    echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
590 590
 }
591 591
 
592 592
 function wpinv_gateways_callback( $args ) {
593
-	global $wpinv_options;
593
+    global $wpinv_options;
594 594
     
595 595
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
596 596
 
597
-	foreach ( $args['options'] as $key => $option ) :
598
-		$sanitize_key = wpinv_sanitize_key( $key );
597
+    foreach ( $args['options'] as $key => $option ) :
598
+        $sanitize_key = wpinv_sanitize_key( $key );
599 599
         
600 600
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
601
-			$enabled = '1';
602
-		else
603
-			$enabled = null;
601
+            $enabled = '1';
602
+        else
603
+            $enabled = null;
604 604
 
605
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
606
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
607
-	endforeach;
605
+        echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
606
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
607
+    endforeach;
608 608
 }
609 609
 
610 610
 function wpinv_gateway_select_callback($args) {
611
-	global $wpinv_options;
611
+    global $wpinv_options;
612 612
     
613 613
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
614 614
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
615 615
 
616
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
616
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
617 617
 
618
-	foreach ( $args['options'] as $key => $option ) :
619
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
618
+    foreach ( $args['options'] as $key => $option ) :
619
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
620 620
             $selected = selected( $key, $args['selected'], false );
621 621
         } else {
622 622
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
623 623
         }
624
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
625
-	endforeach;
624
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
625
+    endforeach;
626 626
 
627
-	echo '</select>';
628
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
627
+    echo '</select>';
628
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
629 629
 }
630 630
 
631 631
 function wpinv_text_callback( $args ) {
632
-	global $wpinv_options;
632
+    global $wpinv_options;
633 633
     
634 634
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
635 635
 
636
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
637
-		$value = $wpinv_options[ $args['id'] ];
638
-	} else {
639
-		$value = isset( $args['std'] ) ? $args['std'] : '';
640
-	}
641
-
642
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
643
-		$args['readonly'] = true;
644
-		$value = isset( $args['std'] ) ? $args['std'] : '';
645
-		$name  = '';
646
-	} else {
647
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
648
-	}
649
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
650
-
651
-	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
652
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
653
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
654
-	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
655
-
656
-	echo $html;
636
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
637
+        $value = $wpinv_options[ $args['id'] ];
638
+    } else {
639
+        $value = isset( $args['std'] ) ? $args['std'] : '';
640
+    }
641
+
642
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
643
+        $args['readonly'] = true;
644
+        $value = isset( $args['std'] ) ? $args['std'] : '';
645
+        $name  = '';
646
+    } else {
647
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
648
+    }
649
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
650
+
651
+    $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
652
+    $size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
653
+    $html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
654
+    $html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
655
+
656
+    echo $html;
657 657
 }
658 658
 
659 659
 function wpinv_number_callback( $args ) {
660
-	global $wpinv_options;
660
+    global $wpinv_options;
661 661
     
662 662
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
663 663
 
664
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
665
-		$value = $wpinv_options[ $args['id'] ];
666
-	} else {
667
-		$value = isset( $args['std'] ) ? $args['std'] : '';
668
-	}
669
-
670
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
671
-		$args['readonly'] = true;
672
-		$value = isset( $args['std'] ) ? $args['std'] : '';
673
-		$name  = '';
674
-	} else {
675
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
676
-	}
677
-
678
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
679
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
680
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
681
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
682
-
683
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
684
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
685
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
686
-
687
-	echo $html;
664
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
665
+        $value = $wpinv_options[ $args['id'] ];
666
+    } else {
667
+        $value = isset( $args['std'] ) ? $args['std'] : '';
668
+    }
669
+
670
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
671
+        $args['readonly'] = true;
672
+        $value = isset( $args['std'] ) ? $args['std'] : '';
673
+        $name  = '';
674
+    } else {
675
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
676
+    }
677
+
678
+    $max  = isset( $args['max'] ) ? $args['max'] : 999999;
679
+    $min  = isset( $args['min'] ) ? $args['min'] : 0;
680
+    $step = isset( $args['step'] ) ? $args['step'] : 1;
681
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
682
+
683
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
684
+    $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
685
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
686
+
687
+    echo $html;
688 688
 }
689 689
 
690 690
 function wpinv_textarea_callback( $args ) {
691
-	global $wpinv_options;
691
+    global $wpinv_options;
692 692
     
693 693
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
694 694
 
695
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
696
-		$value = $wpinv_options[ $args['id'] ];
697
-	} else {
698
-		$value = isset( $args['std'] ) ? $args['std'] : '';
699
-	}
695
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
696
+        $value = $wpinv_options[ $args['id'] ];
697
+    } else {
698
+        $value = isset( $args['std'] ) ? $args['std'] : '';
699
+    }
700 700
     
701 701
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
702 702
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
703 703
 
704
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
705
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
704
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
705
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
706 706
 
707
-	echo $html;
707
+    echo $html;
708 708
 }
709 709
 
710 710
 function wpinv_password_callback( $args ) {
711
-	global $wpinv_options;
711
+    global $wpinv_options;
712 712
     
713 713
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
714 714
 
715
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
716
-		$value = $wpinv_options[ $args['id'] ];
717
-	} else {
718
-		$value = isset( $args['std'] ) ? $args['std'] : '';
719
-	}
715
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
716
+        $value = $wpinv_options[ $args['id'] ];
717
+    } else {
718
+        $value = isset( $args['std'] ) ? $args['std'] : '';
719
+    }
720 720
 
721
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
722
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
723
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
721
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
722
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
723
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
724 724
 
725
-	echo $html;
725
+    echo $html;
726 726
 }
727 727
 
728 728
 function wpinv_missing_callback($args) {
729
-	printf(
730
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
731
-		'<strong>' . $args['id'] . '</strong>'
732
-	);
729
+    printf(
730
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
731
+        '<strong>' . $args['id'] . '</strong>'
732
+    );
733 733
 }
734 734
 
735 735
 function wpinv_select_callback($args) {
736
-	global $wpinv_options;
736
+    global $wpinv_options;
737 737
     
738 738
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
739 739
 
740
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
741
-		$value = $wpinv_options[ $args['id'] ];
742
-	} else {
743
-		$value = isset( $args['std'] ) ? $args['std'] : '';
744
-	}
740
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
741
+        $value = $wpinv_options[ $args['id'] ];
742
+    } else {
743
+        $value = isset( $args['std'] ) ? $args['std'] : '';
744
+    }
745 745
     
746 746
     if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
747 747
         $value = $args['selected'];
748 748
     }
749 749
 
750
-	if ( isset( $args['placeholder'] ) ) {
751
-		$placeholder = $args['placeholder'];
752
-	} else {
753
-		$placeholder = '';
754
-	}
750
+    if ( isset( $args['placeholder'] ) ) {
751
+        $placeholder = $args['placeholder'];
752
+    } else {
753
+        $placeholder = '';
754
+    }
755 755
     
756 756
     if( !empty( $args['onchange'] ) ) {
757 757
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
@@ -761,143 +761,143 @@  discard block
 block discarded – undo
761 761
 
762 762
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
763 763
 
764
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
764
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
765 765
 
766
-	foreach ( $args['options'] as $option => $name ) {
767
-		$selected = selected( $option, $value, false );
768
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
769
-	}
766
+    foreach ( $args['options'] as $option => $name ) {
767
+        $selected = selected( $option, $value, false );
768
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
769
+    }
770 770
 
771
-	$html .= '</select>';
772
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
771
+    $html .= '</select>';
772
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
773 773
 
774
-	echo $html;
774
+    echo $html;
775 775
 }
776 776
 
777 777
 function wpinv_color_select_callback( $args ) {
778
-	global $wpinv_options;
778
+    global $wpinv_options;
779 779
     
780 780
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
781 781
 
782
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
783
-		$value = $wpinv_options[ $args['id'] ];
784
-	} else {
785
-		$value = isset( $args['std'] ) ? $args['std'] : '';
786
-	}
782
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
783
+        $value = $wpinv_options[ $args['id'] ];
784
+    } else {
785
+        $value = isset( $args['std'] ) ? $args['std'] : '';
786
+    }
787 787
 
788
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
788
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
789 789
 
790
-	foreach ( $args['options'] as $option => $color ) {
791
-		$selected = selected( $option, $value, false );
792
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
793
-	}
790
+    foreach ( $args['options'] as $option => $color ) {
791
+        $selected = selected( $option, $value, false );
792
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
793
+    }
794 794
 
795
-	$html .= '</select>';
796
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
795
+    $html .= '</select>';
796
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
797 797
 
798
-	echo $html;
798
+    echo $html;
799 799
 }
800 800
 
801 801
 function wpinv_rich_editor_callback( $args ) {
802
-	global $wpinv_options, $wp_version;
802
+    global $wpinv_options, $wp_version;
803 803
     
804 804
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
805 805
 
806
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
807
-		$value = $wpinv_options[ $args['id'] ];
806
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
807
+        $value = $wpinv_options[ $args['id'] ];
808 808
 
809
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
810
-			$value = isset( $args['std'] ) ? $args['std'] : '';
811
-		}
812
-	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
814
-	}
809
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
810
+            $value = isset( $args['std'] ) ? $args['std'] : '';
811
+        }
812
+    } else {
813
+        $value = isset( $args['std'] ) ? $args['std'] : '';
814
+    }
815 815
 
816
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
816
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
817 817
 
818
-	$html = '<div class="getpaid-settings-editor-input">';
819
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
820
-		ob_start();
821
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
822
-		$html .= ob_get_clean();
823
-	} else {
824
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
825
-	}
818
+    $html = '<div class="getpaid-settings-editor-input">';
819
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
820
+        ob_start();
821
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
822
+        $html .= ob_get_clean();
823
+    } else {
824
+        $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
825
+    }
826 826
 
827
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
827
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
828 828
 
829
-	echo $html;
829
+    echo $html;
830 830
 }
831 831
 
832 832
 function wpinv_upload_callback( $args ) {
833
-	global $wpinv_options;
833
+    global $wpinv_options;
834 834
     
835 835
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
836 836
 
837
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
838
-		$value = $wpinv_options[$args['id']];
839
-	} else {
840
-		$value = isset($args['std']) ? $args['std'] : '';
841
-	}
837
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
838
+        $value = $wpinv_options[$args['id']];
839
+    } else {
840
+        $value = isset($args['std']) ? $args['std'] : '';
841
+    }
842 842
 
843
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
844
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
845
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
846
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
843
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
844
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
845
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
846
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
847 847
 
848
-	echo $html;
848
+    echo $html;
849 849
 }
850 850
 
851 851
 function wpinv_color_callback( $args ) {
852
-	global $wpinv_options;
852
+    global $wpinv_options;
853 853
     
854 854
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
855 855
 
856
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
857
-		$value = $wpinv_options[ $args['id'] ];
858
-	} else {
859
-		$value = isset( $args['std'] ) ? $args['std'] : '';
860
-	}
856
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
857
+        $value = $wpinv_options[ $args['id'] ];
858
+    } else {
859
+        $value = isset( $args['std'] ) ? $args['std'] : '';
860
+    }
861 861
 
862
-	$default = isset( $args['std'] ) ? $args['std'] : '';
862
+    $default = isset( $args['std'] ) ? $args['std'] : '';
863 863
 
864
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
865
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
864
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
865
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
866 866
 
867
-	echo $html;
867
+    echo $html;
868 868
 }
869 869
 
870 870
 function wpinv_country_states_callback($args) {
871
-	global $wpinv_options;
871
+    global $wpinv_options;
872 872
     
873 873
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
874 874
 
875
-	if ( isset( $args['placeholder'] ) ) {
876
-		$placeholder = $args['placeholder'];
877
-	} else {
878
-		$placeholder = '';
879
-	}
875
+    if ( isset( $args['placeholder'] ) ) {
876
+        $placeholder = $args['placeholder'];
877
+    } else {
878
+        $placeholder = '';
879
+    }
880 880
 
881
-	$states = wpinv_get_country_states();
881
+    $states = wpinv_get_country_states();
882 882
 
883
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
883
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
885 885
 
886
-	foreach ( $states as $option => $name ) {
887
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
888
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
889
-	}
886
+    foreach ( $states as $option => $name ) {
887
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
888
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
889
+    }
890 890
 
891
-	$html .= '</select>';
892
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
891
+    $html .= '</select>';
892
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
893 893
 
894
-	echo $html;
894
+    echo $html;
895 895
 }
896 896
 
897 897
 function wpinv_tax_rates_callback($args) {
898
-	global $wpinv_options;
899
-	$rates = wpinv_get_tax_rates();
900
-	ob_start(); ?>
898
+    global $wpinv_options;
899
+    $rates = wpinv_get_tax_rates();
900
+    ob_start(); ?>
901 901
     </td><tr>
902 902
     <td colspan="2" class="wpinv_tax_tdbox">
903 903
 	<p><?php echo $args['desc']; ?></p>
@@ -921,40 +921,40 @@  discard block
 block discarded – undo
921 921
 			<tr>
922 922
 				<td class="wpinv_tax_country">
923 923
 					<?php
924
-					echo wpinv_html_select( array(
925
-						'options'          => wpinv_get_country_list( true ),
926
-						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
924
+                    echo wpinv_html_select( array(
925
+                        'options'          => wpinv_get_country_list( true ),
926
+                        'name'             => 'tax_rates[' . $sanitized_key . '][country]',
927 927
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
928
-						'selected'         => $rate['country'],
929
-						'show_option_all'  => false,
930
-						'show_option_none' => false,
931
-						'class'            => 'wpinv-tax-country wpi_select2',
932
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
933
-					) );
934
-					?>
928
+                        'selected'         => $rate['country'],
929
+                        'show_option_all'  => false,
930
+                        'show_option_none' => false,
931
+                        'class'            => 'wpinv-tax-country wpi_select2',
932
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
933
+                    ) );
934
+                    ?>
935 935
 				</td>
936 936
 				<td class="wpinv_tax_state">
937 937
 					<?php
938
-					$states = wpinv_get_country_states( $rate['country'] );
939
-					if( !empty( $states ) ) {
940
-						echo wpinv_html_select( array(
941
-							'options'          => array_merge( array( '' => '' ), $states ),
942
-							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
938
+                    $states = wpinv_get_country_states( $rate['country'] );
939
+                    if( !empty( $states ) ) {
940
+                        echo wpinv_html_select( array(
941
+                            'options'          => array_merge( array( '' => '' ), $states ),
942
+                            'name'             => 'tax_rates[' . $sanitized_key . '][state]',
943 943
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
944
-							'selected'         => $rate['state'],
945
-							'show_option_all'  => false,
946
-							'show_option_none' => false,
944
+                            'selected'         => $rate['state'],
945
+                            'show_option_all'  => false,
946
+                            'show_option_none' => false,
947 947
                             'class'            => 'wpi_select2',
948
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
949
-						) );
950
-					} else {
951
-						echo wpinv_html_text( array(
952
-							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
953
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
948
+                            'placeholder'      => __( 'Choose a state', 'invoicing' )
949
+                        ) );
950
+                    } else {
951
+                        echo wpinv_html_text( array(
952
+                            'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
953
+                            'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
954 954
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
955
-						) );
956
-					}
957
-					?>
955
+                        ) );
956
+                    }
957
+                    ?>
958 958
 				</td>
959 959
 				<td class="wpinv_tax_global">
960 960
 					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
@@ -969,19 +969,19 @@  discard block
 block discarded – undo
969 969
 			<tr>
970 970
 				<td class="wpinv_tax_country">
971 971
 					<?php
972
-					echo wpinv_html_select( array(
973
-						'options'          => wpinv_get_country_list( true ),
974
-						'name'             => 'tax_rates[0][country]',
975
-						'show_option_all'  => false,
976
-						'show_option_none' => false,
977
-						'class'            => 'wpinv-tax-country wpi_select2',
978
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
979
-					) ); ?>
972
+                    echo wpinv_html_select( array(
973
+                        'options'          => wpinv_get_country_list( true ),
974
+                        'name'             => 'tax_rates[0][country]',
975
+                        'show_option_all'  => false,
976
+                        'show_option_none' => false,
977
+                        'class'            => 'wpinv-tax-country wpi_select2',
978
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
979
+                    ) ); ?>
980 980
 				</td>
981 981
 				<td class="wpinv_tax_state">
982 982
 					<?php echo wpinv_html_text( array(
983
-						'name' => 'tax_rates[0][state]'
984
-					) ); ?>
983
+                        'name' => 'tax_rates[0][state]'
984
+                    ) ); ?>
985 985
 				</td>
986 986
 				<td class="wpinv_tax_global">
987 987
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
         <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
997 997
 	</table>
998 998
 	<?php
999
-	echo ob_get_clean();
999
+    echo ob_get_clean();
1000 1000
 }
1001 1001
 
1002 1002
 function wpinv_tools_callback($args) {
@@ -1024,15 +1024,15 @@  discard block
 block discarded – undo
1024 1024
 }
1025 1025
 
1026 1026
 function wpinv_descriptive_text_callback( $args ) {
1027
-	echo wp_kses_post( $args['desc'] );
1027
+    echo wp_kses_post( $args['desc'] );
1028 1028
 }
1029 1029
 
1030 1030
 function wpinv_hook_callback( $args ) {
1031
-	do_action( 'wpinv_' . $args['id'], $args );
1031
+    do_action( 'wpinv_' . $args['id'], $args );
1032 1032
 }
1033 1033
 
1034 1034
 function wpinv_set_settings_cap() {
1035
-	return wpinv_get_capability();
1035
+    return wpinv_get_capability();
1036 1036
 }
1037 1037
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1038 1038
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form.php 1 patch
Indentation   +533 added lines, -533 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,55 +10,55 @@  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
-	);
46
-
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';
55
-
56
-	/**
57
-	 * Stores a reference to the invoice if the form is for an invoice..
58
-	 *
59
-	 * @var WPInv_Invoice
60
-	 */
61
-	public $invoice = 0;
40
+        'items'                => null,
41
+        'earned'               => 0,
42
+        'refunded'             => 0,
43
+        'cancelled'            => 0,
44
+        'failed'               => 0,
45
+    );
46
+
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';
55
+
56
+    /**
57
+     * Stores a reference to the invoice if the form is for an invoice..
58
+     *
59
+     * @var WPInv_Invoice
60
+     */
61
+    public $invoice = 0;
62 62
 
63 63
     /**
64 64
      * Stores a reference to the original WP_Post object
@@ -68,35 +68,35 @@  discard block
 block discarded – undo
68 68
     protected $post = null;
69 69
 
70 70
     /**
71
-	 * Get the form if ID is passed, otherwise the form is new and empty.
72
-	 *
73
-	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74
-	 */
75
-	public function __construct( $form = 0 ) {
76
-		parent::__construct( $form );
71
+     * Get the form if ID is passed, otherwise the form is new and empty.
72
+     *
73
+     * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74
+     */
75
+    public function __construct( $form = 0 ) {
76
+        parent::__construct( $form );
77 77
 
78
-		if ( is_numeric( $form ) && $form > 0 ) {
79
-			$this->set_id( $form );
80
-		} elseif ( $form instanceof self ) {
78
+        if ( is_numeric( $form ) && $form > 0 ) {
79
+            $this->set_id( $form );
80
+        } elseif ( $form instanceof self ) {
81 81
 
82
-			$this->set_id( $form->get_id() );
83
-			$this->invoice = $form->invoice;
82
+            $this->set_id( $form->get_id() );
83
+            $this->invoice = $form->invoice;
84 84
 
85
-		} elseif ( ! empty( $form->ID ) ) {
86
-			$this->set_id( $form->ID );
87
-		} else {
88
-			$this->set_object_read( true );
89
-		}
85
+        } elseif ( ! empty( $form->ID ) ) {
86
+            $this->set_id( $form->ID );
87
+        } else {
88
+            $this->set_object_read( true );
89
+        }
90 90
 
91 91
         // Load the datastore.
92
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
92
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
93 93
 
94
-		if ( $this->get_id() > 0 ) {
94
+        if ( $this->get_id() > 0 ) {
95 95
             $this->post = get_post( $this->get_id() );
96
-			$this->data_store->read( $this );
96
+            $this->data_store->read( $this );
97 97
         }
98 98
 
99
-	}
99
+    }
100 100
 
101 101
     /*
102 102
 	|--------------------------------------------------------------------------
@@ -114,358 +114,358 @@  discard block
 block discarded – undo
114 114
     */
115 115
 
116 116
     /**
117
-	 * Get plugin version when the form was created.
118
-	 *
119
-	 * @since 1.0.19
120
-	 * @param  string $context View or edit context.
121
-	 * @return string
122
-	 */
123
-	public function get_version( $context = 'view' ) {
124
-		return $this->get_prop( 'version', $context );
117
+     * Get plugin version when the form was created.
118
+     *
119
+     * @since 1.0.19
120
+     * @param  string $context View or edit context.
121
+     * @return string
122
+     */
123
+    public function get_version( $context = 'view' ) {
124
+        return $this->get_prop( 'version', $context );
125 125
     }
126 126
 
127 127
     /**
128
-	 * Get date when the form was created.
129
-	 *
130
-	 * @since 1.0.19
131
-	 * @param  string $context View or edit context.
132
-	 * @return string
133
-	 */
134
-	public function get_date_created( $context = 'view' ) {
135
-		return $this->get_prop( 'date_created', $context );
128
+     * Get date when the form was created.
129
+     *
130
+     * @since 1.0.19
131
+     * @param  string $context View or edit context.
132
+     * @return string
133
+     */
134
+    public function get_date_created( $context = 'view' ) {
135
+        return $this->get_prop( 'date_created', $context );
136 136
     }
137 137
 
138 138
     /**
139
-	 * Get GMT date when the form was created.
140
-	 *
141
-	 * @since 1.0.19
142
-	 * @param  string $context View or edit context.
143
-	 * @return string
144
-	 */
145
-	public function get_date_created_gmt( $context = 'view' ) {
139
+     * Get GMT date when the form was created.
140
+     *
141
+     * @since 1.0.19
142
+     * @param  string $context View or edit context.
143
+     * @return string
144
+     */
145
+    public function get_date_created_gmt( $context = 'view' ) {
146 146
         $date = $this->get_date_created( $context );
147 147
 
148 148
         if ( $date ) {
149 149
             $date = get_gmt_from_date( $date );
150 150
         }
151
-		return $date;
151
+        return $date;
152 152
     }
153 153
 
154 154
     /**
155
-	 * Get date when the form was last modified.
156
-	 *
157
-	 * @since 1.0.19
158
-	 * @param  string $context View or edit context.
159
-	 * @return string
160
-	 */
161
-	public function get_date_modified( $context = 'view' ) {
162
-		return $this->get_prop( 'date_modified', $context );
155
+     * Get date when the form was last modified.
156
+     *
157
+     * @since 1.0.19
158
+     * @param  string $context View or edit context.
159
+     * @return string
160
+     */
161
+    public function get_date_modified( $context = 'view' ) {
162
+        return $this->get_prop( 'date_modified', $context );
163 163
     }
164 164
 
165 165
     /**
166
-	 * Get GMT date when the form was last modified.
167
-	 *
168
-	 * @since 1.0.19
169
-	 * @param  string $context View or edit context.
170
-	 * @return string
171
-	 */
172
-	public function get_date_modified_gmt( $context = 'view' ) {
166
+     * Get GMT date when the form was last modified.
167
+     *
168
+     * @since 1.0.19
169
+     * @param  string $context View or edit context.
170
+     * @return string
171
+     */
172
+    public function get_date_modified_gmt( $context = 'view' ) {
173 173
         $date = $this->get_date_modified( $context );
174 174
 
175 175
         if ( $date ) {
176 176
             $date = get_gmt_from_date( $date );
177 177
         }
178
-		return $date;
178
+        return $date;
179 179
     }
180 180
 
181 181
     /**
182
-	 * Get the form name.
183
-	 *
184
-	 * @since 1.0.19
185
-	 * @param  string $context View or edit context.
186
-	 * @return string
187
-	 */
188
-	public function get_name( $context = 'view' ) {
189
-		return $this->get_prop( 'name', $context );
182
+     * Get the form name.
183
+     *
184
+     * @since 1.0.19
185
+     * @param  string $context View or edit context.
186
+     * @return string
187
+     */
188
+    public function get_name( $context = 'view' ) {
189
+        return $this->get_prop( 'name', $context );
190 190
     }
191 191
 
192 192
     /**
193
-	 * Alias of self::get_name().
194
-	 *
195
-	 * @since 1.0.19
196
-	 * @param  string $context View or edit context.
197
-	 * @return string
198
-	 */
199
-	public function get_title( $context = 'view' ) {
200
-		return $this->get_name( $context );
201
-	}
193
+     * Alias of self::get_name().
194
+     *
195
+     * @since 1.0.19
196
+     * @param  string $context View or edit context.
197
+     * @return string
198
+     */
199
+    public function get_title( $context = 'view' ) {
200
+        return $this->get_name( $context );
201
+    }
202 202
 
203 203
     /**
204
-	 * Get the owner of the form.
205
-	 *
206
-	 * @since 1.0.19
207
-	 * @param  string $context View or edit context.
208
-	 * @return int
209
-	 */
210
-	public function get_author( $context = 'view' ) {
211
-		return (int) $this->get_prop( 'author', $context );
204
+     * Get the owner of the form.
205
+     *
206
+     * @since 1.0.19
207
+     * @param  string $context View or edit context.
208
+     * @return int
209
+     */
210
+    public function get_author( $context = 'view' ) {
211
+        return (int) $this->get_prop( 'author', $context );
212 212
     }
213 213
 
214 214
     /**
215
-	 * Get the elements that make up the form.
216
-	 *
217
-	 * @since 1.0.19
218
-	 * @param  string $context View or edit context.
219
-	 * @return array
220
-	 */
221
-	public function get_elements( $context = 'view' ) {
222
-		$elements = $this->get_prop( 'elements', $context );
215
+     * Get the elements that make up the form.
216
+     *
217
+     * @since 1.0.19
218
+     * @param  string $context View or edit context.
219
+     * @return array
220
+     */
221
+    public function get_elements( $context = 'view' ) {
222
+        $elements = $this->get_prop( 'elements', $context );
223 223
 
224
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
224
+        if ( empty( $elements ) || ! is_array( $elements ) ) {
225 225
             return wpinv_get_data( 'sample-payment-form' );
226
-		}
226
+        }
227 227
 
228
-		// Ensure that all required elements exist.
229
-		$_elements = array();
230
-		foreach ( $elements as $element ) {
228
+        // Ensure that all required elements exist.
229
+        $_elements = array();
230
+        foreach ( $elements as $element ) {
231 231
 
232
-			if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
232
+            if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
233 233
 
234
-				$_elements[] = array(
235
-					'text'        => __( 'Select Payment Method', 'invoicing' ),
236
-					'id'          => 'gtscicd',
237
-					'name'        => 'gtscicd',
238
-					'type'        => 'gateway_select',
239
-					'premade'     => true
234
+                $_elements[] = array(
235
+                    'text'        => __( 'Select Payment Method', 'invoicing' ),
236
+                    'id'          => 'gtscicd',
237
+                    'name'        => 'gtscicd',
238
+                    'type'        => 'gateway_select',
239
+                    'premade'     => true
240 240
 			
241
-				);
241
+                );
242 242
 
243
-			}
243
+            }
244 244
 
245
-			$_elements[] = $element;
245
+            $_elements[] = $element;
246 246
 
247
-		}
247
+        }
248 248
 
249 249
         return $_elements;
250
-	}
251
-
252
-	/**
253
-	 * Get the items sold via the form.
254
-	 *
255
-	 * @since 1.0.19
256
-	 * @param  string $context View or edit context.
257
-	 * @param  string $return objects or arrays.
258
-	 * @return GetPaid_Form_Item[]
259
-	 */
260
-	public function get_items( $context = 'view', $return = 'objects' ) {
261
-		$items = $this->get_prop( 'items', $context );
262
-
263
-		if ( empty( $items ) || ! is_array( $items ) ) {
250
+    }
251
+
252
+    /**
253
+     * Get the items sold via the form.
254
+     *
255
+     * @since 1.0.19
256
+     * @param  string $context View or edit context.
257
+     * @param  string $return objects or arrays.
258
+     * @return GetPaid_Form_Item[]
259
+     */
260
+    public function get_items( $context = 'view', $return = 'objects' ) {
261
+        $items = $this->get_prop( 'items', $context );
262
+
263
+        if ( empty( $items ) || ! is_array( $items ) ) {
264 264
             $items = wpinv_get_data( 'sample-payment-form-items' );
265
-		}
265
+        }
266
+
267
+        // Convert the items.
268
+        $prepared = array();
266 269
 
267
-		// Convert the items.
268
-		$prepared = array();
270
+        foreach ( $items as $key => $value ) {
269 271
 
270
-		foreach ( $items as $key => $value ) {
272
+            // Form items.
273
+            if ( $value instanceof GetPaid_Form_Item ) {
271 274
 
272
-			// Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
275
+                if ( $value->can_purchase() ) {
276
+                    $prepared[] = $value;
277
+                }
274 278
 
275
-				if ( $value->can_purchase() ) {
276
-					$prepared[] = $value;
277
-				}
279
+                continue;
278 280
 
279
-				continue;
281
+            }
280 282
 
281
-			}
283
+            // $item_id => $quantity (buy buttons)
284
+            if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
+                $item = new GetPaid_Form_Item( $key );
282 286
 
283
-			// $item_id => $quantity (buy buttons)
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
287
+                if ( $item->can_purchase() ) {
286 288
 
287
-				if ( $item->can_purchase() ) {
289
+                    $value = (int) $value;
290
+                    $item->set_quantity( $value );
291
+                    if ( 0 == $value ) {
292
+                        $item->set_quantity( 1 );
293
+                        $item->set_allow_quantities( true );
294
+                    }
288 295
 
289
-					$value = (int) $value;
290
-					$item->set_quantity( $value );
291
-					if ( 0 == $value ) {
292
-						$item->set_quantity( 1 );
293
-						$item->set_allow_quantities( true );
294
-					}
296
+                    $prepared[] = $item;
297
+                }
295 298
 
296
-					$prepared[] = $item;
297
-				}
299
+                continue;
300
+            }
298 301
 
299
-				continue;
300
-			}
302
+            // Items saved via payment forms editor.
303
+            if ( is_array( $value ) && isset( $value['id'] ) ) {
301 304
 
302
-			// Items saved via payment forms editor.
303
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
305
+                $item = new GetPaid_Form_Item( $value['id'] );
304 306
 
305
-				$item = new GetPaid_Form_Item( $value['id'] );
307
+                if ( ! $item->can_purchase() ) {
308
+                    continue;
309
+                }
306 310
 
307
-				if ( ! $item->can_purchase() ) {
308
-					continue;
309
-				}
311
+                // Sub-total (Cart items).
312
+                if ( isset( $value['subtotal'] ) ) {
313
+                    $item->set_price( $value['subtotal'] );
314
+                }
310 315
 
311
-				// Sub-total (Cart items).
312
-				if ( isset( $value['subtotal'] ) ) {
313
-					$item->set_price( $value['subtotal'] );
314
-				}
316
+                if ( isset( $value['quantity'] ) ) {
317
+                    $item->set_quantity( $value['quantity'] );
318
+                }
315 319
 
316
-				if ( isset( $value['quantity'] ) ) {
317
-					$item->set_quantity( $value['quantity'] );
318
-				}
320
+                if ( isset( $value['allow_quantities'] ) ) {
321
+                    $item->set_allow_quantities( $value['allow_quantities'] );
322
+                }
319 323
 
320
-				if ( isset( $value['allow_quantities'] ) ) {
321
-					$item->set_allow_quantities( $value['allow_quantities'] );
322
-				}
324
+                if ( isset( $value['required'] ) ) {
325
+                    $item->set_is_required( $value['required'] );
326
+                }
323 327
 
324
-				if ( isset( $value['required'] ) ) {
325
-					$item->set_is_required( $value['required'] );
326
-				}
328
+                if ( isset( $value['description'] ) ) {
329
+                    $item->set_custom_description( $value['description'] );
330
+                }
327 331
 
328
-				if ( isset( $value['description'] ) ) {
329
-					$item->set_custom_description( $value['description'] );
330
-				}
332
+                $prepared[] = $item;
333
+                continue;
331 334
 
332
-				$prepared[] = $item;
333
-				continue;
335
+            }
336
+
337
+            // $item_id => array( 'price' => 10 ) (item variations)
338
+            if ( is_numeric( $key ) && is_array( $value ) ) {
339
+                $item = new GetPaid_Form_Item( $key );
340
+
341
+                if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
342
+                    $item->set_price( $value['price'] );
343
+                }
344
+
345
+                if ( $item->can_purchase() ) {
346
+                    $prepared[] = $item;
347
+                }
348
+
349
+                continue;
350
+            }
351
+
352
+        }
353
+
354
+        if ( 'objects' == $return && 'view' == $context ) {
355
+            return $prepared;
356
+        }
357
+
358
+        $items = array();
359
+        foreach ( $prepared as $item ) {
360
+            $items[] = $item->prepare_data_for_use();
361
+        }
362
+
363
+        return $items;
364
+    }
365
+
366
+    /**
367
+     * Get a single item belonging to the form.
368
+     *
369
+     * @since 1.0.19
370
+     * @param  int $item_id The item id to return.
371
+     * @return GetPaid_Form_Item|bool
372
+     */
373
+    public function get_item( $item_id ) {
374
+
375
+        if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
376
+            return false;
377
+        }
378
+
379
+        foreach( $this->get_items() as $item ) {
380
+            if ( $item->get_id() == (int) $item_id ) {
381
+                return $item;
382
+            }
383
+        }
384
+
385
+        return false;
386
+
387
+    }
388
+
389
+    /**
390
+     * Gets a single element.
391
+     *
392
+     * @since 1.0.19
393
+     * @param  string $element_type The element type to return.
394
+     * @return array|bool
395
+     */
396
+    public function get_element_type( $element_type ) {
397
+
398
+        if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
399
+            return false;
400
+        }
401
+
402
+        foreach ( $this->get_prop( 'elements' ) as $element ) {
403
+
404
+            if ( $element['type'] == $element_type ) {
405
+                return $element;
406
+            }
407
+
408
+        }
409
+
410
+        return false;
411
+
412
+    }
413
+
414
+    /**
415
+     * Get the total amount earned via this form.
416
+     *
417
+     * @since 1.0.19
418
+     * @param  string $context View or edit context.
419
+     * @return array
420
+     */
421
+    public function get_earned( $context = 'view' ) {
422
+        return $this->get_prop( 'earned', $context );
423
+    }
424
+
425
+    /**
426
+     * Get the total amount refunded via this form.
427
+     *
428
+     * @since 1.0.19
429
+     * @param  string $context View or edit context.
430
+     * @return array
431
+     */
432
+    public function get_refunded( $context = 'view' ) {
433
+        return $this->get_prop( 'refunded', $context );
434
+    }
334 435
 
335
-			}
436
+    /**
437
+     * Get the total amount cancelled via this form.
438
+     *
439
+     * @since 1.0.19
440
+     * @param  string $context View or edit context.
441
+     * @return array
442
+     */
443
+    public function get_cancelled( $context = 'view' ) {
444
+        return $this->get_prop( 'cancelled', $context );
445
+    }
336 446
 
337
-			// $item_id => array( 'price' => 10 ) (item variations)
338
-			if ( is_numeric( $key ) && is_array( $value ) ) {
339
-				$item = new GetPaid_Form_Item( $key );
447
+    /**
448
+     * Get the total amount failed via this form.
449
+     *
450
+     * @since 1.0.19
451
+     * @param  string $context View or edit context.
452
+     * @return array
453
+     */
454
+    public function get_failed( $context = 'view' ) {
455
+        return $this->get_prop( 'failed', $context );
456
+    }
340 457
 
341
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
342
-					$item->set_price( $value['price'] );
343
-				}
344
-
345
-				if ( $item->can_purchase() ) {
346
-					$prepared[] = $item;
347
-				}
348
-
349
-				continue;
350
-			}
351
-
352
-		}
353
-
354
-		if ( 'objects' == $return && 'view' == $context ) {
355
-			return $prepared;
356
-		}
357
-
358
-		$items = array();
359
-		foreach ( $prepared as $item ) {
360
-			$items[] = $item->prepare_data_for_use();
361
-		}
362
-
363
-		return $items;
364
-	}
365
-
366
-	/**
367
-	 * Get a single item belonging to the form.
368
-	 *
369
-	 * @since 1.0.19
370
-	 * @param  int $item_id The item id to return.
371
-	 * @return GetPaid_Form_Item|bool
372
-	 */
373
-	public function get_item( $item_id ) {
374
-
375
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
376
-			return false;
377
-		}
378
-
379
-		foreach( $this->get_items() as $item ) {
380
-			if ( $item->get_id() == (int) $item_id ) {
381
-				return $item;
382
-			}
383
-		}
384
-
385
-		return false;
386
-
387
-	}
388
-
389
-	/**
390
-	 * Gets a single element.
391
-	 *
392
-	 * @since 1.0.19
393
-	 * @param  string $element_type The element type to return.
394
-	 * @return array|bool
395
-	 */
396
-	public function get_element_type( $element_type ) {
397
-
398
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
399
-			return false;
400
-		}
401
-
402
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
403
-
404
-			if ( $element['type'] == $element_type ) {
405
-				return $element;
406
-			}
407
-
408
-		}
409
-
410
-		return false;
411
-
412
-	}
413
-
414
-	/**
415
-	 * Get the total amount earned via this form.
416
-	 *
417
-	 * @since 1.0.19
418
-	 * @param  string $context View or edit context.
419
-	 * @return array
420
-	 */
421
-	public function get_earned( $context = 'view' ) {
422
-		return $this->get_prop( 'earned', $context );
423
-	}
424
-
425
-	/**
426
-	 * Get the total amount refunded via this form.
427
-	 *
428
-	 * @since 1.0.19
429
-	 * @param  string $context View or edit context.
430
-	 * @return array
431
-	 */
432
-	public function get_refunded( $context = 'view' ) {
433
-		return $this->get_prop( 'refunded', $context );
434
-	}
435
-
436
-	/**
437
-	 * Get the total amount cancelled via this form.
438
-	 *
439
-	 * @since 1.0.19
440
-	 * @param  string $context View or edit context.
441
-	 * @return array
442
-	 */
443
-	public function get_cancelled( $context = 'view' ) {
444
-		return $this->get_prop( 'cancelled', $context );
445
-	}
446
-
447
-	/**
448
-	 * Get the total amount failed via this form.
449
-	 *
450
-	 * @since 1.0.19
451
-	 * @param  string $context View or edit context.
452
-	 * @return array
453
-	 */
454
-	public function get_failed( $context = 'view' ) {
455
-		return $this->get_prop( 'failed', $context );
456
-	}
457
-
458
-	/**
459
-	 * Get the currency.
460
-	 *
461
-	 * @since 1.0.19
462
-	 * @param  string $context View or edit context.
463
-	 * @return string
464
-	 */
465
-	public function get_currency() {
466
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
467
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
468
-	}
458
+    /**
459
+     * Get the currency.
460
+     *
461
+     * @since 1.0.19
462
+     * @param  string $context View or edit context.
463
+     * @return string
464
+     */
465
+    public function get_currency() {
466
+        $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
467
+        return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
468
+    }
469 469
 
470 470
     /*
471 471
 	|--------------------------------------------------------------------------
@@ -478,22 +478,22 @@  discard block
 block discarded – undo
478 478
     */
479 479
 
480 480
     /**
481
-	 * Set plugin version when the item was created.
482
-	 *
483
-	 * @since 1.0.19
484
-	 */
485
-	public function set_version( $value ) {
486
-		$this->set_prop( 'version', $value );
481
+     * Set plugin version when the item was created.
482
+     *
483
+     * @since 1.0.19
484
+     */
485
+    public function set_version( $value ) {
486
+        $this->set_prop( 'version', $value );
487 487
     }
488 488
 
489 489
     /**
490
-	 * Set date when the item was created.
491
-	 *
492
-	 * @since 1.0.19
493
-	 * @param string $value Value to set.
490
+     * Set date when the item was created.
491
+     *
492
+     * @since 1.0.19
493
+     * @param string $value Value to set.
494 494
      * @return bool Whether or not the date was set.
495
-	 */
496
-	public function set_date_created( $value ) {
495
+     */
496
+    public function set_date_created( $value ) {
497 497
         $date = strtotime( $value );
498 498
 
499 499
         if ( $date ) {
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
     }
507 507
 
508 508
     /**
509
-	 * Set date when the item was last modified.
510
-	 *
511
-	 * @since 1.0.19
512
-	 * @param string $value Value to set.
509
+     * Set date when the item was last modified.
510
+     *
511
+     * @since 1.0.19
512
+     * @param string $value Value to set.
513 513
      * @return bool Whether or not the date was set.
514
-	 */
515
-	public function set_date_modified( $value ) {
514
+     */
515
+    public function set_date_modified( $value ) {
516 516
         $date = strtotime( $value );
517 517
 
518 518
         if ( $date ) {
@@ -525,118 +525,118 @@  discard block
 block discarded – undo
525 525
     }
526 526
 
527 527
     /**
528
-	 * Set the item name.
529
-	 *
530
-	 * @since 1.0.19
531
-	 * @param  string $value New name.
532
-	 */
533
-	public function set_name( $value ) {
534
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
535
-    }
536
-
537
-    /**
538
-	 * Alias of self::set_name().
539
-	 *
540
-	 * @since 1.0.19
541
-	 * @param  string $value New name.
542
-	 */
543
-	public function set_title( $value ) {
544
-		$this->set_name( $value );
545
-    }
546
-
547
-    /**
548
-	 * Set the owner of the item.
549
-	 *
550
-	 * @since 1.0.19
551
-	 * @param  int $value New author.
552
-	 */
553
-	public function set_author( $value ) {
554
-		$this->set_prop( 'author', (int) $value );
555
-	}
556
-
557
-	/**
558
-	 * Set the form elements.
559
-	 *
560
-	 * @since 1.0.19
561
-	 * @param  array $value Form elements.
562
-	 */
563
-	public function set_elements( $value ) {
564
-		if ( is_array( $value ) ) {
565
-			$this->set_prop( 'elements', $value );
566
-		}
567
-	}
568
-
569
-	/**
570
-	 * Set the form items.
571
-	 *
572
-	 * @since 1.0.19
573
-	 * @param  array $value Form elements.
574
-	 */
575
-	public function set_items( $value ) {
576
-		if ( is_array( $value ) ) {
577
-			$this->set_prop( 'items', $value );
578
-		}
579
-	}
580
-
581
-	/**
582
-	 * Set the total amount earned via this form.
583
-	 *
584
-	 * @since 1.0.19
585
-	 * @param  float $value Amount earned.
586
-	 */
587
-	public function set_earned( $value ) {
588
-		$value = max( (float) $value, 0 );
589
-		$this->set_prop( 'earned', $value );
590
-	}
591
-
592
-	/**
593
-	 * Set the total amount refunded via this form.
594
-	 *
595
-	 * @since 1.0.19
596
-	 * @param  float $value Amount refunded.
597
-	 */
598
-	public function set_refunded( $value ) {
599
-		$value = max( (float) $value, 0 );
600
-		$this->set_prop( 'refunded', $value );
601
-	}
602
-
603
-	/**
604
-	 * Set the total amount cancelled via this form.
605
-	 *
606
-	 * @since 1.0.19
607
-	 * @param  float $value Amount cancelled.
608
-	 */
609
-	public function set_cancelled( $value ) {
610
-		$value = max( (float) $value, 0 );
611
-		$this->set_prop( 'cancelled', $value );
612
-	}
613
-
614
-	/**
615
-	 * Set the total amount failed via this form.
616
-	 *
617
-	 * @since 1.0.19
618
-	 * @param  float $value Amount cancelled.
619
-	 */
620
-	public function set_failed( $value ) {
621
-		$value = max( (float) $value, 0 );
622
-		$this->set_prop( 'failed', $value );
623
-	}
528
+     * Set the item name.
529
+     *
530
+     * @since 1.0.19
531
+     * @param  string $value New name.
532
+     */
533
+    public function set_name( $value ) {
534
+        $this->set_prop( 'name', sanitize_text_field( $value ) );
535
+    }
536
+
537
+    /**
538
+     * Alias of self::set_name().
539
+     *
540
+     * @since 1.0.19
541
+     * @param  string $value New name.
542
+     */
543
+    public function set_title( $value ) {
544
+        $this->set_name( $value );
545
+    }
546
+
547
+    /**
548
+     * Set the owner of the item.
549
+     *
550
+     * @since 1.0.19
551
+     * @param  int $value New author.
552
+     */
553
+    public function set_author( $value ) {
554
+        $this->set_prop( 'author', (int) $value );
555
+    }
556
+
557
+    /**
558
+     * Set the form elements.
559
+     *
560
+     * @since 1.0.19
561
+     * @param  array $value Form elements.
562
+     */
563
+    public function set_elements( $value ) {
564
+        if ( is_array( $value ) ) {
565
+            $this->set_prop( 'elements', $value );
566
+        }
567
+    }
568
+
569
+    /**
570
+     * Set the form items.
571
+     *
572
+     * @since 1.0.19
573
+     * @param  array $value Form elements.
574
+     */
575
+    public function set_items( $value ) {
576
+        if ( is_array( $value ) ) {
577
+            $this->set_prop( 'items', $value );
578
+        }
579
+    }
580
+
581
+    /**
582
+     * Set the total amount earned via this form.
583
+     *
584
+     * @since 1.0.19
585
+     * @param  float $value Amount earned.
586
+     */
587
+    public function set_earned( $value ) {
588
+        $value = max( (float) $value, 0 );
589
+        $this->set_prop( 'earned', $value );
590
+    }
591
+
592
+    /**
593
+     * Set the total amount refunded via this form.
594
+     *
595
+     * @since 1.0.19
596
+     * @param  float $value Amount refunded.
597
+     */
598
+    public function set_refunded( $value ) {
599
+        $value = max( (float) $value, 0 );
600
+        $this->set_prop( 'refunded', $value );
601
+    }
602
+
603
+    /**
604
+     * Set the total amount cancelled via this form.
605
+     *
606
+     * @since 1.0.19
607
+     * @param  float $value Amount cancelled.
608
+     */
609
+    public function set_cancelled( $value ) {
610
+        $value = max( (float) $value, 0 );
611
+        $this->set_prop( 'cancelled', $value );
612
+    }
613
+
614
+    /**
615
+     * Set the total amount failed via this form.
616
+     *
617
+     * @since 1.0.19
618
+     * @param  float $value Amount cancelled.
619
+     */
620
+    public function set_failed( $value ) {
621
+        $value = max( (float) $value, 0 );
622
+        $this->set_prop( 'failed', $value );
623
+    }
624 624
 
625 625
     /**
626 626
      * Create an item. For backwards compatibilty.
627 627
      *
628 628
      * @deprecated
629
-	 * @return int item id
629
+     * @return int item id
630 630
      */
631 631
     public function create( $data = array() ) {
632 632
 
633
-		// Set the properties.
634
-		if ( is_array( $data ) ) {
635
-			$this->set_props( $data );
636
-		}
633
+        // Set the properties.
634
+        if ( is_array( $data ) ) {
635
+            $this->set_props( $data );
636
+        }
637 637
 
638
-		// Save the item.
639
-		return $this->save();
638
+        // Save the item.
639
+        return $this->save();
640 640
 
641 641
     }
642 642
 
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
      * Updates an item. For backwards compatibilty.
645 645
      *
646 646
      * @deprecated
647
-	 * @return int item id
647
+     * @return int item id
648 648
      */
649 649
     public function update( $data = array() ) {
650 650
         return $this->create( $data );
@@ -660,22 +660,22 @@  discard block
 block discarded – undo
660 660
 	*/
661 661
 
662 662
     /**
663
-	 * Checks whether this is the default payment form.
664
-	 *
665
-	 * @since 1.0.19
666
-	 * @return bool
667
-	 */
663
+     * Checks whether this is the default payment form.
664
+     *
665
+     * @since 1.0.19
666
+     * @return bool
667
+     */
668 668
     public function is_default() {
669 669
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
670 670
         return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
671
-	}
671
+    }
672 672
 
673 673
     /**
674
-	 * Checks whether the form is active.
675
-	 *
676
-	 * @since 1.0.19
677
-	 * @return bool
678
-	 */
674
+     * Checks whether the form is active.
675
+     *
676
+     * @since 1.0.19
677
+     * @return bool
678
+     */
679 679
     public function is_active() {
680 680
         $is_active = 0 !== (int) $this->get_id();
681 681
 
@@ -684,76 +684,76 @@  discard block
 block discarded – undo
684 684
         }
685 685
 
686 686
         return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
687
-	}
688
-
689
-	/**
690
-	 * Checks whether the form has a given item.
691
-	 *
692
-	 * @since 1.0.19
693
-	 * @return bool
694
-	 */
687
+    }
688
+
689
+    /**
690
+     * Checks whether the form has a given item.
691
+     *
692
+     * @since 1.0.19
693
+     * @return bool
694
+     */
695 695
     public function has_item( $item_id ) {
696 696
         return false !== $this->get_item( $item_id );
697
-	}
698
-
699
-	/**
700
-	 * Checks whether the form has a given element.
701
-	 *
702
-	 * @since 1.0.19
703
-	 * @return bool
704
-	 */
697
+    }
698
+
699
+    /**
700
+     * Checks whether the form has a given element.
701
+     *
702
+     * @since 1.0.19
703
+     * @return bool
704
+     */
705 705
     public function has_element_type( $element_type ) {
706 706
         return false !== $this->get_element_type( $element_type );
707
-	}
708
-
709
-	/**
710
-	 * Checks whether this form is recurring or not.
711
-	 *
712
-	 * @since 1.0.19
713
-	 * @return bool
714
-	 */
707
+    }
708
+
709
+    /**
710
+     * Checks whether this form is recurring or not.
711
+     *
712
+     * @since 1.0.19
713
+     * @return bool
714
+     */
715 715
     public function is_recurring() {
716 716
 
717
-		if ( ! empty( $this->invoice ) ) {
718
-			return $this->invoice->is_recurring();
719
-		}
717
+        if ( ! empty( $this->invoice ) ) {
718
+            return $this->invoice->is_recurring();
719
+        }
720 720
 
721
-		foreach ( $this->get_items() as $item ) {
721
+        foreach ( $this->get_items() as $item ) {
722 722
 
723
-			if ( $item->is_recurring() ) {
724
-				return true;
725
-			}
723
+            if ( $item->is_recurring() ) {
724
+                return true;
725
+            }
726 726
 
727
-		}
727
+        }
728 728
 
729 729
         return false;
730
-	}
730
+    }
731 731
 
732
-	/**
733
-	 * Retrieves the form's html.
734
-	 *
735
-	 * @since 1.0.19
736
-	 */
732
+    /**
733
+     * Retrieves the form's html.
734
+     *
735
+     * @since 1.0.19
736
+     */
737 737
     public function get_html( $extra_markup = '' ) {
738 738
 
739
-		// Return the HTML.
740
-		return wpinv_get_template_html(
741
-			'payment-forms/form.php',
742
-			array(
743
-				'form'         => $this,
744
-				'extra_markup' => $extra_markup,
745
-			)
746
-		);
747
-
748
-	}
749
-
750
-	/**
751
-	 * Displays the payment form.
752
-	 *
753
-	 * @since 1.0.19
754
-	 */
739
+        // Return the HTML.
740
+        return wpinv_get_template_html(
741
+            'payment-forms/form.php',
742
+            array(
743
+                'form'         => $this,
744
+                'extra_markup' => $extra_markup,
745
+            )
746
+        );
747
+
748
+    }
749
+
750
+    /**
751
+     * Displays the payment form.
752
+     *
753
+     * @since 1.0.19
754
+     */
755 755
     public function display( $extra_markup = '' ) {
756
-		echo $this->get_html( $extra_markup );
756
+        echo $this->get_html( $extra_markup );
757 757
     }
758 758
 
759 759
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-items.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -12,79 +12,79 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Items {
14 14
 
15
-	/**
16
-	 * Submission items.
17
-	 * @var GetPaid_Form_Item[]
18
-	 */
19
-	public $items = array();
20
-
21 15
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$data         = $submission->get_data();
29
-		$payment_form = $submission->get_payment_form();
30
-
31
-		// Prepare the selected items.
32
-		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
35
-		}
36
-
37
-		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) {
39
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
40
-			$payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
41
-		}
16
+     * Submission items.
17
+     * @var GetPaid_Form_Item[]
18
+     */
19
+    public $items = array();
42 20
 
43
-		// Process each individual item.
44
-		foreach ( $payment_form->get_items() as $item ) {
45
-			$this->process_item( $item, $selected_items );
46
-		}
47
-
48
-	}
21
+    /**
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $data         = $submission->get_data();
29
+        $payment_form = $submission->get_payment_form();
30
+
31
+        // Prepare the selected items.
32
+        $selected_items = array();
33
+        if ( ! empty( $data['getpaid-items'] ) ) {
34
+            $selected_items = wpinv_clean( $data['getpaid-items'] );
35
+        }
36
+
37
+        // For default forms, ensure that an item has been set.
38
+        if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) {
39
+            $form_items = wpinv_clean( $data['getpaid-form-items'] );
40
+            $payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
41
+        }
42
+
43
+        // Process each individual item.
44
+        foreach ( $payment_form->get_items() as $item ) {
45
+            $this->process_item( $item, $selected_items );
46
+        }
47
+
48
+    }
49 49
 
50
-	/**
51
-	 * Process a single item.
52
-	 *
53
-	 * @param GetPaid_Form_Item $item
54
-	 * @param array $selected_items
55
-	 */
56
-	public function process_item( $item, $selected_items ) {
50
+    /**
51
+     * Process a single item.
52
+     *
53
+     * @param GetPaid_Form_Item $item
54
+     * @param array $selected_items
55
+     */
56
+    public function process_item( $item, $selected_items ) {
57 57
 
58
-		// Abort if this is an optional item and it has not been selected.
59
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
60
-			return;
61
-		}
58
+        // Abort if this is an optional item and it has not been selected.
59
+        if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
60
+            return;
61
+        }
62 62
 
63
-		// (maybe) let customers change the quantities and prices.
64
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
63
+        // (maybe) let customers change the quantities and prices.
64
+        if ( isset( $selected_items[ $item->get_id() ] ) ) {
65 65
 
66
-			// Maybe change the quantities.
67
-			if ( $item->allows_quantities() ) {
68
-				$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
69
-			}
66
+            // Maybe change the quantities.
67
+            if ( $item->allows_quantities() ) {
68
+                $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
69
+            }
70 70
 
71
-			// Maybe change the price.
72
-			if ( $item->user_can_set_their_price() ) {
73
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
71
+            // Maybe change the price.
72
+            if ( $item->user_can_set_their_price() ) {
73
+                $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
74 74
 
75
-				if ( $item->get_minimum_price() > $price ) {
76
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
77
-				}
75
+                if ( $item->get_minimum_price() > $price ) {
76
+                    throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
77
+                }
78 78
 
79
-				$item->set_price( $price );
79
+                $item->set_price( $price );
80 80
 
81
-			}
81
+            }
82 82
 
83
-		}
83
+        }
84 84
 
85
-		// Save the item.
86
-		$this->items[] = $item;
85
+        // Save the item.
86
+        $this->items[] = $item;
87 87
 
88
-	}
88
+    }
89 89
 
90 90
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-items-report-table.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,129 +21,129 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Items_Report_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 300;
29
-
30
-
31
-	/**
32
-	 * Get things started
33
-	 *
34
-	 * @since 1.0.19
35
-	 * @see WP_List_Table::__construct()
36
-	 */
37
-	public function __construct() {
38
-
39
-		// Set parent defaults
40
-		parent::__construct( array(
41
-			'singular' => 'id',
42
-			'plural'   => 'ids',
43
-			'ajax'     => false,
44
-		) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Gets the name of the primary column.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @access protected
53
-	 *
54
-	 * @return string Name of the primary column.
55
-	 */
56
-	protected function get_primary_column_name() {
57
-		return 'item';
58
-	}
59
-
60
-	/**
61
-	 * This function renders most of the columns in the list table.
62
-	 *
63
-	 * @since 1.0.19
64
-	 *
65
-	 * @param array $item Contains all the data of the gateways
66
-	 * @param string $column_name The name of the column
67
-	 *
68
-	 * @return string Column Name
69
-	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve the table columns
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @return array $columns Array of all the list table columns
79
-	 */
80
-	public function get_columns() {
81
-
82
-		return array(
83
-			'item'     => __( 'Item', 'invoicing' ),
84
-			'sales'    => __( 'Quantity Sold', 'invoicing' ),
85
-			'total'    => __( 'Total Earnings', 'invoicing' ),
86
-			'discount' => __( 'Total Discounts', 'invoicing' ),
87
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
88
-		);
89
-
90
-	}
91
-
92
-	/**
93
-	 * Retrieve the current page number
94
-	 *
95
-	 * @since 1.0.19
96
-	 * @return int Current page number
97
-	 */
98
-	public function get_paged() {
99
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
100
-	}
101
-
102
-	/**
103
-	 * Outputs the reporting views
104
-	 *
105
-	 * @since 1.0.19
106
-	 * @return void
107
-	 */
108
-	public function bulk_actions( $which = '' ) {
109
-		return array();
110
-	}
111
-
112
-	/**
113
-	 * Build all the reports data
114
-	 *
115
-	 * @since 1.0.19
116
-	 * @return array $reports_data All the data for gateway reports
117
-	 */
118
-	public function reports_data() {
119
-
120
-		$reports_data = $this->revenue_reports_data();
121
-
122
-		$prepared = array();
123
-		foreach ( $reports_data as $report_data ) {
124
-			$prepared[] = array(
125
-				'item'     => $report_data['item_name'],
126
-				'sales'    => $report_data['sales'],
127
-				'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
128
-				'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
129
-				'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
130
-			);
131
-		}
132
-
133
-		return $prepared;
134
-	}
135
-
136
-	/**
137
-	 * Retrieves report data.
138
-	 *
139
-	 * @since 1.0.19
140
-	 */
141
-	public function revenue_reports_data() {
142
-		global $wpdb;
143
-
144
-		$table =  $wpdb->prefix . 'getpaid_invoice_items';
145
-		return $wpdb->get_results(
146
-			"SELECT
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 300;
29
+
30
+
31
+    /**
32
+     * Get things started
33
+     *
34
+     * @since 1.0.19
35
+     * @see WP_List_Table::__construct()
36
+     */
37
+    public function __construct() {
38
+
39
+        // Set parent defaults
40
+        parent::__construct( array(
41
+            'singular' => 'id',
42
+            'plural'   => 'ids',
43
+            'ajax'     => false,
44
+        ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Gets the name of the primary column.
50
+     *
51
+     * @since 1.0.19
52
+     * @access protected
53
+     *
54
+     * @return string Name of the primary column.
55
+     */
56
+    protected function get_primary_column_name() {
57
+        return 'item';
58
+    }
59
+
60
+    /**
61
+     * This function renders most of the columns in the list table.
62
+     *
63
+     * @since 1.0.19
64
+     *
65
+     * @param array $item Contains all the data of the gateways
66
+     * @param string $column_name The name of the column
67
+     *
68
+     * @return string Column Name
69
+     */
70
+    public function column_default( $item, $column_name ) {
71
+        return wp_kses_post( $item[ $column_name ] );
72
+    }
73
+
74
+    /**
75
+     * Retrieve the table columns
76
+     *
77
+     * @since 1.0.19
78
+     * @return array $columns Array of all the list table columns
79
+     */
80
+    public function get_columns() {
81
+
82
+        return array(
83
+            'item'     => __( 'Item', 'invoicing' ),
84
+            'sales'    => __( 'Quantity Sold', 'invoicing' ),
85
+            'total'    => __( 'Total Earnings', 'invoicing' ),
86
+            'discount' => __( 'Total Discounts', 'invoicing' ),
87
+            'tax'      => __( 'Total Taxes', 'invoicing' ),
88
+        );
89
+
90
+    }
91
+
92
+    /**
93
+     * Retrieve the current page number
94
+     *
95
+     * @since 1.0.19
96
+     * @return int Current page number
97
+     */
98
+    public function get_paged() {
99
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
100
+    }
101
+
102
+    /**
103
+     * Outputs the reporting views
104
+     *
105
+     * @since 1.0.19
106
+     * @return void
107
+     */
108
+    public function bulk_actions( $which = '' ) {
109
+        return array();
110
+    }
111
+
112
+    /**
113
+     * Build all the reports data
114
+     *
115
+     * @since 1.0.19
116
+     * @return array $reports_data All the data for gateway reports
117
+     */
118
+    public function reports_data() {
119
+
120
+        $reports_data = $this->revenue_reports_data();
121
+
122
+        $prepared = array();
123
+        foreach ( $reports_data as $report_data ) {
124
+            $prepared[] = array(
125
+                'item'     => $report_data['item_name'],
126
+                'sales'    => $report_data['sales'],
127
+                'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
128
+                'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
129
+                'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
130
+            );
131
+        }
132
+
133
+        return $prepared;
134
+    }
135
+
136
+    /**
137
+     * Retrieves report data.
138
+     *
139
+     * @since 1.0.19
140
+     */
141
+    public function revenue_reports_data() {
142
+        global $wpdb;
143
+
144
+        $table =  $wpdb->prefix . 'getpaid_invoice_items';
145
+        return $wpdb->get_results(
146
+            "SELECT
147 147
 				SUM(quantity) as sales,
148 148
 				item_name,
149 149
 				SUM(tax) as tax,
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 			GROUP BY item_id
158 158
 			ORDER BY item_name ASC", ARRAY_A);
159 159
 
160
-	}
161
-
162
-	/**
163
-	 * Setup the final data for the table
164
-	 *
165
-	 * @since 1.0.19
166
-	 * @return void
167
-	 */
168
-	public function prepare_items() {
169
-		$columns               = $this->get_columns();
170
-		$hidden                = array(); // No hidden columns
171
-		$sortable              = $this->get_sortable_columns();
172
-		$this->_column_headers = array( $columns, $hidden, $sortable );
173
-		$this->items           = $this->reports_data();
174
-	}
160
+    }
161
+
162
+    /**
163
+     * Setup the final data for the table
164
+     *
165
+     * @since 1.0.19
166
+     * @return void
167
+     */
168
+    public function prepare_items() {
169
+        $columns               = $this->get_columns();
170
+        $hidden                = array(); // No hidden columns
171
+        $sortable              = $this->get_sortable_columns();
172
+        $this->_column_headers = array( $columns, $hidden, $sortable );
173
+        $this->items           = $this->reports_data();
174
+    }
175 175
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-gateways-report-table.php 1 patch
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,148 +21,148 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Gateways_Report_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 300;
29
-
30
-
31
-	/**
32
-	 * Get things started
33
-	 *
34
-	 * @since 1.0.19
35
-	 * @see WP_List_Table::__construct()
36
-	 */
37
-	public function __construct() {
38
-
39
-		// Set parent defaults
40
-		parent::__construct( array(
41
-			'singular' => 'id',
42
-			'plural'   => 'ids',
43
-			'ajax'     => false,
44
-		) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Gets the name of the primary column.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @access protected
53
-	 *
54
-	 * @return string Name of the primary column.
55
-	 */
56
-	protected function get_primary_column_name() {
57
-		return 'gateway';
58
-	}
59
-
60
-	/**
61
-	 * This function renders most of the columns in the list table.
62
-	 *
63
-	 * @since 1.0.19
64
-	 *
65
-	 * @param array $item Contains all the data of the gateways
66
-	 * @param string $column_name The name of the column
67
-	 *
68
-	 * @return string Column Name
69
-	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve the table columns
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @return array $columns Array of all the list table columns
79
-	 */
80
-	public function get_columns() {
81
-
82
-		return array(
83
-			'gateway'  => __( 'Gateway', 'invoicing' ),
84
-			'sales'    => __( 'Total Sales', 'invoicing' ),
85
-			'total'    => __( 'Total Earnings', 'invoicing' ),
86
-			'discount' => __( 'Total Discounts', 'invoicing' ),
87
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
88
-			'fees'     => __( 'Total Fees', 'invoicing' ),
89
-		);
90
-
91
-	}
92
-
93
-	/**
94
-	 * Retrieve the current page number
95
-	 *
96
-	 * @since 1.0.19
97
-	 * @return int Current page number
98
-	 */
99
-	public function get_paged() {
100
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
101
-	}
102
-
103
-	/**
104
-	 * Outputs the reporting views
105
-	 *
106
-	 * @since 1.0.19
107
-	 * @return void
108
-	 */
109
-	public function bulk_actions( $which = '' ) {
110
-		return array();
111
-	}
112
-
113
-	/**
114
-	 * Build all the reports data
115
-	 *
116
-	 * @since 1.0.19
117
-	 * @return array $reports_data All the data for gateway reports
118
-	 */
119
-	public function reports_data() {
120
-
121
-		$reports_data = $this->revenue_reports_data();
122
-		$gateways     = wpinv_get_payment_gateways();
123
-
124
-		foreach ( $gateways as $gateway_id => $gateway ) {
125
-
126
-			if ( ! empty( $reports_data[ $gateway_id ] ) ) {
127
-				continue;
128
-			}
129
-
130
-			$reports_data[] = array(
131
-				'gateway'  => $gateway_id,
132
-				'sales'    => 0,
133
-				'total'    => 0,
134
-				'discount' => 0,
135
-				'tax'      => 0,
136
-				'fees'     => 0,
137
-			);
138
-		}
139
-
140
-		$prepared = array();
141
-		foreach ( $reports_data as $report_data ) {
142
-			$prepared[] = array(
143
-				'gateway'  => wpinv_get_gateway_admin_label( $report_data['gateway'] ),
144
-				'sales'    => $report_data['sales'],
145
-				'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
146
-				'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
147
-				'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
148
-				'fees'     => wpinv_price( wpinv_format_amount( $report_data['fees'] ) ),
149
-			);
150
-		}
151
-
152
-		return $prepared;
153
-	}
154
-
155
-	/**
156
-	 * Retrieves report data.
157
-	 *
158
-	 * @since 1.0.19
159
-	 */
160
-	public function revenue_reports_data() {
161
-		global $wpdb;
162
-
163
-		$table =  $wpdb->prefix . 'getpaid_invoices';
164
-		$data  = $wpdb->get_results(
165
-			"SELECT
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 300;
29
+
30
+
31
+    /**
32
+     * Get things started
33
+     *
34
+     * @since 1.0.19
35
+     * @see WP_List_Table::__construct()
36
+     */
37
+    public function __construct() {
38
+
39
+        // Set parent defaults
40
+        parent::__construct( array(
41
+            'singular' => 'id',
42
+            'plural'   => 'ids',
43
+            'ajax'     => false,
44
+        ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Gets the name of the primary column.
50
+     *
51
+     * @since 1.0.19
52
+     * @access protected
53
+     *
54
+     * @return string Name of the primary column.
55
+     */
56
+    protected function get_primary_column_name() {
57
+        return 'gateway';
58
+    }
59
+
60
+    /**
61
+     * This function renders most of the columns in the list table.
62
+     *
63
+     * @since 1.0.19
64
+     *
65
+     * @param array $item Contains all the data of the gateways
66
+     * @param string $column_name The name of the column
67
+     *
68
+     * @return string Column Name
69
+     */
70
+    public function column_default( $item, $column_name ) {
71
+        return wp_kses_post( $item[ $column_name ] );
72
+    }
73
+
74
+    /**
75
+     * Retrieve the table columns
76
+     *
77
+     * @since 1.0.19
78
+     * @return array $columns Array of all the list table columns
79
+     */
80
+    public function get_columns() {
81
+
82
+        return array(
83
+            'gateway'  => __( 'Gateway', 'invoicing' ),
84
+            'sales'    => __( 'Total Sales', 'invoicing' ),
85
+            'total'    => __( 'Total Earnings', 'invoicing' ),
86
+            'discount' => __( 'Total Discounts', 'invoicing' ),
87
+            'tax'      => __( 'Total Taxes', 'invoicing' ),
88
+            'fees'     => __( 'Total Fees', 'invoicing' ),
89
+        );
90
+
91
+    }
92
+
93
+    /**
94
+     * Retrieve the current page number
95
+     *
96
+     * @since 1.0.19
97
+     * @return int Current page number
98
+     */
99
+    public function get_paged() {
100
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
101
+    }
102
+
103
+    /**
104
+     * Outputs the reporting views
105
+     *
106
+     * @since 1.0.19
107
+     * @return void
108
+     */
109
+    public function bulk_actions( $which = '' ) {
110
+        return array();
111
+    }
112
+
113
+    /**
114
+     * Build all the reports data
115
+     *
116
+     * @since 1.0.19
117
+     * @return array $reports_data All the data for gateway reports
118
+     */
119
+    public function reports_data() {
120
+
121
+        $reports_data = $this->revenue_reports_data();
122
+        $gateways     = wpinv_get_payment_gateways();
123
+
124
+        foreach ( $gateways as $gateway_id => $gateway ) {
125
+
126
+            if ( ! empty( $reports_data[ $gateway_id ] ) ) {
127
+                continue;
128
+            }
129
+
130
+            $reports_data[] = array(
131
+                'gateway'  => $gateway_id,
132
+                'sales'    => 0,
133
+                'total'    => 0,
134
+                'discount' => 0,
135
+                'tax'      => 0,
136
+                'fees'     => 0,
137
+            );
138
+        }
139
+
140
+        $prepared = array();
141
+        foreach ( $reports_data as $report_data ) {
142
+            $prepared[] = array(
143
+                'gateway'  => wpinv_get_gateway_admin_label( $report_data['gateway'] ),
144
+                'sales'    => $report_data['sales'],
145
+                'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
146
+                'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
147
+                'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
148
+                'fees'     => wpinv_price( wpinv_format_amount( $report_data['fees'] ) ),
149
+            );
150
+        }
151
+
152
+        return $prepared;
153
+    }
154
+
155
+    /**
156
+     * Retrieves report data.
157
+     *
158
+     * @since 1.0.19
159
+     */
160
+    public function revenue_reports_data() {
161
+        global $wpdb;
162
+
163
+        $table =  $wpdb->prefix . 'getpaid_invoices';
164
+        $data  = $wpdb->get_results(
165
+            "SELECT
166 166
 				COUNT(posts.ID) as sales,
167 167
 				meta.gateway as gateway,
168 168
 				SUM(meta.total) as total,
@@ -177,27 +177,27 @@  discard block
 block discarded – undo
177 177
                 AND ( posts.post_status = 'publish' OR posts.post_status = 'renewal' )
178 178
 			GROUP BY meta.gateway", ARRAY_A);
179 179
 		
180
-		$return = array();
181
-
182
-		foreach ( $data as $gateway ) {
183
-			$return[ $gateway ['gateway']] = $gateway;
184
-		}
185
-
186
-		return $return;
187
-
188
-	}
189
-
190
-	/**
191
-	 * Setup the final data for the table
192
-	 *
193
-	 * @since 1.0.19
194
-	 * @return void
195
-	 */
196
-	public function prepare_items() {
197
-		$columns               = $this->get_columns();
198
-		$hidden                = array(); // No hidden columns
199
-		$sortable              = $this->get_sortable_columns();
200
-		$this->_column_headers = array( $columns, $hidden, $sortable );
201
-		$this->items           = $this->reports_data();
202
-	}
180
+        $return = array();
181
+
182
+        foreach ( $data as $gateway ) {
183
+            $return[ $gateway ['gateway']] = $gateway;
184
+        }
185
+
186
+        return $return;
187
+
188
+    }
189
+
190
+    /**
191
+     * Setup the final data for the table
192
+     *
193
+     * @since 1.0.19
194
+     * @return void
195
+     */
196
+    public function prepare_items() {
197
+        $columns               = $this->get_columns();
198
+        $hidden                = array(); // No hidden columns
199
+        $sortable              = $this->get_sortable_columns();
200
+        $this->_column_headers = array( $columns, $hidden, $sortable );
201
+        $this->items           = $this->reports_data();
202
+    }
203 203
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-taxes-report-table.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,145 +21,145 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Taxes_Reports_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 300;
29
-
30
-
31
-	/**
32
-	 * Get things started
33
-	 *
34
-	 * @since 1.0.19
35
-	 * @see WP_List_Table::__construct()
36
-	 */
37
-	public function __construct() {
38
-
39
-		// Set parent defaults
40
-		parent::__construct( array(
41
-			'singular' => 'id',
42
-			'plural'   => 'ids',
43
-			'ajax'     => false,
44
-		) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Gets the name of the primary column.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @access protected
53
-	 *
54
-	 * @return string Name of the primary column.
55
-	 */
56
-	protected function get_primary_column_name() {
57
-		return 'month';
58
-	}
59
-
60
-	/**
61
-	 * This function renders most of the columns in the list table.
62
-	 *
63
-	 * @since 1.0.19
64
-	 *
65
-	 * @param array $item Contains all the data of the gateways
66
-	 * @param string $column_name The name of the column
67
-	 *
68
-	 * @return string Column Name
69
-	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve the table columns
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @return array $columns Array of all the list table columns
79
-	 */
80
-	public function get_columns() {
81
-
82
-		return array(
83
-			'month'    => __( 'Month', 'invoicing' ),
84
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
85
-		);
86
-
87
-	}
88
-
89
-	/**
90
-	 * Retrieve the current page number
91
-	 *
92
-	 * @since 1.0.19
93
-	 * @return int Current page number
94
-	 */
95
-	public function get_paged() {
96
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
97
-	}
98
-
99
-	/**
100
-	 * Outputs the reporting views
101
-	 *
102
-	 * @since 1.0.19
103
-	 * @return void
104
-	 */
105
-	public function bulk_actions( $which = '' ) {
106
-		return array();
107
-	}
108
-
109
-	/**
110
-	 * Build all the reports data
111
-	 *
112
-	 * @since 1.0.19
113
-	 * @return array $reports_data All the data for taxes reports
114
-	 */
115
-	public function reports_data() {
116
-
117
-		$reports_data = $this->taxes_reports_data();
118
-		$months       = array(
119
-			'1' => __( 'January', 'invoicing' ),
120
-			'2' => __( 'February', 'invoicing' ),
121
-			'3' => __( 'March', 'invoicing' ),
122
-			'4' => __( 'April', 'invoicing' ),
123
-			'5' => __( 'May', 'invoicing' ),
124
-			'6' => __( 'June', 'invoicing' ),
125
-			'7' => __( 'July', 'invoicing' ),
126
-			'8' => __( 'August', 'invoicing' ),
127
-			'9' => __( 'September', 'invoicing' ),
128
-			'10' => __( 'October', 'invoicing' ),
129
-			'11' => __( 'November', 'invoicing' ),
130
-			'12' => __( 'December', 'invoicing' ),
131
-		);
132
-
133
-		$prepared = array();
134
-		foreach ( $months as $month => $label ) {
135
-
136
-			$tax = wpinv_price( 0 );
137
-			if ( ! empty( $reports_data[ $month ] ) ) {
138
-				$tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) );
139
-			}
140
-
141
-			$prepared[] = array(
142
-				'month'    => $label,
143
-				'tax'      => $tax,
144
-			);
145
-
146
-		}
147
-
148
-		return $prepared;
149
-	}
150
-
151
-	/**
152
-	 * Retrieves taxes data.
153
-	 *
154
-	 * @since 1.0.19
155
-	 */
156
-	public function taxes_reports_data() {
157
-		global $wpdb;
158
-
159
-		$table =  $wpdb->prefix . 'getpaid_invoices';
160
-		$year  = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
161
-		$data  = $wpdb->get_results(
162
-			"SELECT
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 300;
29
+
30
+
31
+    /**
32
+     * Get things started
33
+     *
34
+     * @since 1.0.19
35
+     * @see WP_List_Table::__construct()
36
+     */
37
+    public function __construct() {
38
+
39
+        // Set parent defaults
40
+        parent::__construct( array(
41
+            'singular' => 'id',
42
+            'plural'   => 'ids',
43
+            'ajax'     => false,
44
+        ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Gets the name of the primary column.
50
+     *
51
+     * @since 1.0.19
52
+     * @access protected
53
+     *
54
+     * @return string Name of the primary column.
55
+     */
56
+    protected function get_primary_column_name() {
57
+        return 'month';
58
+    }
59
+
60
+    /**
61
+     * This function renders most of the columns in the list table.
62
+     *
63
+     * @since 1.0.19
64
+     *
65
+     * @param array $item Contains all the data of the gateways
66
+     * @param string $column_name The name of the column
67
+     *
68
+     * @return string Column Name
69
+     */
70
+    public function column_default( $item, $column_name ) {
71
+        return wp_kses_post( $item[ $column_name ] );
72
+    }
73
+
74
+    /**
75
+     * Retrieve the table columns
76
+     *
77
+     * @since 1.0.19
78
+     * @return array $columns Array of all the list table columns
79
+     */
80
+    public function get_columns() {
81
+
82
+        return array(
83
+            'month'    => __( 'Month', 'invoicing' ),
84
+            'tax'      => __( 'Total Taxes', 'invoicing' ),
85
+        );
86
+
87
+    }
88
+
89
+    /**
90
+     * Retrieve the current page number
91
+     *
92
+     * @since 1.0.19
93
+     * @return int Current page number
94
+     */
95
+    public function get_paged() {
96
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
97
+    }
98
+
99
+    /**
100
+     * Outputs the reporting views
101
+     *
102
+     * @since 1.0.19
103
+     * @return void
104
+     */
105
+    public function bulk_actions( $which = '' ) {
106
+        return array();
107
+    }
108
+
109
+    /**
110
+     * Build all the reports data
111
+     *
112
+     * @since 1.0.19
113
+     * @return array $reports_data All the data for taxes reports
114
+     */
115
+    public function reports_data() {
116
+
117
+        $reports_data = $this->taxes_reports_data();
118
+        $months       = array(
119
+            '1' => __( 'January', 'invoicing' ),
120
+            '2' => __( 'February', 'invoicing' ),
121
+            '3' => __( 'March', 'invoicing' ),
122
+            '4' => __( 'April', 'invoicing' ),
123
+            '5' => __( 'May', 'invoicing' ),
124
+            '6' => __( 'June', 'invoicing' ),
125
+            '7' => __( 'July', 'invoicing' ),
126
+            '8' => __( 'August', 'invoicing' ),
127
+            '9' => __( 'September', 'invoicing' ),
128
+            '10' => __( 'October', 'invoicing' ),
129
+            '11' => __( 'November', 'invoicing' ),
130
+            '12' => __( 'December', 'invoicing' ),
131
+        );
132
+
133
+        $prepared = array();
134
+        foreach ( $months as $month => $label ) {
135
+
136
+            $tax = wpinv_price( 0 );
137
+            if ( ! empty( $reports_data[ $month ] ) ) {
138
+                $tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) );
139
+            }
140
+
141
+            $prepared[] = array(
142
+                'month'    => $label,
143
+                'tax'      => $tax,
144
+            );
145
+
146
+        }
147
+
148
+        return $prepared;
149
+    }
150
+
151
+    /**
152
+     * Retrieves taxes data.
153
+     *
154
+     * @since 1.0.19
155
+     */
156
+    public function taxes_reports_data() {
157
+        global $wpdb;
158
+
159
+        $table =  $wpdb->prefix . 'getpaid_invoices';
160
+        $year  = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
161
+        $data  = $wpdb->get_results(
162
+            "SELECT
163 163
 				MONTH(meta.completed_date) as _month,
164 164
 				SUM(meta.tax) as tax
165 165
 			FROM $wpdb->posts as posts
@@ -171,21 +171,21 @@  discard block
 block discarded – undo
171 171
 				AND ( YEAR(meta.completed_date) = '$year' )
172 172
 			GROUP BY MONTH(meta.completed_date)");
173 173
 
174
-		return wp_list_pluck( $data, 'tax', '_month' );
175
-
176
-	}
177
-
178
-	/**
179
-	 * Setup the final data for the table
180
-	 *
181
-	 * @since 1.0.19
182
-	 * @return void
183
-	 */
184
-	public function prepare_items() {
185
-		$columns               = $this->get_columns();
186
-		$hidden                = array(); // No hidden columns
187
-		$sortable              = $this->get_sortable_columns();
188
-		$this->_column_headers = array( $columns, $hidden, $sortable );
189
-		$this->items           = $this->reports_data();
190
-	}
174
+        return wp_list_pluck( $data, 'tax', '_month' );
175
+
176
+    }
177
+
178
+    /**
179
+     * Setup the final data for the table
180
+     *
181
+     * @since 1.0.19
182
+     * @return void
183
+     */
184
+    public function prepare_items() {
185
+        $columns               = $this->get_columns();
186
+        $hidden                = array(); // No hidden columns
187
+        $sortable              = $this->get_sortable_columns();
188
+        $this->_column_headers = array( $columns, $hidden, $sortable );
189
+        $this->items           = $this->reports_data();
190
+    }
191 191
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Indentation   +459 added lines, -459 removed lines patch added patch discarded remove patch
@@ -14,406 +14,406 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * Tax instance.
40
-	 *
41
-	 * @var WPInv_EUVat
42
-	 */
43
-	public $tax;
44
-
45
-	/**
46
-	 * @param array An array of payment gateways.
47
-	 */
48
-	public $gateways;
49
-
50
-	/**
51
-	 * Class constructor.
52
-	 */
53
-	public function __construct() {
54
-		$this->define_constants();
55
-		$this->includes();
56
-		$this->init_hooks();
57
-		$this->set_properties();
58
-	}
59
-
60
-	/**
61
-	 * Sets a custom data property.
62
-	 * 
63
-	 * @param string $prop The prop to set.
64
-	 * @param mixed $value The value to retrieve.
65
-	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
68
-	}
69
-
70
-	/**
71
-	 * Gets a custom data property.
72
-	 *
73
-	 * @param string $prop The prop to set.
74
-	 * @return mixed The value.
75
-	 */
76
-	public function get( $prop ) {
77
-
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
80
-		}
81
-
82
-		return null;
83
-	}
84
-
85
-	/**
86
-	 * Define class properties.
87
-	 */
88
-	public function set_properties() {
89
-
90
-		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
-		$this->tax              = new WPInv_EUVat();
94
-		$this->tax->init();
95
-		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
96
-
97
-		// Init other objects.
98
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
99
-		$this->set( 'session', new WPInv_Session_Handler() );
100
-		$this->set( 'notes', new WPInv_Notes() );
101
-		$this->set( 'api', new WPInv_API() );
102
-		$this->set( 'post_types', new GetPaid_Post_Types() );
103
-		$this->set( 'template', new GetPaid_Template() );
104
-		$this->set( 'admin', new GetPaid_Admin() );
105
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
106
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
107
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
108
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
109
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
110
-
111
-	}
112
-
113
-	 /**
114
-	 * Define plugin constants.
115
-	 */
116
-	public function define_constants() {
117
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
118
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
119
-		$this->version = WPINV_VERSION;
120
-	}
121
-
122
-	/**
123
-	 * Hook into actions and filters.
124
-	 *
125
-	 * @since 1.0.19
126
-	 */
127
-	protected function init_hooks() {
128
-		/* Internationalize the text strings used. */
129
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
130
-
131
-		// Init the plugin after WordPress inits.
132
-		add_action( 'init', array( $this, 'init' ), 1 );
133
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
134
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
135
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
136
-
137
-		if ( class_exists( 'BuddyPress' ) ) {
138
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
139
-		}
140
-
141
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
142
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
143
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
144
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
145
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
146
-
147
-		// Fires after registering actions.
148
-		do_action( 'wpinv_actions', $this );
149
-		do_action( 'getpaid_actions', $this );
150
-
151
-	}
152
-
153
-	public function plugins_loaded() {
154
-		/* Internationalize the text strings used. */
155
-		$this->load_textdomain();
156
-
157
-		do_action( 'wpinv_loaded' );
158
-
159
-		// Fix oxygen page builder conflict
160
-		if ( function_exists( 'ct_css_output' ) ) {
161
-			wpinv_oxygen_fix_conflict();
162
-		}
163
-	}
164
-
165
-	/**
166
-	 * Load the translation of the plugin.
167
-	 *
168
-	 * @since 1.0
169
-	 */
170
-	public function load_textdomain( $locale = NULL ) {
171
-		if ( empty( $locale ) ) {
172
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
173
-		}
174
-
175
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
176
-
177
-		unload_textdomain( 'invoicing' );
178
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
179
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
180
-
181
-		/**
182
-		 * Define language constants.
183
-		 */
184
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
185
-	}
186
-
187
-	/**
188
-	 * Include required core files used in admin and on the frontend.
189
-	 */
190
-	public function includes() {
191
-
192
-		// Start with the settings.
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
194
-
195
-		// Packages/libraries.
196
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
198
-
199
-		// Load functions.
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
212
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
215
-
216
-		// Register autoloader.
217
-		try {
218
-			spl_autoload_register( array( $this, 'autoload' ), true );
219
-		} catch ( Exception $e ) {
220
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
221
-		}
222
-
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
242
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
243
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
244
-
245
-		/**
246
-		 * Load the tax class.
247
-		 */
248
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
249
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
250
-		}
251
-
252
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
253
-			GetPaid_Post_Types_Admin::init();
254
-
255
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
256
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
257
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
258
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
259
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
260
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
261
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
262
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
263
-			// load the user class only on the users.php page
264
-			global $pagenow;
265
-			if($pagenow=='users.php'){
266
-				new WPInv_Admin_Users();
267
-			}
268
-		}
269
-
270
-		// Register cli commands
271
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
272
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
273
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
274
-		}
275
-
276
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
277
-	}
278
-
279
-	/**
280
-	 * Class autoloader
281
-	 *
282
-	 * @param       string $class_name The name of the class to load.
283
-	 * @access      public
284
-	 * @since       1.0.19
285
-	 * @return      void
286
-	 */
287
-	public function autoload( $class_name ) {
288
-
289
-		// Normalize the class name...
290
-		$class_name  = strtolower( $class_name );
291
-
292
-		// ... and make sure it is our class.
293
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
294
-			return;
295
-		}
296
-
297
-		// Next, prepare the file name from the class.
298
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
299
-
300
-		// Base path of the classes.
301
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
302
-
303
-		// And an array of possible locations in order of importance.
304
-		$locations = array(
305
-			"$plugin_path/includes",
306
-			"$plugin_path/includes/data-stores",
307
-			"$plugin_path/includes/gateways",
308
-			"$plugin_path/includes/payments",
309
-			"$plugin_path/includes/api",
310
-			"$plugin_path/includes/admin",
311
-			"$plugin_path/includes/admin/meta-boxes",
312
-		);
313
-
314
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
315
-
316
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
317
-				include trailingslashit( $location ) . $file_name;
318
-				break;
319
-			}
320
-
321
-		}
322
-
323
-	}
324
-
325
-	/**
326
-	 * Inits hooks etc.
327
-	 */
328
-	public function init() {
329
-
330
-		// Fires before getpaid inits.
331
-		do_action( 'before_getpaid_init', $this );
332
-
333
-		// Load default gateways.
334
-		$gateways = apply_filters(
335
-			'getpaid_default_gateways',
336
-			array(
337
-				'manual'        => 'GetPaid_Manual_Gateway',
338
-				'paypal'        => 'GetPaid_Paypal_Gateway',
339
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
340
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
341
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
342
-			)
343
-		);
344
-
345
-		foreach ( $gateways as $id => $class ) {
346
-			$this->gateways[ $id ] = new $class();
347
-		}
348
-
349
-		// Fires after getpaid inits.
350
-		do_action( 'getpaid_init', $this );
351
-
352
-	}
353
-
354
-	/**
355
-	 * Checks if this is an IPN request and processes it.
356
-	 */
357
-	public function maybe_process_ipn() {
358
-
359
-		// Ensure that this is an IPN request.
360
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
361
-			return;
362
-		}
363
-
364
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
365
-
366
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
367
-		do_action( "wpinv_verify_{$gateway}_ipn" );
368
-		exit;
369
-
370
-	}
371
-
372
-	public function enqueue_scripts() {
373
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
374
-
375
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
376
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
377
-		wp_enqueue_style( 'wpinv_front_style' );
378
-
379
-		// Register scripts
380
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
381
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
382
-
383
-		$localize                         = array();
384
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
385
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
386
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
387
-		$localize['UseTaxes']             = wpinv_use_taxes();
388
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
389
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
390
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * Tax instance.
40
+     *
41
+     * @var WPInv_EUVat
42
+     */
43
+    public $tax;
44
+
45
+    /**
46
+     * @param array An array of payment gateways.
47
+     */
48
+    public $gateways;
49
+
50
+    /**
51
+     * Class constructor.
52
+     */
53
+    public function __construct() {
54
+        $this->define_constants();
55
+        $this->includes();
56
+        $this->init_hooks();
57
+        $this->set_properties();
58
+    }
59
+
60
+    /**
61
+     * Sets a custom data property.
62
+     * 
63
+     * @param string $prop The prop to set.
64
+     * @param mixed $value The value to retrieve.
65
+     */
66
+    public function set( $prop, $value ) {
67
+        $this->data[ $prop ] = $value;
68
+    }
69
+
70
+    /**
71
+     * Gets a custom data property.
72
+     *
73
+     * @param string $prop The prop to set.
74
+     * @return mixed The value.
75
+     */
76
+    public function get( $prop ) {
77
+
78
+        if ( isset( $this->data[ $prop ] ) ) {
79
+            return $this->data[ $prop ];
80
+        }
81
+
82
+        return null;
83
+    }
84
+
85
+    /**
86
+     * Define class properties.
87
+     */
88
+    public function set_properties() {
89
+
90
+        // Sessions.
91
+        $this->set( 'session', new WPInv_Session_Handler() );
92
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
+        $this->tax              = new WPInv_EUVat();
94
+        $this->tax->init();
95
+        $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
96
+
97
+        // Init other objects.
98
+        $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
99
+        $this->set( 'session', new WPInv_Session_Handler() );
100
+        $this->set( 'notes', new WPInv_Notes() );
101
+        $this->set( 'api', new WPInv_API() );
102
+        $this->set( 'post_types', new GetPaid_Post_Types() );
103
+        $this->set( 'template', new GetPaid_Template() );
104
+        $this->set( 'admin', new GetPaid_Admin() );
105
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
106
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
107
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
108
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
109
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
110
+
111
+    }
112
+
113
+        /**
114
+         * Define plugin constants.
115
+         */
116
+    public function define_constants() {
117
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
118
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
119
+        $this->version = WPINV_VERSION;
120
+    }
121
+
122
+    /**
123
+     * Hook into actions and filters.
124
+     *
125
+     * @since 1.0.19
126
+     */
127
+    protected function init_hooks() {
128
+        /* Internationalize the text strings used. */
129
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
130
+
131
+        // Init the plugin after WordPress inits.
132
+        add_action( 'init', array( $this, 'init' ), 1 );
133
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
134
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
135
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
136
+
137
+        if ( class_exists( 'BuddyPress' ) ) {
138
+            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
139
+        }
140
+
141
+        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
142
+        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
143
+        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
144
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
145
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
146
+
147
+        // Fires after registering actions.
148
+        do_action( 'wpinv_actions', $this );
149
+        do_action( 'getpaid_actions', $this );
150
+
151
+    }
152
+
153
+    public function plugins_loaded() {
154
+        /* Internationalize the text strings used. */
155
+        $this->load_textdomain();
156
+
157
+        do_action( 'wpinv_loaded' );
158
+
159
+        // Fix oxygen page builder conflict
160
+        if ( function_exists( 'ct_css_output' ) ) {
161
+            wpinv_oxygen_fix_conflict();
162
+        }
163
+    }
164
+
165
+    /**
166
+     * Load the translation of the plugin.
167
+     *
168
+     * @since 1.0
169
+     */
170
+    public function load_textdomain( $locale = NULL ) {
171
+        if ( empty( $locale ) ) {
172
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
173
+        }
174
+
175
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
176
+
177
+        unload_textdomain( 'invoicing' );
178
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
179
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
180
+
181
+        /**
182
+         * Define language constants.
183
+         */
184
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
185
+    }
186
+
187
+    /**
188
+     * Include required core files used in admin and on the frontend.
189
+     */
190
+    public function includes() {
191
+
192
+        // Start with the settings.
193
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
194
+
195
+        // Packages/libraries.
196
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
197
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
198
+
199
+        // Load functions.
200
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
205
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
206
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
207
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
208
+        require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
209
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
210
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
211
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
212
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
213
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
215
+
216
+        // Register autoloader.
217
+        try {
218
+            spl_autoload_register( array( $this, 'autoload' ), true );
219
+        } catch ( Exception $e ) {
220
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
221
+        }
222
+
223
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
234
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
235
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
236
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
237
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
238
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
239
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
240
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
241
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
242
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
243
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
244
+
245
+        /**
246
+         * Load the tax class.
247
+         */
248
+        if ( ! class_exists( 'WPInv_EUVat' ) ) {
249
+            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
250
+        }
251
+
252
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
253
+            GetPaid_Post_Types_Admin::init();
254
+
255
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
256
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
257
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
258
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
259
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
260
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
261
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
262
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
263
+            // load the user class only on the users.php page
264
+            global $pagenow;
265
+            if($pagenow=='users.php'){
266
+                new WPInv_Admin_Users();
267
+            }
268
+        }
269
+
270
+        // Register cli commands
271
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
272
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
273
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
274
+        }
275
+
276
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
277
+    }
278
+
279
+    /**
280
+     * Class autoloader
281
+     *
282
+     * @param       string $class_name The name of the class to load.
283
+     * @access      public
284
+     * @since       1.0.19
285
+     * @return      void
286
+     */
287
+    public function autoload( $class_name ) {
288
+
289
+        // Normalize the class name...
290
+        $class_name  = strtolower( $class_name );
291
+
292
+        // ... and make sure it is our class.
293
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
294
+            return;
295
+        }
296
+
297
+        // Next, prepare the file name from the class.
298
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
299
+
300
+        // Base path of the classes.
301
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
302
+
303
+        // And an array of possible locations in order of importance.
304
+        $locations = array(
305
+            "$plugin_path/includes",
306
+            "$plugin_path/includes/data-stores",
307
+            "$plugin_path/includes/gateways",
308
+            "$plugin_path/includes/payments",
309
+            "$plugin_path/includes/api",
310
+            "$plugin_path/includes/admin",
311
+            "$plugin_path/includes/admin/meta-boxes",
312
+        );
313
+
314
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
315
+
316
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
317
+                include trailingslashit( $location ) . $file_name;
318
+                break;
319
+            }
320
+
321
+        }
322
+
323
+    }
324
+
325
+    /**
326
+     * Inits hooks etc.
327
+     */
328
+    public function init() {
329
+
330
+        // Fires before getpaid inits.
331
+        do_action( 'before_getpaid_init', $this );
332
+
333
+        // Load default gateways.
334
+        $gateways = apply_filters(
335
+            'getpaid_default_gateways',
336
+            array(
337
+                'manual'        => 'GetPaid_Manual_Gateway',
338
+                'paypal'        => 'GetPaid_Paypal_Gateway',
339
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
340
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
341
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
342
+            )
343
+        );
344
+
345
+        foreach ( $gateways as $id => $class ) {
346
+            $this->gateways[ $id ] = new $class();
347
+        }
348
+
349
+        // Fires after getpaid inits.
350
+        do_action( 'getpaid_init', $this );
351
+
352
+    }
353
+
354
+    /**
355
+     * Checks if this is an IPN request and processes it.
356
+     */
357
+    public function maybe_process_ipn() {
358
+
359
+        // Ensure that this is an IPN request.
360
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
361
+            return;
362
+        }
391 363
 
392
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
393
-
394
-		wp_enqueue_script( 'jquery-blockui' );
364
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
395 365
 
396
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' );
397
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
366
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
367
+        do_action( "wpinv_verify_{$gateway}_ipn" );
368
+        exit;
398 369
 
399
-		wp_enqueue_script( 'wpinv-front-script' );
400
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
401
-
402
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
403
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
404
-	}
405
-
406
-	public function wpinv_actions() {
407
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
408
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
409
-		}
410
-	}
370
+    }
371
+
372
+    public function enqueue_scripts() {
373
+        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
374
+
375
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
376
+        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
377
+        wp_enqueue_style( 'wpinv_front_style' );
378
+
379
+        // Register scripts
380
+        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
381
+        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
382
+
383
+        $localize                         = array();
384
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
385
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
386
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
387
+        $localize['UseTaxes']             = wpinv_use_taxes();
388
+        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
389
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
390
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
391
+
392
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
393
+
394
+        wp_enqueue_script( 'jquery-blockui' );
395
+
396
+        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' );
397
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
398
+
399
+        wp_enqueue_script( 'wpinv-front-script' );
400
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
401
+
402
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
403
+        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
404
+    }
405
+
406
+    public function wpinv_actions() {
407
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
408
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
409
+        }
410
+    }
411 411
 
412
-	/**
412
+    /**
413 413
      * Fires an action after verifying that a user can fire them.
414
-	 *
415
-	 * Note: If the action is on an invoice, subscription etc, esure that the
416
-	 * current user owns the invoice/subscription.
414
+     *
415
+     * Note: If the action is on an invoice, subscription etc, esure that the
416
+     * current user owns the invoice/subscription.
417 417
      */
418 418
     public function maybe_do_authenticated_action() {
419 419
 
@@ -424,82 +424,82 @@  discard block
 block discarded – undo
424 424
 
425 425
     }
426 426
 
427
-	public function pre_get_posts( $wp_query ) {
428
-		if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
429
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
430
-		}
431
-
432
-		return $wp_query;
433
-	}
434
-
435
-	public function bp_invoicing_init() {
436
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
437
-	}
438
-
439
-	/**
440
-	 * Register widgets
441
-	 *
442
-	 */
443
-	public function register_widgets() {
444
-		$widgets = apply_filters(
445
-			'getpaid_widget_classes',
446
-			array(
447
-				'WPInv_Checkout_Widget',
448
-				'WPInv_History_Widget',
449
-				'WPInv_Receipt_Widget',
450
-				'WPInv_Subscriptions_Widget',
451
-				'WPInv_Buy_Item_Widget',
452
-				'WPInv_Messages_Widget',
453
-				'WPInv_GetPaid_Widget'
454
-			)
455
-		);
456
-
457
-		foreach ( $widgets as $widget ) {
458
-			register_widget( $widget );
459
-		}
427
+    public function pre_get_posts( $wp_query ) {
428
+        if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
429
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
430
+        }
431
+
432
+        return $wp_query;
433
+    }
434
+
435
+    public function bp_invoicing_init() {
436
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
437
+    }
438
+
439
+    /**
440
+     * Register widgets
441
+     *
442
+     */
443
+    public function register_widgets() {
444
+        $widgets = apply_filters(
445
+            'getpaid_widget_classes',
446
+            array(
447
+                'WPInv_Checkout_Widget',
448
+                'WPInv_History_Widget',
449
+                'WPInv_Receipt_Widget',
450
+                'WPInv_Subscriptions_Widget',
451
+                'WPInv_Buy_Item_Widget',
452
+                'WPInv_Messages_Widget',
453
+                'WPInv_GetPaid_Widget'
454
+            )
455
+        );
456
+
457
+        foreach ( $widgets as $widget ) {
458
+            register_widget( $widget );
459
+        }
460 460
 		
461
-	}
461
+    }
462 462
 
463
-	/**
464
-	 * Remove our pages from yoast sitemaps.
465
-	 *
466
-	 * @since 1.0.19
467
-	 * @param int[] $excluded_posts_ids
468
-	 */
469
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
463
+    /**
464
+     * Remove our pages from yoast sitemaps.
465
+     *
466
+     * @since 1.0.19
467
+     * @param int[] $excluded_posts_ids
468
+     */
469
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
470 470
 
471
-		// Ensure that we have an array.
472
-		if ( ! is_array( $excluded_posts_ids ) ) {
473
-			$excluded_posts_ids = array();
474
-		}
471
+        // Ensure that we have an array.
472
+        if ( ! is_array( $excluded_posts_ids ) ) {
473
+            $excluded_posts_ids = array();
474
+        }
475 475
 
476
-		// Prepare our pages.
477
-		$our_pages = array();
476
+        // Prepare our pages.
477
+        $our_pages = array();
478 478
 
479
-		// Checkout page.
480
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
479
+        // Checkout page.
480
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
481 481
 
482
-		// Success page.
483
-		$our_pages[] = wpinv_get_option( 'success_page', false );
482
+        // Success page.
483
+        $our_pages[] = wpinv_get_option( 'success_page', false );
484 484
 
485
-		// Failure page.
486
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
485
+        // Failure page.
486
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
487 487
 
488
-		// History page.
489
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
488
+        // History page.
489
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
490 490
 
491
-		// Subscriptions page.
492
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
491
+        // Subscriptions page.
492
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
493 493
 
494
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
494
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
495 495
 
496
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
497
-		return array_unique( $excluded_posts_ids );
496
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
497
+        return array_unique( $excluded_posts_ids );
498 498
 
499
-	}
499
+    }
500 500
 
501
-	public function wp_footer() {
502
-		echo '
501
+    public function wp_footer() {
502
+        echo '
503 503
 			<div class="bsui">
504 504
 				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
505 505
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
@@ -510,6 +510,6 @@  discard block
 block discarded – undo
510 510
 				</div>
511 511
 			</div>
512 512
 		';
513
-	}
513
+    }
514 514
 
515 515
 }
Please login to merge, or discard this patch.