Passed
Push — master ( 7db120...b4ab02 )
by Brian
07:23 queued 02:27
created
includes/class-getpaid-subscriptions-query.php 2 patches
Indentation   +476 added lines, -476 removed lines patch added patch discarded remove patch
@@ -16,481 +16,481 @@
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Subscriptions_Query {
18 18
 
19
-	/**
20
-	 * Query vars, after parsing
21
-	 *
22
-	 * @since 1.0.19
23
-	 * @var array
24
-	 */
25
-	public $query_vars = array();
26
-
27
-	/**
28
-	 * List of found subscriptions.
29
-	 *
30
-	 * @since 1.0.19
31
-	 * @var array
32
-	 */
33
-	private $results;
34
-
35
-	/**
36
-	 * Total number of found subscriptions for the current query
37
-	 *
38
-	 * @since 1.0.19
39
-	 * @var int
40
-	 */
41
-	private $total_subscriptions = 0;
42
-
43
-	/**
44
-	 * The SQL query used to fetch matching subscriptions.
45
-	 *
46
-	 * @since 1.0.19
47
-	 * @var string
48
-	 */
49
-	public $request;
50
-
51
-	// SQL clauses
52
-
53
-	/**
54
-	 * Contains the 'FIELDS' sql clause
55
-	 *
56
-	 * @since 1.0.19
57
-	 * @var string
58
-	 */
59
-	public $query_fields;
60
-
61
-	/**
62
-	 * Contains the 'FROM' sql clause
63
-	 *
64
-	 * @since 1.0.19
65
-	 * @var string
66
-	 */
67
-	public $query_from;
68
-
69
-	/**
70
-	 * Contains the 'WHERE' sql clause
71
-	 *
72
-	 * @since 1.0.19
73
-	 * @var string
74
-	 */
75
-	public $query_where;
76
-
77
-	/**
78
-	 * Contains the 'ORDER BY' sql clause
79
-	 *
80
-	 * @since 1.0.19
81
-	 * @var string
82
-	 */
83
-	public $query_orderby;
84
-
85
-	/**
86
-	 * Contains the 'LIMIT' sql clause
87
-	 *
88
-	 * @since 1.0.19
89
-	 * @var string
90
-	 */
91
-	public $query_limit;
92
-
93
-	/**
94
-	 * Class constructor.
95
-	 *
96
-	 * @since 1.0.19
97
-	 *
98
-	 * @param null|string|array $query Optional. The query variables.
99
-	 */
100
-	public function __construct( $query = null ) {
101
-		if ( ! is_null( $query ) ) {
102
-			$this->prepare_query( $query );
103
-			$this->query();
104
-		}
105
-	}
106
-
107
-	/**
108
-	 * Fills in missing query variables with default values.
109
-	 *
110
-	 * @since 1.0.19
111
-	 *
112
-	 * @param  string|array $args Query vars, as passed to `GetPaid_Subscriptions_Query`.
113
-	 * @return array Complete query variables with undefined ones filled in with defaults.
114
-	 */
115
-	public static function fill_query_vars( $args ) {
116
-		$defaults = array(
117
-			'status'            => 'all',
118
-			'customer_in'       => array(),
119
-			'customer_not_in'   => array(),
120
-			'product_in'        => array(),
121
-			'product_not_in'    => array(),
122
-			'include'           => array(),
123
-			'exclude'           => array(),
124
-			'orderby'           => 'id',
125
-			'order'             => 'DESC',
126
-			'offset'            => '',
127
-			'number'            => 10,
128
-			'paged'             => 1,
129
-			'count_total'       => true,
130
-			'fields'            => 'all',
131
-		);
132
-
133
-		return wp_parse_args( $args, $defaults );
134
-	}
135
-
136
-	/**
137
-	 * Prepare the query variables.
138
-	 *
139
-	 * @since 1.0.19
140
-	 *
141
-	 * @global wpdb $wpdb WordPress database abstraction object.
142
-	 *
143
-	 * @param string|array $query {
144
-	 *     Optional. Array or string of Query parameters.
145
-	 *
146
-	 *     @type string|array $status              The subscription status to filter by. Can either be a single status or an array of statuses.
147
-	 *                                             Default is all.
148
-	 *     @type int[]        $customer_in         An array of customer ids to filter by.
149
-	 *     @type int[]        $customer_not_in     An array of customer ids whose subscriptions should be excluded.
150
-	 *     @type int[]        $product_in          An array of product ids to filter by.
151
-	 *     @type int[]        $product_not_in      An array of product ids whose subscriptions should be excluded.
152
-	 *     @type array        $date_created_query  A WP_Date_Query compatible array use to filter subscriptions by their date of creation.
153
-	 *     @type array        $date_expires_query  A WP_Date_Query compatible array use to filter subscriptions by their expiration date.
154
-	 *     @type array        $include             An array of subscription IDs to include. Default empty array.
155
-	 *     @type array        $exclude             An array of subscription IDs to exclude. Default empty array.
156
-	 *     @type string|array $orderby             Field(s) to sort the retrieved subscription by. May be a single value,
157
-	 *                                             an array of values, or a multi-dimensional array with fields as
158
-	 *                                             keys and orders ('ASC' or 'DESC') as values. Accepted values are
159
-	 *                                             'id', 'customer_id', 'frequency', 'period', 'initial_amount,
160
-	 *                                             'recurring_amount', 'bill_times', 'parent_payment_id', 'created', 'expiration'
161
-	 *                                             'transaction_id', 'product_id', 'trial_period', 'include', 'status', 'profile_id'. Default array( 'id' ).
162
-	 *     @type string       $order               Designates ascending or descending order of subscriptions. Order values
163
-	 *                                             passed as part of an `$orderby` array take precedence over this
164
-	 *                                             parameter. Accepts 'ASC', 'DESC'. Default 'DESC'.
165
-	 *     @type int          $offset              Number of subscriptions to offset in retrieved results. Can be used in
166
-	 *                                             conjunction with pagination. Default 0.
167
-	 *     @type int          $number              Number of subscriptions to limit the query for. Can be used in
168
-	 *                                             conjunction with pagination. Value -1 (all) is supported, but
169
-	 *                                             should be used with caution on larger sites.
170
-	 *                                             Default 10.
171
-	 *     @type int          $paged               When used with number, defines the page of results to return.
172
-	 *                                             Default 1.
173
-	 *     @type bool         $count_total         Whether to count the total number of subscriptions found. If pagination
174
-	 *                                             is not needed, setting this to false can improve performance.
175
-	 *                                             Default true.
176
-	 *     @type string|array $fields              Which fields to return. Single or all fields (string), or array
177
-	 *                                             of fields. Accepts 'id', 'customer_id', 'frequency', 'period', 'initial_amount,
178
-	 *                                             'recurring_amount', 'bill_times', 'parent_payment_id', 'created', 'expiration'
179
-	 *                                             'transaction_id', 'product_id', 'trial_period', 'status', 'profile_id'.
180
-	 *                                             Use 'all' for all fields. Default 'all'.
181
-	 * }
182
-	 */
183
-	public function prepare_query( $query = array() ) {
184
-		global $wpdb;
185
-
186
-		if ( empty( $this->query_vars ) || ! empty( $query ) ) {
187
-			$this->query_limit = null;
188
-			$this->query_vars  = $this->fill_query_vars( $query );
189
-		}
190
-
191
-		if ( ! empty( $this->query_vars['fields'] ) && 'all' !== $this->query_vars['fields'] ) {
192
-			$this->query_vars['fields'] = wpinv_parse_list( $this->query_vars['fields'] );
193
-		}
194
-
195
-		do_action( 'getpaid_pre_get_subscriptions', array( &$this ) );
196
-
197
-		// Ensure that query vars are filled after 'getpaid_pre_get_subscriptions'.
198
-		$qv                =& $this->query_vars;
199
-		$qv                = $this->fill_query_vars( $qv );
200
-		$table             = $wpdb->prefix . 'wpinv_subscriptions';
201
-		$this->query_from  = "FROM $table";
202
-
203
-		// Prepare query fields.
204
-		$this->prepare_query_fields( $qv, $table );
205
-
206
-		// Prepare query where.
207
-		$this->prepare_query_where( $qv, $table );
208
-
209
-		// Prepare query order.
210
-		$this->prepare_query_order( $qv, $table );
211
-
212
-		// limit
213
-		if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
214
-			if ( $qv['offset'] ) {
215
-				$this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] );
216
-			} else {
217
-				$this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
218
-			}
219
-		}
220
-
221
-		do_action_ref_array( 'getpaid_after_subscriptions_query', array( &$this ) );
222
-	}
223
-
224
-	/**
225
-	 * Prepares the query fields.
226
-	 *
227
-	 * @since 1.0.19
228
-	 *
229
-	 * @param array $qv Query vars.
230
-	 * @param string $table Table name.
231
-	 */
232
-	protected function prepare_query_fields( &$qv, $table ) {
233
-
234
-		if ( is_array( $qv['fields'] ) ) {
235
-			$qv['fields'] = array_unique( $qv['fields'] );
236
-
237
-			$query_fields = array();
238
-			foreach ( $qv['fields'] as $field ) {
239
-				$field          = sanitize_key( $field );
240
-				$query_fields[] = "$table.`$field`";
241
-			}
242
-			$this->query_fields = implode( ',', $query_fields );
243
-		} else {
244
-			$this->query_fields = "$table.*";
245
-		}
246
-
247
-		if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
248
-			$this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
249
-		}
250
-
251
-	}
252
-
253
-	/**
254
-	 * Prepares the query where.
255
-	 *
256
-	 * @since 1.0.19
257
-	 *
258
-	 * @param array $qv Query vars.
259
-	 * @param string $table Table name.
260
-	 */
261
-	protected function prepare_query_where( &$qv, $table ) {
262
-		global $wpdb;
263
-		$this->query_where = 'WHERE 1=1';
264
-
265
-		// Status.
266
-		if ( 'all' !== $qv['status'] ) {
267
-			$statuses           = wpinv_clean( wpinv_parse_list( $qv['status'] ) );
268
-			$prepared_statuses  = join( ',', array_fill( 0, count( $statuses ), '%s' ) );
269
-			$this->query_where .= $wpdb->prepare( " AND $table.`status` IN ( $prepared_statuses )", $statuses );
270
-		}
271
-
272
-		if ( ! empty( $qv['customer_in'] ) ) {
273
-			$customer_in        = implode( ',', wp_parse_id_list( $qv['customer_in'] ) );
274
-			$this->query_where .= " AND $table.`customer_id` IN ($customer_in)";
275
-		} elseif ( ! empty( $qv['customer_not_in'] ) ) {
276
-			$customer_not_in    = implode( ',', wp_parse_id_list( $qv['customer_not_in'] ) );
277
-			$this->query_where .= " AND $table.`customer_id` NOT IN ($customer_not_in)";
278
-		}
279
-
280
-		if ( ! empty( $qv['product_in'] ) ) {
281
-			$product_in         = implode( ',', wp_parse_id_list( $qv['product_in'] ) );
282
-			$this->query_where .= " AND $table.`product_id` IN ($product_in)";
283
-		} elseif ( ! empty( $qv['product_not_in'] ) ) {
284
-			$product_not_in     = implode( ',', wp_parse_id_list( $qv['product_not_in'] ) );
285
-			$this->query_where .= " AND $table.`product_id` NOT IN ($product_not_in)";
286
-		}
287
-
288
-		if ( ! empty( $qv['include'] ) ) {
289
-			$include            = implode( ',', wp_parse_id_list( $qv['include'] ) );
290
-			$this->query_where .= " AND $table.`id` IN ($include)";
291
-		} elseif ( ! empty( $qv['exclude'] ) ) {
292
-			$exclude            = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
293
-			$this->query_where .= " AND $table.`id` NOT IN ($exclude)";
294
-		}
295
-
296
-		// Date queries are allowed for the subscription creation date.
297
-		if ( ! empty( $qv['date_created_query'] ) && is_array( $qv['date_created_query'] ) ) {
298
-			$date_created_query = new WP_Date_Query( $qv['date_created_query'], "$table.created" );
299
-			$this->query_where .= $date_created_query->get_sql();
300
-		}
301
-
302
-		// Date queries are also allowed for the subscription expiration date.
303
-		if ( ! empty( $qv['date_expires_query'] ) && is_array( $qv['date_expires_query'] ) ) {
304
-			$date_expires_query = new WP_Date_Query( $qv['date_expires_query'], "$table.expiration" );
305
-			$this->query_where .= $date_expires_query->get_sql();
306
-		}
307
-
308
-	}
309
-
310
-	/**
311
-	 * Prepares the query order.
312
-	 *
313
-	 * @since 1.0.19
314
-	 *
315
-	 * @param array $qv Query vars.
316
-	 * @param string $table Table name.
317
-	 */
318
-	protected function prepare_query_order( &$qv, $table ) {
319
-
320
-		// sorting.
321
-		$qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : '';
322
-		$order       = $this->parse_order( $qv['order'] );
323
-
324
-		// Default order is by 'id' (latest subscriptions).
325
-		if ( empty( $qv['orderby'] ) ) {
326
-			$qv['orderby'] = array( 'id' );
327
-		}
328
-
329
-		// 'orderby' values may be an array, comma- or space-separated list.
330
-		$ordersby      = array_filter( wpinv_parse_list(  $qv['orderby'] ) );
331
-
332
-		$orderby_array = array();
333
-		foreach ( $ordersby as $_key => $_value ) {
334
-
335
-			if ( is_int( $_key ) ) {
336
-				// Integer key means this is a flat array of 'orderby' fields.
337
-				$_orderby = $_value;
338
-				$_order   = $order;
339
-			} else {
340
-				// Non-integer key means that the key is the field and the value is ASC/DESC.
341
-				$_orderby = $_key;
342
-				$_order   = $_value;
343
-			}
344
-
345
-			$parsed = $this->parse_orderby( $_orderby, $table );
346
-
347
-			if ( $parsed ) {
348
-				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
349
-			}
350
-
351
-		}
352
-
353
-		// If no valid clauses were found, order by id.
354
-		if ( empty( $orderby_array ) ) {
355
-			$orderby_array[] = "id $order";
356
-		}
357
-
358
-		$this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array );
359
-
360
-	}
361
-
362
-	/**
363
-	 * Execute the query, with the current variables.
364
-	 *
365
-	 * @since 1.0.19
366
-	 *
367
-	 * @global wpdb $wpdb WordPress database abstraction object.
368
-	 */
369
-	public function query() {
370
-		global $wpdb;
371
-
372
-		$qv =& $this->query_vars;
373
-
374
-		// Return a non-null value to bypass the default GetPaid subscriptions query and remember to set the
375
-		// total_subscriptions property.
376
-		$this->results = apply_filters_ref_array( 'getpaid_subscriptions_pre_query', array( null, &$this ) );
377
-
378
-		if ( null === $this->results ) {
379
-			$this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
380
-
381
-			if ( ( is_array( $qv['fields'] ) && 1 != count( $qv['fields'] ) ) || 'all' == $qv['fields'] ) {
382
-				$this->results = $wpdb->get_results( $this->request );
383
-			} else {
384
-				$this->results = $wpdb->get_col( $this->request );
385
-			}
386
-
387
-			if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
388
-				$found_subscriptions_query = apply_filters( 'getpaid_found_subscriptions_query', 'SELECT FOUND_ROWS()', $this );
389
-				$this->total_subscriptions   = (int) $wpdb->get_var( $found_subscriptions_query );
390
-			}
391
-		}
392
-
393
-		if ( 'all' == $qv['fields'] ) {
394
-			foreach ( $this->results as $key => $subscription ) {
395
-				$this->results[ $key ] = new WPInv_Subscription( $subscription );
396
-			}
397
-		}
398
-
399
-	}
400
-
401
-	/**
402
-	 * Retrieve query variable.
403
-	 *
404
-	 * @since 1.0.19
405
-	 *
406
-	 * @param string $query_var Query variable key.
407
-	 * @return mixed
408
-	 */
409
-	public function get( $query_var ) {
410
-		if ( isset( $this->query_vars[ $query_var ] ) ) {
411
-			return $this->query_vars[ $query_var ];
412
-		}
413
-
414
-		return null;
415
-	}
416
-
417
-	/**
418
-	 * Set query variable.
419
-	 *
420
-	 * @since 1.0.19
421
-	 *
422
-	 * @param string $query_var Query variable key.
423
-	 * @param mixed $value Query variable value.
424
-	 */
425
-	public function set( $query_var, $value ) {
426
-		$this->query_vars[ $query_var ] = $value;
427
-	}
428
-
429
-	/**
430
-	 * Return the list of subscriptions.
431
-	 *
432
-	 * @since 1.0.19
433
-	 *
434
-	 * @return WPInv_Subscription[]|array Found subscriptions.
435
-	 */
436
-	public function get_results() {
437
-		return $this->results;
438
-	}
439
-
440
-	/**
441
-	 * Return the total number of subscriptions for the current query.
442
-	 *
443
-	 * @since 1.0.19
444
-	 *
445
-	 * @return int Number of total subscriptions.
446
-	 */
447
-	public function get_total() {
448
-		return $this->total_subscriptions;
449
-	}
450
-
451
-	/**
452
-	 * Parse and sanitize 'orderby' keys passed to the subscriptions query.
453
-	 *
454
-	 * @since 1.0.19
455
-	 *
456
-	 * @param string $orderby Alias for the field to order by.
457
-	 *  @param string $table The current table.
458
-	 * @return string Value to use in the ORDER clause, if `$orderby` is valid.
459
-	 */
460
-	protected function parse_orderby( $orderby, $table ) {
461
-
462
-		$_orderby = '';
463
-		if ( in_array( $orderby, array( 'customer_id', 'frequency', 'period', 'initial_amount', 'recurring_amount', 'bill_times', 'transaction_id', 'parent_payment_id', 'product_id', 'created', 'expiration', 'trial_period', 'status', 'profile_id' ) ) ) {
464
-			$_orderby = "$table.`$orderby`";
465
-		} elseif ( 'id' === strtolower( $orderby ) ) {
466
-			$_orderby = "$table.id";
467
-		} elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) {
468
-			$include     = wp_parse_id_list( $this->query_vars['include'] );
469
-			$include_sql = implode( ',', $include );
470
-			$_orderby    = "FIELD( $table.id, $include_sql )";
471
-		}
472
-
473
-		return $_orderby;
474
-	}
475
-
476
-	/**
477
-	 * Parse an 'order' query variable and cast it to ASC or DESC as necessary.
478
-	 *
479
-	 * @since 1.0.19
480
-	 *
481
-	 * @param string $order The 'order' query variable.
482
-	 * @return string The sanitized 'order' query variable.
483
-	 */
484
-	protected function parse_order( $order ) {
485
-		if ( ! is_string( $order ) || empty( $order ) ) {
486
-			return 'DESC';
487
-		}
488
-
489
-		if ( 'ASC' === strtoupper( $order ) ) {
490
-			return 'ASC';
491
-		} else {
492
-			return 'DESC';
493
-		}
494
-	}
19
+    /**
20
+     * Query vars, after parsing
21
+     *
22
+     * @since 1.0.19
23
+     * @var array
24
+     */
25
+    public $query_vars = array();
26
+
27
+    /**
28
+     * List of found subscriptions.
29
+     *
30
+     * @since 1.0.19
31
+     * @var array
32
+     */
33
+    private $results;
34
+
35
+    /**
36
+     * Total number of found subscriptions for the current query
37
+     *
38
+     * @since 1.0.19
39
+     * @var int
40
+     */
41
+    private $total_subscriptions = 0;
42
+
43
+    /**
44
+     * The SQL query used to fetch matching subscriptions.
45
+     *
46
+     * @since 1.0.19
47
+     * @var string
48
+     */
49
+    public $request;
50
+
51
+    // SQL clauses
52
+
53
+    /**
54
+     * Contains the 'FIELDS' sql clause
55
+     *
56
+     * @since 1.0.19
57
+     * @var string
58
+     */
59
+    public $query_fields;
60
+
61
+    /**
62
+     * Contains the 'FROM' sql clause
63
+     *
64
+     * @since 1.0.19
65
+     * @var string
66
+     */
67
+    public $query_from;
68
+
69
+    /**
70
+     * Contains the 'WHERE' sql clause
71
+     *
72
+     * @since 1.0.19
73
+     * @var string
74
+     */
75
+    public $query_where;
76
+
77
+    /**
78
+     * Contains the 'ORDER BY' sql clause
79
+     *
80
+     * @since 1.0.19
81
+     * @var string
82
+     */
83
+    public $query_orderby;
84
+
85
+    /**
86
+     * Contains the 'LIMIT' sql clause
87
+     *
88
+     * @since 1.0.19
89
+     * @var string
90
+     */
91
+    public $query_limit;
92
+
93
+    /**
94
+     * Class constructor.
95
+     *
96
+     * @since 1.0.19
97
+     *
98
+     * @param null|string|array $query Optional. The query variables.
99
+     */
100
+    public function __construct( $query = null ) {
101
+        if ( ! is_null( $query ) ) {
102
+            $this->prepare_query( $query );
103
+            $this->query();
104
+        }
105
+    }
106
+
107
+    /**
108
+     * Fills in missing query variables with default values.
109
+     *
110
+     * @since 1.0.19
111
+     *
112
+     * @param  string|array $args Query vars, as passed to `GetPaid_Subscriptions_Query`.
113
+     * @return array Complete query variables with undefined ones filled in with defaults.
114
+     */
115
+    public static function fill_query_vars( $args ) {
116
+        $defaults = array(
117
+            'status'            => 'all',
118
+            'customer_in'       => array(),
119
+            'customer_not_in'   => array(),
120
+            'product_in'        => array(),
121
+            'product_not_in'    => array(),
122
+            'include'           => array(),
123
+            'exclude'           => array(),
124
+            'orderby'           => 'id',
125
+            'order'             => 'DESC',
126
+            'offset'            => '',
127
+            'number'            => 10,
128
+            'paged'             => 1,
129
+            'count_total'       => true,
130
+            'fields'            => 'all',
131
+        );
132
+
133
+        return wp_parse_args( $args, $defaults );
134
+    }
135
+
136
+    /**
137
+     * Prepare the query variables.
138
+     *
139
+     * @since 1.0.19
140
+     *
141
+     * @global wpdb $wpdb WordPress database abstraction object.
142
+     *
143
+     * @param string|array $query {
144
+     *     Optional. Array or string of Query parameters.
145
+     *
146
+     *     @type string|array $status              The subscription status to filter by. Can either be a single status or an array of statuses.
147
+     *                                             Default is all.
148
+     *     @type int[]        $customer_in         An array of customer ids to filter by.
149
+     *     @type int[]        $customer_not_in     An array of customer ids whose subscriptions should be excluded.
150
+     *     @type int[]        $product_in          An array of product ids to filter by.
151
+     *     @type int[]        $product_not_in      An array of product ids whose subscriptions should be excluded.
152
+     *     @type array        $date_created_query  A WP_Date_Query compatible array use to filter subscriptions by their date of creation.
153
+     *     @type array        $date_expires_query  A WP_Date_Query compatible array use to filter subscriptions by their expiration date.
154
+     *     @type array        $include             An array of subscription IDs to include. Default empty array.
155
+     *     @type array        $exclude             An array of subscription IDs to exclude. Default empty array.
156
+     *     @type string|array $orderby             Field(s) to sort the retrieved subscription by. May be a single value,
157
+     *                                             an array of values, or a multi-dimensional array with fields as
158
+     *                                             keys and orders ('ASC' or 'DESC') as values. Accepted values are
159
+     *                                             'id', 'customer_id', 'frequency', 'period', 'initial_amount,
160
+     *                                             'recurring_amount', 'bill_times', 'parent_payment_id', 'created', 'expiration'
161
+     *                                             'transaction_id', 'product_id', 'trial_period', 'include', 'status', 'profile_id'. Default array( 'id' ).
162
+     *     @type string       $order               Designates ascending or descending order of subscriptions. Order values
163
+     *                                             passed as part of an `$orderby` array take precedence over this
164
+     *                                             parameter. Accepts 'ASC', 'DESC'. Default 'DESC'.
165
+     *     @type int          $offset              Number of subscriptions to offset in retrieved results. Can be used in
166
+     *                                             conjunction with pagination. Default 0.
167
+     *     @type int          $number              Number of subscriptions to limit the query for. Can be used in
168
+     *                                             conjunction with pagination. Value -1 (all) is supported, but
169
+     *                                             should be used with caution on larger sites.
170
+     *                                             Default 10.
171
+     *     @type int          $paged               When used with number, defines the page of results to return.
172
+     *                                             Default 1.
173
+     *     @type bool         $count_total         Whether to count the total number of subscriptions found. If pagination
174
+     *                                             is not needed, setting this to false can improve performance.
175
+     *                                             Default true.
176
+     *     @type string|array $fields              Which fields to return. Single or all fields (string), or array
177
+     *                                             of fields. Accepts 'id', 'customer_id', 'frequency', 'period', 'initial_amount,
178
+     *                                             'recurring_amount', 'bill_times', 'parent_payment_id', 'created', 'expiration'
179
+     *                                             'transaction_id', 'product_id', 'trial_period', 'status', 'profile_id'.
180
+     *                                             Use 'all' for all fields. Default 'all'.
181
+     * }
182
+     */
183
+    public function prepare_query( $query = array() ) {
184
+        global $wpdb;
185
+
186
+        if ( empty( $this->query_vars ) || ! empty( $query ) ) {
187
+            $this->query_limit = null;
188
+            $this->query_vars  = $this->fill_query_vars( $query );
189
+        }
190
+
191
+        if ( ! empty( $this->query_vars['fields'] ) && 'all' !== $this->query_vars['fields'] ) {
192
+            $this->query_vars['fields'] = wpinv_parse_list( $this->query_vars['fields'] );
193
+        }
194
+
195
+        do_action( 'getpaid_pre_get_subscriptions', array( &$this ) );
196
+
197
+        // Ensure that query vars are filled after 'getpaid_pre_get_subscriptions'.
198
+        $qv                =& $this->query_vars;
199
+        $qv                = $this->fill_query_vars( $qv );
200
+        $table             = $wpdb->prefix . 'wpinv_subscriptions';
201
+        $this->query_from  = "FROM $table";
202
+
203
+        // Prepare query fields.
204
+        $this->prepare_query_fields( $qv, $table );
205
+
206
+        // Prepare query where.
207
+        $this->prepare_query_where( $qv, $table );
208
+
209
+        // Prepare query order.
210
+        $this->prepare_query_order( $qv, $table );
211
+
212
+        // limit
213
+        if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
214
+            if ( $qv['offset'] ) {
215
+                $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] );
216
+            } else {
217
+                $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
218
+            }
219
+        }
220
+
221
+        do_action_ref_array( 'getpaid_after_subscriptions_query', array( &$this ) );
222
+    }
223
+
224
+    /**
225
+     * Prepares the query fields.
226
+     *
227
+     * @since 1.0.19
228
+     *
229
+     * @param array $qv Query vars.
230
+     * @param string $table Table name.
231
+     */
232
+    protected function prepare_query_fields( &$qv, $table ) {
233
+
234
+        if ( is_array( $qv['fields'] ) ) {
235
+            $qv['fields'] = array_unique( $qv['fields'] );
236
+
237
+            $query_fields = array();
238
+            foreach ( $qv['fields'] as $field ) {
239
+                $field          = sanitize_key( $field );
240
+                $query_fields[] = "$table.`$field`";
241
+            }
242
+            $this->query_fields = implode( ',', $query_fields );
243
+        } else {
244
+            $this->query_fields = "$table.*";
245
+        }
246
+
247
+        if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
248
+            $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
249
+        }
250
+
251
+    }
252
+
253
+    /**
254
+     * Prepares the query where.
255
+     *
256
+     * @since 1.0.19
257
+     *
258
+     * @param array $qv Query vars.
259
+     * @param string $table Table name.
260
+     */
261
+    protected function prepare_query_where( &$qv, $table ) {
262
+        global $wpdb;
263
+        $this->query_where = 'WHERE 1=1';
264
+
265
+        // Status.
266
+        if ( 'all' !== $qv['status'] ) {
267
+            $statuses           = wpinv_clean( wpinv_parse_list( $qv['status'] ) );
268
+            $prepared_statuses  = join( ',', array_fill( 0, count( $statuses ), '%s' ) );
269
+            $this->query_where .= $wpdb->prepare( " AND $table.`status` IN ( $prepared_statuses )", $statuses );
270
+        }
271
+
272
+        if ( ! empty( $qv['customer_in'] ) ) {
273
+            $customer_in        = implode( ',', wp_parse_id_list( $qv['customer_in'] ) );
274
+            $this->query_where .= " AND $table.`customer_id` IN ($customer_in)";
275
+        } elseif ( ! empty( $qv['customer_not_in'] ) ) {
276
+            $customer_not_in    = implode( ',', wp_parse_id_list( $qv['customer_not_in'] ) );
277
+            $this->query_where .= " AND $table.`customer_id` NOT IN ($customer_not_in)";
278
+        }
279
+
280
+        if ( ! empty( $qv['product_in'] ) ) {
281
+            $product_in         = implode( ',', wp_parse_id_list( $qv['product_in'] ) );
282
+            $this->query_where .= " AND $table.`product_id` IN ($product_in)";
283
+        } elseif ( ! empty( $qv['product_not_in'] ) ) {
284
+            $product_not_in     = implode( ',', wp_parse_id_list( $qv['product_not_in'] ) );
285
+            $this->query_where .= " AND $table.`product_id` NOT IN ($product_not_in)";
286
+        }
287
+
288
+        if ( ! empty( $qv['include'] ) ) {
289
+            $include            = implode( ',', wp_parse_id_list( $qv['include'] ) );
290
+            $this->query_where .= " AND $table.`id` IN ($include)";
291
+        } elseif ( ! empty( $qv['exclude'] ) ) {
292
+            $exclude            = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
293
+            $this->query_where .= " AND $table.`id` NOT IN ($exclude)";
294
+        }
295
+
296
+        // Date queries are allowed for the subscription creation date.
297
+        if ( ! empty( $qv['date_created_query'] ) && is_array( $qv['date_created_query'] ) ) {
298
+            $date_created_query = new WP_Date_Query( $qv['date_created_query'], "$table.created" );
299
+            $this->query_where .= $date_created_query->get_sql();
300
+        }
301
+
302
+        // Date queries are also allowed for the subscription expiration date.
303
+        if ( ! empty( $qv['date_expires_query'] ) && is_array( $qv['date_expires_query'] ) ) {
304
+            $date_expires_query = new WP_Date_Query( $qv['date_expires_query'], "$table.expiration" );
305
+            $this->query_where .= $date_expires_query->get_sql();
306
+        }
307
+
308
+    }
309
+
310
+    /**
311
+     * Prepares the query order.
312
+     *
313
+     * @since 1.0.19
314
+     *
315
+     * @param array $qv Query vars.
316
+     * @param string $table Table name.
317
+     */
318
+    protected function prepare_query_order( &$qv, $table ) {
319
+
320
+        // sorting.
321
+        $qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : '';
322
+        $order       = $this->parse_order( $qv['order'] );
323
+
324
+        // Default order is by 'id' (latest subscriptions).
325
+        if ( empty( $qv['orderby'] ) ) {
326
+            $qv['orderby'] = array( 'id' );
327
+        }
328
+
329
+        // 'orderby' values may be an array, comma- or space-separated list.
330
+        $ordersby      = array_filter( wpinv_parse_list(  $qv['orderby'] ) );
331
+
332
+        $orderby_array = array();
333
+        foreach ( $ordersby as $_key => $_value ) {
334
+
335
+            if ( is_int( $_key ) ) {
336
+                // Integer key means this is a flat array of 'orderby' fields.
337
+                $_orderby = $_value;
338
+                $_order   = $order;
339
+            } else {
340
+                // Non-integer key means that the key is the field and the value is ASC/DESC.
341
+                $_orderby = $_key;
342
+                $_order   = $_value;
343
+            }
344
+
345
+            $parsed = $this->parse_orderby( $_orderby, $table );
346
+
347
+            if ( $parsed ) {
348
+                $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
349
+            }
350
+
351
+        }
352
+
353
+        // If no valid clauses were found, order by id.
354
+        if ( empty( $orderby_array ) ) {
355
+            $orderby_array[] = "id $order";
356
+        }
357
+
358
+        $this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array );
359
+
360
+    }
361
+
362
+    /**
363
+     * Execute the query, with the current variables.
364
+     *
365
+     * @since 1.0.19
366
+     *
367
+     * @global wpdb $wpdb WordPress database abstraction object.
368
+     */
369
+    public function query() {
370
+        global $wpdb;
371
+
372
+        $qv =& $this->query_vars;
373
+
374
+        // Return a non-null value to bypass the default GetPaid subscriptions query and remember to set the
375
+        // total_subscriptions property.
376
+        $this->results = apply_filters_ref_array( 'getpaid_subscriptions_pre_query', array( null, &$this ) );
377
+
378
+        if ( null === $this->results ) {
379
+            $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
380
+
381
+            if ( ( is_array( $qv['fields'] ) && 1 != count( $qv['fields'] ) ) || 'all' == $qv['fields'] ) {
382
+                $this->results = $wpdb->get_results( $this->request );
383
+            } else {
384
+                $this->results = $wpdb->get_col( $this->request );
385
+            }
386
+
387
+            if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
388
+                $found_subscriptions_query = apply_filters( 'getpaid_found_subscriptions_query', 'SELECT FOUND_ROWS()', $this );
389
+                $this->total_subscriptions   = (int) $wpdb->get_var( $found_subscriptions_query );
390
+            }
391
+        }
392
+
393
+        if ( 'all' == $qv['fields'] ) {
394
+            foreach ( $this->results as $key => $subscription ) {
395
+                $this->results[ $key ] = new WPInv_Subscription( $subscription );
396
+            }
397
+        }
398
+
399
+    }
400
+
401
+    /**
402
+     * Retrieve query variable.
403
+     *
404
+     * @since 1.0.19
405
+     *
406
+     * @param string $query_var Query variable key.
407
+     * @return mixed
408
+     */
409
+    public function get( $query_var ) {
410
+        if ( isset( $this->query_vars[ $query_var ] ) ) {
411
+            return $this->query_vars[ $query_var ];
412
+        }
413
+
414
+        return null;
415
+    }
416
+
417
+    /**
418
+     * Set query variable.
419
+     *
420
+     * @since 1.0.19
421
+     *
422
+     * @param string $query_var Query variable key.
423
+     * @param mixed $value Query variable value.
424
+     */
425
+    public function set( $query_var, $value ) {
426
+        $this->query_vars[ $query_var ] = $value;
427
+    }
428
+
429
+    /**
430
+     * Return the list of subscriptions.
431
+     *
432
+     * @since 1.0.19
433
+     *
434
+     * @return WPInv_Subscription[]|array Found subscriptions.
435
+     */
436
+    public function get_results() {
437
+        return $this->results;
438
+    }
439
+
440
+    /**
441
+     * Return the total number of subscriptions for the current query.
442
+     *
443
+     * @since 1.0.19
444
+     *
445
+     * @return int Number of total subscriptions.
446
+     */
447
+    public function get_total() {
448
+        return $this->total_subscriptions;
449
+    }
450
+
451
+    /**
452
+     * Parse and sanitize 'orderby' keys passed to the subscriptions query.
453
+     *
454
+     * @since 1.0.19
455
+     *
456
+     * @param string $orderby Alias for the field to order by.
457
+     *  @param string $table The current table.
458
+     * @return string Value to use in the ORDER clause, if `$orderby` is valid.
459
+     */
460
+    protected function parse_orderby( $orderby, $table ) {
461
+
462
+        $_orderby = '';
463
+        if ( in_array( $orderby, array( 'customer_id', 'frequency', 'period', 'initial_amount', 'recurring_amount', 'bill_times', 'transaction_id', 'parent_payment_id', 'product_id', 'created', 'expiration', 'trial_period', 'status', 'profile_id' ) ) ) {
464
+            $_orderby = "$table.`$orderby`";
465
+        } elseif ( 'id' === strtolower( $orderby ) ) {
466
+            $_orderby = "$table.id";
467
+        } elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) {
468
+            $include     = wp_parse_id_list( $this->query_vars['include'] );
469
+            $include_sql = implode( ',', $include );
470
+            $_orderby    = "FIELD( $table.id, $include_sql )";
471
+        }
472
+
473
+        return $_orderby;
474
+    }
475
+
476
+    /**
477
+     * Parse an 'order' query variable and cast it to ASC or DESC as necessary.
478
+     *
479
+     * @since 1.0.19
480
+     *
481
+     * @param string $order The 'order' query variable.
482
+     * @return string The sanitized 'order' query variable.
483
+     */
484
+    protected function parse_order( $order ) {
485
+        if ( ! is_string( $order ) || empty( $order ) ) {
486
+            return 'DESC';
487
+        }
488
+
489
+        if ( 'ASC' === strtoupper( $order ) ) {
490
+            return 'ASC';
491
+        } else {
492
+            return 'DESC';
493
+        }
494
+    }
495 495
 
496 496
 }
Please login to merge, or discard this patch.
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param null|string|array $query Optional. The query variables.
99 99
 	 */
100
-	public function __construct( $query = null ) {
101
-		if ( ! is_null( $query ) ) {
102
-			$this->prepare_query( $query );
100
+	public function __construct($query = null) {
101
+		if (!is_null($query)) {
102
+			$this->prepare_query($query);
103 103
 			$this->query();
104 104
 		}
105 105
 	}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @param  string|array $args Query vars, as passed to `GetPaid_Subscriptions_Query`.
113 113
 	 * @return array Complete query variables with undefined ones filled in with defaults.
114 114
 	 */
115
-	public static function fill_query_vars( $args ) {
115
+	public static function fill_query_vars($args) {
116 116
 		$defaults = array(
117 117
 			'status'            => 'all',
118 118
 			'customer_in'       => array(),
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			'fields'            => 'all',
131 131
 		);
132 132
 
133
-		return wp_parse_args( $args, $defaults );
133
+		return wp_parse_args($args, $defaults);
134 134
 	}
135 135
 
136 136
 	/**
@@ -180,45 +180,45 @@  discard block
 block discarded – undo
180 180
 	 *                                             Use 'all' for all fields. Default 'all'.
181 181
 	 * }
182 182
 	 */
183
-	public function prepare_query( $query = array() ) {
183
+	public function prepare_query($query = array()) {
184 184
 		global $wpdb;
185 185
 
186
-		if ( empty( $this->query_vars ) || ! empty( $query ) ) {
186
+		if (empty($this->query_vars) || !empty($query)) {
187 187
 			$this->query_limit = null;
188
-			$this->query_vars  = $this->fill_query_vars( $query );
188
+			$this->query_vars  = $this->fill_query_vars($query);
189 189
 		}
190 190
 
191
-		if ( ! empty( $this->query_vars['fields'] ) && 'all' !== $this->query_vars['fields'] ) {
192
-			$this->query_vars['fields'] = wpinv_parse_list( $this->query_vars['fields'] );
191
+		if (!empty($this->query_vars['fields']) && 'all' !== $this->query_vars['fields']) {
192
+			$this->query_vars['fields'] = wpinv_parse_list($this->query_vars['fields']);
193 193
 		}
194 194
 
195
-		do_action( 'getpaid_pre_get_subscriptions', array( &$this ) );
195
+		do_action('getpaid_pre_get_subscriptions', array(&$this));
196 196
 
197 197
 		// Ensure that query vars are filled after 'getpaid_pre_get_subscriptions'.
198
-		$qv                =& $this->query_vars;
199
-		$qv                = $this->fill_query_vars( $qv );
198
+		$qv                = & $this->query_vars;
199
+		$qv                = $this->fill_query_vars($qv);
200 200
 		$table             = $wpdb->prefix . 'wpinv_subscriptions';
201 201
 		$this->query_from  = "FROM $table";
202 202
 
203 203
 		// Prepare query fields.
204
-		$this->prepare_query_fields( $qv, $table );
204
+		$this->prepare_query_fields($qv, $table);
205 205
 
206 206
 		// Prepare query where.
207
-		$this->prepare_query_where( $qv, $table );
207
+		$this->prepare_query_where($qv, $table);
208 208
 
209 209
 		// Prepare query order.
210
-		$this->prepare_query_order( $qv, $table );
210
+		$this->prepare_query_order($qv, $table);
211 211
 
212 212
 		// limit
213
-		if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
214
-			if ( $qv['offset'] ) {
215
-				$this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] );
213
+		if (isset($qv['number']) && $qv['number'] > 0) {
214
+			if ($qv['offset']) {
215
+				$this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['offset'], $qv['number']);
216 216
 			} else {
217
-				$this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
217
+				$this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['number'] * ($qv['paged'] - 1), $qv['number']);
218 218
 			}
219 219
 		}
220 220
 
221
-		do_action_ref_array( 'getpaid_after_subscriptions_query', array( &$this ) );
221
+		do_action_ref_array('getpaid_after_subscriptions_query', array(&$this));
222 222
 	}
223 223
 
224 224
 	/**
@@ -229,22 +229,22 @@  discard block
 block discarded – undo
229 229
 	 * @param array $qv Query vars.
230 230
 	 * @param string $table Table name.
231 231
 	 */
232
-	protected function prepare_query_fields( &$qv, $table ) {
232
+	protected function prepare_query_fields(&$qv, $table) {
233 233
 
234
-		if ( is_array( $qv['fields'] ) ) {
235
-			$qv['fields'] = array_unique( $qv['fields'] );
234
+		if (is_array($qv['fields'])) {
235
+			$qv['fields'] = array_unique($qv['fields']);
236 236
 
237 237
 			$query_fields = array();
238
-			foreach ( $qv['fields'] as $field ) {
239
-				$field          = sanitize_key( $field );
238
+			foreach ($qv['fields'] as $field) {
239
+				$field          = sanitize_key($field);
240 240
 				$query_fields[] = "$table.`$field`";
241 241
 			}
242
-			$this->query_fields = implode( ',', $query_fields );
242
+			$this->query_fields = implode(',', $query_fields);
243 243
 		} else {
244 244
 			$this->query_fields = "$table.*";
245 245
 		}
246 246
 
247
-		if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
247
+		if (isset($qv['count_total']) && $qv['count_total']) {
248 248
 			$this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
249 249
 		}
250 250
 
@@ -258,50 +258,50 @@  discard block
 block discarded – undo
258 258
 	 * @param array $qv Query vars.
259 259
 	 * @param string $table Table name.
260 260
 	 */
261
-	protected function prepare_query_where( &$qv, $table ) {
261
+	protected function prepare_query_where(&$qv, $table) {
262 262
 		global $wpdb;
263 263
 		$this->query_where = 'WHERE 1=1';
264 264
 
265 265
 		// Status.
266
-		if ( 'all' !== $qv['status'] ) {
267
-			$statuses           = wpinv_clean( wpinv_parse_list( $qv['status'] ) );
268
-			$prepared_statuses  = join( ',', array_fill( 0, count( $statuses ), '%s' ) );
269
-			$this->query_where .= $wpdb->prepare( " AND $table.`status` IN ( $prepared_statuses )", $statuses );
266
+		if ('all' !== $qv['status']) {
267
+			$statuses           = wpinv_clean(wpinv_parse_list($qv['status']));
268
+			$prepared_statuses  = join(',', array_fill(0, count($statuses), '%s'));
269
+			$this->query_where .= $wpdb->prepare(" AND $table.`status` IN ( $prepared_statuses )", $statuses);
270 270
 		}
271 271
 
272
-		if ( ! empty( $qv['customer_in'] ) ) {
273
-			$customer_in        = implode( ',', wp_parse_id_list( $qv['customer_in'] ) );
272
+		if (!empty($qv['customer_in'])) {
273
+			$customer_in        = implode(',', wp_parse_id_list($qv['customer_in']));
274 274
 			$this->query_where .= " AND $table.`customer_id` IN ($customer_in)";
275
-		} elseif ( ! empty( $qv['customer_not_in'] ) ) {
276
-			$customer_not_in    = implode( ',', wp_parse_id_list( $qv['customer_not_in'] ) );
275
+		} elseif (!empty($qv['customer_not_in'])) {
276
+			$customer_not_in    = implode(',', wp_parse_id_list($qv['customer_not_in']));
277 277
 			$this->query_where .= " AND $table.`customer_id` NOT IN ($customer_not_in)";
278 278
 		}
279 279
 
280
-		if ( ! empty( $qv['product_in'] ) ) {
281
-			$product_in         = implode( ',', wp_parse_id_list( $qv['product_in'] ) );
280
+		if (!empty($qv['product_in'])) {
281
+			$product_in         = implode(',', wp_parse_id_list($qv['product_in']));
282 282
 			$this->query_where .= " AND $table.`product_id` IN ($product_in)";
283
-		} elseif ( ! empty( $qv['product_not_in'] ) ) {
284
-			$product_not_in     = implode( ',', wp_parse_id_list( $qv['product_not_in'] ) );
283
+		} elseif (!empty($qv['product_not_in'])) {
284
+			$product_not_in     = implode(',', wp_parse_id_list($qv['product_not_in']));
285 285
 			$this->query_where .= " AND $table.`product_id` NOT IN ($product_not_in)";
286 286
 		}
287 287
 
288
-		if ( ! empty( $qv['include'] ) ) {
289
-			$include            = implode( ',', wp_parse_id_list( $qv['include'] ) );
288
+		if (!empty($qv['include'])) {
289
+			$include            = implode(',', wp_parse_id_list($qv['include']));
290 290
 			$this->query_where .= " AND $table.`id` IN ($include)";
291
-		} elseif ( ! empty( $qv['exclude'] ) ) {
292
-			$exclude            = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
291
+		} elseif (!empty($qv['exclude'])) {
292
+			$exclude            = implode(',', wp_parse_id_list($qv['exclude']));
293 293
 			$this->query_where .= " AND $table.`id` NOT IN ($exclude)";
294 294
 		}
295 295
 
296 296
 		// Date queries are allowed for the subscription creation date.
297
-		if ( ! empty( $qv['date_created_query'] ) && is_array( $qv['date_created_query'] ) ) {
298
-			$date_created_query = new WP_Date_Query( $qv['date_created_query'], "$table.created" );
297
+		if (!empty($qv['date_created_query']) && is_array($qv['date_created_query'])) {
298
+			$date_created_query = new WP_Date_Query($qv['date_created_query'], "$table.created");
299 299
 			$this->query_where .= $date_created_query->get_sql();
300 300
 		}
301 301
 
302 302
 		// Date queries are also allowed for the subscription expiration date.
303
-		if ( ! empty( $qv['date_expires_query'] ) && is_array( $qv['date_expires_query'] ) ) {
304
-			$date_expires_query = new WP_Date_Query( $qv['date_expires_query'], "$table.expiration" );
303
+		if (!empty($qv['date_expires_query']) && is_array($qv['date_expires_query'])) {
304
+			$date_expires_query = new WP_Date_Query($qv['date_expires_query'], "$table.expiration");
305 305
 			$this->query_where .= $date_expires_query->get_sql();
306 306
 		}
307 307
 
@@ -315,24 +315,24 @@  discard block
 block discarded – undo
315 315
 	 * @param array $qv Query vars.
316 316
 	 * @param string $table Table name.
317 317
 	 */
318
-	protected function prepare_query_order( &$qv, $table ) {
318
+	protected function prepare_query_order(&$qv, $table) {
319 319
 
320 320
 		// sorting.
321
-		$qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : '';
322
-		$order       = $this->parse_order( $qv['order'] );
321
+		$qv['order'] = isset($qv['order']) ? strtoupper($qv['order']) : '';
322
+		$order       = $this->parse_order($qv['order']);
323 323
 
324 324
 		// Default order is by 'id' (latest subscriptions).
325
-		if ( empty( $qv['orderby'] ) ) {
326
-			$qv['orderby'] = array( 'id' );
325
+		if (empty($qv['orderby'])) {
326
+			$qv['orderby'] = array('id');
327 327
 		}
328 328
 
329 329
 		// 'orderby' values may be an array, comma- or space-separated list.
330
-		$ordersby      = array_filter( wpinv_parse_list(  $qv['orderby'] ) );
330
+		$ordersby      = array_filter(wpinv_parse_list($qv['orderby']));
331 331
 
332 332
 		$orderby_array = array();
333
-		foreach ( $ordersby as $_key => $_value ) {
333
+		foreach ($ordersby as $_key => $_value) {
334 334
 
335
-			if ( is_int( $_key ) ) {
335
+			if (is_int($_key)) {
336 336
 				// Integer key means this is a flat array of 'orderby' fields.
337 337
 				$_orderby = $_value;
338 338
 				$_order   = $order;
@@ -342,20 +342,20 @@  discard block
 block discarded – undo
342 342
 				$_order   = $_value;
343 343
 			}
344 344
 
345
-			$parsed = $this->parse_orderby( $_orderby, $table );
345
+			$parsed = $this->parse_orderby($_orderby, $table);
346 346
 
347
-			if ( $parsed ) {
348
-				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
347
+			if ($parsed) {
348
+				$orderby_array[] = $parsed . ' ' . $this->parse_order($_order);
349 349
 			}
350 350
 
351 351
 		}
352 352
 
353 353
 		// If no valid clauses were found, order by id.
354
-		if ( empty( $orderby_array ) ) {
354
+		if (empty($orderby_array)) {
355 355
 			$orderby_array[] = "id $order";
356 356
 		}
357 357
 
358
-		$this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array );
358
+		$this->query_orderby = 'ORDER BY ' . implode(', ', $orderby_array);
359 359
 
360 360
 	}
361 361
 
@@ -369,30 +369,30 @@  discard block
 block discarded – undo
369 369
 	public function query() {
370 370
 		global $wpdb;
371 371
 
372
-		$qv =& $this->query_vars;
372
+		$qv = & $this->query_vars;
373 373
 
374 374
 		// Return a non-null value to bypass the default GetPaid subscriptions query and remember to set the
375 375
 		// total_subscriptions property.
376
-		$this->results = apply_filters_ref_array( 'getpaid_subscriptions_pre_query', array( null, &$this ) );
376
+		$this->results = apply_filters_ref_array('getpaid_subscriptions_pre_query', array(null, &$this));
377 377
 
378
-		if ( null === $this->results ) {
378
+		if (null === $this->results) {
379 379
 			$this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
380 380
 
381
-			if ( ( is_array( $qv['fields'] ) && 1 != count( $qv['fields'] ) ) || 'all' == $qv['fields'] ) {
382
-				$this->results = $wpdb->get_results( $this->request );
381
+			if ((is_array($qv['fields']) && 1 != count($qv['fields'])) || 'all' == $qv['fields']) {
382
+				$this->results = $wpdb->get_results($this->request);
383 383
 			} else {
384
-				$this->results = $wpdb->get_col( $this->request );
384
+				$this->results = $wpdb->get_col($this->request);
385 385
 			}
386 386
 
387
-			if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
388
-				$found_subscriptions_query = apply_filters( 'getpaid_found_subscriptions_query', 'SELECT FOUND_ROWS()', $this );
389
-				$this->total_subscriptions   = (int) $wpdb->get_var( $found_subscriptions_query );
387
+			if (isset($qv['count_total']) && $qv['count_total']) {
388
+				$found_subscriptions_query = apply_filters('getpaid_found_subscriptions_query', 'SELECT FOUND_ROWS()', $this);
389
+				$this->total_subscriptions = (int) $wpdb->get_var($found_subscriptions_query);
390 390
 			}
391 391
 		}
392 392
 
393
-		if ( 'all' == $qv['fields'] ) {
394
-			foreach ( $this->results as $key => $subscription ) {
395
-				$this->results[ $key ] = new WPInv_Subscription( $subscription );
393
+		if ('all' == $qv['fields']) {
394
+			foreach ($this->results as $key => $subscription) {
395
+				$this->results[$key] = new WPInv_Subscription($subscription);
396 396
 			}
397 397
 		}
398 398
 
@@ -406,9 +406,9 @@  discard block
 block discarded – undo
406 406
 	 * @param string $query_var Query variable key.
407 407
 	 * @return mixed
408 408
 	 */
409
-	public function get( $query_var ) {
410
-		if ( isset( $this->query_vars[ $query_var ] ) ) {
411
-			return $this->query_vars[ $query_var ];
409
+	public function get($query_var) {
410
+		if (isset($this->query_vars[$query_var])) {
411
+			return $this->query_vars[$query_var];
412 412
 		}
413 413
 
414 414
 		return null;
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
 	 * @param string $query_var Query variable key.
423 423
 	 * @param mixed $value Query variable value.
424 424
 	 */
425
-	public function set( $query_var, $value ) {
426
-		$this->query_vars[ $query_var ] = $value;
425
+	public function set($query_var, $value) {
426
+		$this->query_vars[$query_var] = $value;
427 427
 	}
428 428
 
429 429
 	/**
@@ -457,16 +457,16 @@  discard block
 block discarded – undo
457 457
 	 *  @param string $table The current table.
458 458
 	 * @return string Value to use in the ORDER clause, if `$orderby` is valid.
459 459
 	 */
460
-	protected function parse_orderby( $orderby, $table ) {
460
+	protected function parse_orderby($orderby, $table) {
461 461
 
462 462
 		$_orderby = '';
463
-		if ( in_array( $orderby, array( 'customer_id', 'frequency', 'period', 'initial_amount', 'recurring_amount', 'bill_times', 'transaction_id', 'parent_payment_id', 'product_id', 'created', 'expiration', 'trial_period', 'status', 'profile_id' ) ) ) {
463
+		if (in_array($orderby, array('customer_id', 'frequency', 'period', 'initial_amount', 'recurring_amount', 'bill_times', 'transaction_id', 'parent_payment_id', 'product_id', 'created', 'expiration', 'trial_period', 'status', 'profile_id'))) {
464 464
 			$_orderby = "$table.`$orderby`";
465
-		} elseif ( 'id' === strtolower( $orderby ) ) {
465
+		} elseif ('id' === strtolower($orderby)) {
466 466
 			$_orderby = "$table.id";
467
-		} elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) {
468
-			$include     = wp_parse_id_list( $this->query_vars['include'] );
469
-			$include_sql = implode( ',', $include );
467
+		} elseif ('include' === $orderby && !empty($this->query_vars['include'])) {
468
+			$include     = wp_parse_id_list($this->query_vars['include']);
469
+			$include_sql = implode(',', $include);
470 470
 			$_orderby    = "FIELD( $table.id, $include_sql )";
471 471
 		}
472 472
 
@@ -481,12 +481,12 @@  discard block
 block discarded – undo
481 481
 	 * @param string $order The 'order' query variable.
482 482
 	 * @return string The sanitized 'order' query variable.
483 483
 	 */
484
-	protected function parse_order( $order ) {
485
-		if ( ! is_string( $order ) || empty( $order ) ) {
484
+	protected function parse_order($order) {
485
+		if (!is_string($order) || empty($order)) {
486 486
 			return 'DESC';
487 487
 		}
488 488
 
489
-		if ( 'ASC' === strtoupper( $order ) ) {
489
+		if ('ASC' === strtoupper($order)) {
490 490
 			return 'ASC';
491 491
 		} else {
492 492
 			return 'DESC';
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data-store.php 1 patch
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -11,186 +11,186 @@
 block discarded – undo
11 11
  */
12 12
 class GetPaid_Data_Store {
13 13
 
14
-	/**
15
-	 * Contains an instance of the data store class that we are working with.
16
-	 *
17
-	 * @var GetPaid_Data_Store
18
-	 */
19
-	private $instance = null;
20
-
21
-	/**
22
-	 * Contains an array of default supported data stores.
23
-	 * Format of object name => class name.
24
-	 * Example: 'item' => 'GetPaid_Item_Data_Store'
25
-	 * You can also pass something like item-<type> for item stores and
26
-	 * that type will be used first when available, if a store is requested like
27
-	 * this and doesn't exist, then the store would fall back to 'item'.
28
-	 * Ran through `getpaid_data_stores`.
29
-	 *
30
-	 * @var array
31
-	 */
32
-	private $stores = array(
33
-		'item'         => 'GetPaid_Item_Data_Store',
34
-		'payment_form' => 'GetPaid_Payment_Form_Data_Store',
35
-		'discount'     => 'GetPaid_Discount_Data_Store',
36
-		'invoice'      => 'GetPaid_Invoice_Data_Store',
37
-		'subscription' => 'GetPaid_Subscription_Data_Store',
38
-	);
39
-
40
-	/**
41
-	 * Contains the name of the current data store's class name.
42
-	 *
43
-	 * @var string
44
-	 */
45
-	private $current_class_name = '';
46
-
47
-	/**
48
-	 * The object type this store works with.
49
-	 *
50
-	 * @var string
51
-	 */
52
-	private $object_type = '';
53
-
54
-	/**
55
-	 * Tells GetPaid_Data_Store which object
56
-	 * store we want to work with.
57
-	 *
58
-	 * @param string $object_type Name of object.
59
-	 */
60
-	public function __construct( $object_type ) {
61
-		$this->object_type = $object_type;
62
-		$this->stores      = apply_filters( 'getpaid_data_stores', $this->stores );
63
-
64
-		// If this object type can't be found, check to see if we can load one
65
-		// level up (so if item-type isn't found, we try item).
66
-		if ( ! array_key_exists( $object_type, $this->stores ) ) {
67
-			$pieces      = explode( '-', $object_type );
68
-			$object_type = $pieces[0];
69
-		}
70
-
71
-		if ( array_key_exists( $object_type, $this->stores ) ) {
72
-			$store = apply_filters( 'getpaid_' . $object_type . '_data_store', $this->stores[ $object_type ] );
73
-			if ( is_object( $store ) ) {
74
-				$this->current_class_name = get_class( $store );
75
-				$this->instance           = $store;
76
-			} else {
77
-				if ( ! class_exists( $store ) ) {
78
-					throw new Exception( __( 'Data store class does not exist.', 'invoicing' ) );
79
-				}
80
-				$this->current_class_name = $store;
81
-				$this->instance           = new $store();
82
-			}
83
-		} else {
84
-			throw new Exception( __( 'Invalid data store.', 'invoicing' ) );
85
-		}
86
-	}
87
-
88
-	/**
89
-	 * Only store the object type to avoid serializing the data store instance.
90
-	 *
91
-	 * @return array
92
-	 */
93
-	public function __sleep() {
94
-		return array( 'object_type' );
95
-	}
96
-
97
-	/**
98
-	 * Re-run the constructor with the object type.
99
-	 *
100
-	 * @throws Exception When validation fails.
101
-	 */
102
-	public function __wakeup() {
103
-		$this->__construct( $this->object_type );
104
-	}
105
-
106
-	/**
107
-	 * Loads a data store.
108
-	 *
109
-	 * @param string $object_type Name of object.
110
-	 *
111
-	 * @since 1.0.19
112
-	 * @throws Exception When validation fails.
113
-	 * @return GetPaid_Data_Store
114
-	 */
115
-	public static function load( $object_type ) {
116
-		return new GetPaid_Data_Store( $object_type );
117
-	}
118
-
119
-	/**
120
-	 * Returns the class name of the current data store.
121
-	 *
122
-	 * @since 1.0.19
123
-	 * @return string
124
-	 */
125
-	public function get_current_class_name() {
126
-		return $this->current_class_name;
127
-	}
128
-
129
-	/**
130
-	 * Returns the object type of the current data store.
131
-	 *
132
-	 * @since 1.0.19
133
-	 * @return string
134
-	 */
135
-	public function get_object_type() {
136
-		return $this->object_type;
137
-	}
138
-
139
-	/**
140
-	 * Reads an object from the data store.
141
-	 *
142
-	 * @since 1.0.19
143
-	 * @param GetPaid_Data $data GetPaid data instance.
144
-	 */
145
-	public function read( &$data ) {
146
-		$this->instance->read( $data );
147
-	}
148
-
149
-	/**
150
-	 * Create an object in the data store.
151
-	 *
152
-	 * @since 1.0.19
153
-	 * @param GetPaid_Data $data GetPaid data instance.
154
-	 */
155
-	public function create( &$data ) {
156
-		$this->instance->create( $data );
157
-	}
158
-
159
-	/**
160
-	 * Update an object in the data store.
161
-	 *
162
-	 * @since 1.0.19
163
-	 * @param GetPaid_Data $data GetPaid data instance.
164
-	 */
165
-	public function update( &$data ) {
166
-		$this->instance->update( $data );
167
-	}
168
-
169
-	/**
170
-	 * Delete an object from the data store.
171
-	 *
172
-	 * @since 1.0.19
173
-	 * @param GetPaid_Data $data GetPaid data instance.
174
-	 * @param array   $args Array of args to pass to the delete method.
175
-	 */
176
-	public function delete( &$data, $args = array() ) {
177
-		$this->instance->delete( $data, $args );
178
-	}
179
-
180
-	/**
181
-	 * Data stores can define additional function. This passes
182
-	 * through to the instance if that function exists.
183
-	 *
184
-	 * @since 1.0.19
185
-	 * @param string $method     Method.
186
-	 * @return mixed
187
-	 */
188
-	public function __call( $method, $parameters ) {
189
-		if ( is_callable( array( $this->instance, $method ) ) ) {
190
-			$object     = array_shift( $parameters );
191
-			$parameters = array_merge( array( &$object ), $parameters );
192
-			return call_user_func_array( array( $this->instance, $method ), $parameters );
193
-		}
194
-	}
14
+    /**
15
+     * Contains an instance of the data store class that we are working with.
16
+     *
17
+     * @var GetPaid_Data_Store
18
+     */
19
+    private $instance = null;
20
+
21
+    /**
22
+     * Contains an array of default supported data stores.
23
+     * Format of object name => class name.
24
+     * Example: 'item' => 'GetPaid_Item_Data_Store'
25
+     * You can also pass something like item-<type> for item stores and
26
+     * that type will be used first when available, if a store is requested like
27
+     * this and doesn't exist, then the store would fall back to 'item'.
28
+     * Ran through `getpaid_data_stores`.
29
+     *
30
+     * @var array
31
+     */
32
+    private $stores = array(
33
+        'item'         => 'GetPaid_Item_Data_Store',
34
+        'payment_form' => 'GetPaid_Payment_Form_Data_Store',
35
+        'discount'     => 'GetPaid_Discount_Data_Store',
36
+        'invoice'      => 'GetPaid_Invoice_Data_Store',
37
+        'subscription' => 'GetPaid_Subscription_Data_Store',
38
+    );
39
+
40
+    /**
41
+     * Contains the name of the current data store's class name.
42
+     *
43
+     * @var string
44
+     */
45
+    private $current_class_name = '';
46
+
47
+    /**
48
+     * The object type this store works with.
49
+     *
50
+     * @var string
51
+     */
52
+    private $object_type = '';
53
+
54
+    /**
55
+     * Tells GetPaid_Data_Store which object
56
+     * store we want to work with.
57
+     *
58
+     * @param string $object_type Name of object.
59
+     */
60
+    public function __construct( $object_type ) {
61
+        $this->object_type = $object_type;
62
+        $this->stores      = apply_filters( 'getpaid_data_stores', $this->stores );
63
+
64
+        // If this object type can't be found, check to see if we can load one
65
+        // level up (so if item-type isn't found, we try item).
66
+        if ( ! array_key_exists( $object_type, $this->stores ) ) {
67
+            $pieces      = explode( '-', $object_type );
68
+            $object_type = $pieces[0];
69
+        }
70
+
71
+        if ( array_key_exists( $object_type, $this->stores ) ) {
72
+            $store = apply_filters( 'getpaid_' . $object_type . '_data_store', $this->stores[ $object_type ] );
73
+            if ( is_object( $store ) ) {
74
+                $this->current_class_name = get_class( $store );
75
+                $this->instance           = $store;
76
+            } else {
77
+                if ( ! class_exists( $store ) ) {
78
+                    throw new Exception( __( 'Data store class does not exist.', 'invoicing' ) );
79
+                }
80
+                $this->current_class_name = $store;
81
+                $this->instance           = new $store();
82
+            }
83
+        } else {
84
+            throw new Exception( __( 'Invalid data store.', 'invoicing' ) );
85
+        }
86
+    }
87
+
88
+    /**
89
+     * Only store the object type to avoid serializing the data store instance.
90
+     *
91
+     * @return array
92
+     */
93
+    public function __sleep() {
94
+        return array( 'object_type' );
95
+    }
96
+
97
+    /**
98
+     * Re-run the constructor with the object type.
99
+     *
100
+     * @throws Exception When validation fails.
101
+     */
102
+    public function __wakeup() {
103
+        $this->__construct( $this->object_type );
104
+    }
105
+
106
+    /**
107
+     * Loads a data store.
108
+     *
109
+     * @param string $object_type Name of object.
110
+     *
111
+     * @since 1.0.19
112
+     * @throws Exception When validation fails.
113
+     * @return GetPaid_Data_Store
114
+     */
115
+    public static function load( $object_type ) {
116
+        return new GetPaid_Data_Store( $object_type );
117
+    }
118
+
119
+    /**
120
+     * Returns the class name of the current data store.
121
+     *
122
+     * @since 1.0.19
123
+     * @return string
124
+     */
125
+    public function get_current_class_name() {
126
+        return $this->current_class_name;
127
+    }
128
+
129
+    /**
130
+     * Returns the object type of the current data store.
131
+     *
132
+     * @since 1.0.19
133
+     * @return string
134
+     */
135
+    public function get_object_type() {
136
+        return $this->object_type;
137
+    }
138
+
139
+    /**
140
+     * Reads an object from the data store.
141
+     *
142
+     * @since 1.0.19
143
+     * @param GetPaid_Data $data GetPaid data instance.
144
+     */
145
+    public function read( &$data ) {
146
+        $this->instance->read( $data );
147
+    }
148
+
149
+    /**
150
+     * Create an object in the data store.
151
+     *
152
+     * @since 1.0.19
153
+     * @param GetPaid_Data $data GetPaid data instance.
154
+     */
155
+    public function create( &$data ) {
156
+        $this->instance->create( $data );
157
+    }
158
+
159
+    /**
160
+     * Update an object in the data store.
161
+     *
162
+     * @since 1.0.19
163
+     * @param GetPaid_Data $data GetPaid data instance.
164
+     */
165
+    public function update( &$data ) {
166
+        $this->instance->update( $data );
167
+    }
168
+
169
+    /**
170
+     * Delete an object from the data store.
171
+     *
172
+     * @since 1.0.19
173
+     * @param GetPaid_Data $data GetPaid data instance.
174
+     * @param array   $args Array of args to pass to the delete method.
175
+     */
176
+    public function delete( &$data, $args = array() ) {
177
+        $this->instance->delete( $data, $args );
178
+    }
179
+
180
+    /**
181
+     * Data stores can define additional function. This passes
182
+     * through to the instance if that function exists.
183
+     *
184
+     * @since 1.0.19
185
+     * @param string $method     Method.
186
+     * @return mixed
187
+     */
188
+    public function __call( $method, $parameters ) {
189
+        if ( is_callable( array( $this->instance, $method ) ) ) {
190
+            $object     = array_shift( $parameters );
191
+            $parameters = array_merge( array( &$object ), $parameters );
192
+            return call_user_func_array( array( $this->instance, $method ), $parameters );
193
+        }
194
+    }
195 195
 
196 196
 }
Please login to merge, or discard this patch.
includes/wpinv-payment-functions.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,155 +1,155 @@  discard block
 block discarded – undo
1 1
 <?php
2
-function wpinv_is_subscription_payment( $invoice = '' ) {
3
-    if ( empty( $invoice ) ) {
2
+function wpinv_is_subscription_payment($invoice = '') {
3
+    if (empty($invoice)) {
4 4
         return false;
5 5
     }
6 6
     
7
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
8
-        $invoice = wpinv_get_invoice( $invoice );
7
+    if (!is_object($invoice) && is_scalar($invoice)) {
8
+        $invoice = wpinv_get_invoice($invoice);
9 9
     }
10 10
     
11
-    if ( empty( $invoice ) ) {
11
+    if (empty($invoice)) {
12 12
         return false;
13 13
     }
14 14
         
15
-    if ( $invoice->is_renewal() ) {
15
+    if ($invoice->is_renewal()) {
16 16
         return true;
17 17
     }
18 18
 
19 19
     return false;
20 20
 }
21 21
 
22
-function wpinv_payment_link_transaction_id( $invoice = '' ) {
23
-    if ( empty( $invoice ) ) {
22
+function wpinv_payment_link_transaction_id($invoice = '') {
23
+    if (empty($invoice)) {
24 24
         return false;
25 25
     }
26 26
     
27
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
28
-        $invoice = wpinv_get_invoice( $invoice );
27
+    if (!is_object($invoice) && is_scalar($invoice)) {
28
+        $invoice = wpinv_get_invoice($invoice);
29 29
     }
30 30
     
31
-    if ( empty( $invoice ) ) {
31
+    if (empty($invoice)) {
32 32
         return false;
33 33
     }
34 34
 
35
-    return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice );
35
+    return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice);
36 36
 }
37 37
 
38
-function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) {
39
-    $interval   = (int)$interval > 0 ? (int)$interval : 1;
38
+function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) {
39
+    $interval   = (int) $interval > 0 ? (int) $interval : 1;
40 40
     
41
-    if ( $trial_interval > 0 && !empty( $trial_period ) ) {
42
-        $amount = __( 'Free', 'invoicing' );
41
+    if ($trial_interval > 0 && !empty($trial_period)) {
42
+        $amount = __('Free', 'invoicing');
43 43
         $interval = $trial_interval;
44 44
         $period = $trial_period;
45 45
     }
46 46
     
47 47
     $description = '';
48
-    switch ( $period ) {
48
+    switch ($period) {
49 49
         case 'D' :
50 50
         case 'day' :
51
-            $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval );
51
+            $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval);
52 52
             break;
53 53
         case 'W' :
54 54
         case 'week' :
55
-            $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval );
55
+            $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval);
56 56
             break;
57 57
         case 'M' :
58 58
         case 'month' :
59
-            $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval );
59
+            $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval);
60 60
             break;
61 61
         case 'Y' :
62 62
         case 'year' :
63
-            $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval );
63
+            $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval);
64 64
             break;
65 65
     }
66 66
 
67
-    return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval  );
67
+    return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval);
68 68
 }
69 69
 
70
-function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) {
71
-    $interval   = (int)$interval > 0 ? (int)$interval : 1;
72
-    $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0;
70
+function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) {
71
+    $interval   = (int) $interval > 0 ? (int) $interval : 1;
72
+    $bill_times = (int) $bill_times > 0 ? (int) $bill_times : 0;
73 73
     
74 74
     $description = '';
75
-    switch ( $period ) {
75
+    switch ($period) {
76 76
         case 'D' :
77 77
         case 'day' :            
78
-            if ( (int)$bill_times > 0 ) {
79
-                if ( $interval > 1 ) {
80
-                    if ( $bill_times > 1 ) {
81
-                        $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
78
+            if ((int) $bill_times > 0) {
79
+                if ($interval > 1) {
80
+                    if ($bill_times > 1) {
81
+                        $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
82 82
                     } else {
83
-                        $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval );
83
+                        $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval);
84 84
                     }
85 85
                 } else {
86
-                    $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
86
+                    $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
87 87
                 }
88 88
             } else {
89
-                $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval );
89
+                $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval);
90 90
             }
91 91
             break;
92 92
         case 'W' :
93 93
         case 'week' :            
94
-            if ( (int)$bill_times > 0 ) {
95
-                if ( $interval > 1 ) {
96
-                    if ( $bill_times > 1 ) {
97
-                        $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
94
+            if ((int) $bill_times > 0) {
95
+                if ($interval > 1) {
96
+                    if ($bill_times > 1) {
97
+                        $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
98 98
                     } else {
99
-                        $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval );
99
+                        $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval);
100 100
                     }
101 101
                 } else {
102
-                    $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
102
+                    $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
103 103
                 }
104 104
             } else {
105
-                $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval );
105
+                $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval);
106 106
             }
107 107
             break;
108 108
         case 'M' :
109 109
         case 'month' :            
110
-            if ( (int)$bill_times > 0 ) {
111
-                if ( $interval > 1 ) {
112
-                    if ( $bill_times > 1 ) {
113
-                        $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
110
+            if ((int) $bill_times > 0) {
111
+                if ($interval > 1) {
112
+                    if ($bill_times > 1) {
113
+                        $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
114 114
                     } else {
115
-                        $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval );
115
+                        $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval);
116 116
                     }
117 117
                 } else {
118
-                    $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
118
+                    $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
119 119
                 }
120 120
             } else {
121
-                $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval );
121
+                $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval);
122 122
             }
123 123
             break;
124 124
         case 'Y' :
125 125
         case 'year' :            
126
-            if ( (int)$bill_times > 0 ) {
127
-                if ( $interval > 1 ) {
128
-                    if ( $bill_times > 1 ) {
129
-                        $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
126
+            if ((int) $bill_times > 0) {
127
+                if ($interval > 1) {
128
+                    if ($bill_times > 1) {
129
+                        $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
130 130
                     } else {
131
-                        $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval );
131
+                        $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval);
132 132
                     }
133 133
                 } else {
134
-                    $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
134
+                    $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
135 135
                 }
136 136
             } else {
137
-                $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval );
137
+                $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval);
138 138
             }
139 139
             break;
140 140
     }
141 141
 
142
-    return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
142
+    return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
143 143
 }
144 144
 
145
-function wpinv_subscription_payment_desc( $invoice ) {
146
-    if ( empty( $invoice ) ) {
145
+function wpinv_subscription_payment_desc($invoice) {
146
+    if (empty($invoice)) {
147 147
         return NULL;
148 148
     }
149 149
 
150 150
     $description = '';
151
-    if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) {
152
-        if ( $item->has_free_trial() ) {
151
+    if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) {
152
+        if ($item->has_free_trial()) {
153 153
             $trial_period = $item->get_trial_period();
154 154
             $trial_interval = $item->get_trial_interval();
155 155
         } else {
@@ -157,46 +157,46 @@  discard block
 block discarded – undo
157 157
             $trial_interval = 0;
158 158
         }
159 159
         
160
-        $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() );
160
+        $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency());
161 161
     }
162 162
     
163
-    return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice );
163
+    return apply_filters('wpinv_subscription_payment_desc', $description, $invoice);
164 164
 }
165 165
 
166
-function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) {
167
-    $initial_total      = wpinv_round_amount( $initial );
168
-    $recurring_total    = wpinv_round_amount( $recurring );
166
+function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') {
167
+    $initial_total      = wpinv_round_amount($initial);
168
+    $recurring_total    = wpinv_round_amount($recurring);
169 169
     
170
-    if ( $trial_interval > 0 && !empty( $trial_period ) ) {
170
+    if ($trial_interval > 0 && !empty($trial_period)) {
171 171
         // Free trial
172 172
     } else {
173
-        if ( $bill_times == 1 ) {
173
+        if ($bill_times == 1) {
174 174
             $recurring_total = $initial_total;
175
-        } else if ( $bill_times > 1 && $initial_total != $recurring_total ) {
175
+        } else if ($bill_times > 1 && $initial_total != $recurring_total) {
176 176
             $bill_times--;
177 177
         }
178 178
     }
179 179
     
180
-    $initial_amount     = wpinv_price( wpinv_format_amount( $initial_total ), $currency );
181
-    $recurring_amount   = wpinv_price( wpinv_format_amount( $recurring_total ), $currency );
180
+    $initial_amount     = wpinv_price(wpinv_format_amount($initial_total), $currency);
181
+    $recurring_amount   = wpinv_price(wpinv_format_amount($recurring_total), $currency);
182 182
     
183
-    $recurring          = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
183
+    $recurring          = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
184 184
         
185
-    if ( $initial_total != $recurring_total ) {
186
-        $initial        = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval );
185
+    if ($initial_total != $recurring_total) {
186
+        $initial        = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval);
187 187
         
188
-        $description    = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring );
188
+        $description    = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring);
189 189
     } else {
190 190
         $description    = $recurring;
191 191
     }
192 192
     
193
-    return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency );
193
+    return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency);
194 194
 }
195 195
 
196 196
 /**
197 197
  * @param WPInv_Subscription $subscription
198 198
  */
199
-function wpinv_recurring_send_payment_failed( $subscription ) {
200
-    wpinv_failed_invoice_notification( $subscription->get_parent_payment_id() );
199
+function wpinv_recurring_send_payment_failed($subscription) {
200
+    wpinv_failed_invoice_notification($subscription->get_parent_payment_id());
201 201
 }
202
-add_action( 'getpaid_subscription_failing', 'wpinv_recurring_send_payment_failed', 10, 2 );
203 202
\ No newline at end of file
203
+add_action('getpaid_subscription_failing', 'wpinv_recurring_send_payment_failed', 10, 2);
204 204
\ No newline at end of file
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-subscription-data-store.php 2 patches
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit;
8
+    exit;
9 9
 }
10 10
 
11 11
 /**
@@ -15,193 +15,193 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Subscription_Data_Store {
17 17
 
18
-	/**
19
-	 * A map of database fields to data types.
20
-	 *
21
-	 * @since 1.0.19
22
-	 * @var array
23
-	 */
24
-	protected $database_fields_to_data_type = array(
25
-		'id'                => '%d',
26
-		'customer_id'       => '%d',
27
-		'frequency'         => '%d',
28
-		'period'            => '%s',
29
-		'initial_amount'    => '%s',
30
-		'recurring_amount'  => '%s',
31
-		'bill_times'        => '%d',
32
-		'transaction_id'    => '%s',
33
-		'parent_payment_id' => '%d',
34
-		'product_id'        => '%d',
35
-		'created'           => '%s',
36
-		'expiration'        => '%s',
37
-		'trial_period'      => '%s',
38
-		'status'            => '%s',
39
-		'profile_id'        => '%s',
40
-	);
41
-
42
-	/*
18
+    /**
19
+     * A map of database fields to data types.
20
+     *
21
+     * @since 1.0.19
22
+     * @var array
23
+     */
24
+    protected $database_fields_to_data_type = array(
25
+        'id'                => '%d',
26
+        'customer_id'       => '%d',
27
+        'frequency'         => '%d',
28
+        'period'            => '%s',
29
+        'initial_amount'    => '%s',
30
+        'recurring_amount'  => '%s',
31
+        'bill_times'        => '%d',
32
+        'transaction_id'    => '%s',
33
+        'parent_payment_id' => '%d',
34
+        'product_id'        => '%d',
35
+        'created'           => '%s',
36
+        'expiration'        => '%s',
37
+        'trial_period'      => '%s',
38
+        'status'            => '%s',
39
+        'profile_id'        => '%s',
40
+    );
41
+
42
+    /*
43 43
 	|--------------------------------------------------------------------------
44 44
 	| CRUD Methods
45 45
 	|--------------------------------------------------------------------------
46 46
 	*/
47 47
 
48
-	/**
49
-	 * Method to create a new subscription in the database.
50
-	 *
51
-	 * @param WPInv_Subscription $subscription Subscription object.
52
-	 */
53
-	public function create( &$subscription ) {
54
-		global $wpdb;
55
-
56
-		$values  = array();
57
-		$formats = array();
58
-
59
-		$fields = $this->database_fields_to_data_type;
60
-		unset( $fields['id'] );
61
-
62
-		foreach ( $fields as $key => $format ) {
63
-			$method     = "get_$key";
64
-			$values[]   = $subscription->$method( 'edit' );
65
-			$formats[]  = $format;
66
-		}
67
-
68
-		$result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $fields, $formats );
69
-
70
-		if ( $result ) {
71
-			$subscription->set_id( $wpdb->insert_id );
72
-			$subscription->apply_changes();
73
-			$subscription->clear_cache();
74
-			do_action( 'getpaid_new_subscription', $subscription );
75
-			return true;
76
-		}
77
-
78
-		return false;
79
-	}
80
-
81
-	/**
82
-	 * Method to read a subscription from the database.
83
-	 *
84
-	 * @param WPInv_Subscription $subscription Subscription object.
85
-	 *
86
-	 */
87
-	public function read( &$subscription ) {
88
-		global $wpdb;
89
-
90
-		$subscription->set_defaults();
91
-
92
-		if ( ! $subscription->get_id() ) {
93
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
94
-			$subscription->set_id( 0 );
95
-			return false;
96
-		}
97
-
98
-		// Maybe retrieve from the cache.
99
-		$raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
100
-
101
-		// If not found, retrieve from the db.
102
-		if ( false === $raw_subscription ) {
103
-
104
-			$raw_subscription = $wpdb->get_row(
105
-				$wpdb->prepare(
106
-					"SELECT * FROM {$wpdb->prefix}wpinv_subscriptions WHERE id = %d",
107
-					$subscription->get_id()
108
-				)
109
-			);
110
-
111
-			// Update the cache with our data
112
-			wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
113
-
114
-		}
115
-
116
-		if ( ! $raw_subscription ) {
117
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
118
-			return false;
119
-		}
120
-
121
-		foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
122
-			$method     = "set_$key";
123
-			$subscription->$method( $raw_subscription->$key );
124
-		}
125
-
126
-		$subscription->set_object_read( true );
127
-		do_action( 'getpaid_read_subscription', $subscription );
128
-
129
-	}
130
-
131
-	/**
132
-	 * Method to update a subscription in the database.
133
-	 *
134
-	 * @param WPInv_Subscription $subscription Subscription object.
135
-	 */
136
-	public function update( &$subscription ) {
137
-		global $wpdb;
138
-
139
-		if ( null === $subscription->get_date_created( 'edit' ) ) {
140
-			$subscription->set_date_created(  current_time('mysql') );
141
-		}
142
-
143
-		$changes = $subscription->get_changes();
144
-		$values  = array();
145
-		$format  = array();
146
-
147
-		foreach ( $this->database_fields_to_data_type as $key => $format ) {
148
-			if ( array_key_exists( $key, $changes ) ) {
149
-				$method     = "get_$key";
150
-				$values[]   = $subscription->$method( 'edit' );
151
-				$formats[]  = $format;
152
-			}
153
-		}
154
-
155
-		if ( empty( $values ) ) {
156
-			return;
157
-		}
158
-
159
-		$wpdb->update(
160
-			$wpdb->prefix . 'wpinv_subscriptions',
161
-			$values,
162
-			array(
163
-				'id' => $subscription->get_id(),
164
-			),
165
-			$formats
166
-		);
167
-
168
-		// Apply the changes.
169
-		$subscription->apply_changes();
170
-
171
-		// Delete cache.
172
-		$subscription->clear_cache();
173
-
174
-		// Fire a hook.
175
-		do_action( 'getpaid_update_subscription', $subscription->get_id(), $subscription );
176
-
177
-	}
178
-
179
-	/**
180
-	 * Method to delete a subscription from the database.
181
-	 *
182
-	 * @param WPInv_Subscription $subscription
183
-	 */
184
-	public function delete( &$subscription ) {
185
-		global $wpdb;
186
-
187
-		$wpdb->query(
188
-			$wpdb->prepare(
189
-				"DELETE FROM {$wpdb->prefix}getpaid_subscriptions
48
+    /**
49
+     * Method to create a new subscription in the database.
50
+     *
51
+     * @param WPInv_Subscription $subscription Subscription object.
52
+     */
53
+    public function create( &$subscription ) {
54
+        global $wpdb;
55
+
56
+        $values  = array();
57
+        $formats = array();
58
+
59
+        $fields = $this->database_fields_to_data_type;
60
+        unset( $fields['id'] );
61
+
62
+        foreach ( $fields as $key => $format ) {
63
+            $method     = "get_$key";
64
+            $values[]   = $subscription->$method( 'edit' );
65
+            $formats[]  = $format;
66
+        }
67
+
68
+        $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $fields, $formats );
69
+
70
+        if ( $result ) {
71
+            $subscription->set_id( $wpdb->insert_id );
72
+            $subscription->apply_changes();
73
+            $subscription->clear_cache();
74
+            do_action( 'getpaid_new_subscription', $subscription );
75
+            return true;
76
+        }
77
+
78
+        return false;
79
+    }
80
+
81
+    /**
82
+     * Method to read a subscription from the database.
83
+     *
84
+     * @param WPInv_Subscription $subscription Subscription object.
85
+     *
86
+     */
87
+    public function read( &$subscription ) {
88
+        global $wpdb;
89
+
90
+        $subscription->set_defaults();
91
+
92
+        if ( ! $subscription->get_id() ) {
93
+            $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
94
+            $subscription->set_id( 0 );
95
+            return false;
96
+        }
97
+
98
+        // Maybe retrieve from the cache.
99
+        $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
100
+
101
+        // If not found, retrieve from the db.
102
+        if ( false === $raw_subscription ) {
103
+
104
+            $raw_subscription = $wpdb->get_row(
105
+                $wpdb->prepare(
106
+                    "SELECT * FROM {$wpdb->prefix}wpinv_subscriptions WHERE id = %d",
107
+                    $subscription->get_id()
108
+                )
109
+            );
110
+
111
+            // Update the cache with our data
112
+            wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
113
+
114
+        }
115
+
116
+        if ( ! $raw_subscription ) {
117
+            $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
118
+            return false;
119
+        }
120
+
121
+        foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
122
+            $method     = "set_$key";
123
+            $subscription->$method( $raw_subscription->$key );
124
+        }
125
+
126
+        $subscription->set_object_read( true );
127
+        do_action( 'getpaid_read_subscription', $subscription );
128
+
129
+    }
130
+
131
+    /**
132
+     * Method to update a subscription in the database.
133
+     *
134
+     * @param WPInv_Subscription $subscription Subscription object.
135
+     */
136
+    public function update( &$subscription ) {
137
+        global $wpdb;
138
+
139
+        if ( null === $subscription->get_date_created( 'edit' ) ) {
140
+            $subscription->set_date_created(  current_time('mysql') );
141
+        }
142
+
143
+        $changes = $subscription->get_changes();
144
+        $values  = array();
145
+        $format  = array();
146
+
147
+        foreach ( $this->database_fields_to_data_type as $key => $format ) {
148
+            if ( array_key_exists( $key, $changes ) ) {
149
+                $method     = "get_$key";
150
+                $values[]   = $subscription->$method( 'edit' );
151
+                $formats[]  = $format;
152
+            }
153
+        }
154
+
155
+        if ( empty( $values ) ) {
156
+            return;
157
+        }
158
+
159
+        $wpdb->update(
160
+            $wpdb->prefix . 'wpinv_subscriptions',
161
+            $values,
162
+            array(
163
+                'id' => $subscription->get_id(),
164
+            ),
165
+            $formats
166
+        );
167
+
168
+        // Apply the changes.
169
+        $subscription->apply_changes();
170
+
171
+        // Delete cache.
172
+        $subscription->clear_cache();
173
+
174
+        // Fire a hook.
175
+        do_action( 'getpaid_update_subscription', $subscription->get_id(), $subscription );
176
+
177
+    }
178
+
179
+    /**
180
+     * Method to delete a subscription from the database.
181
+     *
182
+     * @param WPInv_Subscription $subscription
183
+     */
184
+    public function delete( &$subscription ) {
185
+        global $wpdb;
186
+
187
+        $wpdb->query(
188
+            $wpdb->prepare(
189
+                "DELETE FROM {$wpdb->prefix}getpaid_subscriptions
190 190
 				WHERE id = %d",
191
-				$subscription->get_id()
192
-			)
193
-		);
191
+                $subscription->get_id()
192
+            )
193
+        );
194 194
 
195
-		// Delete cache.
196
-		$subscription->clear_cache();
195
+        // Delete cache.
196
+        $subscription->clear_cache();
197 197
 
198
-		// Fire a hook.
199
-		do_action( 'getpaid_delete_subscription', $subscription->get_id(), $subscription );
198
+        // Fire a hook.
199
+        do_action( 'getpaid_delete_subscription', $subscription->get_id(), $subscription );
200 200
 
201
-		$subscription->set_id( 0 );
202
-	}
201
+        $subscription->set_id( 0 );
202
+    }
203 203
 
204
-	/*
204
+    /*
205 205
 	|--------------------------------------------------------------------------
206 206
 	| Additional Methods
207 207
 	|--------------------------------------------------------------------------
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * GetPaid_Subscription_Data_Store class file.
5 5
  *
6 6
  */
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -50,28 +50,28 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param WPInv_Subscription $subscription Subscription object.
52 52
 	 */
53
-	public function create( &$subscription ) {
53
+	public function create(&$subscription) {
54 54
 		global $wpdb;
55 55
 
56 56
 		$values  = array();
57 57
 		$formats = array();
58 58
 
59 59
 		$fields = $this->database_fields_to_data_type;
60
-		unset( $fields['id'] );
60
+		unset($fields['id']);
61 61
 
62
-		foreach ( $fields as $key => $format ) {
62
+		foreach ($fields as $key => $format) {
63 63
 			$method     = "get_$key";
64
-			$values[]   = $subscription->$method( 'edit' );
64
+			$values[]   = $subscription->$method('edit');
65 65
 			$formats[]  = $format;
66 66
 		}
67 67
 
68
-		$result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $fields, $formats );
68
+		$result = $wpdb->insert($wpdb->prefix . 'wpinv_subscriptions', $fields, $formats);
69 69
 
70
-		if ( $result ) {
71
-			$subscription->set_id( $wpdb->insert_id );
70
+		if ($result) {
71
+			$subscription->set_id($wpdb->insert_id);
72 72
 			$subscription->apply_changes();
73 73
 			$subscription->clear_cache();
74
-			do_action( 'getpaid_new_subscription', $subscription );
74
+			do_action('getpaid_new_subscription', $subscription);
75 75
 			return true;
76 76
 		}
77 77
 
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 	 * @param WPInv_Subscription $subscription Subscription object.
85 85
 	 *
86 86
 	 */
87
-	public function read( &$subscription ) {
87
+	public function read(&$subscription) {
88 88
 		global $wpdb;
89 89
 
90 90
 		$subscription->set_defaults();
91 91
 
92
-		if ( ! $subscription->get_id() ) {
93
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
94
-			$subscription->set_id( 0 );
92
+		if (!$subscription->get_id()) {
93
+			$subscription->last_error = __('Invalid subscription ID.', 'invoicing');
94
+			$subscription->set_id(0);
95 95
 			return false;
96 96
 		}
97 97
 
98 98
 		// Maybe retrieve from the cache.
99
-		$raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
99
+		$raw_subscription = wp_cache_get($subscription->get_id(), 'getpaid_subscriptions');
100 100
 
101 101
 		// If not found, retrieve from the db.
102
-		if ( false === $raw_subscription ) {
102
+		if (false === $raw_subscription) {
103 103
 
104 104
 			$raw_subscription = $wpdb->get_row(
105 105
 				$wpdb->prepare(
@@ -109,22 +109,22 @@  discard block
 block discarded – undo
109 109
 			);
110 110
 
111 111
 			// Update the cache with our data
112
-			wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
112
+			wp_cache_set($subscription->get_id(), $raw_subscription, 'getpaid_subscriptions');
113 113
 
114 114
 		}
115 115
 
116
-		if ( ! $raw_subscription ) {
117
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
116
+		if (!$raw_subscription) {
117
+			$subscription->last_error = __('Invalid subscription ID.', 'invoicing');
118 118
 			return false;
119 119
 		}
120 120
 
121
-		foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
122
-			$method     = "set_$key";
123
-			$subscription->$method( $raw_subscription->$key );
121
+		foreach (array_keys($this->database_fields_to_data_type) as $key) {
122
+			$method = "set_$key";
123
+			$subscription->$method($raw_subscription->$key);
124 124
 		}
125 125
 
126
-		$subscription->set_object_read( true );
127
-		do_action( 'getpaid_read_subscription', $subscription );
126
+		$subscription->set_object_read(true);
127
+		do_action('getpaid_read_subscription', $subscription);
128 128
 
129 129
 	}
130 130
 
@@ -133,26 +133,26 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param WPInv_Subscription $subscription Subscription object.
135 135
 	 */
136
-	public function update( &$subscription ) {
136
+	public function update(&$subscription) {
137 137
 		global $wpdb;
138 138
 
139
-		if ( null === $subscription->get_date_created( 'edit' ) ) {
140
-			$subscription->set_date_created(  current_time('mysql') );
139
+		if (null === $subscription->get_date_created('edit')) {
140
+			$subscription->set_date_created(current_time('mysql'));
141 141
 		}
142 142
 
143 143
 		$changes = $subscription->get_changes();
144 144
 		$values  = array();
145 145
 		$format  = array();
146 146
 
147
-		foreach ( $this->database_fields_to_data_type as $key => $format ) {
148
-			if ( array_key_exists( $key, $changes ) ) {
147
+		foreach ($this->database_fields_to_data_type as $key => $format) {
148
+			if (array_key_exists($key, $changes)) {
149 149
 				$method     = "get_$key";
150
-				$values[]   = $subscription->$method( 'edit' );
150
+				$values[]   = $subscription->$method('edit');
151 151
 				$formats[]  = $format;
152 152
 			}
153 153
 		}
154 154
 
155
-		if ( empty( $values ) ) {
155
+		if (empty($values)) {
156 156
 			return;
157 157
 		}
158 158
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		$subscription->clear_cache();
173 173
 
174 174
 		// Fire a hook.
175
-		do_action( 'getpaid_update_subscription', $subscription->get_id(), $subscription );
175
+		do_action('getpaid_update_subscription', $subscription->get_id(), $subscription);
176 176
 
177 177
 	}
178 178
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @param WPInv_Subscription $subscription
183 183
 	 */
184
-	public function delete( &$subscription ) {
184
+	public function delete(&$subscription) {
185 185
 		global $wpdb;
186 186
 
187 187
 		$wpdb->query(
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 		$subscription->clear_cache();
197 197
 
198 198
 		// Fire a hook.
199
-		do_action( 'getpaid_delete_subscription', $subscription->get_id(), $subscription );
199
+		do_action('getpaid_delete_subscription', $subscription->get_id(), $subscription);
200 200
 
201
-		$subscription->set_id( 0 );
201
+		$subscription->set_id(0);
202 202
 	}
203 203
 
204 204
 	/*
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 2 patches
Indentation   +948 added lines, -948 removed lines patch added patch discarded remove patch
@@ -15,127 +15,127 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class WPInv_Subscription extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
23
-	protected $data_store_name = 'subscription';
24
-
25
-	/**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'subscription';
31
-
32
-	/**
33
-	 * Item Data array. This is the core item data exposed in APIs.
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array(
39
-		'customer_id'       => 0,
40
-		'frequency'         => 1,
41
-		'period'            => 'D',
42
-		'initial_amount'    => null,
43
-		'recurring_amount'  => null,
44
-		'bill_times'        => 0,
45
-		'transaction_id'    => '',
46
-		'parent_payment_id' => null,
47
-		'product_id'        => 0,
48
-		'created'           => '0000-00-00 00:00:00',
49
-		'expiration'        => '0000-00-00 00:00:00',
50
-		'trial_period'      => null,
51
-		'status'            => 'pending',
52
-		'profile_id'        => '',
53
-		'gateway'           => '',
54
-		'customer'          => '',
55
-	);
56
-
57
-	/**
58
-	 * Stores the status transition information.
59
-	 *
60
-	 * @since 1.0.19
61
-	 * @var bool
62
-	 */
63
-	protected $status_transition = false;
64
-
65
-	private $subs_db;
66
-
67
-	/**
68
-	 * Get the subscription if ID is passed, otherwise the subscription is new and empty.
69
-	 *
70
-	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
71
-	 * @param  bool $deprecated
72
-	 */
73
-	function __construct( $subscription = 0, $deprecated = false ) {
74
-
75
-		parent::__construct( $subscription );
76
-
77
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
78
-			$this->set_id( $subscription );
79
-		} elseif ( $subscription instanceof self ) {
80
-			$this->set_id( $subscription->get_id() );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
83
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
84
-			$this->set_id( $subscription_id );
85
-		} else {
86
-			$this->set_object_read( true );
87
-		}
88
-
89
-		// Load the datastore.
90
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
91
-
92
-		if ( $this->get_id() > 0 ) {
93
-			$this->data_store->read( $this );
94
-		}
95
-
96
-	}
97
-
98
-	/**
99
-	 * Given an invoice id, profile id, transaction id, it returns the subscription's id.
100
-	 *
101
-	 *
102
-	 * @static
103
-	 * @param string $value
104
-	 * @param string $field Either invoice_id, transaction_id or profile_id.
105
-	 * @since 1.0.19
106
-	 * @return int
107
-	 */
108
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23
+    protected $data_store_name = 'subscription';
24
+
25
+    /**
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'subscription';
31
+
32
+    /**
33
+     * Item Data array. This is the core item data exposed in APIs.
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array(
39
+        'customer_id'       => 0,
40
+        'frequency'         => 1,
41
+        'period'            => 'D',
42
+        'initial_amount'    => null,
43
+        'recurring_amount'  => null,
44
+        'bill_times'        => 0,
45
+        'transaction_id'    => '',
46
+        'parent_payment_id' => null,
47
+        'product_id'        => 0,
48
+        'created'           => '0000-00-00 00:00:00',
49
+        'expiration'        => '0000-00-00 00:00:00',
50
+        'trial_period'      => null,
51
+        'status'            => 'pending',
52
+        'profile_id'        => '',
53
+        'gateway'           => '',
54
+        'customer'          => '',
55
+    );
56
+
57
+    /**
58
+     * Stores the status transition information.
59
+     *
60
+     * @since 1.0.19
61
+     * @var bool
62
+     */
63
+    protected $status_transition = false;
64
+
65
+    private $subs_db;
66
+
67
+    /**
68
+     * Get the subscription if ID is passed, otherwise the subscription is new and empty.
69
+     *
70
+     * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
71
+     * @param  bool $deprecated
72
+     */
73
+    function __construct( $subscription = 0, $deprecated = false ) {
74
+
75
+        parent::__construct( $subscription );
76
+
77
+        if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
78
+            $this->set_id( $subscription );
79
+        } elseif ( $subscription instanceof self ) {
80
+            $this->set_id( $subscription->get_id() );
81
+        } elseif ( ! empty( $subscription->id ) ) {
82
+            $this->set_id( $subscription->id );
83
+        } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
84
+            $this->set_id( $subscription_id );
85
+        } else {
86
+            $this->set_object_read( true );
87
+        }
88
+
89
+        // Load the datastore.
90
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
91
+
92
+        if ( $this->get_id() > 0 ) {
93
+            $this->data_store->read( $this );
94
+        }
95
+
96
+    }
97
+
98
+    /**
99
+     * Given an invoice id, profile id, transaction id, it returns the subscription's id.
100
+     *
101
+     *
102
+     * @static
103
+     * @param string $value
104
+     * @param string $field Either invoice_id, transaction_id or profile_id.
105
+     * @since 1.0.19
106
+     * @return int
107
+     */
108
+    public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
109 109
         global $wpdb;
110 110
 
111
-		// Trim the value.
112
-		$value = trim( $value );
111
+        // Trim the value.
112
+        $value = trim( $value );
113 113
 
114
-		if ( empty( $value ) ) {
115
-			return 0;
116
-		}
114
+        if ( empty( $value ) ) {
115
+            return 0;
116
+        }
117 117
 
118
-		if ( 'invoice_id' == $field ) {
119
-			$field = 'parent_payment_id';
120
-		}
118
+        if ( 'invoice_id' == $field ) {
119
+            $field = 'parent_payment_id';
120
+        }
121 121
 
122 122
         // Valid fields.
123 123
         $fields = array(
124
-			'parent_payment_id',
125
-			'transaction_id',
126
-			'profile_id'
127
-		);
128
-
129
-		// Ensure a field has been passed.
130
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
131
-			return 0;
132
-		}
133
-
134
-		// Maybe retrieve from the cache.
135
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
136
-		if ( ! empty( $subscription_id ) ) {
137
-			return $subscription_id;
138
-		}
124
+            'parent_payment_id',
125
+            'transaction_id',
126
+            'profile_id'
127
+        );
128
+
129
+        // Ensure a field has been passed.
130
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
131
+            return 0;
132
+        }
133
+
134
+        // Maybe retrieve from the cache.
135
+        $subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
136
+        if ( ! empty( $subscription_id ) ) {
137
+            return $subscription_id;
138
+        }
139 139
 
140 140
         // Fetch from the db.
141 141
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
@@ -143,34 +143,34 @@  discard block
 block discarded – undo
143 143
             $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
144 144
         );
145 145
 
146
-		if ( empty( $subscription_id ) ) {
147
-			return 0;
148
-		}
146
+        if ( empty( $subscription_id ) ) {
147
+            return 0;
148
+        }
149 149
 
150
-		// Update the cache with our data.
151
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
150
+        // Update the cache with our data.
151
+        wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
152 152
 
153
-		return $subscription_id;
154
-	}
153
+        return $subscription_id;
154
+    }
155 155
 
156
-	/**
156
+    /**
157 157
      * Clears the subscription's cache.
158 158
      */
159 159
     public function clear_cache() {
160
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
162
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
163
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
164
-	}
160
+        wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
161
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
162
+        wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
163
+        wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
164
+    }
165 165
 
166
-	/**
166
+    /**
167 167
      * Checks if a subscription key is set.
168 168
      */
169 169
     public function _isset( $key ) {
170 170
         return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
171
-	}
171
+    }
172 172
 
173
-	/*
173
+    /*
174 174
 	|--------------------------------------------------------------------------
175 175
 	| CRUD methods
176 176
 	|--------------------------------------------------------------------------
@@ -179,57 +179,57 @@  discard block
 block discarded – undo
179 179
 	|
180 180
     */
181 181
 
182
-	/*
182
+    /*
183 183
 	|--------------------------------------------------------------------------
184 184
 	| Getters
185 185
 	|--------------------------------------------------------------------------
186 186
 	*/
187 187
 
188
-	/**
189
-	 * Get customer id.
190
-	 *
191
-	 * @since 1.0.19
192
-	 * @param  string $context View or edit context.
193
-	 * @return int
194
-	 */
195
-	public function get_customer_id( $context = 'view' ) {
196
-		return (int) $this->get_prop( 'customer_id', $context );
197
-	}
198
-
199
-	/**
200
-	 * Get customer information.
201
-	 *
202
-	 * @since 1.0.19
203
-	 * @param  string $context View or edit context.
204
-	 * @return WP_User|false WP_User object on success, false on failure.
205
-	 */
206
-	public function get_customer( $context = 'view' ) {
207
-		return get_userdata( $this->get_customer_id( $context ) );
208
-	}
209
-
210
-	/**
211
-	 * Get parent invoice id.
212
-	 *
213
-	 * @since 1.0.19
214
-	 * @param  string $context View or edit context.
215
-	 * @return int
216
-	 */
217
-	public function get_parent_invoice_id( $context = 'view' ) {
218
-		return (int) $this->get_prop( 'parent_payment_id', $context );
219
-	}
220
-
221
-	/**
222
-	 * Alias for self::get_parent_invoice_id().
223
-	 *
224
-	 * @since 1.0.19
225
-	 * @param  string $context View or edit context.
226
-	 * @return int
227
-	 */
188
+    /**
189
+     * Get customer id.
190
+     *
191
+     * @since 1.0.19
192
+     * @param  string $context View or edit context.
193
+     * @return int
194
+     */
195
+    public function get_customer_id( $context = 'view' ) {
196
+        return (int) $this->get_prop( 'customer_id', $context );
197
+    }
198
+
199
+    /**
200
+     * Get customer information.
201
+     *
202
+     * @since 1.0.19
203
+     * @param  string $context View or edit context.
204
+     * @return WP_User|false WP_User object on success, false on failure.
205
+     */
206
+    public function get_customer( $context = 'view' ) {
207
+        return get_userdata( $this->get_customer_id( $context ) );
208
+    }
209
+
210
+    /**
211
+     * Get parent invoice id.
212
+     *
213
+     * @since 1.0.19
214
+     * @param  string $context View or edit context.
215
+     * @return int
216
+     */
217
+    public function get_parent_invoice_id( $context = 'view' ) {
218
+        return (int) $this->get_prop( 'parent_payment_id', $context );
219
+    }
220
+
221
+    /**
222
+     * Alias for self::get_parent_invoice_id().
223
+     *
224
+     * @since 1.0.19
225
+     * @param  string $context View or edit context.
226
+     * @return int
227
+     */
228 228
     public function get_parent_payment_id( $context = 'view' ) {
229 229
         return $this->get_parent_invoice_id( $context );
230
-	}
230
+    }
231 231
 
232
-	/**
232
+    /**
233 233
      * Alias for self::get_parent_invoice_id().
234 234
      *
235 235
      * @since  1.0.0
@@ -239,390 +239,390 @@  discard block
 block discarded – undo
239 239
         return $this->get_parent_invoice_id( $context );
240 240
     }
241 241
 
242
-	/**
243
-	 * Get parent invoice.
244
-	 *
245
-	 * @since 1.0.19
246
-	 * @param  string $context View or edit context.
247
-	 * @return WPInv_Invoice
248
-	 */
249
-	public function get_parent_invoice( $context = 'view' ) {
250
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
251
-	}
252
-
253
-	/**
254
-	 * Alias for self::get_parent_invoice().
255
-	 *
256
-	 * @since 1.0.19
257
-	 * @param  string $context View or edit context.
258
-	 * @return WPInv_Invoice
259
-	 */
242
+    /**
243
+     * Get parent invoice.
244
+     *
245
+     * @since 1.0.19
246
+     * @param  string $context View or edit context.
247
+     * @return WPInv_Invoice
248
+     */
249
+    public function get_parent_invoice( $context = 'view' ) {
250
+        return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
251
+    }
252
+
253
+    /**
254
+     * Alias for self::get_parent_invoice().
255
+     *
256
+     * @since 1.0.19
257
+     * @param  string $context View or edit context.
258
+     * @return WPInv_Invoice
259
+     */
260 260
     public function get_parent_payment( $context = 'view' ) {
261 261
         return $this->get_parent_invoice( $context );
262
-	}
263
-
264
-	/**
265
-	 * Get subscription's product id.
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @param  string $context View or edit context.
269
-	 * @return int
270
-	 */
271
-	public function get_product_id( $context = 'view' ) {
272
-		return (int) $this->get_prop( 'product_id', $context );
273
-	}
274
-
275
-	/**
276
-	 * Get the subscription product.
277
-	 *
278
-	 * @since 1.0.19
279
-	 * @param  string $context View or edit context.
280
-	 * @return WPInv_Item
281
-	 */
282
-	public function get_product( $context = 'view' ) {
283
-		return new WPInv_Item( $this->get_product_id( $context ) );
284
-	}
285
-
286
-	/**
287
-	 * Get parent invoice's gateway.
288
-	 *
289
-	 * Here for backwards compatibility.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @param  string $context View or edit context.
293
-	 * @return string
294
-	 */
295
-	public function get_gateway( $context = 'view' ) {
296
-		return $this->get_parent_invoice( $context )->get_gateway();
297
-	}
298
-
299
-	/**
300
-	 * Get the period of a renewal.
301
-	 *
302
-	 * @since 1.0.19
303
-	 * @param  string $context View or edit context.
304
-	 * @return string
305
-	 */
306
-	public function get_period( $context = 'view' ) {
307
-		return $this->get_prop( 'period', $context );
308
-	}
309
-
310
-	/**
311
-	 * Get number of periods each renewal is valid for.
312
-	 *
313
-	 * @since 1.0.19
314
-	 * @param  string $context View or edit context.
315
-	 * @return int
316
-	 */
317
-	public function get_frequency( $context = 'view' ) {
318
-		return (int) $this->get_prop( 'frequency', $context );
319
-	}
320
-
321
-	/**
322
-	 * Get the initial amount for the subscription.
323
-	 *
324
-	 * @since 1.0.19
325
-	 * @param  string $context View or edit context.
326
-	 * @return float
327
-	 */
328
-	public function get_initial_amount( $context = 'view' ) {
329
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
330
-	}
331
-
332
-	/**
333
-	 * Get the recurring amount for the subscription.
334
-	 *
335
-	 * @since 1.0.19
336
-	 * @param  string $context View or edit context.
337
-	 * @return float
338
-	 */
339
-	public function get_recurring_amount( $context = 'view' ) {
340
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
341
-	}
342
-
343
-	/**
344
-	 * Get number of times that this subscription can be renewed.
345
-	 *
346
-	 * @since 1.0.19
347
-	 * @param  string $context View or edit context.
348
-	 * @return int
349
-	 */
350
-	public function get_bill_times( $context = 'view' ) {
351
-		return (int) $this->get_prop( 'bill_times', $context );
352
-	}
353
-
354
-	/**
355
-	 * Get transaction id of this subscription's parent invoice.
356
-	 *
357
-	 * @since 1.0.19
358
-	 * @param  string $context View or edit context.
359
-	 * @return string
360
-	 */
361
-	public function get_transaction_id( $context = 'view' ) {
362
-		return $this->get_prop( 'transaction_id', $context );
363
-	}
364
-
365
-	/**
366
-	 * Get the date that the subscription was created.
367
-	 *
368
-	 * @since 1.0.19
369
-	 * @param  string $context View or edit context.
370
-	 * @return string
371
-	 */
372
-	public function get_created( $context = 'view' ) {
373
-		return $this->get_prop( 'created', $context );
374
-	}
375
-
376
-	/**
377
-	 * Alias for self::get_created().
378
-	 *
379
-	 * @since 1.0.19
380
-	 * @param  string $context View or edit context.
381
-	 * @return string
382
-	 */
383
-	public function get_date_created( $context = 'view' ) {
384
-		return $this->get_created( $context );
385
-	}
386
-
387
-	/**
388
-	 * Retrieves the creation date in a timestamp
389
-	 *
390
-	 * @since  1.0.0
391
-	 * @return int
392
-	 */
393
-	public function get_time_created() {
394
-		$created = $this->get_date_created();
395
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
396
-	}
397
-
398
-	/**
399
-	 * Get GMT date when the subscription was created.
400
-	 *
401
-	 * @since 1.0.19
402
-	 * @param  string $context View or edit context.
403
-	 * @return string
404
-	 */
405
-	public function get_date_created_gmt( $context = 'view' ) {
262
+    }
263
+
264
+    /**
265
+     * Get subscription's product id.
266
+     *
267
+     * @since 1.0.19
268
+     * @param  string $context View or edit context.
269
+     * @return int
270
+     */
271
+    public function get_product_id( $context = 'view' ) {
272
+        return (int) $this->get_prop( 'product_id', $context );
273
+    }
274
+
275
+    /**
276
+     * Get the subscription product.
277
+     *
278
+     * @since 1.0.19
279
+     * @param  string $context View or edit context.
280
+     * @return WPInv_Item
281
+     */
282
+    public function get_product( $context = 'view' ) {
283
+        return new WPInv_Item( $this->get_product_id( $context ) );
284
+    }
285
+
286
+    /**
287
+     * Get parent invoice's gateway.
288
+     *
289
+     * Here for backwards compatibility.
290
+     *
291
+     * @since 1.0.19
292
+     * @param  string $context View or edit context.
293
+     * @return string
294
+     */
295
+    public function get_gateway( $context = 'view' ) {
296
+        return $this->get_parent_invoice( $context )->get_gateway();
297
+    }
298
+
299
+    /**
300
+     * Get the period of a renewal.
301
+     *
302
+     * @since 1.0.19
303
+     * @param  string $context View or edit context.
304
+     * @return string
305
+     */
306
+    public function get_period( $context = 'view' ) {
307
+        return $this->get_prop( 'period', $context );
308
+    }
309
+
310
+    /**
311
+     * Get number of periods each renewal is valid for.
312
+     *
313
+     * @since 1.0.19
314
+     * @param  string $context View or edit context.
315
+     * @return int
316
+     */
317
+    public function get_frequency( $context = 'view' ) {
318
+        return (int) $this->get_prop( 'frequency', $context );
319
+    }
320
+
321
+    /**
322
+     * Get the initial amount for the subscription.
323
+     *
324
+     * @since 1.0.19
325
+     * @param  string $context View or edit context.
326
+     * @return float
327
+     */
328
+    public function get_initial_amount( $context = 'view' ) {
329
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
330
+    }
331
+
332
+    /**
333
+     * Get the recurring amount for the subscription.
334
+     *
335
+     * @since 1.0.19
336
+     * @param  string $context View or edit context.
337
+     * @return float
338
+     */
339
+    public function get_recurring_amount( $context = 'view' ) {
340
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
341
+    }
342
+
343
+    /**
344
+     * Get number of times that this subscription can be renewed.
345
+     *
346
+     * @since 1.0.19
347
+     * @param  string $context View or edit context.
348
+     * @return int
349
+     */
350
+    public function get_bill_times( $context = 'view' ) {
351
+        return (int) $this->get_prop( 'bill_times', $context );
352
+    }
353
+
354
+    /**
355
+     * Get transaction id of this subscription's parent invoice.
356
+     *
357
+     * @since 1.0.19
358
+     * @param  string $context View or edit context.
359
+     * @return string
360
+     */
361
+    public function get_transaction_id( $context = 'view' ) {
362
+        return $this->get_prop( 'transaction_id', $context );
363
+    }
364
+
365
+    /**
366
+     * Get the date that the subscription was created.
367
+     *
368
+     * @since 1.0.19
369
+     * @param  string $context View or edit context.
370
+     * @return string
371
+     */
372
+    public function get_created( $context = 'view' ) {
373
+        return $this->get_prop( 'created', $context );
374
+    }
375
+
376
+    /**
377
+     * Alias for self::get_created().
378
+     *
379
+     * @since 1.0.19
380
+     * @param  string $context View or edit context.
381
+     * @return string
382
+     */
383
+    public function get_date_created( $context = 'view' ) {
384
+        return $this->get_created( $context );
385
+    }
386
+
387
+    /**
388
+     * Retrieves the creation date in a timestamp
389
+     *
390
+     * @since  1.0.0
391
+     * @return int
392
+     */
393
+    public function get_time_created() {
394
+        $created = $this->get_date_created();
395
+        return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
396
+    }
397
+
398
+    /**
399
+     * Get GMT date when the subscription was created.
400
+     *
401
+     * @since 1.0.19
402
+     * @param  string $context View or edit context.
403
+     * @return string
404
+     */
405
+    public function get_date_created_gmt( $context = 'view' ) {
406 406
         $date = $this->get_date_created( $context );
407 407
 
408 408
         if ( $date ) {
409 409
             $date = get_gmt_from_date( $date );
410 410
         }
411
-		return $date;
412
-	}
413
-
414
-	/**
415
-	 * Get the date that the subscription will renew.
416
-	 *
417
-	 * @since 1.0.19
418
-	 * @param  string $context View or edit context.
419
-	 * @return string
420
-	 */
421
-	public function get_next_renewal_date( $context = 'view' ) {
422
-		return $this->get_prop( 'expiration', $context );
423
-	}
424
-
425
-	/**
426
-	 * Alias for self::get_next_renewal_date().
427
-	 *
428
-	 * @since 1.0.19
429
-	 * @param  string $context View or edit context.
430
-	 * @return string
431
-	 */
432
-	public function get_expiration( $context = 'view' ) {
433
-		return $this->get_next_renewal_date( $context );
434
-	}
435
-
436
-	/**
437
-	 * Retrieves the expiration date in a timestamp
438
-	 *
439
-	 * @since  1.0.0
440
-	 * @return int
441
-	 */
442
-	public function get_expiration_time() {
443
-		$expiration = $this->get_expiration();
444
-
445
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
446
-			return current_time( 'timestamp' );
447
-		}
448
-
449
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
450
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
451
-	}
452
-
453
-	/**
454
-	 * Get GMT date when the subscription will renew.
455
-	 *
456
-	 * @since 1.0.19
457
-	 * @param  string $context View or edit context.
458
-	 * @return string
459
-	 */
460
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
411
+        return $date;
412
+    }
413
+
414
+    /**
415
+     * Get the date that the subscription will renew.
416
+     *
417
+     * @since 1.0.19
418
+     * @param  string $context View or edit context.
419
+     * @return string
420
+     */
421
+    public function get_next_renewal_date( $context = 'view' ) {
422
+        return $this->get_prop( 'expiration', $context );
423
+    }
424
+
425
+    /**
426
+     * Alias for self::get_next_renewal_date().
427
+     *
428
+     * @since 1.0.19
429
+     * @param  string $context View or edit context.
430
+     * @return string
431
+     */
432
+    public function get_expiration( $context = 'view' ) {
433
+        return $this->get_next_renewal_date( $context );
434
+    }
435
+
436
+    /**
437
+     * Retrieves the expiration date in a timestamp
438
+     *
439
+     * @since  1.0.0
440
+     * @return int
441
+     */
442
+    public function get_expiration_time() {
443
+        $expiration = $this->get_expiration();
444
+
445
+        if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
446
+            return current_time( 'timestamp' );
447
+        }
448
+
449
+        $expiration = strtotime( $expiration, current_time( 'timestamp' ) );
450
+        return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
451
+    }
452
+
453
+    /**
454
+     * Get GMT date when the subscription will renew.
455
+     *
456
+     * @since 1.0.19
457
+     * @param  string $context View or edit context.
458
+     * @return string
459
+     */
460
+    public function get_next_renewal_date_gmt( $context = 'view' ) {
461 461
         $date = $this->get_next_renewal_date( $context );
462 462
 
463 463
         if ( $date ) {
464 464
             $date = get_gmt_from_date( $date );
465 465
         }
466
-		return $date;
467
-	}
468
-
469
-	/**
470
-	 * Get the subscription's trial period.
471
-	 *
472
-	 * @since 1.0.19
473
-	 * @param  string $context View or edit context.
474
-	 * @return string
475
-	 */
476
-	public function get_trial_period( $context = 'view' ) {
477
-		return $this->get_prop( 'trial_period', $context );
478
-	}
479
-
480
-	/**
481
-	 * Get the subscription's status.
482
-	 *
483
-	 * @since 1.0.19
484
-	 * @param  string $context View or edit context.
485
-	 * @return string
486
-	 */
487
-	public function get_status( $context = 'view' ) {
488
-		return $this->get_prop( 'status', $context );
489
-	}
490
-
491
-	/**
492
-	 * Get the subscription's profile id.
493
-	 *
494
-	 * @since 1.0.19
495
-	 * @param  string $context View or edit context.
496
-	 * @return string
497
-	 */
498
-	public function get_profile_id( $context = 'view' ) {
499
-		return $this->get_prop( 'profile_id', $context );
500
-	}
501
-
502
-	/*
466
+        return $date;
467
+    }
468
+
469
+    /**
470
+     * Get the subscription's trial period.
471
+     *
472
+     * @since 1.0.19
473
+     * @param  string $context View or edit context.
474
+     * @return string
475
+     */
476
+    public function get_trial_period( $context = 'view' ) {
477
+        return $this->get_prop( 'trial_period', $context );
478
+    }
479
+
480
+    /**
481
+     * Get the subscription's status.
482
+     *
483
+     * @since 1.0.19
484
+     * @param  string $context View or edit context.
485
+     * @return string
486
+     */
487
+    public function get_status( $context = 'view' ) {
488
+        return $this->get_prop( 'status', $context );
489
+    }
490
+
491
+    /**
492
+     * Get the subscription's profile id.
493
+     *
494
+     * @since 1.0.19
495
+     * @param  string $context View or edit context.
496
+     * @return string
497
+     */
498
+    public function get_profile_id( $context = 'view' ) {
499
+        return $this->get_prop( 'profile_id', $context );
500
+    }
501
+
502
+    /*
503 503
 	|--------------------------------------------------------------------------
504 504
 	| Setters
505 505
 	|--------------------------------------------------------------------------
506 506
 	*/
507 507
 
508
-	/**
509
-	 * Set customer id.
510
-	 *
511
-	 * @since 1.0.19
512
-	 * @param  int $value The customer's id.
513
-	 */
514
-	public function set_customer_id( $value ) {
515
-		$this->set_prop( 'customer_id', (int) $value );
516
-	}
517
-
518
-	/**
519
-	 * Set parent invoice id.
520
-	 *
521
-	 * @since 1.0.19
522
-	 * @param  int $value The parent invoice id.
523
-	 */
524
-	public function set_parent_invoice_id( $value ) {
525
-		$this->set_prop( 'parent_payment_id', (int) $value );
526
-	}
527
-
528
-	/**
529
-	 * Alias for self::set_parent_invoice_id().
530
-	 *
531
-	 * @since 1.0.19
532
-	 * @param  int $value The parent invoice id.
533
-	 */
508
+    /**
509
+     * Set customer id.
510
+     *
511
+     * @since 1.0.19
512
+     * @param  int $value The customer's id.
513
+     */
514
+    public function set_customer_id( $value ) {
515
+        $this->set_prop( 'customer_id', (int) $value );
516
+    }
517
+
518
+    /**
519
+     * Set parent invoice id.
520
+     *
521
+     * @since 1.0.19
522
+     * @param  int $value The parent invoice id.
523
+     */
524
+    public function set_parent_invoice_id( $value ) {
525
+        $this->set_prop( 'parent_payment_id', (int) $value );
526
+    }
527
+
528
+    /**
529
+     * Alias for self::set_parent_invoice_id().
530
+     *
531
+     * @since 1.0.19
532
+     * @param  int $value The parent invoice id.
533
+     */
534 534
     public function set_parent_payment_id( $value ) {
535 535
         $this->set_parent_invoice_id( $value );
536
-	}
536
+    }
537 537
 
538
-	/**
538
+    /**
539 539
      * Alias for self::set_parent_invoice_id().
540 540
      *
541 541
      * @since 1.0.19
542
-	 * @param  int $value The parent invoice id.
542
+     * @param  int $value The parent invoice id.
543 543
      */
544 544
     public function set_original_payment_id( $value ) {
545 545
         $this->set_parent_invoice_id( $value );
546
-	}
547
-
548
-	/**
549
-	 * Set subscription's product id.
550
-	 *
551
-	 * @since 1.0.19
552
-	 * @param  int $value The subscription product id.
553
-	 */
554
-	public function set_product_id( $value ) {
555
-		$this->set_prop( 'product_id', (int) $value );
556
-	}
557
-
558
-	/**
559
-	 * Set the period of a renewal.
560
-	 *
561
-	 * @since 1.0.19
562
-	 * @param  string $value The renewal period.
563
-	 */
564
-	public function set_period( $value ) {
565
-		$this->set_prop( 'period', $value );
566
-	}
567
-
568
-	/**
569
-	 * Set number of periods each renewal is valid for.
570
-	 *
571
-	 * @since 1.0.19
572
-	 * @param  int $value The subscription frequency.
573
-	 */
574
-	public function set_frequency( $value ) {
575
-		$value = empty( $value ) ? 1 : (int) $value;
576
-		$this->set_prop( 'frequency', absint( $value ) );
577
-	}
578
-
579
-	/**
580
-	 * Set the initial amount for the subscription.
581
-	 *
582
-	 * @since 1.0.19
583
-	 * @param  float $value The initial subcription amount.
584
-	 */
585
-	public function set_initial_amount( $value ) {
586
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
587
-	}
588
-
589
-	/**
590
-	 * Set the recurring amount for the subscription.
591
-	 *
592
-	 * @since 1.0.19
593
-	 * @param  float $value The recurring subcription amount.
594
-	 */
595
-	public function set_recurring_amount( $value ) {
596
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
597
-	}
598
-
599
-	/**
600
-	 * Set number of times that this subscription can be renewed.
601
-	 *
602
-	 * @since 1.0.19
603
-	 * @param  int $value Bill times.
604
-	 */
605
-	public function set_bill_times( $value ) {
606
-		$this->set_prop( 'bill_times', (int) $value );
607
-	}
608
-
609
-	/**
610
-	 * Get transaction id of this subscription's parent invoice.
611
-	 *
612
-	 * @since 1.0.19
613
-	 * @param string $value Bill times.
614
-	 */
615
-	public function set_transaction_id( $value ) {
616
-		$this->set_prop( 'transaction_id', $value );
617
-	}
618
-
619
-	/**
620
-	 * Set date when this subscription started.
621
-	 *
622
-	 * @since 1.0.19
623
-	 * @param string $value strtotime compliant date.
624
-	 */
625
-	public function set_created( $value ) {
546
+    }
547
+
548
+    /**
549
+     * Set subscription's product id.
550
+     *
551
+     * @since 1.0.19
552
+     * @param  int $value The subscription product id.
553
+     */
554
+    public function set_product_id( $value ) {
555
+        $this->set_prop( 'product_id', (int) $value );
556
+    }
557
+
558
+    /**
559
+     * Set the period of a renewal.
560
+     *
561
+     * @since 1.0.19
562
+     * @param  string $value The renewal period.
563
+     */
564
+    public function set_period( $value ) {
565
+        $this->set_prop( 'period', $value );
566
+    }
567
+
568
+    /**
569
+     * Set number of periods each renewal is valid for.
570
+     *
571
+     * @since 1.0.19
572
+     * @param  int $value The subscription frequency.
573
+     */
574
+    public function set_frequency( $value ) {
575
+        $value = empty( $value ) ? 1 : (int) $value;
576
+        $this->set_prop( 'frequency', absint( $value ) );
577
+    }
578
+
579
+    /**
580
+     * Set the initial amount for the subscription.
581
+     *
582
+     * @since 1.0.19
583
+     * @param  float $value The initial subcription amount.
584
+     */
585
+    public function set_initial_amount( $value ) {
586
+        $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
587
+    }
588
+
589
+    /**
590
+     * Set the recurring amount for the subscription.
591
+     *
592
+     * @since 1.0.19
593
+     * @param  float $value The recurring subcription amount.
594
+     */
595
+    public function set_recurring_amount( $value ) {
596
+        $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
597
+    }
598
+
599
+    /**
600
+     * Set number of times that this subscription can be renewed.
601
+     *
602
+     * @since 1.0.19
603
+     * @param  int $value Bill times.
604
+     */
605
+    public function set_bill_times( $value ) {
606
+        $this->set_prop( 'bill_times', (int) $value );
607
+    }
608
+
609
+    /**
610
+     * Get transaction id of this subscription's parent invoice.
611
+     *
612
+     * @since 1.0.19
613
+     * @param string $value Bill times.
614
+     */
615
+    public function set_transaction_id( $value ) {
616
+        $this->set_prop( 'transaction_id', $value );
617
+    }
618
+
619
+    /**
620
+     * Set date when this subscription started.
621
+     *
622
+     * @since 1.0.19
623
+     * @param string $value strtotime compliant date.
624
+     */
625
+    public function set_created( $value ) {
626 626
         $date = strtotime( $value );
627 627
 
628 628
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -630,94 +630,94 @@  discard block
 block discarded – undo
630 630
             return;
631 631
         }
632 632
 
633
-		$this->set_prop( 'created', '' );
633
+        $this->set_prop( 'created', '' );
634 634
 
635
-	}
635
+    }
636 636
 
637
-	/**
638
-	 * Alias for self::set_created().
639
-	 *
640
-	 * @since 1.0.19
641
-	 * @param string $value strtotime compliant date.
642
-	 */
643
-	public function set_date_created( $value ) {
644
-		$this->set_created( $value );
637
+    /**
638
+     * Alias for self::set_created().
639
+     *
640
+     * @since 1.0.19
641
+     * @param string $value strtotime compliant date.
642
+     */
643
+    public function set_date_created( $value ) {
644
+        $this->set_created( $value );
645 645
     }
646 646
 
647
-	/**
648
-	 * Set the date that the subscription will renew.
649
-	 *
650
-	 * @since 1.0.19
651
-	 * @param string $value strtotime compliant date.
652
-	 */
653
-	public function set_next_renewal_date( $value ) {
654
-		$date = strtotime( $value );
647
+    /**
648
+     * Set the date that the subscription will renew.
649
+     *
650
+     * @since 1.0.19
651
+     * @param string $value strtotime compliant date.
652
+     */
653
+    public function set_next_renewal_date( $value ) {
654
+        $date = strtotime( $value );
655 655
 
656 656
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
657 657
             $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
658 658
             return;
659
-		}
660
-
661
-		$this->set_prop( 'expiration', '' );
662
-
663
-	}
664
-
665
-	/**
666
-	 * Alias for self::set_next_renewal_date().
667
-	 *
668
-	 * @since 1.0.19
669
-	 * @param string $value strtotime compliant date.
670
-	 */
671
-	public function set_expiration( $value ) {
672
-		$this->set_next_renewal_date( $value );
673
-    }
674
-
675
-	/**
676
-	 * Set the subscription's trial period.
677
-	 *
678
-	 * @since 1.0.19
679
-	 * @param string $value trial period e.g 1 year.
680
-	 */
681
-	public function set_trial_period( $value ) {
682
-		$this->set_prop( 'trial_period', $value );
683
-	}
684
-
685
-	/**
686
-	 * Set the subscription's status.
687
-	 *
688
-	 * @since 1.0.19
689
-	 * @param string $new_status    New subscription status.
690
-	 */
691
-	public function set_status( $new_status ) {
692
-
693
-		// Abort if this is not a valid status;
694
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
695
-			return;
696
-		}
697
-
698
-		$old_status = $this->get_status();
699
-		$this->set_prop( 'status', $new_status );
700
-
701
-		if ( true === $this->object_read && $old_status !== $new_status ) {
702
-			$this->status_transition = array(
703
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
704
-				'to'     => $new_status,
705
-			);
706
-		}
707
-
708
-	}
709
-
710
-	/**
711
-	 * Set the subscription's (remote) profile id.
712
-	 *
713
-	 * @since 1.0.19
714
-	 * @param  string $value the remote profile id.
715
-	 */
716
-	public function set_profile_id( $value ) {
717
-		$this->set_prop( 'profile_id', $value );
718
-	}
719
-
720
-	/*
659
+        }
660
+
661
+        $this->set_prop( 'expiration', '' );
662
+
663
+    }
664
+
665
+    /**
666
+     * Alias for self::set_next_renewal_date().
667
+     *
668
+     * @since 1.0.19
669
+     * @param string $value strtotime compliant date.
670
+     */
671
+    public function set_expiration( $value ) {
672
+        $this->set_next_renewal_date( $value );
673
+    }
674
+
675
+    /**
676
+     * Set the subscription's trial period.
677
+     *
678
+     * @since 1.0.19
679
+     * @param string $value trial period e.g 1 year.
680
+     */
681
+    public function set_trial_period( $value ) {
682
+        $this->set_prop( 'trial_period', $value );
683
+    }
684
+
685
+    /**
686
+     * Set the subscription's status.
687
+     *
688
+     * @since 1.0.19
689
+     * @param string $new_status    New subscription status.
690
+     */
691
+    public function set_status( $new_status ) {
692
+
693
+        // Abort if this is not a valid status;
694
+        if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
695
+            return;
696
+        }
697
+
698
+        $old_status = $this->get_status();
699
+        $this->set_prop( 'status', $new_status );
700
+
701
+        if ( true === $this->object_read && $old_status !== $new_status ) {
702
+            $this->status_transition = array(
703
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
704
+                'to'     => $new_status,
705
+            );
706
+        }
707
+
708
+    }
709
+
710
+    /**
711
+     * Set the subscription's (remote) profile id.
712
+     *
713
+     * @since 1.0.19
714
+     * @param  string $value the remote profile id.
715
+     */
716
+    public function set_profile_id( $value ) {
717
+        $this->set_prop( 'profile_id', $value );
718
+    }
719
+
720
+    /*
721 721
 	|--------------------------------------------------------------------------
722 722
 	| Boolean methods
723 723
 	|--------------------------------------------------------------------------
@@ -726,45 +726,45 @@  discard block
 block discarded – undo
726 726
 	|
727 727
 	*/
728 728
 
729
-	/**
729
+    /**
730 730
      * Checks if the subscription has a given status.
731
-	 *
732
-	 * @param string|array String or array of strings to check for.
733
-	 * @return bool
731
+     *
732
+     * @param string|array String or array of strings to check for.
733
+     * @return bool
734 734
      */
735 735
     public function has_status( $status ) {
736 736
         return in_array( $this->get_status(), wpinv_parse_list( $status ) );
737
-	}
737
+    }
738 738
 
739
-	/**
739
+    /**
740 740
      * Checks if the subscription has a trial period.
741
-	 *
742
-	 * @return bool
741
+     *
742
+     * @return bool
743 743
      */
744 744
     public function has_trial_period() {
745
-		$period = $this->get_trial_period();
745
+        $period = $this->get_trial_period();
746 746
         return ! empty( $period );
747
-	}
748
-
749
-	/**
750
-	 * Is the subscription active?
751
-	 *
752
-	 * @return bool
753
-	 */
754
-	public function is_active() {
755
-		return $this->has_status( 'active trialling' ) && $this->get_expiration_time() > current_time( 'mysql' );
756
-	}
757
-
758
-	/**
759
-	 * Is the subscription expired?
760
-	 *
761
-	 * @return bool
762
-	 */
763
-	public function is_expired() {
764
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
765
-	}
766
-
767
-	/*
747
+    }
748
+
749
+    /**
750
+     * Is the subscription active?
751
+     *
752
+     * @return bool
753
+     */
754
+    public function is_active() {
755
+        return $this->has_status( 'active trialling' ) && $this->get_expiration_time() > current_time( 'mysql' );
756
+    }
757
+
758
+    /**
759
+     * Is the subscription expired?
760
+     *
761
+     * @return bool
762
+     */
763
+    public function is_expired() {
764
+        return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
765
+    }
766
+
767
+    /*
768 768
 	|--------------------------------------------------------------------------
769 769
 	| Additional methods
770 770
 	|--------------------------------------------------------------------------
@@ -773,27 +773,27 @@  discard block
 block discarded – undo
773 773
 	|
774 774
 	*/
775 775
 
776
-	/**
777
-	 * Backwards compatibilty.
778
-	 */
779
-	public function create( $data = array() ) {
776
+    /**
777
+     * Backwards compatibilty.
778
+     */
779
+    public function create( $data = array() ) {
780 780
 
781
-		// Set the properties.
782
-		if ( is_array( $data ) ) {
783
-			$this->set_props( $data );
784
-		}
781
+        // Set the properties.
782
+        if ( is_array( $data ) ) {
783
+            $this->set_props( $data );
784
+        }
785 785
 
786
-		// Save the item.
787
-		return $this->save();
786
+        // Save the item.
787
+        return $this->save();
788 788
 
789
-	}
789
+    }
790 790
 
791
-	/**
792
-	 * Backwards compatibilty.
793
-	 */
794
-	public function update( $args = array() ) {
795
-		return $this->create( $args );
796
-	}
791
+    /**
792
+     * Backwards compatibilty.
793
+     */
794
+    public function update( $args = array() ) {
795
+        return $this->create( $args );
796
+    }
797 797
 
798 798
     /**
799 799
      * Retrieve renewal payments for a subscription
@@ -803,15 +803,15 @@  discard block
 block discarded – undo
803 803
      */
804 804
     public function get_child_payments() {
805 805
         return get_posts(
806
-			array(
807
-            	'post_parent'    => $this->get_parent_payment_id(),
808
-            	'numberposts'    => -1,
809
-            	'post_status'    => array( 'publish', 'wpi-processing', 'wpi-renewal' ),
810
-            	'orderby'        => 'ID',
811
-            	'order'          => 'DESC',
812
-            	'post_type'      => 'wpi_invoice'
813
-			)
814
-		);
806
+            array(
807
+                'post_parent'    => $this->get_parent_payment_id(),
808
+                'numberposts'    => -1,
809
+                'post_status'    => array( 'publish', 'wpi-processing', 'wpi-renewal' ),
810
+                'orderby'        => 'ID',
811
+                'order'          => 'DESC',
812
+                'post_type'      => 'wpi_invoice'
813
+            )
814
+        );
815 815
     }
816 816
 
817 817
     /**
@@ -821,16 +821,16 @@  discard block
 block discarded – undo
821 821
      * @return int
822 822
      */
823 823
     public function get_total_payments() {
824
-		global $wpdb;
824
+        global $wpdb;
825 825
 
826
-		$count = $wpdb->get_var(
827
-			$wpdb->prepare(
828
-				"SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent=%d AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
829
-				$this->get_parent_invoice_id()
830
-			)
831
-		);
826
+        $count = $wpdb->get_var(
827
+            $wpdb->prepare(
828
+                "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent=%d AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
829
+                $this->get_parent_invoice_id()
830
+            )
831
+        );
832 832
 
833
-		// Maybe include parent invoice.
833
+        // Maybe include parent invoice.
834 834
         if ( ! $this->has_status( 'pending' ) ) {
835 835
             $count++;
836 836
         }
@@ -859,57 +859,57 @@  discard block
 block discarded – undo
859 859
      *
860 860
      * @since  2.4
861 861
      * @param  array $args Array of values for the payment, including amount and transaction ID
862
-	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
862
+     * @param  WPInv_Invoice $invoice If adding an existing invoice.
863 863
      * @return bool
864 864
      */
865 865
     public function add_payment( $args = array(), $invoice = false ) {
866 866
 
867
-		// Process each payment once.
867
+        // Process each payment once.
868 868
         if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
869 869
             return false;
870 870
         }
871 871
 
872
-		// Are we creating a new invoice?
873
-		if ( empty( $invoice ) ) {
874
-			$invoice = $this->create_payment();
872
+        // Are we creating a new invoice?
873
+        if ( empty( $invoice ) ) {
874
+            $invoice = $this->create_payment();
875 875
 
876
-			if ( empty( $invoice ) ) {
877
-				return false;
878
-			}
876
+            if ( empty( $invoice ) ) {
877
+                return false;
878
+            }
879 879
 
880
-			$invoice->set_status( 'wpi-renewal' );
880
+            $invoice->set_status( 'wpi-renewal' );
881 881
 
882
-		}
882
+        }
883 883
 
884
-		// Maybe set a transaction id.
885
-		if ( ! empty( $args['transaction_id'] ) ) {
886
-			$invoice->set_transaction_id( $args['transaction_id'] );
887
-		}
884
+        // Maybe set a transaction id.
885
+        if ( ! empty( $args['transaction_id'] ) ) {
886
+            $invoice->set_transaction_id( $args['transaction_id'] );
887
+        }
888 888
 
889
-		// Set the completed date.
890
-		$invoice->set_completed_date( current_time( 'mysql' ) );
889
+        // Set the completed date.
890
+        $invoice->set_completed_date( current_time( 'mysql' ) );
891 891
 
892
-		// And the gateway.
893
-		if ( ! empty( $args['gateway'] ) ) {
894
-			$invoice->set_gateway( $args['gateway'] );
895
-		}
892
+        // And the gateway.
893
+        if ( ! empty( $args['gateway'] ) ) {
894
+            $invoice->set_gateway( $args['gateway'] );
895
+        }
896 896
 
897
-		$invoice->save();
897
+        $invoice->save();
898 898
 
899
-		if ( ! $invoice->get_id() ) {
900
-			return 0;
901
-		}
899
+        if ( ! $invoice->get_id() ) {
900
+            return 0;
901
+        }
902 902
 
903
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
904
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
903
+        do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
904
+        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
905 905
         do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
906 906
 
907 907
         update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
908 908
 
909 909
         return $invoice->get_id();
910
-	}
910
+    }
911 911
 
912
-	/**
912
+    /**
913 913
      * Creates a new invoice and returns it.
914 914
      *
915 915
      * @since  1.0.19
@@ -917,103 +917,103 @@  discard block
 block discarded – undo
917 917
      */
918 918
     public function create_payment() {
919 919
 
920
-		$parent_invoice = $this->get_parent_payment();
921
-
922
-		if ( ! $parent_invoice->get_id() ) {
923
-			return false;
924
-		}
925
-
926
-		// Duplicate the parent invoice.
927
-		$invoice = new WPInv_Invoice();
928
-		$invoice->set_props( $parent_invoice->get_data() );
929
-		$invoice->set_id( 0 );
930
-		$invoice->set_parent_id( $parent_invoice->get_id() );
931
-		$invoice->set_transaction_id( '' );
932
-		$invoice->set_key( $invoice->generate_key( 'renewal_' ) );
933
-		$invoice->set_number( '' );
934
-		$invoice->set_completed_date( '' );
935
-		$invoice->set_status( 'wpi-pending' );
936
-		$invoice->recalculate_total();
937
-		$invoice->save();
938
-
939
-		return $invoice->get_id() ? $invoice : false;
940
-    }
941
-
942
-	/**
943
-	 * Renews or completes a subscription
944
-	 *
945
-	 * @since  1.0.0
946
-	 * @return int The subscription's id
947
-	 */
948
-	public function renew() {
949
-
950
-		// Complete subscription if applicable
951
-		if ( $this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times() ) {
952
-			return $this->complete();
953
-		}
954
-
955
-		// Calculate new expiration
956
-		$frequency      = $this->get_frequency();
957
-		$period         = $this->get_period();
958
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
959
-
960
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
961
-		$this->set_status( 'active' );
962
-		return $this->save();
963
-
964
-		do_action( 'getpaid_subscription_renewed', $this );
965
-
966
-	}
967
-
968
-	/**
969
-	 * Marks a subscription as completed
970
-	 *
971
-	 * Subscription is completed when the number of payments matches the billing_times field
972
-	 *
973
-	 * @since  1.0.0
974
-	 * @return int|bool Subscription id or false if the subscription is cancelled.
975
-	 */
976
-	public function complete() {
977
-
978
-		// Only mark a subscription as complete if it's not already cancelled.
979
-		if ( $this->has_status( 'cancelled' ) ) {
980
-			return false;
981
-		}
982
-
983
-		$this->set_status( 'completed' );
984
-		return $this->save();
985
-
986
-	}
987
-
988
-	/**
989
-	 * Marks a subscription as expired
990
-	 *
991
-	 * @since  1.0.0
992
-	 * @param  bool $check_expiration
993
-	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
994
-	 */
995
-	public function expire( $check_expiration = false ) {
996
-
997
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
998
-			// Do not mark as expired since real expiration date is in the future
999
-			return false;
1000
-		}
1001
-
1002
-		$this->set_status( 'expired' );
1003
-		return $this->save();
1004
-
1005
-	}
1006
-
1007
-	/**
1008
-	 * Marks a subscription as failing
1009
-	 *
1010
-	 * @since  2.4.2
1011
-	 * @return int Subscription id.
1012
-	 */
1013
-	public function failing() {
1014
-		$this->set_status( 'failing' );
1015
-		return $this->save();
1016
-	}
920
+        $parent_invoice = $this->get_parent_payment();
921
+
922
+        if ( ! $parent_invoice->get_id() ) {
923
+            return false;
924
+        }
925
+
926
+        // Duplicate the parent invoice.
927
+        $invoice = new WPInv_Invoice();
928
+        $invoice->set_props( $parent_invoice->get_data() );
929
+        $invoice->set_id( 0 );
930
+        $invoice->set_parent_id( $parent_invoice->get_id() );
931
+        $invoice->set_transaction_id( '' );
932
+        $invoice->set_key( $invoice->generate_key( 'renewal_' ) );
933
+        $invoice->set_number( '' );
934
+        $invoice->set_completed_date( '' );
935
+        $invoice->set_status( 'wpi-pending' );
936
+        $invoice->recalculate_total();
937
+        $invoice->save();
938
+
939
+        return $invoice->get_id() ? $invoice : false;
940
+    }
941
+
942
+    /**
943
+     * Renews or completes a subscription
944
+     *
945
+     * @since  1.0.0
946
+     * @return int The subscription's id
947
+     */
948
+    public function renew() {
949
+
950
+        // Complete subscription if applicable
951
+        if ( $this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times() ) {
952
+            return $this->complete();
953
+        }
954
+
955
+        // Calculate new expiration
956
+        $frequency      = $this->get_frequency();
957
+        $period         = $this->get_period();
958
+        $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
959
+
960
+        $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
961
+        $this->set_status( 'active' );
962
+        return $this->save();
963
+
964
+        do_action( 'getpaid_subscription_renewed', $this );
965
+
966
+    }
967
+
968
+    /**
969
+     * Marks a subscription as completed
970
+     *
971
+     * Subscription is completed when the number of payments matches the billing_times field
972
+     *
973
+     * @since  1.0.0
974
+     * @return int|bool Subscription id or false if the subscription is cancelled.
975
+     */
976
+    public function complete() {
977
+
978
+        // Only mark a subscription as complete if it's not already cancelled.
979
+        if ( $this->has_status( 'cancelled' ) ) {
980
+            return false;
981
+        }
982
+
983
+        $this->set_status( 'completed' );
984
+        return $this->save();
985
+
986
+    }
987
+
988
+    /**
989
+     * Marks a subscription as expired
990
+     *
991
+     * @since  1.0.0
992
+     * @param  bool $check_expiration
993
+     * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
994
+     */
995
+    public function expire( $check_expiration = false ) {
996
+
997
+        if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
998
+            // Do not mark as expired since real expiration date is in the future
999
+            return false;
1000
+        }
1001
+
1002
+        $this->set_status( 'expired' );
1003
+        return $this->save();
1004
+
1005
+    }
1006
+
1007
+    /**
1008
+     * Marks a subscription as failing
1009
+     *
1010
+     * @since  2.4.2
1011
+     * @return int Subscription id.
1012
+     */
1013
+    public function failing() {
1014
+        $this->set_status( 'failing' );
1015
+        return $this->save();
1016
+    }
1017 1017
 
1018 1018
     /**
1019 1019
      * Marks a subscription as cancelled
@@ -1022,19 +1022,19 @@  discard block
 block discarded – undo
1022 1022
      * @return int Subscription id.
1023 1023
      */
1024 1024
     public function cancel() {
1025
-		$this->set_status( 'cancelled' );
1026
-		return $this->save();
1025
+        $this->set_status( 'cancelled' );
1026
+        return $this->save();
1027 1027
     }
1028 1028
 
1029
-	/**
1030
-	 * Determines if a subscription can be cancelled both locally and with a payment processor.
1031
-	 *
1032
-	 * @since  1.0.0
1033
-	 * @return bool
1034
-	 */
1035
-	public function can_cancel() {
1036
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1037
-	}
1029
+    /**
1030
+     * Determines if a subscription can be cancelled both locally and with a payment processor.
1031
+     *
1032
+     * @since  1.0.0
1033
+     * @return bool
1034
+     */
1035
+    public function can_cancel() {
1036
+        return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1037
+    }
1038 1038
 
1039 1039
     /**
1040 1040
      * Returns an array of subscription statuses that can be cancelled
@@ -1047,82 +1047,82 @@  discard block
 block discarded – undo
1047 1047
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1048 1048
     }
1049 1049
 
1050
-	/**
1051
-	 * Retrieves the URL to cancel subscription
1052
-	 *
1053
-	 * @since  1.0.0
1054
-	 * @return string
1055
-	 */
1056
-	public function get_cancel_url() {
1057
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->get_id() ) ), 'wpinv-recurring-cancel' );
1058
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1059
-	}
1060
-
1061
-	/**
1062
-	 * Determines if subscription can be manually renewed
1063
-	 *
1064
-	 * This method is filtered by payment gateways in order to return true on subscriptions
1065
-	 * that can be renewed manually
1066
-	 *
1067
-	 * @since  2.5
1068
-	 * @return bool
1069
-	 */
1070
-	public function can_renew() {
1071
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1072
-	}
1073
-
1074
-	/**
1075
-	 * Retrieves the URL to renew a subscription
1076
-	 *
1077
-	 * @since  2.5
1078
-	 * @return string
1079
-	 */
1080
-	public function get_renew_url() {
1081
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'wpinv-recurring-renew' );
1082
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1083
-	}
1084
-
1085
-	/**
1086
-	 * Determines if subscription can have their payment method updated
1087
-	 *
1088
-	 * @since  1.0.0
1089
-	 * @return bool
1090
-	 */
1091
-	public function can_update() {
1092
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1093
-	}
1094
-
1095
-	/**
1096
-	 * Retrieves the URL to update subscription
1097
-	 *
1098
-	 * @since  1.0.0
1099
-	 * @return string
1100
-	 */
1101
-	public function get_update_url() {
1102
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1103
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1104
-	}
1105
-
1106
-	/**
1107
-	 * Retrieves the subscription status label
1108
-	 *
1109
-	 * @since  1.0.0
1110
-	 * @return string
1111
-	 */
1112
-	public function get_status_label() {
1113
-		return getpaid_get_subscription_status_label( $this->get_status() );
1114
-	}
1115
-
1116
-	/**
1117
-	 * Retrieves the subscription status class
1118
-	 *
1119
-	 * @since  1.0.19
1120
-	 * @return string
1121
-	 */
1122
-	public function get_status_class() {
1123
-		$statuses = getpaid_get_subscription_status_classes();
1124
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary';
1125
-	}
1050
+    /**
1051
+     * Retrieves the URL to cancel subscription
1052
+     *
1053
+     * @since  1.0.0
1054
+     * @return string
1055
+     */
1056
+    public function get_cancel_url() {
1057
+        $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->get_id() ) ), 'wpinv-recurring-cancel' );
1058
+        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1059
+    }
1060
+
1061
+    /**
1062
+     * Determines if subscription can be manually renewed
1063
+     *
1064
+     * This method is filtered by payment gateways in order to return true on subscriptions
1065
+     * that can be renewed manually
1066
+     *
1067
+     * @since  2.5
1068
+     * @return bool
1069
+     */
1070
+    public function can_renew() {
1071
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1072
+    }
1073
+
1074
+    /**
1075
+     * Retrieves the URL to renew a subscription
1076
+     *
1077
+     * @since  2.5
1078
+     * @return string
1079
+     */
1080
+    public function get_renew_url() {
1081
+        $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'wpinv-recurring-renew' );
1082
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1083
+    }
1084
+
1085
+    /**
1086
+     * Determines if subscription can have their payment method updated
1087
+     *
1088
+     * @since  1.0.0
1089
+     * @return bool
1090
+     */
1091
+    public function can_update() {
1092
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
1093
+    }
1094
+
1095
+    /**
1096
+     * Retrieves the URL to update subscription
1097
+     *
1098
+     * @since  1.0.0
1099
+     * @return string
1100
+     */
1101
+    public function get_update_url() {
1102
+        $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1103
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1104
+    }
1105
+
1106
+    /**
1107
+     * Retrieves the subscription status label
1108
+     *
1109
+     * @since  1.0.0
1110
+     * @return string
1111
+     */
1112
+    public function get_status_label() {
1113
+        return getpaid_get_subscription_status_label( $this->get_status() );
1114
+    }
1115
+
1116
+    /**
1117
+     * Retrieves the subscription status class
1118
+     *
1119
+     * @since  1.0.19
1120
+     * @return string
1121
+     */
1122
+    public function get_status_class() {
1123
+        $statuses = getpaid_get_subscription_status_classes();
1124
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary';
1125
+    }
1126 1126
 
1127 1127
     /**
1128 1128
      * Retrieves the subscription status label
@@ -1132,11 +1132,11 @@  discard block
 block discarded – undo
1132 1132
      */
1133 1133
     public function get_status_label_html() {
1134 1134
 
1135
-		$status_label = sanitize_text_field( $this->get_status_label() );
1136
-		$class        = sanitize_html_class( $this->get_status_class() );
1137
-		$status       = sanitize_html_class( $this->get_status_label() );
1135
+        $status_label = sanitize_text_field( $this->get_status_label() );
1136
+        $class        = sanitize_html_class( $this->get_status_class() );
1137
+        $status       = sanitize_html_class( $this->get_status_label() );
1138 1138
 
1139
-		"<span class='bsui'><small class='d-inline-block py-1 px-2 rounded $class $status'>$status_label</small></span>";
1139
+        "<span class='bsui'><small class='d-inline-block py-1 px-2 rounded $class $status'>$status_label</small></span>";
1140 1140
     }
1141 1141
 
1142 1142
     /**
@@ -1147,63 +1147,63 @@  discard block
 block discarded – undo
1147 1147
      * @return bool
1148 1148
      */
1149 1149
     public function payment_exists( $txn_id = '' ) {
1150
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1150
+        $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1151 1151
         return ! empty( $invoice_id );
1152
-	}
1153
-
1154
-	/**
1155
-	 * Handle the status transition.
1156
-	 */
1157
-	protected function status_transition() {
1158
-		$status_transition = $this->status_transition;
1159
-
1160
-		// Reset status transition variable.
1161
-		$this->status_transition = false;
1162
-
1163
-		if ( $status_transition ) {
1164
-			try {
1165
-
1166
-				// Fire a hook for the status change.
1167
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1168
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1169
-
1170
-				if ( ! empty( $status_transition['from'] ) ) {
1171
-
1172
-					/* translators: 1: old subscription status 2: new subscription status */
1173
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1174
-
1175
-					// Fire another hook.
1176
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1177
-					do_action( 'getpaid_subscription_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
1178
-
1179
-					// Note the transition occurred.
1180
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1181
-
1182
-				} else {
1183
-					/* translators: %s: new invoice status */
1184
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1185
-
1186
-					// Note the transition occurred.
1187
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1188
-
1189
-				}
1190
-			} catch ( Exception $e ) {
1191
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1192
-			}
1193
-		}
1194
-
1195
-	}
1196
-
1197
-	/**
1198
-	 * Save data to the database.
1199
-	 *
1200
-	 * @since 1.0.19
1201
-	 * @return int subscription ID
1202
-	 */
1203
-	public function save() {
1204
-		parent::save();
1205
-		$this->status_transition();
1206
-		return $this->get_id();
1207
-	}
1152
+    }
1153
+
1154
+    /**
1155
+     * Handle the status transition.
1156
+     */
1157
+    protected function status_transition() {
1158
+        $status_transition = $this->status_transition;
1159
+
1160
+        // Reset status transition variable.
1161
+        $this->status_transition = false;
1162
+
1163
+        if ( $status_transition ) {
1164
+            try {
1165
+
1166
+                // Fire a hook for the status change.
1167
+                do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1168
+                do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1169
+
1170
+                if ( ! empty( $status_transition['from'] ) ) {
1171
+
1172
+                    /* translators: 1: old subscription status 2: new subscription status */
1173
+                    $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1174
+
1175
+                    // Fire another hook.
1176
+                    do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1177
+                    do_action( 'getpaid_subscription_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
1178
+
1179
+                    // Note the transition occurred.
1180
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1181
+
1182
+                } else {
1183
+                    /* translators: %s: new invoice status */
1184
+                    $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1185
+
1186
+                    // Note the transition occurred.
1187
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1188
+
1189
+                }
1190
+            } catch ( Exception $e ) {
1191
+                $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1192
+            }
1193
+        }
1194
+
1195
+    }
1196
+
1197
+    /**
1198
+     * Save data to the database.
1199
+     *
1200
+     * @since 1.0.19
1201
+     * @return int subscription ID
1202
+     */
1203
+    public function save() {
1204
+        parent::save();
1205
+        $this->status_transition();
1206
+        return $this->get_id();
1207
+    }
1208 1208
 
1209 1209
 }
Please login to merge, or discard this patch.
Spacing   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * The Subscription Class
@@ -70,27 +70,27 @@  discard block
 block discarded – undo
70 70
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
71 71
 	 * @param  bool $deprecated
72 72
 	 */
73
-	function __construct( $subscription = 0, $deprecated = false ) {
73
+	function __construct($subscription = 0, $deprecated = false) {
74 74
 
75
-		parent::__construct( $subscription );
75
+		parent::__construct($subscription);
76 76
 
77
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
78
-			$this->set_id( $subscription );
79
-		} elseif ( $subscription instanceof self ) {
80
-			$this->set_id( $subscription->get_id() );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
83
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
84
-			$this->set_id( $subscription_id );
77
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
78
+			$this->set_id($subscription);
79
+		} elseif ($subscription instanceof self) {
80
+			$this->set_id($subscription->get_id());
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
84
+			$this->set_id($subscription_id);
85 85
 		} else {
86
-			$this->set_object_read( true );
86
+			$this->set_object_read(true);
87 87
 		}
88 88
 
89 89
 		// Load the datastore.
90
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
90
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
91 91
 
92
-		if ( $this->get_id() > 0 ) {
93
-			$this->data_store->read( $this );
92
+		if ($this->get_id() > 0) {
93
+			$this->data_store->read($this);
94 94
 		}
95 95
 
96 96
 	}
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
 	 * @since 1.0.19
106 106
 	 * @return int
107 107
 	 */
108
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
108
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
109 109
         global $wpdb;
110 110
 
111 111
 		// Trim the value.
112
-		$value = trim( $value );
112
+		$value = trim($value);
113 113
 
114
-		if ( empty( $value ) ) {
114
+		if (empty($value)) {
115 115
 			return 0;
116 116
 		}
117 117
 
118
-		if ( 'invoice_id' == $field ) {
118
+		if ('invoice_id' == $field) {
119 119
 			$field = 'parent_payment_id';
120 120
 		}
121 121
 
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
 		);
128 128
 
129 129
 		// Ensure a field has been passed.
130
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
130
+		if (empty($field) || !in_array($field, $fields)) {
131 131
 			return 0;
132 132
 		}
133 133
 
134 134
 		// Maybe retrieve from the cache.
135
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
136
-		if ( ! empty( $subscription_id ) ) {
135
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
136
+		if (!empty($subscription_id)) {
137 137
 			return $subscription_id;
138 138
 		}
139 139
 
140 140
         // Fetch from the db.
141 141
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
142 142
         $subscription_id  = (int) $wpdb->get_var(
143
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
143
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
144 144
         );
145 145
 
146
-		if ( empty( $subscription_id ) ) {
146
+		if (empty($subscription_id)) {
147 147
 			return 0;
148 148
 		}
149 149
 
150 150
 		// Update the cache with our data.
151
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
151
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
152 152
 
153 153
 		return $subscription_id;
154 154
 	}
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
      * Clears the subscription's cache.
158 158
      */
159 159
     public function clear_cache() {
160
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
162
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
163
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
160
+		wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids');
161
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids');
162
+		wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids');
163
+		wp_cache_delete($this->get_id(), 'getpaid_subscriptions');
164 164
 	}
165 165
 
166 166
 	/**
167 167
      * Checks if a subscription key is set.
168 168
      */
169
-    public function _isset( $key ) {
170
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
169
+    public function _isset($key) {
170
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
171 171
 	}
172 172
 
173 173
 	/*
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * @param  string $context View or edit context.
193 193
 	 * @return int
194 194
 	 */
195
-	public function get_customer_id( $context = 'view' ) {
196
-		return (int) $this->get_prop( 'customer_id', $context );
195
+	public function get_customer_id($context = 'view') {
196
+		return (int) $this->get_prop('customer_id', $context);
197 197
 	}
198 198
 
199 199
 	/**
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	 * @param  string $context View or edit context.
204 204
 	 * @return WP_User|false WP_User object on success, false on failure.
205 205
 	 */
206
-	public function get_customer( $context = 'view' ) {
207
-		return get_userdata( $this->get_customer_id( $context ) );
206
+	public function get_customer($context = 'view') {
207
+		return get_userdata($this->get_customer_id($context));
208 208
 	}
209 209
 
210 210
 	/**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @param  string $context View or edit context.
215 215
 	 * @return int
216 216
 	 */
217
-	public function get_parent_invoice_id( $context = 'view' ) {
218
-		return (int) $this->get_prop( 'parent_payment_id', $context );
217
+	public function get_parent_invoice_id($context = 'view') {
218
+		return (int) $this->get_prop('parent_payment_id', $context);
219 219
 	}
220 220
 
221 221
 	/**
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param  string $context View or edit context.
226 226
 	 * @return int
227 227
 	 */
228
-    public function get_parent_payment_id( $context = 'view' ) {
229
-        return $this->get_parent_invoice_id( $context );
228
+    public function get_parent_payment_id($context = 'view') {
229
+        return $this->get_parent_invoice_id($context);
230 230
 	}
231 231
 
232 232
 	/**
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
      * @since  1.0.0
236 236
      * @return int
237 237
      */
238
-    public function get_original_payment_id( $context = 'view' ) {
239
-        return $this->get_parent_invoice_id( $context );
238
+    public function get_original_payment_id($context = 'view') {
239
+        return $this->get_parent_invoice_id($context);
240 240
     }
241 241
 
242 242
 	/**
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * @param  string $context View or edit context.
247 247
 	 * @return WPInv_Invoice
248 248
 	 */
249
-	public function get_parent_invoice( $context = 'view' ) {
250
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
249
+	public function get_parent_invoice($context = 'view') {
250
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
251 251
 	}
252 252
 
253 253
 	/**
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $context View or edit context.
258 258
 	 * @return WPInv_Invoice
259 259
 	 */
260
-    public function get_parent_payment( $context = 'view' ) {
261
-        return $this->get_parent_invoice( $context );
260
+    public function get_parent_payment($context = 'view') {
261
+        return $this->get_parent_invoice($context);
262 262
 	}
263 263
 
264 264
 	/**
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @param  string $context View or edit context.
269 269
 	 * @return int
270 270
 	 */
271
-	public function get_product_id( $context = 'view' ) {
272
-		return (int) $this->get_prop( 'product_id', $context );
271
+	public function get_product_id($context = 'view') {
272
+		return (int) $this->get_prop('product_id', $context);
273 273
 	}
274 274
 
275 275
 	/**
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param  string $context View or edit context.
280 280
 	 * @return WPInv_Item
281 281
 	 */
282
-	public function get_product( $context = 'view' ) {
283
-		return new WPInv_Item( $this->get_product_id( $context ) );
282
+	public function get_product($context = 'view') {
283
+		return new WPInv_Item($this->get_product_id($context));
284 284
 	}
285 285
 
286 286
 	/**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return string
294 294
 	 */
295
-	public function get_gateway( $context = 'view' ) {
296
-		return $this->get_parent_invoice( $context )->get_gateway();
295
+	public function get_gateway($context = 'view') {
296
+		return $this->get_parent_invoice($context)->get_gateway();
297 297
 	}
298 298
 
299 299
 	/**
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return string
305 305
 	 */
306
-	public function get_period( $context = 'view' ) {
307
-		return $this->get_prop( 'period', $context );
306
+	public function get_period($context = 'view') {
307
+		return $this->get_prop('period', $context);
308 308
 	}
309 309
 
310 310
 	/**
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 	 * @param  string $context View or edit context.
315 315
 	 * @return int
316 316
 	 */
317
-	public function get_frequency( $context = 'view' ) {
318
-		return (int) $this->get_prop( 'frequency', $context );
317
+	public function get_frequency($context = 'view') {
318
+		return (int) $this->get_prop('frequency', $context);
319 319
 	}
320 320
 
321 321
 	/**
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 	 * @param  string $context View or edit context.
326 326
 	 * @return float
327 327
 	 */
328
-	public function get_initial_amount( $context = 'view' ) {
329
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
328
+	public function get_initial_amount($context = 'view') {
329
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
330 330
 	}
331 331
 
332 332
 	/**
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @param  string $context View or edit context.
337 337
 	 * @return float
338 338
 	 */
339
-	public function get_recurring_amount( $context = 'view' ) {
340
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
339
+	public function get_recurring_amount($context = 'view') {
340
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
341 341
 	}
342 342
 
343 343
 	/**
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 * @param  string $context View or edit context.
348 348
 	 * @return int
349 349
 	 */
350
-	public function get_bill_times( $context = 'view' ) {
351
-		return (int) $this->get_prop( 'bill_times', $context );
350
+	public function get_bill_times($context = 'view') {
351
+		return (int) $this->get_prop('bill_times', $context);
352 352
 	}
353 353
 
354 354
 	/**
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 * @param  string $context View or edit context.
359 359
 	 * @return string
360 360
 	 */
361
-	public function get_transaction_id( $context = 'view' ) {
362
-		return $this->get_prop( 'transaction_id', $context );
361
+	public function get_transaction_id($context = 'view') {
362
+		return $this->get_prop('transaction_id', $context);
363 363
 	}
364 364
 
365 365
 	/**
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 * @param  string $context View or edit context.
370 370
 	 * @return string
371 371
 	 */
372
-	public function get_created( $context = 'view' ) {
373
-		return $this->get_prop( 'created', $context );
372
+	public function get_created($context = 'view') {
373
+		return $this->get_prop('created', $context);
374 374
 	}
375 375
 
376 376
 	/**
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 	 * @param  string $context View or edit context.
381 381
 	 * @return string
382 382
 	 */
383
-	public function get_date_created( $context = 'view' ) {
384
-		return $this->get_created( $context );
383
+	public function get_date_created($context = 'view') {
384
+		return $this->get_created($context);
385 385
 	}
386 386
 
387 387
 	/**
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 */
393 393
 	public function get_time_created() {
394 394
 		$created = $this->get_date_created();
395
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
395
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
396 396
 	}
397 397
 
398 398
 	/**
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 	 * @param  string $context View or edit context.
403 403
 	 * @return string
404 404
 	 */
405
-	public function get_date_created_gmt( $context = 'view' ) {
406
-        $date = $this->get_date_created( $context );
405
+	public function get_date_created_gmt($context = 'view') {
406
+        $date = $this->get_date_created($context);
407 407
 
408
-        if ( $date ) {
409
-            $date = get_gmt_from_date( $date );
408
+        if ($date) {
409
+            $date = get_gmt_from_date($date);
410 410
         }
411 411
 		return $date;
412 412
 	}
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 * @param  string $context View or edit context.
419 419
 	 * @return string
420 420
 	 */
421
-	public function get_next_renewal_date( $context = 'view' ) {
422
-		return $this->get_prop( 'expiration', $context );
421
+	public function get_next_renewal_date($context = 'view') {
422
+		return $this->get_prop('expiration', $context);
423 423
 	}
424 424
 
425 425
 	/**
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 	 * @param  string $context View or edit context.
430 430
 	 * @return string
431 431
 	 */
432
-	public function get_expiration( $context = 'view' ) {
433
-		return $this->get_next_renewal_date( $context );
432
+	public function get_expiration($context = 'view') {
433
+		return $this->get_next_renewal_date($context);
434 434
 	}
435 435
 
436 436
 	/**
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
 	public function get_expiration_time() {
443 443
 		$expiration = $this->get_expiration();
444 444
 
445
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
446
-			return current_time( 'timestamp' );
445
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
446
+			return current_time('timestamp');
447 447
 		}
448 448
 
449
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
450
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
449
+		$expiration = strtotime($expiration, current_time('timestamp'));
450
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
451 451
 	}
452 452
 
453 453
 	/**
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 * @param  string $context View or edit context.
458 458
 	 * @return string
459 459
 	 */
460
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
461
-        $date = $this->get_next_renewal_date( $context );
460
+	public function get_next_renewal_date_gmt($context = 'view') {
461
+        $date = $this->get_next_renewal_date($context);
462 462
 
463
-        if ( $date ) {
464
-            $date = get_gmt_from_date( $date );
463
+        if ($date) {
464
+            $date = get_gmt_from_date($date);
465 465
         }
466 466
 		return $date;
467 467
 	}
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	 * @param  string $context View or edit context.
474 474
 	 * @return string
475 475
 	 */
476
-	public function get_trial_period( $context = 'view' ) {
477
-		return $this->get_prop( 'trial_period', $context );
476
+	public function get_trial_period($context = 'view') {
477
+		return $this->get_prop('trial_period', $context);
478 478
 	}
479 479
 
480 480
 	/**
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	 * @param  string $context View or edit context.
485 485
 	 * @return string
486 486
 	 */
487
-	public function get_status( $context = 'view' ) {
488
-		return $this->get_prop( 'status', $context );
487
+	public function get_status($context = 'view') {
488
+		return $this->get_prop('status', $context);
489 489
 	}
490 490
 
491 491
 	/**
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 	 * @param  string $context View or edit context.
496 496
 	 * @return string
497 497
 	 */
498
-	public function get_profile_id( $context = 'view' ) {
499
-		return $this->get_prop( 'profile_id', $context );
498
+	public function get_profile_id($context = 'view') {
499
+		return $this->get_prop('profile_id', $context);
500 500
 	}
501 501
 
502 502
 	/*
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 	 * @since 1.0.19
512 512
 	 * @param  int $value The customer's id.
513 513
 	 */
514
-	public function set_customer_id( $value ) {
515
-		$this->set_prop( 'customer_id', (int) $value );
514
+	public function set_customer_id($value) {
515
+		$this->set_prop('customer_id', (int) $value);
516 516
 	}
517 517
 
518 518
 	/**
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
 	 * @since 1.0.19
522 522
 	 * @param  int $value The parent invoice id.
523 523
 	 */
524
-	public function set_parent_invoice_id( $value ) {
525
-		$this->set_prop( 'parent_payment_id', (int) $value );
524
+	public function set_parent_invoice_id($value) {
525
+		$this->set_prop('parent_payment_id', (int) $value);
526 526
 	}
527 527
 
528 528
 	/**
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	 * @since 1.0.19
532 532
 	 * @param  int $value The parent invoice id.
533 533
 	 */
534
-    public function set_parent_payment_id( $value ) {
535
-        $this->set_parent_invoice_id( $value );
534
+    public function set_parent_payment_id($value) {
535
+        $this->set_parent_invoice_id($value);
536 536
 	}
537 537
 
538 538
 	/**
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
      * @since 1.0.19
542 542
 	 * @param  int $value The parent invoice id.
543 543
      */
544
-    public function set_original_payment_id( $value ) {
545
-        $this->set_parent_invoice_id( $value );
544
+    public function set_original_payment_id($value) {
545
+        $this->set_parent_invoice_id($value);
546 546
 	}
547 547
 
548 548
 	/**
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 	 * @since 1.0.19
552 552
 	 * @param  int $value The subscription product id.
553 553
 	 */
554
-	public function set_product_id( $value ) {
555
-		$this->set_prop( 'product_id', (int) $value );
554
+	public function set_product_id($value) {
555
+		$this->set_prop('product_id', (int) $value);
556 556
 	}
557 557
 
558 558
 	/**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @since 1.0.19
562 562
 	 * @param  string $value The renewal period.
563 563
 	 */
564
-	public function set_period( $value ) {
565
-		$this->set_prop( 'period', $value );
564
+	public function set_period($value) {
565
+		$this->set_prop('period', $value);
566 566
 	}
567 567
 
568 568
 	/**
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
 	 * @since 1.0.19
572 572
 	 * @param  int $value The subscription frequency.
573 573
 	 */
574
-	public function set_frequency( $value ) {
575
-		$value = empty( $value ) ? 1 : (int) $value;
576
-		$this->set_prop( 'frequency', absint( $value ) );
574
+	public function set_frequency($value) {
575
+		$value = empty($value) ? 1 : (int) $value;
576
+		$this->set_prop('frequency', absint($value));
577 577
 	}
578 578
 
579 579
 	/**
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 	 * @since 1.0.19
583 583
 	 * @param  float $value The initial subcription amount.
584 584
 	 */
585
-	public function set_initial_amount( $value ) {
586
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
585
+	public function set_initial_amount($value) {
586
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
587 587
 	}
588 588
 
589 589
 	/**
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 	 * @since 1.0.19
593 593
 	 * @param  float $value The recurring subcription amount.
594 594
 	 */
595
-	public function set_recurring_amount( $value ) {
596
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
595
+	public function set_recurring_amount($value) {
596
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
597 597
 	}
598 598
 
599 599
 	/**
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
 	 * @since 1.0.19
603 603
 	 * @param  int $value Bill times.
604 604
 	 */
605
-	public function set_bill_times( $value ) {
606
-		$this->set_prop( 'bill_times', (int) $value );
605
+	public function set_bill_times($value) {
606
+		$this->set_prop('bill_times', (int) $value);
607 607
 	}
608 608
 
609 609
 	/**
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 	 * @since 1.0.19
613 613
 	 * @param string $value Bill times.
614 614
 	 */
615
-	public function set_transaction_id( $value ) {
616
-		$this->set_prop( 'transaction_id', $value );
615
+	public function set_transaction_id($value) {
616
+		$this->set_prop('transaction_id', $value);
617 617
 	}
618 618
 
619 619
 	/**
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
 	 * @since 1.0.19
623 623
 	 * @param string $value strtotime compliant date.
624 624
 	 */
625
-	public function set_created( $value ) {
626
-        $date = strtotime( $value );
625
+	public function set_created($value) {
626
+        $date = strtotime($value);
627 627
 
628
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
629
-            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
628
+        if ($date && $value !== '0000-00-00 00:00:00') {
629
+            $this->set_prop('created', date('Y-m-d H:i:s', $date));
630 630
             return;
631 631
         }
632 632
 
633
-		$this->set_prop( 'created', '' );
633
+		$this->set_prop('created', '');
634 634
 
635 635
 	}
636 636
 
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 * @since 1.0.19
641 641
 	 * @param string $value strtotime compliant date.
642 642
 	 */
643
-	public function set_date_created( $value ) {
644
-		$this->set_created( $value );
643
+	public function set_date_created($value) {
644
+		$this->set_created($value);
645 645
     }
646 646
 
647 647
 	/**
@@ -650,15 +650,15 @@  discard block
 block discarded – undo
650 650
 	 * @since 1.0.19
651 651
 	 * @param string $value strtotime compliant date.
652 652
 	 */
653
-	public function set_next_renewal_date( $value ) {
654
-		$date = strtotime( $value );
653
+	public function set_next_renewal_date($value) {
654
+		$date = strtotime($value);
655 655
 
656
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
657
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
656
+        if ($date && $value !== '0000-00-00 00:00:00') {
657
+            $this->set_prop('expiration', date('Y-m-d H:i:s', $date));
658 658
             return;
659 659
 		}
660 660
 
661
-		$this->set_prop( 'expiration', '' );
661
+		$this->set_prop('expiration', '');
662 662
 
663 663
 	}
664 664
 
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 	 * @since 1.0.19
669 669
 	 * @param string $value strtotime compliant date.
670 670
 	 */
671
-	public function set_expiration( $value ) {
672
-		$this->set_next_renewal_date( $value );
671
+	public function set_expiration($value) {
672
+		$this->set_next_renewal_date($value);
673 673
     }
674 674
 
675 675
 	/**
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
 	 * @since 1.0.19
679 679
 	 * @param string $value trial period e.g 1 year.
680 680
 	 */
681
-	public function set_trial_period( $value ) {
682
-		$this->set_prop( 'trial_period', $value );
681
+	public function set_trial_period($value) {
682
+		$this->set_prop('trial_period', $value);
683 683
 	}
684 684
 
685 685
 	/**
@@ -688,19 +688,19 @@  discard block
 block discarded – undo
688 688
 	 * @since 1.0.19
689 689
 	 * @param string $new_status    New subscription status.
690 690
 	 */
691
-	public function set_status( $new_status ) {
691
+	public function set_status($new_status) {
692 692
 
693 693
 		// Abort if this is not a valid status;
694
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
694
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
695 695
 			return;
696 696
 		}
697 697
 
698 698
 		$old_status = $this->get_status();
699
-		$this->set_prop( 'status', $new_status );
699
+		$this->set_prop('status', $new_status);
700 700
 
701
-		if ( true === $this->object_read && $old_status !== $new_status ) {
701
+		if (true === $this->object_read && $old_status !== $new_status) {
702 702
 			$this->status_transition = array(
703
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
703
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
704 704
 				'to'     => $new_status,
705 705
 			);
706 706
 		}
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 * @since 1.0.19
714 714
 	 * @param  string $value the remote profile id.
715 715
 	 */
716
-	public function set_profile_id( $value ) {
717
-		$this->set_prop( 'profile_id', $value );
716
+	public function set_profile_id($value) {
717
+		$this->set_prop('profile_id', $value);
718 718
 	}
719 719
 
720 720
 	/*
@@ -732,8 +732,8 @@  discard block
 block discarded – undo
732 732
 	 * @param string|array String or array of strings to check for.
733 733
 	 * @return bool
734 734
      */
735
-    public function has_status( $status ) {
736
-        return in_array( $this->get_status(), wpinv_parse_list( $status ) );
735
+    public function has_status($status) {
736
+        return in_array($this->get_status(), wpinv_parse_list($status));
737 737
 	}
738 738
 
739 739
 	/**
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
      */
744 744
     public function has_trial_period() {
745 745
 		$period = $this->get_trial_period();
746
-        return ! empty( $period );
746
+        return !empty($period);
747 747
 	}
748 748
 
749 749
 	/**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	 * @return bool
753 753
 	 */
754 754
 	public function is_active() {
755
-		return $this->has_status( 'active trialling' ) && $this->get_expiration_time() > current_time( 'mysql' );
755
+		return $this->has_status('active trialling') && $this->get_expiration_time() > current_time('mysql');
756 756
 	}
757 757
 
758 758
 	/**
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	 * @return bool
762 762
 	 */
763 763
 	public function is_expired() {
764
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
764
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql'));
765 765
 	}
766 766
 
767 767
 	/*
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 	/**
777 777
 	 * Backwards compatibilty.
778 778
 	 */
779
-	public function create( $data = array() ) {
779
+	public function create($data = array()) {
780 780
 
781 781
 		// Set the properties.
782
-		if ( is_array( $data ) ) {
783
-			$this->set_props( $data );
782
+		if (is_array($data)) {
783
+			$this->set_props($data);
784 784
 		}
785 785
 
786 786
 		// Save the item.
@@ -791,8 +791,8 @@  discard block
 block discarded – undo
791 791
 	/**
792 792
 	 * Backwards compatibilty.
793 793
 	 */
794
-	public function update( $args = array() ) {
795
-		return $this->create( $args );
794
+	public function update($args = array()) {
795
+		return $this->create($args);
796 796
 	}
797 797
 
798 798
     /**
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 			array(
807 807
             	'post_parent'    => $this->get_parent_payment_id(),
808 808
             	'numberposts'    => -1,
809
-            	'post_status'    => array( 'publish', 'wpi-processing', 'wpi-renewal' ),
809
+            	'post_status'    => array('publish', 'wpi-processing', 'wpi-renewal'),
810 810
             	'orderby'        => 'ID',
811 811
             	'order'          => 'DESC',
812 812
             	'post_type'      => 'wpi_invoice'
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 		);
832 832
 
833 833
 		// Maybe include parent invoice.
834
-        if ( ! $this->has_status( 'pending' ) ) {
834
+        if (!$this->has_status('pending')) {
835 835
             $count++;
836 836
         }
837 837
 
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
     public function get_times_billed() {
848 848
         $times_billed = $this->get_total_payments();
849 849
 
850
-        if ( $this->has_trial_period() && $times_billed > 0 ) {
850
+        if ($this->has_trial_period() && $times_billed > 0) {
851 851
             $times_billed--;
852 852
         }
853 853
 
@@ -862,49 +862,49 @@  discard block
 block discarded – undo
862 862
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
863 863
      * @return bool
864 864
      */
865
-    public function add_payment( $args = array(), $invoice = false ) {
865
+    public function add_payment($args = array(), $invoice = false) {
866 866
 
867 867
 		// Process each payment once.
868
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
868
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
869 869
             return false;
870 870
         }
871 871
 
872 872
 		// Are we creating a new invoice?
873
-		if ( empty( $invoice ) ) {
873
+		if (empty($invoice)) {
874 874
 			$invoice = $this->create_payment();
875 875
 
876
-			if ( empty( $invoice ) ) {
876
+			if (empty($invoice)) {
877 877
 				return false;
878 878
 			}
879 879
 
880
-			$invoice->set_status( 'wpi-renewal' );
880
+			$invoice->set_status('wpi-renewal');
881 881
 
882 882
 		}
883 883
 
884 884
 		// Maybe set a transaction id.
885
-		if ( ! empty( $args['transaction_id'] ) ) {
886
-			$invoice->set_transaction_id( $args['transaction_id'] );
885
+		if (!empty($args['transaction_id'])) {
886
+			$invoice->set_transaction_id($args['transaction_id']);
887 887
 		}
888 888
 
889 889
 		// Set the completed date.
890
-		$invoice->set_completed_date( current_time( 'mysql' ) );
890
+		$invoice->set_completed_date(current_time('mysql'));
891 891
 
892 892
 		// And the gateway.
893
-		if ( ! empty( $args['gateway'] ) ) {
894
-			$invoice->set_gateway( $args['gateway'] );
893
+		if (!empty($args['gateway'])) {
894
+			$invoice->set_gateway($args['gateway']);
895 895
 		}
896 896
 
897 897
 		$invoice->save();
898 898
 
899
-		if ( ! $invoice->get_id() ) {
899
+		if (!$invoice->get_id()) {
900 900
 			return 0;
901 901
 		}
902 902
 
903
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
904
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
905
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
903
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
904
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
905
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
906 906
 
907
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
907
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
908 908
 
909 909
         return $invoice->get_id();
910 910
 	}
@@ -919,20 +919,20 @@  discard block
 block discarded – undo
919 919
 
920 920
 		$parent_invoice = $this->get_parent_payment();
921 921
 
922
-		if ( ! $parent_invoice->get_id() ) {
922
+		if (!$parent_invoice->get_id()) {
923 923
 			return false;
924 924
 		}
925 925
 
926 926
 		// Duplicate the parent invoice.
927 927
 		$invoice = new WPInv_Invoice();
928
-		$invoice->set_props( $parent_invoice->get_data() );
929
-		$invoice->set_id( 0 );
930
-		$invoice->set_parent_id( $parent_invoice->get_id() );
931
-		$invoice->set_transaction_id( '' );
932
-		$invoice->set_key( $invoice->generate_key( 'renewal_' ) );
933
-		$invoice->set_number( '' );
934
-		$invoice->set_completed_date( '' );
935
-		$invoice->set_status( 'wpi-pending' );
928
+		$invoice->set_props($parent_invoice->get_data());
929
+		$invoice->set_id(0);
930
+		$invoice->set_parent_id($parent_invoice->get_id());
931
+		$invoice->set_transaction_id('');
932
+		$invoice->set_key($invoice->generate_key('renewal_'));
933
+		$invoice->set_number('');
934
+		$invoice->set_completed_date('');
935
+		$invoice->set_status('wpi-pending');
936 936
 		$invoice->recalculate_total();
937 937
 		$invoice->save();
938 938
 
@@ -948,20 +948,20 @@  discard block
 block discarded – undo
948 948
 	public function renew() {
949 949
 
950 950
 		// Complete subscription if applicable
951
-		if ( $this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times() ) {
951
+		if ($this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times()) {
952 952
 			return $this->complete();
953 953
 		}
954 954
 
955 955
 		// Calculate new expiration
956 956
 		$frequency      = $this->get_frequency();
957 957
 		$period         = $this->get_period();
958
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
958
+		$new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time());
959 959
 
960
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
961
-		$this->set_status( 'active' );
960
+		$this->set_expiration(date('Y-m-d H:i:s', $new_expiration));
961
+		$this->set_status('active');
962 962
 		return $this->save();
963 963
 
964
-		do_action( 'getpaid_subscription_renewed', $this );
964
+		do_action('getpaid_subscription_renewed', $this);
965 965
 
966 966
 	}
967 967
 
@@ -976,11 +976,11 @@  discard block
 block discarded – undo
976 976
 	public function complete() {
977 977
 
978 978
 		// Only mark a subscription as complete if it's not already cancelled.
979
-		if ( $this->has_status( 'cancelled' ) ) {
979
+		if ($this->has_status('cancelled')) {
980 980
 			return false;
981 981
 		}
982 982
 
983
-		$this->set_status( 'completed' );
983
+		$this->set_status('completed');
984 984
 		return $this->save();
985 985
 
986 986
 	}
@@ -992,14 +992,14 @@  discard block
 block discarded – undo
992 992
 	 * @param  bool $check_expiration
993 993
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
994 994
 	 */
995
-	public function expire( $check_expiration = false ) {
995
+	public function expire($check_expiration = false) {
996 996
 
997
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
997
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
998 998
 			// Do not mark as expired since real expiration date is in the future
999 999
 			return false;
1000 1000
 		}
1001 1001
 
1002
-		$this->set_status( 'expired' );
1002
+		$this->set_status('expired');
1003 1003
 		return $this->save();
1004 1004
 
1005 1005
 	}
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 	 * @return int Subscription id.
1012 1012
 	 */
1013 1013
 	public function failing() {
1014
-		$this->set_status( 'failing' );
1014
+		$this->set_status('failing');
1015 1015
 		return $this->save();
1016 1016
 	}
1017 1017
 
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
      * @return int Subscription id.
1023 1023
      */
1024 1024
     public function cancel() {
1025
-		$this->set_status( 'cancelled' );
1025
+		$this->set_status('cancelled');
1026 1026
 		return $this->save();
1027 1027
     }
1028 1028
 
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 	 * @return bool
1034 1034
 	 */
1035 1035
 	public function can_cancel() {
1036
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1036
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1037 1037
 	}
1038 1038
 
1039 1039
     /**
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
      * @return      array
1045 1045
      */
1046 1046
     public function get_cancellable_statuses() {
1047
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1047
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1048 1048
     }
1049 1049
 
1050 1050
 	/**
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 	 * @return string
1055 1055
 	 */
1056 1056
 	public function get_cancel_url() {
1057
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->get_id() ) ), 'wpinv-recurring-cancel' );
1058
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1057
+		$url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'cancel_subscription', 'sub_id' => $this->get_id())), 'wpinv-recurring-cancel');
1058
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1059 1059
 	}
1060 1060
 
1061 1061
 	/**
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 	 * @return bool
1069 1069
 	 */
1070 1070
 	public function can_renew() {
1071
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1071
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1072 1072
 	}
1073 1073
 
1074 1074
 	/**
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 	 * @return string
1079 1079
 	 */
1080 1080
 	public function get_renew_url() {
1081
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'wpinv-recurring-renew' );
1082
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1081
+		$url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'wpinv-recurring-renew');
1082
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1083 1083
 	}
1084 1084
 
1085 1085
 	/**
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 	 * @return bool
1090 1090
 	 */
1091 1091
 	public function can_update() {
1092
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1092
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1093 1093
 	}
1094 1094
 
1095 1095
 	/**
@@ -1099,8 +1099,8 @@  discard block
 block discarded – undo
1099 1099
 	 * @return string
1100 1100
 	 */
1101 1101
 	public function get_update_url() {
1102
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1103
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1102
+		$url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id()));
1103
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1104 1104
 	}
1105 1105
 
1106 1106
 	/**
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 	 * @return string
1111 1111
 	 */
1112 1112
 	public function get_status_label() {
1113
-		return getpaid_get_subscription_status_label( $this->get_status() );
1113
+		return getpaid_get_subscription_status_label($this->get_status());
1114 1114
 	}
1115 1115
 
1116 1116
 	/**
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 	 */
1122 1122
 	public function get_status_class() {
1123 1123
 		$statuses = getpaid_get_subscription_status_classes();
1124
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary';
1124
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'text-white bg-secondary';
1125 1125
 	}
1126 1126
 
1127 1127
     /**
@@ -1132,9 +1132,9 @@  discard block
 block discarded – undo
1132 1132
      */
1133 1133
     public function get_status_label_html() {
1134 1134
 
1135
-		$status_label = sanitize_text_field( $this->get_status_label() );
1136
-		$class        = sanitize_html_class( $this->get_status_class() );
1137
-		$status       = sanitize_html_class( $this->get_status_label() );
1135
+		$status_label = sanitize_text_field($this->get_status_label());
1136
+		$class        = sanitize_html_class($this->get_status_class());
1137
+		$status       = sanitize_html_class($this->get_status_label());
1138 1138
 
1139 1139
 		"<span class='bsui'><small class='d-inline-block py-1 px-2 rounded $class $status'>$status_label</small></span>";
1140 1140
     }
@@ -1146,9 +1146,9 @@  discard block
 block discarded – undo
1146 1146
      * @param  string $txn_id The transaction ID from the merchant processor
1147 1147
      * @return bool
1148 1148
      */
1149
-    public function payment_exists( $txn_id = '' ) {
1150
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1151
-        return ! empty( $invoice_id );
1149
+    public function payment_exists($txn_id = '') {
1150
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1151
+        return !empty($invoice_id);
1152 1152
 	}
1153 1153
 
1154 1154
 	/**
@@ -1160,35 +1160,35 @@  discard block
 block discarded – undo
1160 1160
 		// Reset status transition variable.
1161 1161
 		$this->status_transition = false;
1162 1162
 
1163
-		if ( $status_transition ) {
1163
+		if ($status_transition) {
1164 1164
 			try {
1165 1165
 
1166 1166
 				// Fire a hook for the status change.
1167
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1168
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1167
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1168
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1169 1169
 
1170
-				if ( ! empty( $status_transition['from'] ) ) {
1170
+				if (!empty($status_transition['from'])) {
1171 1171
 
1172 1172
 					/* translators: 1: old subscription status 2: new subscription status */
1173
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1173
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1174 1174
 
1175 1175
 					// Fire another hook.
1176
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1177
-					do_action( 'getpaid_subscription_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
1176
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1177
+					do_action('getpaid_subscription_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this);
1178 1178
 
1179 1179
 					// Note the transition occurred.
1180
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1180
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1181 1181
 
1182 1182
 				} else {
1183 1183
 					/* translators: %s: new invoice status */
1184
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1184
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1185 1185
 
1186 1186
 					// Note the transition occurred.
1187
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1187
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1188 1188
 
1189 1189
 				}
1190
-			} catch ( Exception $e ) {
1191
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1190
+			} catch (Exception $e) {
1191
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1192 1192
 			}
1193 1193
 		}
1194 1194
 
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2235 added lines, -2235 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,20 +79,20 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'is_viewed'            => false,
84
-		'email_cc'             => '',
85
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'is_viewed'            => false,
84
+        'email_cc'             => '',
85
+        'template'             => 'quantity', // hours, amount only
86 86
     );
87 87
 
88 88
     /**
89
-	 * Stores meta in cache for future reads.
90
-	 *
91
-	 * A group must be set to to enable caching.
92
-	 *
93
-	 * @var string
94
-	 */
95
-	protected $cache_group = 'getpaid_invoices';
89
+     * Stores meta in cache for future reads.
90
+     *
91
+     * A group must be set to to enable caching.
92
+     *
93
+     * @var string
94
+     */
95
+    protected $cache_group = 'getpaid_invoices';
96 96
 
97 97
     /**
98 98
      * Stores a reference to the original WP_Post object
@@ -106,104 +106,104 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @var int
108 108
      */
109
-	protected $recurring_item = null;
109
+    protected $recurring_item = null;
110 110
 
111
-	/**
111
+    /**
112 112
      * Stores an array of item totals.
113
-	 *
114
-	 * e.g $totals['discount'] = array(
115
-	 * 		'initial'   => 10,
116
-	 * 		'recurring' => 10,
117
-	 * )
113
+     *
114
+     * e.g $totals['discount'] = array(
115
+     * 		'initial'   => 10,
116
+     * 		'recurring' => 10,
117
+     * )
118 118
      *
119 119
      * @var array
120 120
      */
121
-	protected $totals = array();
121
+    protected $totals = array();
122 122
 
123
-	/**
124
-	 * Stores the status transition information.
125
-	 *
126
-	 * @since 1.0.19
127
-	 * @var bool
128
-	 */
129
-	protected $status_transition = false;
123
+    /**
124
+     * Stores the status transition information.
125
+     *
126
+     * @since 1.0.19
127
+     * @var bool
128
+     */
129
+    protected $status_transition = false;
130 130
 
131 131
     /**
132
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
133
-	 *
134
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135
-	 */
132
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
133
+     *
134
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135
+     */
136 136
     public function __construct( $invoice = false ) {
137 137
 
138 138
         parent::__construct( $invoice );
139 139
 
140
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
-			$this->set_id( $invoice );
142
-		} elseif ( $invoice instanceof self ) {
143
-			$this->set_id( $invoice->get_id() );
144
-		} elseif ( ! empty( $invoice->ID ) ) {
145
-			$this->set_id( $invoice->ID );
146
-		} elseif ( is_array( $invoice ) ) {
147
-			$this->set_props( $invoice );
148
-
149
-			if ( isset( $invoice['ID'] ) ) {
150
-				$this->set_id( $invoice['ID'] );
151
-			}
152
-
153
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
-			$this->set_id( $invoice_id );
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		}else {
160
-			$this->set_object_read( true );
161
-		}
140
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
+            $this->set_id( $invoice );
142
+        } elseif ( $invoice instanceof self ) {
143
+            $this->set_id( $invoice->get_id() );
144
+        } elseif ( ! empty( $invoice->ID ) ) {
145
+            $this->set_id( $invoice->ID );
146
+        } elseif ( is_array( $invoice ) ) {
147
+            $this->set_props( $invoice );
148
+
149
+            if ( isset( $invoice['ID'] ) ) {
150
+                $this->set_id( $invoice['ID'] );
151
+            }
152
+
153
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
+            $this->set_id( $invoice_id );
155
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
+            $this->set_id( $invoice_id );
157
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
+            $this->set_id( $invoice_id );
159
+        }else {
160
+            $this->set_object_read( true );
161
+        }
162 162
 
163 163
         // Load the datastore.
164
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
164
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165 165
 
166
-		if ( $this->get_id() > 0 ) {
166
+        if ( $this->get_id() > 0 ) {
167 167
             $this->post = get_post( $this->get_id() );
168 168
             $this->ID   = $this->get_id();
169
-			$this->data_store->read( $this );
169
+            $this->data_store->read( $this );
170 170
         }
171 171
 
172 172
     }
173 173
 
174 174
     /**
175
-	 * Given an invoice key/number, it returns its id.
176
-	 *
177
-	 *
178
-	 * @static
179
-	 * @param string $value The invoice key or number
180
-	 * @param string $field Either key, transaction_id or number.
181
-	 * @since 1.0.15
182
-	 * @return int
183
-	 */
184
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
175
+     * Given an invoice key/number, it returns its id.
176
+     *
177
+     *
178
+     * @static
179
+     * @param string $value The invoice key or number
180
+     * @param string $field Either key, transaction_id or number.
181
+     * @since 1.0.15
182
+     * @return int
183
+     */
184
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185 185
         global $wpdb;
186 186
 
187
-		// Trim the value.
188
-		$value = trim( $value );
187
+        // Trim the value.
188
+        $value = trim( $value );
189 189
 
190
-		if ( empty( $value ) ) {
191
-			return 0;
192
-		}
190
+        if ( empty( $value ) ) {
191
+            return 0;
192
+        }
193 193
 
194 194
         // Valid fields.
195 195
         $fields = array( 'key', 'number', 'transaction_id' );
196 196
 
197
-		// Ensure a field has been passed.
198
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
-			return 0;
200
-		}
197
+        // Ensure a field has been passed.
198
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
+            return 0;
200
+        }
201 201
 
202
-		// Maybe retrieve from the cache.
203
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
-		if ( ! empty( $invoice_id ) ) {
205
-			return $invoice_id;
206
-		}
202
+        // Maybe retrieve from the cache.
203
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
+        if ( ! empty( $invoice_id ) ) {
205
+            return $invoice_id;
206
+        }
207 207
 
208 208
         // Fetch from the db.
209 209
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
212 212
         );
213 213
 
214
-		if ( empty( $invoice_id ) ) {
215
-			return 0;
216
-		}
214
+        if ( empty( $invoice_id ) ) {
215
+            return 0;
216
+        }
217 217
 
218
-		// Update the cache with our data
219
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
218
+        // Update the cache with our data
219
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
220 220
 
221
-		return $invoice_id;
221
+        return $invoice_id;
222 222
     }
223 223
 
224 224
     /**
@@ -244,73 +244,73 @@  discard block
 block discarded – undo
244 244
     */
245 245
 
246 246
     /**
247
-	 * Get parent invoice ID.
248
-	 *
249
-	 * @since 1.0.19
250
-	 * @param  string $context View or edit context.
251
-	 * @return int
252
-	 */
253
-	public function get_parent_id( $context = 'view' ) {
254
-		return (int) $this->get_prop( 'parent_id', $context );
247
+     * Get parent invoice ID.
248
+     *
249
+     * @since 1.0.19
250
+     * @param  string $context View or edit context.
251
+     * @return int
252
+     */
253
+    public function get_parent_id( $context = 'view' ) {
254
+        return (int) $this->get_prop( 'parent_id', $context );
255 255
     }
256 256
 
257 257
     /**
258
-	 * Get parent invoice.
259
-	 *
260
-	 * @since 1.0.19
261
-	 * @return WPInv_Invoice
262
-	 */
258
+     * Get parent invoice.
259
+     *
260
+     * @since 1.0.19
261
+     * @return WPInv_Invoice
262
+     */
263 263
     public function get_parent_payment() {
264 264
         return new WPInv_Invoice( $this->get_parent_id() );
265 265
     }
266 266
 
267 267
     /**
268
-	 * Alias for self::get_parent_payment().
269
-	 *
270
-	 * @since 1.0.19
271
-	 * @return WPInv_Invoice
272
-	 */
268
+     * Alias for self::get_parent_payment().
269
+     *
270
+     * @since 1.0.19
271
+     * @return WPInv_Invoice
272
+     */
273 273
     public function get_parent() {
274 274
         return $this->get_parent_payment();
275 275
     }
276 276
 
277 277
     /**
278
-	 * Get invoice status.
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return string
283
-	 */
284
-	public function get_status( $context = 'view' ) {
285
-		return $this->get_prop( 'status', $context );
286
-	}
278
+     * Get invoice status.
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return string
283
+     */
284
+    public function get_status( $context = 'view' ) {
285
+        return $this->get_prop( 'status', $context );
286
+    }
287 287
 	
288
-	/**
289
-	 * Retrieves an array of possible invoice statuses.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @return array
293
-	 */
294
-	public function get_all_statuses() {
295
-
296
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
297
-
298
-		// For backwards compatibility.
299
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
288
+    /**
289
+     * Retrieves an array of possible invoice statuses.
290
+     *
291
+     * @since 1.0.19
292
+     * @return array
293
+     */
294
+    public function get_all_statuses() {
295
+
296
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
297
+
298
+        // For backwards compatibility.
299
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
300 300
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
301
-		}
301
+        }
302 302
 
303
-		return $statuses;
303
+        return $statuses;
304 304
     }
305 305
 
306 306
     /**
307
-	 * Get invoice status nice name.
308
-	 *
309
-	 * @since 1.0.19
310
-	 * @return string
311
-	 */
307
+     * Get invoice status nice name.
308
+     *
309
+     * @since 1.0.19
310
+     * @return string
311
+     */
312 312
     public function get_status_nicename() {
313
-		$statuses = $this->get_all_statuses();
313
+        $statuses = $this->get_all_statuses();
314 314
 
315 315
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
316 316
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
     }
319 319
 
320 320
     /**
321
-	 * Get plugin version when the invoice was created.
322
-	 *
323
-	 * @since 1.0.19
324
-	 * @param  string $context View or edit context.
325
-	 * @return string
326
-	 */
327
-	public function get_version( $context = 'view' ) {
328
-		return $this->get_prop( 'version', $context );
329
-	}
321
+     * Get plugin version when the invoice was created.
322
+     *
323
+     * @since 1.0.19
324
+     * @param  string $context View or edit context.
325
+     * @return string
326
+     */
327
+    public function get_version( $context = 'view' ) {
328
+        return $this->get_prop( 'version', $context );
329
+    }
330 330
 
331
-	/**
332
-	 * @deprecated
333
-	 */
334
-	public function get_invoice_date( $formatted = true ) {
331
+    /**
332
+     * @deprecated
333
+     */
334
+    public function get_invoice_date( $formatted = true ) {
335 335
         $date_completed = $this->get_date_completed();
336 336
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
337 337
 
@@ -348,187 +348,187 @@  discard block
 block discarded – undo
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get date when the invoice was created.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_date_created( $context = 'view' ) {
358
-		return $this->get_prop( 'date_created', $context );
359
-	}
351
+     * Get date when the invoice was created.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_date_created( $context = 'view' ) {
358
+        return $this->get_prop( 'date_created', $context );
359
+    }
360 360
 	
361
-	/**
362
-	 * Alias for self::get_date_created().
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_created_date( $context = 'view' ) {
369
-		return $this->get_date_created( $context );
370
-    }
371
-
372
-    /**
373
-	 * Get GMT date when the invoice was created.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_date_created_gmt( $context = 'view' ) {
361
+    /**
362
+     * Alias for self::get_date_created().
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_created_date( $context = 'view' ) {
369
+        return $this->get_date_created( $context );
370
+    }
371
+
372
+    /**
373
+     * Get GMT date when the invoice was created.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_date_created_gmt( $context = 'view' ) {
380 380
         $date = $this->get_date_created( $context );
381 381
 
382 382
         if ( $date ) {
383 383
             $date = get_gmt_from_date( $date );
384 384
         }
385
-		return $date;
385
+        return $date;
386 386
     }
387 387
 
388 388
     /**
389
-	 * Get date when the invoice was last modified.
390
-	 *
391
-	 * @since 1.0.19
392
-	 * @param  string $context View or edit context.
393
-	 * @return string
394
-	 */
395
-	public function get_date_modified( $context = 'view' ) {
396
-		return $this->get_prop( 'date_modified', $context );
397
-	}
389
+     * Get date when the invoice was last modified.
390
+     *
391
+     * @since 1.0.19
392
+     * @param  string $context View or edit context.
393
+     * @return string
394
+     */
395
+    public function get_date_modified( $context = 'view' ) {
396
+        return $this->get_prop( 'date_modified', $context );
397
+    }
398 398
 
399
-	/**
400
-	 * Alias for self::get_date_modified().
401
-	 *
402
-	 * @since 1.0.19
403
-	 * @param  string $context View or edit context.
404
-	 * @return string
405
-	 */
406
-	public function get_modified_date( $context = 'view' ) {
407
-		return $this->get_date_modified( $context );
399
+    /**
400
+     * Alias for self::get_date_modified().
401
+     *
402
+     * @since 1.0.19
403
+     * @param  string $context View or edit context.
404
+     * @return string
405
+     */
406
+    public function get_modified_date( $context = 'view' ) {
407
+        return $this->get_date_modified( $context );
408 408
     }
409 409
 
410 410
     /**
411
-	 * Get GMT date when the invoice was last modified.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_date_modified_gmt( $context = 'view' ) {
411
+     * Get GMT date when the invoice was last modified.
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_date_modified_gmt( $context = 'view' ) {
418 418
         $date = $this->get_date_modified( $context );
419 419
 
420 420
         if ( $date ) {
421 421
             $date = get_gmt_from_date( $date );
422 422
         }
423
-		return $date;
423
+        return $date;
424 424
     }
425 425
 
426 426
     /**
427
-	 * Get the invoice due date.
428
-	 *
429
-	 * @since 1.0.19
430
-	 * @param  string $context View or edit context.
431
-	 * @return string
432
-	 */
433
-	public function get_due_date( $context = 'view' ) {
434
-		return $this->get_prop( 'due_date', $context );
427
+     * Get the invoice due date.
428
+     *
429
+     * @since 1.0.19
430
+     * @param  string $context View or edit context.
431
+     * @return string
432
+     */
433
+    public function get_due_date( $context = 'view' ) {
434
+        return $this->get_prop( 'due_date', $context );
435 435
     }
436 436
 
437 437
     /**
438
-	 * Alias for self::get_due_date().
439
-	 *
440
-	 * @since 1.0.19
441
-	 * @param  string $context View or edit context.
442
-	 * @return string
443
-	 */
444
-	public function get_date_due( $context = 'view' ) {
445
-		return $this->get_due_date( $context );
438
+     * Alias for self::get_due_date().
439
+     *
440
+     * @since 1.0.19
441
+     * @param  string $context View or edit context.
442
+     * @return string
443
+     */
444
+    public function get_date_due( $context = 'view' ) {
445
+        return $this->get_due_date( $context );
446 446
     }
447 447
 
448 448
     /**
449
-	 * Get the invoice GMT due date.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_due_date_gmt( $context = 'view' ) {
449
+     * Get the invoice GMT due date.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_due_date_gmt( $context = 'view' ) {
456 456
         $date = $this->get_due_date( $context );
457 457
 
458 458
         if ( $date ) {
459 459
             $date = get_gmt_from_date( $date );
460 460
         }
461
-		return $date;
461
+        return $date;
462 462
     }
463 463
 
464 464
     /**
465
-	 * Alias for self::get_due_date_gmt().
466
-	 *
467
-	 * @since 1.0.19
468
-	 * @param  string $context View or edit context.
469
-	 * @return string
470
-	 */
471
-	public function get_gmt_date_due( $context = 'view' ) {
472
-		return $this->get_due_date_gmt( $context );
465
+     * Alias for self::get_due_date_gmt().
466
+     *
467
+     * @since 1.0.19
468
+     * @param  string $context View or edit context.
469
+     * @return string
470
+     */
471
+    public function get_gmt_date_due( $context = 'view' ) {
472
+        return $this->get_due_date_gmt( $context );
473 473
     }
474 474
 
475 475
     /**
476
-	 * Get date when the invoice was completed.
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_completed_date( $context = 'view' ) {
483
-		return $this->get_prop( 'completed_date', $context );
476
+     * Get date when the invoice was completed.
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_completed_date( $context = 'view' ) {
483
+        return $this->get_prop( 'completed_date', $context );
484 484
     }
485 485
 
486 486
     /**
487
-	 * Alias for self::get_completed_date().
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_date_completed( $context = 'view' ) {
494
-		return $this->get_completed_date( $context );
487
+     * Alias for self::get_completed_date().
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_date_completed( $context = 'view' ) {
494
+        return $this->get_completed_date( $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Get GMT date when the invoice was was completed.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_completed_date_gmt( $context = 'view' ) {
498
+     * Get GMT date when the invoice was was completed.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_completed_date_gmt( $context = 'view' ) {
505 505
         $date = $this->get_completed_date( $context );
506 506
 
507 507
         if ( $date ) {
508 508
             $date = get_gmt_from_date( $date );
509 509
         }
510
-		return $date;
510
+        return $date;
511 511
     }
512 512
 
513 513
     /**
514
-	 * Alias for self::get_completed_date_gmt().
515
-	 *
516
-	 * @since 1.0.19
517
-	 * @param  string $context View or edit context.
518
-	 * @return string
519
-	 */
520
-	public function get_gmt_completed_date( $context = 'view' ) {
521
-		return $this->get_completed_date_gmt( $context );
514
+     * Alias for self::get_completed_date_gmt().
515
+     *
516
+     * @since 1.0.19
517
+     * @param  string $context View or edit context.
518
+     * @return string
519
+     */
520
+    public function get_gmt_completed_date( $context = 'view' ) {
521
+        return $this->get_completed_date_gmt( $context );
522 522
     }
523 523
 
524 524
     /**
525
-	 * Get the invoice number.
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  string $context View or edit context.
529
-	 * @return string
530
-	 */
531
-	public function get_number( $context = 'view' ) {
525
+     * Get the invoice number.
526
+     *
527
+     * @since 1.0.19
528
+     * @param  string $context View or edit context.
529
+     * @return string
530
+     */
531
+    public function get_number( $context = 'view' ) {
532 532
         $number = $this->get_prop( 'number', $context );
533 533
 
534 534
         if ( empty( $number ) ) {
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
             $this->set_number( $number );
537 537
         }
538 538
 
539
-		return $number;
539
+        return $number;
540 540
     }
541 541
 
542 542
     /**
543
-	 * Get the invoice key.
544
-	 *
545
-	 * @since 1.0.19
546
-	 * @param  string $context View or edit context.
547
-	 * @return string
548
-	 */
549
-	public function get_key( $context = 'view' ) {
543
+     * Get the invoice key.
544
+     *
545
+     * @since 1.0.19
546
+     * @param  string $context View or edit context.
547
+     * @return string
548
+     */
549
+    public function get_key( $context = 'view' ) {
550 550
         $key = $this->get_prop( 'key', $context );
551 551
 
552 552
         if ( empty( $key ) ) {
@@ -554,24 +554,24 @@  discard block
 block discarded – undo
554 554
             $this->set_key( $key );
555 555
         }
556 556
 
557
-		return $key;
557
+        return $key;
558 558
     }
559 559
 
560 560
     /**
561
-	 * Get the invoice type.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @param  string $context View or edit context.
565
-	 * @return string
566
-	 */
567
-	public function get_type( $context = 'view' ) {
561
+     * Get the invoice type.
562
+     *
563
+     * @since 1.0.19
564
+     * @param  string $context View or edit context.
565
+     * @return string
566
+     */
567
+    public function get_type( $context = 'view' ) {
568 568
         return $this->get_prop( 'type', $context );
569
-	}
569
+    }
570 570
 
571
-	/**
572
-	 * @deprecated
573
-	 */
574
-	public function get_invoice_quote_type( $post_id ) {
571
+    /**
572
+     * @deprecated
573
+     */
574
+    public function get_invoice_quote_type( $post_id ) {
575 575
         if ( empty( $post_id ) ) {
576 576
             return '';
577 577
         }
@@ -588,35 +588,35 @@  discard block
 block discarded – undo
588 588
     }
589 589
 
590 590
     /**
591
-	 * Get the invoice post type.
592
-	 *
593
-	 * @since 1.0.19
594
-	 * @param  string $context View or edit context.
595
-	 * @return string
596
-	 */
597
-	public function get_post_type( $context = 'view' ) {
591
+     * Get the invoice post type.
592
+     *
593
+     * @since 1.0.19
594
+     * @param  string $context View or edit context.
595
+     * @return string
596
+     */
597
+    public function get_post_type( $context = 'view' ) {
598 598
         return $this->get_prop( 'post_type', $context );
599 599
     }
600 600
 
601 601
     /**
602
-	 * Get the invoice mode.
603
-	 *
604
-	 * @since 1.0.19
605
-	 * @param  string $context View or edit context.
606
-	 * @return string
607
-	 */
608
-	public function get_mode( $context = 'view' ) {
602
+     * Get the invoice mode.
603
+     *
604
+     * @since 1.0.19
605
+     * @param  string $context View or edit context.
606
+     * @return string
607
+     */
608
+    public function get_mode( $context = 'view' ) {
609 609
         return $this->get_prop( 'mode', $context );
610 610
     }
611 611
 
612 612
     /**
613
-	 * Get the invoice path.
614
-	 *
615
-	 * @since 1.0.19
616
-	 * @param  string $context View or edit context.
617
-	 * @return string
618
-	 */
619
-	public function get_path( $context = 'view' ) {
613
+     * Get the invoice path.
614
+     *
615
+     * @since 1.0.19
616
+     * @param  string $context View or edit context.
617
+     * @return string
618
+     */
619
+    public function get_path( $context = 'view' ) {
620 620
         $path = $this->get_prop( 'path', $context );
621 621
 
622 622
         if ( empty( $path ) ) {
@@ -624,73 +624,73 @@  discard block
 block discarded – undo
624 624
             $path   = sanitize_title( $prefix . $this->get_id() );
625 625
         }
626 626
 
627
-		return $path;
627
+        return $path;
628 628
     }
629 629
 
630 630
     /**
631
-	 * Get the invoice name/title.
632
-	 *
633
-	 * @since 1.0.19
634
-	 * @param  string $context View or edit context.
635
-	 * @return string
636
-	 */
637
-	public function get_name( $context = 'view' ) {
631
+     * Get the invoice name/title.
632
+     *
633
+     * @since 1.0.19
634
+     * @param  string $context View or edit context.
635
+     * @return string
636
+     */
637
+    public function get_name( $context = 'view' ) {
638 638
         $name = $this->get_prop( 'title', $context );
639 639
 
640
-		return empty( $name ) ? $this->get_number( $context ) : $name;
640
+        return empty( $name ) ? $this->get_number( $context ) : $name;
641 641
     }
642 642
 
643 643
     /**
644
-	 * Alias of self::get_name().
645
-	 *
646
-	 * @since 1.0.19
647
-	 * @param  string $context View or edit context.
648
-	 * @return string
649
-	 */
650
-	public function get_title( $context = 'view' ) {
651
-		return $this->get_name( $context );
644
+     * Alias of self::get_name().
645
+     *
646
+     * @since 1.0.19
647
+     * @param  string $context View or edit context.
648
+     * @return string
649
+     */
650
+    public function get_title( $context = 'view' ) {
651
+        return $this->get_name( $context );
652 652
     }
653 653
 
654 654
     /**
655
-	 * Get the invoice description.
656
-	 *
657
-	 * @since 1.0.19
658
-	 * @param  string $context View or edit context.
659
-	 * @return string
660
-	 */
661
-	public function get_description( $context = 'view' ) {
662
-		return $this->get_prop( 'description', $context );
655
+     * Get the invoice description.
656
+     *
657
+     * @since 1.0.19
658
+     * @param  string $context View or edit context.
659
+     * @return string
660
+     */
661
+    public function get_description( $context = 'view' ) {
662
+        return $this->get_prop( 'description', $context );
663 663
     }
664 664
 
665 665
     /**
666
-	 * Alias of self::get_description().
667
-	 *
668
-	 * @since 1.0.19
669
-	 * @param  string $context View or edit context.
670
-	 * @return string
671
-	 */
672
-	public function get_excerpt( $context = 'view' ) {
673
-		return $this->get_description( $context );
666
+     * Alias of self::get_description().
667
+     *
668
+     * @since 1.0.19
669
+     * @param  string $context View or edit context.
670
+     * @return string
671
+     */
672
+    public function get_excerpt( $context = 'view' ) {
673
+        return $this->get_description( $context );
674 674
     }
675 675
 
676 676
     /**
677
-	 * Alias of self::get_description().
678
-	 *
679
-	 * @since 1.0.19
680
-	 * @param  string $context View or edit context.
681
-	 * @return string
682
-	 */
683
-	public function get_summary( $context = 'view' ) {
684
-		return $this->get_description( $context );
677
+     * Alias of self::get_description().
678
+     *
679
+     * @since 1.0.19
680
+     * @param  string $context View or edit context.
681
+     * @return string
682
+     */
683
+    public function get_summary( $context = 'view' ) {
684
+        return $this->get_description( $context );
685 685
     }
686 686
 
687 687
     /**
688
-	 * Returns the user info.
689
-	 *
690
-	 * @since 1.0.19
688
+     * Returns the user info.
689
+     *
690
+     * @since 1.0.19
691 691
      * @param  string $context View or edit context.
692
-	 * @return array
693
-	 */
692
+     * @return array
693
+     */
694 694
     public function get_user_info( $context = 'view' ) {
695 695
 
696 696
         $user_info = array(
@@ -707,605 +707,605 @@  discard block
 block discarded – undo
707 707
             'company'    => $this->get_company( $context ),
708 708
             'vat_number' => $this->get_vat_number( $context ),
709 709
             'discount'   => $this->get_discount_code( $context ),
710
-		);
710
+        );
711 711
 
712
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
712
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
713 713
 
714 714
     }
715 715
 
716 716
     /**
717
-	 * Get the customer id.
718
-	 *
719
-	 * @since 1.0.19
720
-	 * @param  string $context View or edit context.
721
-	 * @return int
722
-	 */
723
-	public function get_author( $context = 'view' ) {
724
-		return (int) $this->get_prop( 'author', $context );
717
+     * Get the customer id.
718
+     *
719
+     * @since 1.0.19
720
+     * @param  string $context View or edit context.
721
+     * @return int
722
+     */
723
+    public function get_author( $context = 'view' ) {
724
+        return (int) $this->get_prop( 'author', $context );
725 725
     }
726 726
 
727 727
     /**
728
-	 * Alias of self::get_author().
729
-	 *
730
-	 * @since 1.0.19
731
-	 * @param  string $context View or edit context.
732
-	 * @return int
733
-	 */
734
-	public function get_user_id( $context = 'view' ) {
735
-		return $this->get_author( $context );
728
+     * Alias of self::get_author().
729
+     *
730
+     * @since 1.0.19
731
+     * @param  string $context View or edit context.
732
+     * @return int
733
+     */
734
+    public function get_user_id( $context = 'view' ) {
735
+        return $this->get_author( $context );
736 736
     }
737 737
 
738
-     /**
739
-	 * Alias of self::get_author().
740
-	 *
741
-	 * @since 1.0.19
742
-	 * @param  string $context View or edit context.
743
-	 * @return int
744
-	 */
745
-	public function get_customer_id( $context = 'view' ) {
746
-		return $this->get_author( $context );
738
+        /**
739
+         * Alias of self::get_author().
740
+         *
741
+         * @since 1.0.19
742
+         * @param  string $context View or edit context.
743
+         * @return int
744
+         */
745
+    public function get_customer_id( $context = 'view' ) {
746
+        return $this->get_author( $context );
747 747
     }
748 748
 
749 749
     /**
750
-	 * Get the customer's ip.
751
-	 *
752
-	 * @since 1.0.19
753
-	 * @param  string $context View or edit context.
754
-	 * @return string
755
-	 */
756
-	public function get_ip( $context = 'view' ) {
757
-		return $this->get_prop( 'user_ip', $context );
750
+     * Get the customer's ip.
751
+     *
752
+     * @since 1.0.19
753
+     * @param  string $context View or edit context.
754
+     * @return string
755
+     */
756
+    public function get_ip( $context = 'view' ) {
757
+        return $this->get_prop( 'user_ip', $context );
758 758
     }
759 759
 
760 760
     /**
761
-	 * Alias of self::get_ip().
762
-	 *
763
-	 * @since 1.0.19
764
-	 * @param  string $context View or edit context.
765
-	 * @return string
766
-	 */
767
-	public function get_user_ip( $context = 'view' ) {
768
-		return $this->get_ip( $context );
761
+     * Alias of self::get_ip().
762
+     *
763
+     * @since 1.0.19
764
+     * @param  string $context View or edit context.
765
+     * @return string
766
+     */
767
+    public function get_user_ip( $context = 'view' ) {
768
+        return $this->get_ip( $context );
769 769
     }
770 770
 
771
-     /**
772
-	 * Alias of self::get_ip().
773
-	 *
774
-	 * @since 1.0.19
775
-	 * @param  string $context View or edit context.
776
-	 * @return string
777
-	 */
778
-	public function get_customer_ip( $context = 'view' ) {
779
-		return $this->get_ip( $context );
771
+        /**
772
+         * Alias of self::get_ip().
773
+         *
774
+         * @since 1.0.19
775
+         * @param  string $context View or edit context.
776
+         * @return string
777
+         */
778
+    public function get_customer_ip( $context = 'view' ) {
779
+        return $this->get_ip( $context );
780 780
     }
781 781
 
782 782
     /**
783
-	 * Get the customer's first name.
784
-	 *
785
-	 * @since 1.0.19
786
-	 * @param  string $context View or edit context.
787
-	 * @return string
788
-	 */
789
-	public function get_first_name( $context = 'view' ) {
790
-		return $this->get_prop( 'first_name', $context );
783
+     * Get the customer's first name.
784
+     *
785
+     * @since 1.0.19
786
+     * @param  string $context View or edit context.
787
+     * @return string
788
+     */
789
+    public function get_first_name( $context = 'view' ) {
790
+        return $this->get_prop( 'first_name', $context );
791 791
     }
792 792
 
793 793
     /**
794
-	 * Alias of self::get_first_name().
795
-	 *
796
-	 * @since 1.0.19
797
-	 * @param  string $context View or edit context.
798
-	 * @return int
799
-	 */
800
-	public function get_user_first_name( $context = 'view' ) {
801
-		return $this->get_first_name( $context );
794
+     * Alias of self::get_first_name().
795
+     *
796
+     * @since 1.0.19
797
+     * @param  string $context View or edit context.
798
+     * @return int
799
+     */
800
+    public function get_user_first_name( $context = 'view' ) {
801
+        return $this->get_first_name( $context );
802 802
     }
803 803
 
804
-     /**
805
-	 * Alias of self::get_first_name().
806
-	 *
807
-	 * @since 1.0.19
808
-	 * @param  string $context View or edit context.
809
-	 * @return int
810
-	 */
811
-	public function get_customer_first_name( $context = 'view' ) {
812
-		return $this->get_first_name( $context );
804
+        /**
805
+         * Alias of self::get_first_name().
806
+         *
807
+         * @since 1.0.19
808
+         * @param  string $context View or edit context.
809
+         * @return int
810
+         */
811
+    public function get_customer_first_name( $context = 'view' ) {
812
+        return $this->get_first_name( $context );
813 813
     }
814 814
 
815 815
     /**
816
-	 * Get the customer's last name.
817
-	 *
818
-	 * @since 1.0.19
819
-	 * @param  string $context View or edit context.
820
-	 * @return string
821
-	 */
822
-	public function get_last_name( $context = 'view' ) {
823
-		return $this->get_prop( 'last_name', $context );
816
+     * Get the customer's last name.
817
+     *
818
+     * @since 1.0.19
819
+     * @param  string $context View or edit context.
820
+     * @return string
821
+     */
822
+    public function get_last_name( $context = 'view' ) {
823
+        return $this->get_prop( 'last_name', $context );
824 824
     }
825 825
 
826 826
     /**
827
-	 * Alias of self::get_last_name().
828
-	 *
829
-	 * @since 1.0.19
830
-	 * @param  string $context View or edit context.
831
-	 * @return int
832
-	 */
833
-	public function get_user_last_name( $context = 'view' ) {
834
-		return $this->get_last_name( $context );
827
+     * Alias of self::get_last_name().
828
+     *
829
+     * @since 1.0.19
830
+     * @param  string $context View or edit context.
831
+     * @return int
832
+     */
833
+    public function get_user_last_name( $context = 'view' ) {
834
+        return $this->get_last_name( $context );
835 835
     }
836 836
 
837 837
     /**
838
-	 * Alias of self::get_last_name().
839
-	 *
840
-	 * @since 1.0.19
841
-	 * @param  string $context View or edit context.
842
-	 * @return int
843
-	 */
844
-	public function get_customer_last_name( $context = 'view' ) {
845
-		return $this->get_last_name( $context );
838
+     * Alias of self::get_last_name().
839
+     *
840
+     * @since 1.0.19
841
+     * @param  string $context View or edit context.
842
+     * @return int
843
+     */
844
+    public function get_customer_last_name( $context = 'view' ) {
845
+        return $this->get_last_name( $context );
846 846
     }
847 847
 
848 848
     /**
849
-	 * Get the customer's full name.
850
-	 *
851
-	 * @since 1.0.19
852
-	 * @param  string $context View or edit context.
853
-	 * @return string
854
-	 */
855
-	public function get_full_name( $context = 'view' ) {
856
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
849
+     * Get the customer's full name.
850
+     *
851
+     * @since 1.0.19
852
+     * @param  string $context View or edit context.
853
+     * @return string
854
+     */
855
+    public function get_full_name( $context = 'view' ) {
856
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
857 857
     }
858 858
 
859 859
     /**
860
-	 * Alias of self::get_full_name().
861
-	 *
862
-	 * @since 1.0.19
863
-	 * @param  string $context View or edit context.
864
-	 * @return int
865
-	 */
866
-	public function get_user_full_name( $context = 'view' ) {
867
-		return $this->get_full_name( $context );
860
+     * Alias of self::get_full_name().
861
+     *
862
+     * @since 1.0.19
863
+     * @param  string $context View or edit context.
864
+     * @return int
865
+     */
866
+    public function get_user_full_name( $context = 'view' ) {
867
+        return $this->get_full_name( $context );
868 868
     }
869 869
 
870 870
     /**
871
-	 * Alias of self::get_full_name().
872
-	 *
873
-	 * @since 1.0.19
874
-	 * @param  string $context View or edit context.
875
-	 * @return int
876
-	 */
877
-	public function get_customer_full_name( $context = 'view' ) {
878
-		return $this->get_full_name( $context );
871
+     * Alias of self::get_full_name().
872
+     *
873
+     * @since 1.0.19
874
+     * @param  string $context View or edit context.
875
+     * @return int
876
+     */
877
+    public function get_customer_full_name( $context = 'view' ) {
878
+        return $this->get_full_name( $context );
879 879
     }
880 880
 
881 881
     /**
882
-	 * Get the customer's phone number.
883
-	 *
884
-	 * @since 1.0.19
885
-	 * @param  string $context View or edit context.
886
-	 * @return string
887
-	 */
888
-	public function get_phone( $context = 'view' ) {
889
-		return $this->get_prop( 'phone', $context );
882
+     * Get the customer's phone number.
883
+     *
884
+     * @since 1.0.19
885
+     * @param  string $context View or edit context.
886
+     * @return string
887
+     */
888
+    public function get_phone( $context = 'view' ) {
889
+        return $this->get_prop( 'phone', $context );
890 890
     }
891 891
 
892 892
     /**
893
-	 * Alias of self::get_phone().
894
-	 *
895
-	 * @since 1.0.19
896
-	 * @param  string $context View or edit context.
897
-	 * @return int
898
-	 */
899
-	public function get_phone_number( $context = 'view' ) {
900
-		return $this->get_phone( $context );
893
+     * Alias of self::get_phone().
894
+     *
895
+     * @since 1.0.19
896
+     * @param  string $context View or edit context.
897
+     * @return int
898
+     */
899
+    public function get_phone_number( $context = 'view' ) {
900
+        return $this->get_phone( $context );
901 901
     }
902 902
 
903 903
     /**
904
-	 * Alias of self::get_phone().
905
-	 *
906
-	 * @since 1.0.19
907
-	 * @param  string $context View or edit context.
908
-	 * @return int
909
-	 */
910
-	public function get_user_phone( $context = 'view' ) {
911
-		return $this->get_phone( $context );
904
+     * Alias of self::get_phone().
905
+     *
906
+     * @since 1.0.19
907
+     * @param  string $context View or edit context.
908
+     * @return int
909
+     */
910
+    public function get_user_phone( $context = 'view' ) {
911
+        return $this->get_phone( $context );
912 912
     }
913 913
 
914 914
     /**
915
-	 * Alias of self::get_phone().
916
-	 *
917
-	 * @since 1.0.19
918
-	 * @param  string $context View or edit context.
919
-	 * @return int
920
-	 */
921
-	public function get_customer_phone( $context = 'view' ) {
922
-		return $this->get_phone( $context );
915
+     * Alias of self::get_phone().
916
+     *
917
+     * @since 1.0.19
918
+     * @param  string $context View or edit context.
919
+     * @return int
920
+     */
921
+    public function get_customer_phone( $context = 'view' ) {
922
+        return $this->get_phone( $context );
923 923
     }
924 924
 
925 925
     /**
926
-	 * Get the customer's email address.
927
-	 *
928
-	 * @since 1.0.19
929
-	 * @param  string $context View or edit context.
930
-	 * @return string
931
-	 */
932
-	public function get_email( $context = 'view' ) {
933
-		return $this->get_prop( 'email', $context );
926
+     * Get the customer's email address.
927
+     *
928
+     * @since 1.0.19
929
+     * @param  string $context View or edit context.
930
+     * @return string
931
+     */
932
+    public function get_email( $context = 'view' ) {
933
+        return $this->get_prop( 'email', $context );
934 934
     }
935 935
 
936 936
     /**
937
-	 * Alias of self::get_email().
938
-	 *
939
-	 * @since 1.0.19
940
-	 * @param  string $context View or edit context.
941
-	 * @return string
942
-	 */
943
-	public function get_email_address( $context = 'view' ) {
944
-		return $this->get_email( $context );
937
+     * Alias of self::get_email().
938
+     *
939
+     * @since 1.0.19
940
+     * @param  string $context View or edit context.
941
+     * @return string
942
+     */
943
+    public function get_email_address( $context = 'view' ) {
944
+        return $this->get_email( $context );
945 945
     }
946 946
 
947 947
     /**
948
-	 * Alias of self::get_email().
949
-	 *
950
-	 * @since 1.0.19
951
-	 * @param  string $context View or edit context.
952
-	 * @return int
953
-	 */
954
-	public function get_user_email( $context = 'view' ) {
955
-		return $this->get_email( $context );
948
+     * Alias of self::get_email().
949
+     *
950
+     * @since 1.0.19
951
+     * @param  string $context View or edit context.
952
+     * @return int
953
+     */
954
+    public function get_user_email( $context = 'view' ) {
955
+        return $this->get_email( $context );
956 956
     }
957 957
 
958 958
     /**
959
-	 * Alias of self::get_email().
960
-	 *
961
-	 * @since 1.0.19
962
-	 * @param  string $context View or edit context.
963
-	 * @return int
964
-	 */
965
-	public function get_customer_email( $context = 'view' ) {
966
-		return $this->get_email( $context );
959
+     * Alias of self::get_email().
960
+     *
961
+     * @since 1.0.19
962
+     * @param  string $context View or edit context.
963
+     * @return int
964
+     */
965
+    public function get_customer_email( $context = 'view' ) {
966
+        return $this->get_email( $context );
967 967
     }
968 968
 
969 969
     /**
970
-	 * Get the customer's country.
971
-	 *
972
-	 * @since 1.0.19
973
-	 * @param  string $context View or edit context.
974
-	 * @return string
975
-	 */
976
-	public function get_country( $context = 'view' ) {
977
-		$country = $this->get_prop( 'country', $context );
978
-		return empty( $country ) ? wpinv_get_default_country() : $country;
970
+     * Get the customer's country.
971
+     *
972
+     * @since 1.0.19
973
+     * @param  string $context View or edit context.
974
+     * @return string
975
+     */
976
+    public function get_country( $context = 'view' ) {
977
+        $country = $this->get_prop( 'country', $context );
978
+        return empty( $country ) ? wpinv_get_default_country() : $country;
979 979
     }
980 980
 
981 981
     /**
982
-	 * Alias of self::get_country().
983
-	 *
984
-	 * @since 1.0.19
985
-	 * @param  string $context View or edit context.
986
-	 * @return int
987
-	 */
988
-	public function get_user_country( $context = 'view' ) {
989
-		return $this->get_country( $context );
982
+     * Alias of self::get_country().
983
+     *
984
+     * @since 1.0.19
985
+     * @param  string $context View or edit context.
986
+     * @return int
987
+     */
988
+    public function get_user_country( $context = 'view' ) {
989
+        return $this->get_country( $context );
990 990
     }
991 991
 
992 992
     /**
993
-	 * Alias of self::get_country().
994
-	 *
995
-	 * @since 1.0.19
996
-	 * @param  string $context View or edit context.
997
-	 * @return int
998
-	 */
999
-	public function get_customer_country( $context = 'view' ) {
1000
-		return $this->get_country( $context );
993
+     * Alias of self::get_country().
994
+     *
995
+     * @since 1.0.19
996
+     * @param  string $context View or edit context.
997
+     * @return int
998
+     */
999
+    public function get_customer_country( $context = 'view' ) {
1000
+        return $this->get_country( $context );
1001 1001
     }
1002 1002
 
1003 1003
     /**
1004
-	 * Get the customer's state.
1005
-	 *
1006
-	 * @since 1.0.19
1007
-	 * @param  string $context View or edit context.
1008
-	 * @return string
1009
-	 */
1010
-	public function get_state( $context = 'view' ) {
1011
-		$state = $this->get_prop( 'state', $context );
1012
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1004
+     * Get the customer's state.
1005
+     *
1006
+     * @since 1.0.19
1007
+     * @param  string $context View or edit context.
1008
+     * @return string
1009
+     */
1010
+    public function get_state( $context = 'view' ) {
1011
+        $state = $this->get_prop( 'state', $context );
1012
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1013 1013
     }
1014 1014
 
1015 1015
     /**
1016
-	 * Alias of self::get_state().
1017
-	 *
1018
-	 * @since 1.0.19
1019
-	 * @param  string $context View or edit context.
1020
-	 * @return int
1021
-	 */
1022
-	public function get_user_state( $context = 'view' ) {
1023
-		return $this->get_state( $context );
1016
+     * Alias of self::get_state().
1017
+     *
1018
+     * @since 1.0.19
1019
+     * @param  string $context View or edit context.
1020
+     * @return int
1021
+     */
1022
+    public function get_user_state( $context = 'view' ) {
1023
+        return $this->get_state( $context );
1024 1024
     }
1025 1025
 
1026 1026
     /**
1027
-	 * Alias of self::get_state().
1028
-	 *
1029
-	 * @since 1.0.19
1030
-	 * @param  string $context View or edit context.
1031
-	 * @return int
1032
-	 */
1033
-	public function get_customer_state( $context = 'view' ) {
1034
-		return $this->get_state( $context );
1027
+     * Alias of self::get_state().
1028
+     *
1029
+     * @since 1.0.19
1030
+     * @param  string $context View or edit context.
1031
+     * @return int
1032
+     */
1033
+    public function get_customer_state( $context = 'view' ) {
1034
+        return $this->get_state( $context );
1035 1035
     }
1036 1036
 
1037 1037
     /**
1038
-	 * Get the customer's city.
1039
-	 *
1040
-	 * @since 1.0.19
1041
-	 * @param  string $context View or edit context.
1042
-	 * @return string
1043
-	 */
1044
-	public function get_city( $context = 'view' ) {
1045
-		return $this->get_prop( 'city', $context );
1038
+     * Get the customer's city.
1039
+     *
1040
+     * @since 1.0.19
1041
+     * @param  string $context View or edit context.
1042
+     * @return string
1043
+     */
1044
+    public function get_city( $context = 'view' ) {
1045
+        return $this->get_prop( 'city', $context );
1046 1046
     }
1047 1047
 
1048 1048
     /**
1049
-	 * Alias of self::get_city().
1050
-	 *
1051
-	 * @since 1.0.19
1052
-	 * @param  string $context View or edit context.
1053
-	 * @return string
1054
-	 */
1055
-	public function get_user_city( $context = 'view' ) {
1056
-		return $this->get_city( $context );
1049
+     * Alias of self::get_city().
1050
+     *
1051
+     * @since 1.0.19
1052
+     * @param  string $context View or edit context.
1053
+     * @return string
1054
+     */
1055
+    public function get_user_city( $context = 'view' ) {
1056
+        return $this->get_city( $context );
1057 1057
     }
1058 1058
 
1059 1059
     /**
1060
-	 * Alias of self::get_city().
1061
-	 *
1062
-	 * @since 1.0.19
1063
-	 * @param  string $context View or edit context.
1064
-	 * @return string
1065
-	 */
1066
-	public function get_customer_city( $context = 'view' ) {
1067
-		return $this->get_city( $context );
1060
+     * Alias of self::get_city().
1061
+     *
1062
+     * @since 1.0.19
1063
+     * @param  string $context View or edit context.
1064
+     * @return string
1065
+     */
1066
+    public function get_customer_city( $context = 'view' ) {
1067
+        return $this->get_city( $context );
1068 1068
     }
1069 1069
 
1070 1070
     /**
1071
-	 * Get the customer's zip.
1072
-	 *
1073
-	 * @since 1.0.19
1074
-	 * @param  string $context View or edit context.
1075
-	 * @return string
1076
-	 */
1077
-	public function get_zip( $context = 'view' ) {
1078
-		return $this->get_prop( 'zip', $context );
1071
+     * Get the customer's zip.
1072
+     *
1073
+     * @since 1.0.19
1074
+     * @param  string $context View or edit context.
1075
+     * @return string
1076
+     */
1077
+    public function get_zip( $context = 'view' ) {
1078
+        return $this->get_prop( 'zip', $context );
1079 1079
     }
1080 1080
 
1081 1081
     /**
1082
-	 * Alias of self::get_zip().
1083
-	 *
1084
-	 * @since 1.0.19
1085
-	 * @param  string $context View or edit context.
1086
-	 * @return string
1087
-	 */
1088
-	public function get_user_zip( $context = 'view' ) {
1089
-		return $this->get_zip( $context );
1082
+     * Alias of self::get_zip().
1083
+     *
1084
+     * @since 1.0.19
1085
+     * @param  string $context View or edit context.
1086
+     * @return string
1087
+     */
1088
+    public function get_user_zip( $context = 'view' ) {
1089
+        return $this->get_zip( $context );
1090 1090
     }
1091 1091
 
1092 1092
     /**
1093
-	 * Alias of self::get_zip().
1094
-	 *
1095
-	 * @since 1.0.19
1096
-	 * @param  string $context View or edit context.
1097
-	 * @return string
1098
-	 */
1099
-	public function get_customer_zip( $context = 'view' ) {
1100
-		return $this->get_zip( $context );
1093
+     * Alias of self::get_zip().
1094
+     *
1095
+     * @since 1.0.19
1096
+     * @param  string $context View or edit context.
1097
+     * @return string
1098
+     */
1099
+    public function get_customer_zip( $context = 'view' ) {
1100
+        return $this->get_zip( $context );
1101 1101
     }
1102 1102
 
1103 1103
     /**
1104
-	 * Get the customer's company.
1105
-	 *
1106
-	 * @since 1.0.19
1107
-	 * @param  string $context View or edit context.
1108
-	 * @return string
1109
-	 */
1110
-	public function get_company( $context = 'view' ) {
1111
-		return $this->get_prop( 'company', $context );
1104
+     * Get the customer's company.
1105
+     *
1106
+     * @since 1.0.19
1107
+     * @param  string $context View or edit context.
1108
+     * @return string
1109
+     */
1110
+    public function get_company( $context = 'view' ) {
1111
+        return $this->get_prop( 'company', $context );
1112 1112
     }
1113 1113
 
1114 1114
     /**
1115
-	 * Alias of self::get_company().
1116
-	 *
1117
-	 * @since 1.0.19
1118
-	 * @param  string $context View or edit context.
1119
-	 * @return string
1120
-	 */
1121
-	public function get_user_company( $context = 'view' ) {
1122
-		return $this->get_company( $context );
1115
+     * Alias of self::get_company().
1116
+     *
1117
+     * @since 1.0.19
1118
+     * @param  string $context View or edit context.
1119
+     * @return string
1120
+     */
1121
+    public function get_user_company( $context = 'view' ) {
1122
+        return $this->get_company( $context );
1123 1123
     }
1124 1124
 
1125 1125
     /**
1126
-	 * Alias of self::get_company().
1127
-	 *
1128
-	 * @since 1.0.19
1129
-	 * @param  string $context View or edit context.
1130
-	 * @return string
1131
-	 */
1132
-	public function get_customer_company( $context = 'view' ) {
1133
-		return $this->get_company( $context );
1126
+     * Alias of self::get_company().
1127
+     *
1128
+     * @since 1.0.19
1129
+     * @param  string $context View or edit context.
1130
+     * @return string
1131
+     */
1132
+    public function get_customer_company( $context = 'view' ) {
1133
+        return $this->get_company( $context );
1134 1134
     }
1135 1135
 
1136 1136
     /**
1137
-	 * Get the customer's vat number.
1138
-	 *
1139
-	 * @since 1.0.19
1140
-	 * @param  string $context View or edit context.
1141
-	 * @return string
1142
-	 */
1143
-	public function get_vat_number( $context = 'view' ) {
1144
-		return $this->get_prop( 'vat_number', $context );
1137
+     * Get the customer's vat number.
1138
+     *
1139
+     * @since 1.0.19
1140
+     * @param  string $context View or edit context.
1141
+     * @return string
1142
+     */
1143
+    public function get_vat_number( $context = 'view' ) {
1144
+        return $this->get_prop( 'vat_number', $context );
1145 1145
     }
1146 1146
 
1147 1147
     /**
1148
-	 * Alias of self::get_vat_number().
1149
-	 *
1150
-	 * @since 1.0.19
1151
-	 * @param  string $context View or edit context.
1152
-	 * @return string
1153
-	 */
1154
-	public function get_user_vat_number( $context = 'view' ) {
1155
-		return $this->get_vat_number( $context );
1148
+     * Alias of self::get_vat_number().
1149
+     *
1150
+     * @since 1.0.19
1151
+     * @param  string $context View or edit context.
1152
+     * @return string
1153
+     */
1154
+    public function get_user_vat_number( $context = 'view' ) {
1155
+        return $this->get_vat_number( $context );
1156 1156
     }
1157 1157
 
1158 1158
     /**
1159
-	 * Alias of self::get_vat_number().
1160
-	 *
1161
-	 * @since 1.0.19
1162
-	 * @param  string $context View or edit context.
1163
-	 * @return string
1164
-	 */
1165
-	public function get_customer_vat_number( $context = 'view' ) {
1166
-		return $this->get_vat_number( $context );
1167
-    }
1168
-
1159
+     * Alias of self::get_vat_number().
1160
+     *
1161
+     * @since 1.0.19
1162
+     * @param  string $context View or edit context.
1163
+     * @return string
1164
+     */
1165
+    public function get_customer_vat_number( $context = 'view' ) {
1166
+        return $this->get_vat_number( $context );
1167
+    }
1168
+
1169
+    /**
1170
+     * Get the customer's vat rate.
1171
+     *
1172
+     * @since 1.0.19
1173
+     * @param  string $context View or edit context.
1174
+     * @return string
1175
+     */
1176
+    public function get_vat_rate( $context = 'view' ) {
1177
+        return $this->get_prop( 'vat_rate', $context );
1178
+    }
1179
+
1180
+    /**
1181
+     * Alias of self::get_vat_rate().
1182
+     *
1183
+     * @since 1.0.19
1184
+     * @param  string $context View or edit context.
1185
+     * @return string
1186
+     */
1187
+    public function get_user_vat_rate( $context = 'view' ) {
1188
+        return $this->get_vat_rate( $context );
1189
+    }
1190
+
1191
+    /**
1192
+     * Alias of self::get_vat_rate().
1193
+     *
1194
+     * @since 1.0.19
1195
+     * @param  string $context View or edit context.
1196
+     * @return string
1197
+     */
1198
+    public function get_customer_vat_rate( $context = 'view' ) {
1199
+        return $this->get_vat_rate( $context );
1200
+    }
1201
+
1169 1202
     /**
1170
-	 * Get the customer's vat rate.
1171
-	 *
1172
-	 * @since 1.0.19
1173
-	 * @param  string $context View or edit context.
1174
-	 * @return string
1175
-	 */
1176
-	public function get_vat_rate( $context = 'view' ) {
1177
-		return $this->get_prop( 'vat_rate', $context );
1203
+     * Get the customer's address.
1204
+     *
1205
+     * @since 1.0.19
1206
+     * @param  string $context View or edit context.
1207
+     * @return string
1208
+     */
1209
+    public function get_address( $context = 'view' ) {
1210
+        return $this->get_prop( 'address', $context );
1178 1211
     }
1179 1212
 
1180 1213
     /**
1181
-	 * Alias of self::get_vat_rate().
1182
-	 *
1183
-	 * @since 1.0.19
1184
-	 * @param  string $context View or edit context.
1185
-	 * @return string
1186
-	 */
1187
-	public function get_user_vat_rate( $context = 'view' ) {
1188
-		return $this->get_vat_rate( $context );
1214
+     * Alias of self::get_address().
1215
+     *
1216
+     * @since 1.0.19
1217
+     * @param  string $context View or edit context.
1218
+     * @return string
1219
+     */
1220
+    public function get_user_address( $context = 'view' ) {
1221
+        return $this->get_address( $context );
1189 1222
     }
1190 1223
 
1191 1224
     /**
1192
-	 * Alias of self::get_vat_rate().
1193
-	 *
1194
-	 * @since 1.0.19
1195
-	 * @param  string $context View or edit context.
1196
-	 * @return string
1197
-	 */
1198
-	public function get_customer_vat_rate( $context = 'view' ) {
1199
-		return $this->get_vat_rate( $context );
1225
+     * Alias of self::get_address().
1226
+     *
1227
+     * @since 1.0.19
1228
+     * @param  string $context View or edit context.
1229
+     * @return string
1230
+     */
1231
+    public function get_customer_address( $context = 'view' ) {
1232
+        return $this->get_address( $context );
1233
+    }
1234
+
1235
+    /**
1236
+     * Get whether the customer has viewed the invoice or not.
1237
+     *
1238
+     * @since 1.0.19
1239
+     * @param  string $context View or edit context.
1240
+     * @return bool
1241
+     */
1242
+    public function get_is_viewed( $context = 'view' ) {
1243
+        return (bool) $this->get_prop( 'is_viewed', $context );
1200 1244
     }
1201 1245
 
1202 1246
     /**
1203
-	 * Get the customer's address.
1204
-	 *
1205
-	 * @since 1.0.19
1206
-	 * @param  string $context View or edit context.
1207
-	 * @return string
1208
-	 */
1209
-	public function get_address( $context = 'view' ) {
1210
-		return $this->get_prop( 'address', $context );
1211
-    }
1212
-
1213
-    /**
1214
-	 * Alias of self::get_address().
1215
-	 *
1216
-	 * @since 1.0.19
1217
-	 * @param  string $context View or edit context.
1218
-	 * @return string
1219
-	 */
1220
-	public function get_user_address( $context = 'view' ) {
1221
-		return $this->get_address( $context );
1222
-    }
1223
-
1224
-    /**
1225
-	 * Alias of self::get_address().
1226
-	 *
1227
-	 * @since 1.0.19
1228
-	 * @param  string $context View or edit context.
1229
-	 * @return string
1230
-	 */
1231
-	public function get_customer_address( $context = 'view' ) {
1232
-		return $this->get_address( $context );
1233
-    }
1234
-
1235
-    /**
1236
-	 * Get whether the customer has viewed the invoice or not.
1237
-	 *
1238
-	 * @since 1.0.19
1239
-	 * @param  string $context View or edit context.
1240
-	 * @return bool
1241
-	 */
1242
-	public function get_is_viewed( $context = 'view' ) {
1243
-		return (bool) $this->get_prop( 'is_viewed', $context );
1244
-	}
1245
-
1246
-	/**
1247
-	 * Get other recipients for invoice communications.
1248
-	 *
1249
-	 * @since 1.0.19
1250
-	 * @param  string $context View or edit context.
1251
-	 * @return bool
1252
-	 */
1253
-	public function get_email_cc( $context = 'view' ) {
1254
-		return $this->get_prop( 'email_cc', $context );
1255
-	}
1256
-
1257
-	/**
1258
-	 * Get invoice template.
1259
-	 *
1260
-	 * @since 1.0.19
1261
-	 * @param  string $context View or edit context.
1262
-	 * @return bool
1263
-	 */
1264
-	public function get_template( $context = 'view' ) {
1265
-		return $this->get_prop( 'template', $context );
1266
-	}
1267
-
1268
-	/**
1269
-	 * Get whether the customer has confirmed their address.
1270
-	 *
1271
-	 * @since 1.0.19
1272
-	 * @param  string $context View or edit context.
1273
-	 * @return bool
1274
-	 */
1275
-	public function get_address_confirmed( $context = 'view' ) {
1276
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1277
-    }
1278
-
1279
-    /**
1280
-	 * Alias of self::get_address_confirmed().
1281
-	 *
1282
-	 * @since 1.0.19
1283
-	 * @param  string $context View or edit context.
1284
-	 * @return bool
1285
-	 */
1286
-	public function get_user_address_confirmed( $context = 'view' ) {
1287
-		return $this->get_address_confirmed( $context );
1288
-    }
1289
-
1290
-    /**
1291
-	 * Alias of self::get_address().
1292
-	 *
1293
-	 * @since 1.0.19
1294
-	 * @param  string $context View or edit context.
1295
-	 * @return bool
1296
-	 */
1297
-	public function get_customer_address_confirmed( $context = 'view' ) {
1298
-		return $this->get_address_confirmed( $context );
1299
-    }
1300
-
1301
-    /**
1302
-	 * Get the invoice subtotal.
1303
-	 *
1304
-	 * @since 1.0.19
1305
-	 * @param  string $context View or edit context.
1306
-	 * @return float
1307
-	 */
1308
-	public function get_subtotal( $context = 'view' ) {
1247
+     * Get other recipients for invoice communications.
1248
+     *
1249
+     * @since 1.0.19
1250
+     * @param  string $context View or edit context.
1251
+     * @return bool
1252
+     */
1253
+    public function get_email_cc( $context = 'view' ) {
1254
+        return $this->get_prop( 'email_cc', $context );
1255
+    }
1256
+
1257
+    /**
1258
+     * Get invoice template.
1259
+     *
1260
+     * @since 1.0.19
1261
+     * @param  string $context View or edit context.
1262
+     * @return bool
1263
+     */
1264
+    public function get_template( $context = 'view' ) {
1265
+        return $this->get_prop( 'template', $context );
1266
+    }
1267
+
1268
+    /**
1269
+     * Get whether the customer has confirmed their address.
1270
+     *
1271
+     * @since 1.0.19
1272
+     * @param  string $context View or edit context.
1273
+     * @return bool
1274
+     */
1275
+    public function get_address_confirmed( $context = 'view' ) {
1276
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1277
+    }
1278
+
1279
+    /**
1280
+     * Alias of self::get_address_confirmed().
1281
+     *
1282
+     * @since 1.0.19
1283
+     * @param  string $context View or edit context.
1284
+     * @return bool
1285
+     */
1286
+    public function get_user_address_confirmed( $context = 'view' ) {
1287
+        return $this->get_address_confirmed( $context );
1288
+    }
1289
+
1290
+    /**
1291
+     * Alias of self::get_address().
1292
+     *
1293
+     * @since 1.0.19
1294
+     * @param  string $context View or edit context.
1295
+     * @return bool
1296
+     */
1297
+    public function get_customer_address_confirmed( $context = 'view' ) {
1298
+        return $this->get_address_confirmed( $context );
1299
+    }
1300
+
1301
+    /**
1302
+     * Get the invoice subtotal.
1303
+     *
1304
+     * @since 1.0.19
1305
+     * @param  string $context View or edit context.
1306
+     * @return float
1307
+     */
1308
+    public function get_subtotal( $context = 'view' ) {
1309 1309
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1310 1310
 
1311 1311
         // Backwards compatibility.
@@ -1317,165 +1317,165 @@  discard block
 block discarded – undo
1317 1317
     }
1318 1318
 
1319 1319
     /**
1320
-	 * Get the invoice discount total.
1321
-	 *
1322
-	 * @since 1.0.19
1323
-	 * @param  string $context View or edit context.
1324
-	 * @return float
1325
-	 */
1326
-	public function get_total_discount( $context = 'view' ) {
1327
-		return (float) $this->get_prop( 'total_discount', $context );
1320
+     * Get the invoice discount total.
1321
+     *
1322
+     * @since 1.0.19
1323
+     * @param  string $context View or edit context.
1324
+     * @return float
1325
+     */
1326
+    public function get_total_discount( $context = 'view' ) {
1327
+        return (float) $this->get_prop( 'total_discount', $context );
1328 1328
     }
1329 1329
 
1330 1330
     /**
1331
-	 * Get the invoice tax total.
1332
-	 *
1333
-	 * @since 1.0.19
1334
-	 * @param  string $context View or edit context.
1335
-	 * @return float
1336
-	 */
1337
-	public function get_total_tax( $context = 'view' ) {
1338
-		return (float) $this->get_prop( 'total_tax', $context );
1339
-	}
1331
+     * Get the invoice tax total.
1332
+     *
1333
+     * @since 1.0.19
1334
+     * @param  string $context View or edit context.
1335
+     * @return float
1336
+     */
1337
+    public function get_total_tax( $context = 'view' ) {
1338
+        return (float) $this->get_prop( 'total_tax', $context );
1339
+    }
1340 1340
 
1341
-	/**
1342
-	 * @deprecated
1343
-	 */
1344
-	public function get_final_tax( $currency = false ) {
1345
-		$tax = $this->get_total_tax();
1341
+    /**
1342
+     * @deprecated
1343
+     */
1344
+    public function get_final_tax( $currency = false ) {
1345
+        $tax = $this->get_total_tax();
1346 1346
 
1347 1347
         if ( $currency ) {
1348
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1348
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1349 1349
         }
1350 1350
 
1351 1351
         return $tax;
1352 1352
     }
1353 1353
 
1354 1354
     /**
1355
-	 * Get the invoice fees total.
1356
-	 *
1357
-	 * @since 1.0.19
1358
-	 * @param  string $context View or edit context.
1359
-	 * @return float
1360
-	 */
1361
-	public function get_total_fees( $context = 'view' ) {
1362
-		return (float) $this->get_prop( 'total_fees', $context );
1355
+     * Get the invoice fees total.
1356
+     *
1357
+     * @since 1.0.19
1358
+     * @param  string $context View or edit context.
1359
+     * @return float
1360
+     */
1361
+    public function get_total_fees( $context = 'view' ) {
1362
+        return (float) $this->get_prop( 'total_fees', $context );
1363 1363
     }
1364 1364
 
1365 1365
     /**
1366
-	 * Alias for self::get_total_fees().
1367
-	 *
1368
-	 * @since 1.0.19
1369
-	 * @param  string $context View or edit context.
1370
-	 * @return float
1371
-	 */
1372
-	public function get_fees_total( $context = 'view' ) {
1373
-		return $this->get_total_fees( $context );
1366
+     * Alias for self::get_total_fees().
1367
+     *
1368
+     * @since 1.0.19
1369
+     * @param  string $context View or edit context.
1370
+     * @return float
1371
+     */
1372
+    public function get_fees_total( $context = 'view' ) {
1373
+        return $this->get_total_fees( $context );
1374 1374
     }
1375 1375
 
1376 1376
     /**
1377
-	 * Get the invoice total.
1378
-	 *
1379
-	 * @since 1.0.19
1377
+     * Get the invoice total.
1378
+     *
1379
+     * @since 1.0.19
1380 1380
      * @return float
1381
-	 */
1382
-	public function get_total() {
1383
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1385
-	}
1381
+     */
1382
+    public function get_total() {
1383
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1385
+    }
1386 1386
 	
1387
-	/**
1388
-	 * Get the invoice totals.
1389
-	 *
1390
-	 * @since 1.0.19
1387
+    /**
1388
+     * Get the invoice totals.
1389
+     *
1390
+     * @since 1.0.19
1391 1391
      * @return float
1392
-	 */
1393
-	public function get_totals() {
1394
-		return $this->totals;
1392
+     */
1393
+    public function get_totals() {
1394
+        return $this->totals;
1395 1395
     }
1396 1396
 
1397 1397
     /**
1398
-	 * Get the initial invoice total.
1399
-	 *
1400
-	 * @since 1.0.19
1398
+     * Get the initial invoice total.
1399
+     *
1400
+     * @since 1.0.19
1401 1401
      * @param  string $context View or edit context.
1402 1402
      * @return float
1403
-	 */
1403
+     */
1404 1404
     public function get_initial_total() {
1405 1405
 
1406
-		if ( empty( $this->totals ) ) {
1407
-			$this->recalculate_total();
1408
-		}
1406
+        if ( empty( $this->totals ) ) {
1407
+            $this->recalculate_total();
1408
+        }
1409 1409
 
1410
-		$tax      = $this->totals['tax']['initial'];
1411
-		$fee      = $this->totals['fee']['initial'];
1412
-		$discount = $this->totals['discount']['initial'];
1413
-		$subtotal = $this->totals['subtotal']['initial'];
1414
-		$total    = $tax + $fee - $discount + $subtotal;
1410
+        $tax      = $this->totals['tax']['initial'];
1411
+        $fee      = $this->totals['fee']['initial'];
1412
+        $discount = $this->totals['discount']['initial'];
1413
+        $subtotal = $this->totals['subtotal']['initial'];
1414
+        $total    = $tax + $fee - $discount + $subtotal;
1415 1415
 
1416
-		if ( 0 > $total ) {
1417
-			$total = 0;
1418
-		}
1416
+        if ( 0 > $total ) {
1417
+            $total = 0;
1418
+        }
1419 1419
 
1420 1420
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1421
-	}
1421
+    }
1422 1422
 
1423
-	/**
1424
-	 * Get the recurring invoice total.
1425
-	 *
1426
-	 * @since 1.0.19
1423
+    /**
1424
+     * Get the recurring invoice total.
1425
+     *
1426
+     * @since 1.0.19
1427 1427
      * @param  string $context View or edit context.
1428 1428
      * @return float
1429
-	 */
1429
+     */
1430 1430
     public function get_recurring_total() {
1431 1431
 
1432
-		if ( empty( $this->totals ) ) {
1433
-			$this->recalculate_total();
1434
-		}
1432
+        if ( empty( $this->totals ) ) {
1433
+            $this->recalculate_total();
1434
+        }
1435 1435
 
1436
-		$tax      = $this->totals['tax']['recurring'];
1437
-		$fee      = $this->totals['fee']['recurring'];
1438
-		$discount = $this->totals['discount']['recurring'];
1439
-		$subtotal = $this->totals['subtotal']['recurring'];
1440
-		$total    = $tax + $fee - $discount + $subtotal;
1436
+        $tax      = $this->totals['tax']['recurring'];
1437
+        $fee      = $this->totals['fee']['recurring'];
1438
+        $discount = $this->totals['discount']['recurring'];
1439
+        $subtotal = $this->totals['subtotal']['recurring'];
1440
+        $total    = $tax + $fee - $discount + $subtotal;
1441 1441
 
1442
-		if ( 0 > $total ) {
1443
-			$total = 0;
1444
-		}
1442
+        if ( 0 > $total ) {
1443
+            $total = 0;
1444
+        }
1445 1445
 
1446 1446
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1447
-	}
1447
+    }
1448 1448
 
1449
-	/**
1450
-	 * Returns recurring payment details.
1451
-	 *
1452
-	 * @since 1.0.19
1449
+    /**
1450
+     * Returns recurring payment details.
1451
+     *
1452
+     * @since 1.0.19
1453 1453
      * @param  string $field Optionally provide a field to return.
1454
-	 * @param string $currency Whether to include the currency.
1454
+     * @param string $currency Whether to include the currency.
1455 1455
      * @return float
1456
-	 */
1456
+     */
1457 1457
     public function get_recurring_details( $field = '', $currency = false ) {
1458 1458
 
1459
-		// Maybe recalculate totals.
1460
-		if ( empty( $this->totals ) ) {
1461
-			$this->recalculate_total();
1462
-		}
1459
+        // Maybe recalculate totals.
1460
+        if ( empty( $this->totals ) ) {
1461
+            $this->recalculate_total();
1462
+        }
1463 1463
 
1464
-		// Prepare recurring totals.
1464
+        // Prepare recurring totals.
1465 1465
         $data = apply_filters(
1466
-			'wpinv_get_invoice_recurring_details',
1467
-			array(
1468
-				'cart_details' => $this->get_cart_details(),
1469
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1470
-				'discount'     => $this->totals['discount']['recurring'],
1471
-				'tax'          => $this->totals['tax']['recurring'],
1472
-				'fee'          => $this->totals['fee']['recurring'],
1473
-				'total'        => $this->get_recurring_total(),
1474
-			),
1475
-			$this,
1476
-			$field,
1477
-			$currency
1478
-		);
1466
+            'wpinv_get_invoice_recurring_details',
1467
+            array(
1468
+                'cart_details' => $this->get_cart_details(),
1469
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1470
+                'discount'     => $this->totals['discount']['recurring'],
1471
+                'tax'          => $this->totals['tax']['recurring'],
1472
+                'fee'          => $this->totals['fee']['recurring'],
1473
+                'total'        => $this->get_recurring_total(),
1474
+            ),
1475
+            $this,
1476
+            $field,
1477
+            $currency
1478
+        );
1479 1479
 
1480 1480
         if ( isset( $data[$field] ) ) {
1481 1481
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1485,145 +1485,145 @@  discard block
 block discarded – undo
1485 1485
     }
1486 1486
 
1487 1487
     /**
1488
-	 * Get the invoice fees.
1489
-	 *
1490
-	 * @since 1.0.19
1491
-	 * @param  string $context View or edit context.
1492
-	 * @return array
1493
-	 */
1494
-	public function get_fees( $context = 'view' ) {
1495
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1488
+     * Get the invoice fees.
1489
+     *
1490
+     * @since 1.0.19
1491
+     * @param  string $context View or edit context.
1492
+     * @return array
1493
+     */
1494
+    public function get_fees( $context = 'view' ) {
1495
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1496 1496
     }
1497 1497
 
1498 1498
     /**
1499
-	 * Get the invoice discounts.
1500
-	 *
1501
-	 * @since 1.0.19
1502
-	 * @param  string $context View or edit context.
1503
-	 * @return array
1504
-	 */
1505
-	public function get_discounts( $context = 'view' ) {
1506
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1499
+     * Get the invoice discounts.
1500
+     *
1501
+     * @since 1.0.19
1502
+     * @param  string $context View or edit context.
1503
+     * @return array
1504
+     */
1505
+    public function get_discounts( $context = 'view' ) {
1506
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1507 1507
     }
1508 1508
 
1509 1509
     /**
1510
-	 * Get the invoice taxes.
1511
-	 *
1512
-	 * @since 1.0.19
1513
-	 * @param  string $context View or edit context.
1514
-	 * @return array
1515
-	 */
1516
-	public function get_taxes( $context = 'view' ) {
1517
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1510
+     * Get the invoice taxes.
1511
+     *
1512
+     * @since 1.0.19
1513
+     * @param  string $context View or edit context.
1514
+     * @return array
1515
+     */
1516
+    public function get_taxes( $context = 'view' ) {
1517
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1518 1518
     }
1519 1519
 
1520 1520
     /**
1521
-	 * Get the invoice items.
1522
-	 *
1523
-	 * @since 1.0.19
1524
-	 * @param  string $context View or edit context.
1525
-	 * @return GetPaid_Form_Item[]
1526
-	 */
1527
-	public function get_items( $context = 'view' ) {
1521
+     * Get the invoice items.
1522
+     *
1523
+     * @since 1.0.19
1524
+     * @param  string $context View or edit context.
1525
+     * @return GetPaid_Form_Item[]
1526
+     */
1527
+    public function get_items( $context = 'view' ) {
1528 1528
         return $this->get_prop( 'items', $context );
1529 1529
     }
1530 1530
 
1531 1531
     /**
1532
-	 * Get the invoice's payment form.
1533
-	 *
1534
-	 * @since 1.0.19
1535
-	 * @param  string $context View or edit context.
1536
-	 * @return int
1537
-	 */
1538
-	public function get_payment_form( $context = 'view' ) {
1539
-		return intval( $this->get_prop( 'payment_form', $context ) );
1532
+     * Get the invoice's payment form.
1533
+     *
1534
+     * @since 1.0.19
1535
+     * @param  string $context View or edit context.
1536
+     * @return int
1537
+     */
1538
+    public function get_payment_form( $context = 'view' ) {
1539
+        return intval( $this->get_prop( 'payment_form', $context ) );
1540 1540
     }
1541 1541
 
1542 1542
     /**
1543
-	 * Get the invoice's submission id.
1544
-	 *
1545
-	 * @since 1.0.19
1546
-	 * @param  string $context View or edit context.
1547
-	 * @return string
1548
-	 */
1549
-	public function get_submission_id( $context = 'view' ) {
1550
-		return $this->get_prop( 'submission_id', $context );
1543
+     * Get the invoice's submission id.
1544
+     *
1545
+     * @since 1.0.19
1546
+     * @param  string $context View or edit context.
1547
+     * @return string
1548
+     */
1549
+    public function get_submission_id( $context = 'view' ) {
1550
+        return $this->get_prop( 'submission_id', $context );
1551 1551
     }
1552 1552
 
1553 1553
     /**
1554
-	 * Get the invoice's discount code.
1555
-	 *
1556
-	 * @since 1.0.19
1557
-	 * @param  string $context View or edit context.
1558
-	 * @return string
1559
-	 */
1560
-	public function get_discount_code( $context = 'view' ) {
1561
-		return $this->get_prop( 'discount_code', $context );
1554
+     * Get the invoice's discount code.
1555
+     *
1556
+     * @since 1.0.19
1557
+     * @param  string $context View or edit context.
1558
+     * @return string
1559
+     */
1560
+    public function get_discount_code( $context = 'view' ) {
1561
+        return $this->get_prop( 'discount_code', $context );
1562 1562
     }
1563 1563
 
1564 1564
     /**
1565
-	 * Get the invoice's gateway.
1566
-	 *
1567
-	 * @since 1.0.19
1568
-	 * @param  string $context View or edit context.
1569
-	 * @return string
1570
-	 */
1571
-	public function get_gateway( $context = 'view' ) {
1572
-		return $this->get_prop( 'gateway', $context );
1565
+     * Get the invoice's gateway.
1566
+     *
1567
+     * @since 1.0.19
1568
+     * @param  string $context View or edit context.
1569
+     * @return string
1570
+     */
1571
+    public function get_gateway( $context = 'view' ) {
1572
+        return $this->get_prop( 'gateway', $context );
1573 1573
     }
1574 1574
 
1575 1575
     /**
1576
-	 * Get the invoice's gateway display title.
1577
-	 *
1578
-	 * @since 1.0.19
1579
-	 * @return string
1580
-	 */
1576
+     * Get the invoice's gateway display title.
1577
+     *
1578
+     * @since 1.0.19
1579
+     * @return string
1580
+     */
1581 1581
     public function get_gateway_title() {
1582 1582
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1583 1583
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1584 1584
     }
1585 1585
 
1586 1586
     /**
1587
-	 * Get the invoice's transaction id.
1588
-	 *
1589
-	 * @since 1.0.19
1590
-	 * @param  string $context View or edit context.
1591
-	 * @return string
1592
-	 */
1593
-	public function get_transaction_id( $context = 'view' ) {
1594
-		return $this->get_prop( 'transaction_id', $context );
1587
+     * Get the invoice's transaction id.
1588
+     *
1589
+     * @since 1.0.19
1590
+     * @param  string $context View or edit context.
1591
+     * @return string
1592
+     */
1593
+    public function get_transaction_id( $context = 'view' ) {
1594
+        return $this->get_prop( 'transaction_id', $context );
1595 1595
     }
1596 1596
 
1597 1597
     /**
1598
-	 * Get the invoice's currency.
1599
-	 *
1600
-	 * @since 1.0.19
1601
-	 * @param  string $context View or edit context.
1602
-	 * @return string
1603
-	 */
1604
-	public function get_currency( $context = 'view' ) {
1598
+     * Get the invoice's currency.
1599
+     *
1600
+     * @since 1.0.19
1601
+     * @param  string $context View or edit context.
1602
+     * @return string
1603
+     */
1604
+    public function get_currency( $context = 'view' ) {
1605 1605
         $currency = $this->get_prop( 'currency', $context );
1606 1606
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1607 1607
     }
1608 1608
 
1609 1609
     /**
1610
-	 * Checks if we are charging taxes for this invoice.
1611
-	 *
1612
-	 * @since 1.0.19
1613
-	 * @param  string $context View or edit context.
1614
-	 * @return bool
1615
-	 */
1616
-	public function get_disable_taxes( $context = 'view' ) {
1610
+     * Checks if we are charging taxes for this invoice.
1611
+     *
1612
+     * @since 1.0.19
1613
+     * @param  string $context View or edit context.
1614
+     * @return bool
1615
+     */
1616
+    public function get_disable_taxes( $context = 'view' ) {
1617 1617
         return (bool) $this->get_prop( 'disable_taxes', $context );
1618 1618
     }
1619 1619
 
1620 1620
     /**
1621
-	 * Retrieves the remote subscription id for an invoice.
1622
-	 *
1623
-	 * @since 1.0.19
1624
-	 * @param  string $context View or edit context.
1625
-	 * @return int
1626
-	 */
1621
+     * Retrieves the remote subscription id for an invoice.
1622
+     *
1623
+     * @since 1.0.19
1624
+     * @param  string $context View or edit context.
1625
+     * @return int
1626
+     */
1627 1627
     public function get_subscription_id( $context = 'view' ) {
1628 1628
         $subscription_id = $this->get_prop( 'subscription_id', $context );
1629 1629
 
@@ -1636,12 +1636,12 @@  discard block
 block discarded – undo
1636 1636
     }
1637 1637
 
1638 1638
     /**
1639
-	 * Retrieves the payment meta for an invoice.
1640
-	 *
1641
-	 * @since 1.0.19
1642
-	 * @param  string $context View or edit context.
1643
-	 * @return array
1644
-	 */
1639
+     * Retrieves the payment meta for an invoice.
1640
+     *
1641
+     * @since 1.0.19
1642
+     * @param  string $context View or edit context.
1643
+     * @return array
1644
+     */
1645 1645
     public function get_payment_meta( $context = 'view' ) {
1646 1646
 
1647 1647
         return array(
@@ -1661,11 +1661,11 @@  discard block
 block discarded – undo
1661 1661
     }
1662 1662
 
1663 1663
     /**
1664
-	 * Retrieves the cart details for an invoice.
1665
-	 *
1666
-	 * @since 1.0.19
1667
-	 * @return array
1668
-	 */
1664
+     * Retrieves the cart details for an invoice.
1665
+     *
1666
+     * @since 1.0.19
1667
+     * @return array
1668
+     */
1669 1669
     public function get_cart_details() {
1670 1670
         $items        = $this->get_items();
1671 1671
         $cart_details = array();
@@ -1675,16 +1675,16 @@  discard block
 block discarded – undo
1675 1675
         }
1676 1676
 
1677 1677
         return $cart_details;
1678
-	}
1678
+    }
1679 1679
 
1680
-	/**
1681
-	 * Retrieves the recurring item.
1682
-	 *
1683
-	 * @return null|GetPaid_Form_Item|int
1684
-	 */
1685
-	public function get_recurring( $object = false ) {
1680
+    /**
1681
+     * Retrieves the recurring item.
1682
+     *
1683
+     * @return null|GetPaid_Form_Item|int
1684
+     */
1685
+    public function get_recurring( $object = false ) {
1686 1686
 
1687
-		// Are we returning an object?
1687
+        // Are we returning an object?
1688 1688
         if ( $object ) {
1689 1689
             return $this->get_item( $this->recurring_item );
1690 1690
         }
@@ -1692,100 +1692,100 @@  discard block
 block discarded – undo
1692 1692
         return $this->recurring_item;
1693 1693
     }
1694 1694
 
1695
-	/**
1696
-	 * Retrieves the subscription name.
1697
-	 *
1698
-	 * @since 1.0.19
1699
-	 * @return string
1700
-	 */
1701
-	public function get_subscription_name() {
1695
+    /**
1696
+     * Retrieves the subscription name.
1697
+     *
1698
+     * @since 1.0.19
1699
+     * @return string
1700
+     */
1701
+    public function get_subscription_name() {
1702 1702
 
1703
-		// Retrieve the recurring name
1703
+        // Retrieve the recurring name
1704 1704
         $item = $this->get_recurring( true );
1705 1705
 
1706
-		// Abort if it does not exist.
1706
+        // Abort if it does not exist.
1707 1707
         if ( empty( $item ) ) {
1708 1708
             return '';
1709 1709
         }
1710 1710
 
1711
-		// Return the item name.
1711
+        // Return the item name.
1712 1712
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1713
-	}
1714
-
1715
-	/**
1716
-	 * Retrieves the view url.
1717
-	 *
1718
-	 * @since 1.0.19
1719
-	 * @return string
1720
-	 */
1721
-	public function get_view_url() {
1713
+    }
1714
+
1715
+    /**
1716
+     * Retrieves the view url.
1717
+     *
1718
+     * @since 1.0.19
1719
+     * @return string
1720
+     */
1721
+    public function get_view_url() {
1722 1722
         $invoice_url = get_permalink( $this->get_id() );
1723
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1723
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1724 1724
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1725
-	}
1725
+    }
1726 1726
 
1727
-	/**
1728
-	 * Retrieves the payment url.
1729
-	 *
1730
-	 * @since 1.0.19
1731
-	 * @return string
1732
-	 */
1733
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1727
+    /**
1728
+     * Retrieves the payment url.
1729
+     *
1730
+     * @since 1.0.19
1731
+     * @return string
1732
+     */
1733
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1734 1734
 
1735
-		// Retrieve the checkout url.
1735
+        // Retrieve the checkout url.
1736 1736
         $pay_url = wpinv_get_checkout_uri();
1737 1737
 
1738
-		// Maybe force ssl.
1738
+        // Maybe force ssl.
1739 1739
         if ( is_ssl() ) {
1740 1740
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1741 1741
         }
1742 1742
 
1743
-		// Add the invoice key.
1744
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1743
+        // Add the invoice key.
1744
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1745 1745
 
1746
-		// (Maybe?) add a secret
1746
+        // (Maybe?) add a secret
1747 1747
         if ( $secret ) {
1748 1748
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1749 1749
         }
1750 1750
 
1751 1751
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1752
-	}
1752
+    }
1753 1753
 	
1754
-	/**
1755
-	 * Retrieves the receipt url.
1756
-	 *
1757
-	 * @since 1.0.19
1758
-	 * @return string
1759
-	 */
1760
-	public function get_receipt_url() {
1761
-
1762
-		// Retrieve the checkout url.
1754
+    /**
1755
+     * Retrieves the receipt url.
1756
+     *
1757
+     * @since 1.0.19
1758
+     * @return string
1759
+     */
1760
+    public function get_receipt_url() {
1761
+
1762
+        // Retrieve the checkout url.
1763 1763
         $receipt_url = wpinv_get_success_page_uri();
1764 1764
 
1765
-		// Maybe force ssl.
1765
+        // Maybe force ssl.
1766 1766
         if ( is_ssl() ) {
1767 1767
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1768 1768
         }
1769 1769
 
1770
-		// Add the invoice key.
1771
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1770
+        // Add the invoice key.
1771
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1772 1772
 
1773 1773
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1774 1774
     }
1775 1775
 
1776 1776
     /**
1777
-	 * Magic method for accessing invoice properties.
1778
-	 *
1779
-	 * @since 1.0.15
1780
-	 * @access public
1781
-	 *
1782
-	 * @param string $key Discount data to retrieve
1783
-	 * @param  string $context View or edit context.
1784
-	 * @return mixed Value of the given invoice property (if set).
1785
-	 */
1786
-	public function get( $key, $context = 'view' ) {
1777
+     * Magic method for accessing invoice properties.
1778
+     *
1779
+     * @since 1.0.15
1780
+     * @access public
1781
+     *
1782
+     * @param string $key Discount data to retrieve
1783
+     * @param  string $context View or edit context.
1784
+     * @return mixed Value of the given invoice property (if set).
1785
+     */
1786
+    public function get( $key, $context = 'view' ) {
1787 1787
         return $this->get_prop( $key, $context );
1788
-	}
1788
+    }
1789 1789
 
1790 1790
     /*
1791 1791
 	|--------------------------------------------------------------------------
@@ -1798,130 +1798,130 @@  discard block
 block discarded – undo
1798 1798
     */
1799 1799
 
1800 1800
     /**
1801
-	 * Magic method for setting invoice properties.
1802
-	 *
1803
-	 * @since 1.0.19
1804
-	 * @access public
1805
-	 *
1806
-	 * @param string $key Discount data to retrieve
1807
-	 * @param  mixed $value new value.
1808
-	 * @return mixed Value of the given invoice property (if set).
1809
-	 */
1810
-	public function set( $key, $value ) {
1801
+     * Magic method for setting invoice properties.
1802
+     *
1803
+     * @since 1.0.19
1804
+     * @access public
1805
+     *
1806
+     * @param string $key Discount data to retrieve
1807
+     * @param  mixed $value new value.
1808
+     * @return mixed Value of the given invoice property (if set).
1809
+     */
1810
+    public function set( $key, $value ) {
1811 1811
 
1812 1812
         $setter = "set_$key";
1813 1813
         if ( is_callable( array( $this, $setter ) ) ) {
1814 1814
             $this->{$setter}( $value );
1815 1815
         }
1816 1816
 
1817
-	}
1817
+    }
1818 1818
 
1819
-	/**
1820
-	 * Sets item status.
1821
-	 *
1822
-	 * @since 1.0.19
1823
-	 * @param string $new_status    New status.
1824
-	 * @param string $note          Optional note to add.
1825
-	 * @param bool   $manual_update Is this a manual status change?.
1826
-	 * @return array details of change.
1827
-	 */
1828
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1829
-		$old_status = $this->get_status();
1819
+    /**
1820
+     * Sets item status.
1821
+     *
1822
+     * @since 1.0.19
1823
+     * @param string $new_status    New status.
1824
+     * @param string $note          Optional note to add.
1825
+     * @param bool   $manual_update Is this a manual status change?.
1826
+     * @return array details of change.
1827
+     */
1828
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1829
+        $old_status = $this->get_status();
1830 1830
 
1831
-		$statuses = $this->get_all_statuses();
1831
+        $statuses = $this->get_all_statuses();
1832 1832
 
1833
-		if ( isset( $statuses[ 'draft' ] ) ) {
1834
-			unset( $statuses[ 'draft' ] );
1835
-		}
1833
+        if ( isset( $statuses[ 'draft' ] ) ) {
1834
+            unset( $statuses[ 'draft' ] );
1835
+        }
1836 1836
 
1837
-		$this->set_prop( 'status', $new_status );
1837
+        $this->set_prop( 'status', $new_status );
1838 1838
 
1839
-		// If setting the status, ensure it's set to a valid status.
1840
-		if ( true === $this->object_read ) {
1839
+        // If setting the status, ensure it's set to a valid status.
1840
+        if ( true === $this->object_read ) {
1841 1841
 
1842
-			// Only allow valid new status.
1843
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1844
-				$new_status = 'wpi-pending';
1845
-			}
1842
+            // Only allow valid new status.
1843
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1844
+                $new_status = 'wpi-pending';
1845
+            }
1846 1846
 
1847
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1848
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1849
-				$old_status = 'wpi-pending';
1850
-			}
1847
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1848
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1849
+                $old_status = 'wpi-pending';
1850
+            }
1851 1851
 
1852
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1853
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1854
-				$old_status = 'wpi-pending';
1855
-			}
1852
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1853
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1854
+                $old_status = 'wpi-pending';
1855
+            }
1856 1856
 
1857
-		}
1857
+        }
1858 1858
 
1859
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1860
-			$this->status_transition = array(
1861
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1862
-				'to'     => $new_status,
1863
-				'note'   => $note,
1864
-				'manual' => (bool) $manual_update,
1865
-			);
1859
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1860
+            $this->status_transition = array(
1861
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1862
+                'to'     => $new_status,
1863
+                'note'   => $note,
1864
+                'manual' => (bool) $manual_update,
1865
+            );
1866 1866
 
1867
-			if ( $manual_update ) {
1868
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1869
-			}
1867
+            if ( $manual_update ) {
1868
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1869
+            }
1870 1870
 
1871
-			$this->maybe_set_date_paid();
1871
+            $this->maybe_set_date_paid();
1872 1872
 
1873
-		}
1873
+        }
1874 1874
 
1875
-		return array(
1876
-			'from' => $old_status,
1877
-			'to'   => $new_status,
1878
-		);
1879
-	}
1875
+        return array(
1876
+            'from' => $old_status,
1877
+            'to'   => $new_status,
1878
+        );
1879
+    }
1880 1880
 
1881
-	/**
1882
-	 * Maybe set date paid.
1883
-	 *
1884
-	 * Sets the date paid variable when transitioning to the payment complete
1885
-	 * order status.
1886
-	 *
1887
-	 * @since 1.0.19
1888
-	 */
1889
-	public function maybe_set_date_paid() {
1881
+    /**
1882
+     * Maybe set date paid.
1883
+     *
1884
+     * Sets the date paid variable when transitioning to the payment complete
1885
+     * order status.
1886
+     *
1887
+     * @since 1.0.19
1888
+     */
1889
+    public function maybe_set_date_paid() {
1890 1890
 
1891
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1892
-			$this->set_date_completed( current_time( 'mysql' ) );
1893
-		}
1894
-	}
1891
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1892
+            $this->set_date_completed( current_time( 'mysql' ) );
1893
+        }
1894
+    }
1895 1895
 
1896 1896
     /**
1897
-	 * Set parent invoice ID.
1898
-	 *
1899
-	 * @since 1.0.19
1900
-	 */
1901
-	public function set_parent_id( $value ) {
1902
-		if ( $value && ( $value === $this->get_id() ) ) {
1903
-			return;
1904
-		}
1905
-		$this->set_prop( 'parent_id', absint( $value ) );
1897
+     * Set parent invoice ID.
1898
+     *
1899
+     * @since 1.0.19
1900
+     */
1901
+    public function set_parent_id( $value ) {
1902
+        if ( $value && ( $value === $this->get_id() ) ) {
1903
+            return;
1904
+        }
1905
+        $this->set_prop( 'parent_id', absint( $value ) );
1906 1906
     }
1907 1907
 
1908 1908
     /**
1909
-	 * Set plugin version when the invoice was created.
1910
-	 *
1911
-	 * @since 1.0.19
1912
-	 */
1913
-	public function set_version( $value ) {
1914
-		$this->set_prop( 'version', $value );
1909
+     * Set plugin version when the invoice was created.
1910
+     *
1911
+     * @since 1.0.19
1912
+     */
1913
+    public function set_version( $value ) {
1914
+        $this->set_prop( 'version', $value );
1915 1915
     }
1916
-
1917
-    /**
1918
-	 * Set date when the invoice was created.
1919
-	 *
1920
-	 * @since 1.0.19
1921
-	 * @param string $value Value to set.
1916
+
1917
+    /**
1918
+     * Set date when the invoice was created.
1919
+     *
1920
+     * @since 1.0.19
1921
+     * @param string $value Value to set.
1922 1922
      * @return bool Whether or not the date was set.
1923
-	 */
1924
-	public function set_date_created( $value ) {
1923
+     */
1924
+    public function set_date_created( $value ) {
1925 1925
         $date = strtotime( $value );
1926 1926
 
1927 1927
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1934,13 +1934,13 @@  discard block
 block discarded – undo
1934 1934
     }
1935 1935
 
1936 1936
     /**
1937
-	 * Set date invoice due date.
1938
-	 *
1939
-	 * @since 1.0.19
1940
-	 * @param string $value Value to set.
1937
+     * Set date invoice due date.
1938
+     *
1939
+     * @since 1.0.19
1940
+     * @param string $value Value to set.
1941 1941
      * @return bool Whether or not the date was set.
1942
-	 */
1943
-	public function set_due_date( $value ) {
1942
+     */
1943
+    public function set_due_date( $value ) {
1944 1944
         $date = strtotime( $value );
1945 1945
 
1946 1946
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1948,29 +1948,29 @@  discard block
 block discarded – undo
1948 1948
             return true;
1949 1949
         }
1950 1950
 
1951
-		$this->set_prop( 'due_date', '' );
1951
+        $this->set_prop( 'due_date', '' );
1952 1952
         return false;
1953 1953
 
1954 1954
     }
1955 1955
 
1956 1956
     /**
1957
-	 * Alias of self::set_due_date().
1958
-	 *
1959
-	 * @since 1.0.19
1960
-	 * @param  string $value New name.
1961
-	 */
1962
-	public function set_date_due( $value ) {
1963
-		$this->set_due_date( $value );
1957
+     * Alias of self::set_due_date().
1958
+     *
1959
+     * @since 1.0.19
1960
+     * @param  string $value New name.
1961
+     */
1962
+    public function set_date_due( $value ) {
1963
+        $this->set_due_date( $value );
1964 1964
     }
1965 1965
 
1966 1966
     /**
1967
-	 * Set date invoice was completed.
1968
-	 *
1969
-	 * @since 1.0.19
1970
-	 * @param string $value Value to set.
1967
+     * Set date invoice was completed.
1968
+     *
1969
+     * @since 1.0.19
1970
+     * @param string $value Value to set.
1971 1971
      * @return bool Whether or not the date was set.
1972
-	 */
1973
-	public function set_completed_date( $value ) {
1972
+     */
1973
+    public function set_completed_date( $value ) {
1974 1974
         $date = strtotime( $value );
1975 1975
 
1976 1976
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -1978,29 +1978,29 @@  discard block
 block discarded – undo
1978 1978
             return true;
1979 1979
         }
1980 1980
 
1981
-		$this->set_prop( 'completed_date', '' );
1981
+        $this->set_prop( 'completed_date', '' );
1982 1982
         return false;
1983 1983
 
1984 1984
     }
1985 1985
 
1986 1986
     /**
1987
-	 * Alias of self::set_completed_date().
1988
-	 *
1989
-	 * @since 1.0.19
1990
-	 * @param  string $value New name.
1991
-	 */
1992
-	public function set_date_completed( $value ) {
1993
-		$this->set_completed_date( $value );
1987
+     * Alias of self::set_completed_date().
1988
+     *
1989
+     * @since 1.0.19
1990
+     * @param  string $value New name.
1991
+     */
1992
+    public function set_date_completed( $value ) {
1993
+        $this->set_completed_date( $value );
1994 1994
     }
1995 1995
 
1996 1996
     /**
1997
-	 * Set date when the invoice was last modified.
1998
-	 *
1999
-	 * @since 1.0.19
2000
-	 * @param string $value Value to set.
1997
+     * Set date when the invoice was last modified.
1998
+     *
1999
+     * @since 1.0.19
2000
+     * @param string $value Value to set.
2001 2001
      * @return bool Whether or not the date was set.
2002
-	 */
2003
-	public function set_date_modified( $value ) {
2002
+     */
2003
+    public function set_date_modified( $value ) {
2004 2004
         $date = strtotime( $value );
2005 2005
 
2006 2006
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2008,706 +2008,706 @@  discard block
 block discarded – undo
2008 2008
             return true;
2009 2009
         }
2010 2010
 
2011
-		$this->set_prop( 'date_modified', '' );
2011
+        $this->set_prop( 'date_modified', '' );
2012 2012
         return false;
2013 2013
 
2014 2014
     }
2015 2015
 
2016 2016
     /**
2017
-	 * Set the invoice number.
2018
-	 *
2019
-	 * @since 1.0.19
2020
-	 * @param  string $value New number.
2021
-	 */
2022
-	public function set_number( $value ) {
2017
+     * Set the invoice number.
2018
+     *
2019
+     * @since 1.0.19
2020
+     * @param  string $value New number.
2021
+     */
2022
+    public function set_number( $value ) {
2023 2023
         $number = sanitize_text_field( $value );
2024
-		$this->set_prop( 'number', $number );
2024
+        $this->set_prop( 'number', $number );
2025 2025
     }
2026 2026
 
2027 2027
     /**
2028
-	 * Set the invoice type.
2029
-	 *
2030
-	 * @since 1.0.19
2031
-	 * @param  string $value Type.
2032
-	 */
2033
-	public function set_type( $value ) {
2028
+     * Set the invoice type.
2029
+     *
2030
+     * @since 1.0.19
2031
+     * @param  string $value Type.
2032
+     */
2033
+    public function set_type( $value ) {
2034 2034
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2035
-		$this->set_prop( 'type', $type );
2036
-	}
2035
+        $this->set_prop( 'type', $type );
2036
+    }
2037 2037
 
2038 2038
     /**
2039
-	 * Set the invoice post type.
2040
-	 *
2041
-	 * @since 1.0.19
2042
-	 * @param  string $value Post type.
2043
-	 */
2044
-	public function set_post_type( $value ) {
2039
+     * Set the invoice post type.
2040
+     *
2041
+     * @since 1.0.19
2042
+     * @param  string $value Post type.
2043
+     */
2044
+    public function set_post_type( $value ) {
2045 2045
         if ( getpaid_is_invoice_post_type( $value ) ) {
2046
-			$this->set_type( $value );
2046
+            $this->set_type( $value );
2047 2047
             $this->set_prop( 'post_type', $value );
2048 2048
         }
2049 2049
     }
2050 2050
 
2051 2051
     /**
2052
-	 * Set the invoice key.
2053
-	 *
2054
-	 * @since 1.0.19
2055
-	 * @param  string $value New key.
2056
-	 */
2057
-	public function set_key( $value ) {
2052
+     * Set the invoice key.
2053
+     *
2054
+     * @since 1.0.19
2055
+     * @param  string $value New key.
2056
+     */
2057
+    public function set_key( $value ) {
2058 2058
         $key = sanitize_text_field( $value );
2059
-		$this->set_prop( 'key', $key );
2059
+        $this->set_prop( 'key', $key );
2060 2060
     }
2061 2061
 
2062 2062
     /**
2063
-	 * Set the invoice mode.
2064
-	 *
2065
-	 * @since 1.0.19
2066
-	 * @param  string $value mode.
2067
-	 */
2068
-	public function set_mode( $value ) {
2063
+     * Set the invoice mode.
2064
+     *
2065
+     * @since 1.0.19
2066
+     * @param  string $value mode.
2067
+     */
2068
+    public function set_mode( $value ) {
2069 2069
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2070 2070
             $this->set_prop( 'value', $value );
2071 2071
         }
2072 2072
     }
2073 2073
 
2074 2074
     /**
2075
-	 * Set the invoice path.
2076
-	 *
2077
-	 * @since 1.0.19
2078
-	 * @param  string $value path.
2079
-	 */
2080
-	public function set_path( $value ) {
2075
+     * Set the invoice path.
2076
+     *
2077
+     * @since 1.0.19
2078
+     * @param  string $value path.
2079
+     */
2080
+    public function set_path( $value ) {
2081 2081
         $this->set_prop( 'path', $value );
2082 2082
     }
2083 2083
 
2084 2084
     /**
2085
-	 * Set the invoice name.
2086
-	 *
2087
-	 * @since 1.0.19
2088
-	 * @param  string $value New name.
2089
-	 */
2090
-	public function set_name( $value ) {
2085
+     * Set the invoice name.
2086
+     *
2087
+     * @since 1.0.19
2088
+     * @param  string $value New name.
2089
+     */
2090
+    public function set_name( $value ) {
2091 2091
         $name = sanitize_text_field( $value );
2092
-		$this->set_prop( 'name', $name );
2092
+        $this->set_prop( 'name', $name );
2093 2093
     }
2094 2094
 
2095 2095
     /**
2096
-	 * Alias of self::set_name().
2097
-	 *
2098
-	 * @since 1.0.19
2099
-	 * @param  string $value New name.
2100
-	 */
2101
-	public function set_title( $value ) {
2102
-		$this->set_name( $value );
2096
+     * Alias of self::set_name().
2097
+     *
2098
+     * @since 1.0.19
2099
+     * @param  string $value New name.
2100
+     */
2101
+    public function set_title( $value ) {
2102
+        $this->set_name( $value );
2103 2103
     }
2104 2104
 
2105 2105
     /**
2106
-	 * Set the invoice description.
2107
-	 *
2108
-	 * @since 1.0.19
2109
-	 * @param  string $value New description.
2110
-	 */
2111
-	public function set_description( $value ) {
2106
+     * Set the invoice description.
2107
+     *
2108
+     * @since 1.0.19
2109
+     * @param  string $value New description.
2110
+     */
2111
+    public function set_description( $value ) {
2112 2112
         $description = wp_kses_post( $value );
2113
-		return $this->set_prop( 'description', $description );
2113
+        return $this->set_prop( 'description', $description );
2114 2114
     }
2115 2115
 
2116 2116
     /**
2117
-	 * Alias of self::set_description().
2118
-	 *
2119
-	 * @since 1.0.19
2120
-	 * @param  string $value New description.
2121
-	 */
2122
-	public function set_excerpt( $value ) {
2123
-		$this->set_description( $value );
2117
+     * Alias of self::set_description().
2118
+     *
2119
+     * @since 1.0.19
2120
+     * @param  string $value New description.
2121
+     */
2122
+    public function set_excerpt( $value ) {
2123
+        $this->set_description( $value );
2124 2124
     }
2125 2125
 
2126 2126
     /**
2127
-	 * Alias of self::set_description().
2128
-	 *
2129
-	 * @since 1.0.19
2130
-	 * @param  string $value New description.
2131
-	 */
2132
-	public function set_summary( $value ) {
2133
-		$this->set_description( $value );
2127
+     * Alias of self::set_description().
2128
+     *
2129
+     * @since 1.0.19
2130
+     * @param  string $value New description.
2131
+     */
2132
+    public function set_summary( $value ) {
2133
+        $this->set_description( $value );
2134 2134
     }
2135 2135
 
2136 2136
     /**
2137
-	 * Set the receiver of the invoice.
2138
-	 *
2139
-	 * @since 1.0.19
2140
-	 * @param  int $value New author.
2141
-	 */
2142
-	public function set_author( $value ) {
2143
-		$user = get_user_by( 'id', (int) $value );
2137
+     * Set the receiver of the invoice.
2138
+     *
2139
+     * @since 1.0.19
2140
+     * @param  int $value New author.
2141
+     */
2142
+    public function set_author( $value ) {
2143
+        $user = get_user_by( 'id', (int) $value );
2144 2144
 
2145
-		if ( $user && $user->ID ) {
2146
-			$this->set_prop( 'author', $user->ID );
2147
-			$this->set_prop( 'email', $user->user_email );
2148
-		}
2145
+        if ( $user && $user->ID ) {
2146
+            $this->set_prop( 'author', $user->ID );
2147
+            $this->set_prop( 'email', $user->user_email );
2148
+        }
2149 2149
 		
2150 2150
     }
2151 2151
 
2152 2152
     /**
2153
-	 * Alias of self::set_author().
2154
-	 *
2155
-	 * @since 1.0.19
2156
-	 * @param  int $value New user id.
2157
-	 */
2158
-	public function set_user_id( $value ) {
2159
-		$this->set_author( $value );
2153
+     * Alias of self::set_author().
2154
+     *
2155
+     * @since 1.0.19
2156
+     * @param  int $value New user id.
2157
+     */
2158
+    public function set_user_id( $value ) {
2159
+        $this->set_author( $value );
2160
+    }
2161
+
2162
+    /**
2163
+     * Alias of self::set_author().
2164
+     *
2165
+     * @since 1.0.19
2166
+     * @param  int $value New user id.
2167
+     */
2168
+    public function set_customer_id( $value ) {
2169
+        $this->set_author( $value );
2170
+    }
2171
+
2172
+    /**
2173
+     * Set the customer's ip.
2174
+     *
2175
+     * @since 1.0.19
2176
+     * @param  string $value ip address.
2177
+     */
2178
+    public function set_ip( $value ) {
2179
+        $this->set_prop( 'ip', $value );
2160 2180
     }
2161 2181
 
2162 2182
     /**
2163
-	 * Alias of self::set_author().
2164
-	 *
2165
-	 * @since 1.0.19
2166
-	 * @param  int $value New user id.
2167
-	 */
2168
-	public function set_customer_id( $value ) {
2169
-		$this->set_author( $value );
2183
+     * Alias of self::set_ip().
2184
+     *
2185
+     * @since 1.0.19
2186
+     * @param  string $value ip address.
2187
+     */
2188
+    public function set_user_ip( $value ) {
2189
+        $this->set_ip( $value );
2170 2190
     }
2171 2191
 
2172 2192
     /**
2173
-	 * Set the customer's ip.
2174
-	 *
2175
-	 * @since 1.0.19
2176
-	 * @param  string $value ip address.
2177
-	 */
2178
-	public function set_ip( $value ) {
2179
-		$this->set_prop( 'ip', $value );
2193
+     * Set the customer's first name.
2194
+     *
2195
+     * @since 1.0.19
2196
+     * @param  string $value first name.
2197
+     */
2198
+    public function set_first_name( $value ) {
2199
+        $this->set_prop( 'first_name', $value );
2180 2200
     }
2181 2201
 
2182 2202
     /**
2183
-	 * Alias of self::set_ip().
2184
-	 *
2185
-	 * @since 1.0.19
2186
-	 * @param  string $value ip address.
2187
-	 */
2188
-	public function set_user_ip( $value ) {
2189
-		$this->set_ip( $value );
2203
+     * Alias of self::set_first_name().
2204
+     *
2205
+     * @since 1.0.19
2206
+     * @param  string $value first name.
2207
+     */
2208
+    public function set_user_first_name( $value ) {
2209
+        $this->set_first_name( $value );
2190 2210
     }
2191 2211
 
2192 2212
     /**
2193
-	 * Set the customer's first name.
2194
-	 *
2195
-	 * @since 1.0.19
2196
-	 * @param  string $value first name.
2197
-	 */
2198
-	public function set_first_name( $value ) {
2199
-		$this->set_prop( 'first_name', $value );
2213
+     * Alias of self::set_first_name().
2214
+     *
2215
+     * @since 1.0.19
2216
+     * @param  string $value first name.
2217
+     */
2218
+    public function set_customer_first_name( $value ) {
2219
+        $this->set_first_name( $value );
2200 2220
     }
2201 2221
 
2202 2222
     /**
2203
-	 * Alias of self::set_first_name().
2204
-	 *
2205
-	 * @since 1.0.19
2206
-	 * @param  string $value first name.
2207
-	 */
2208
-	public function set_user_first_name( $value ) {
2209
-		$this->set_first_name( $value );
2223
+     * Set the customer's last name.
2224
+     *
2225
+     * @since 1.0.19
2226
+     * @param  string $value last name.
2227
+     */
2228
+    public function set_last_name( $value ) {
2229
+        $this->set_prop( 'last_name', $value );
2210 2230
     }
2211 2231
 
2212 2232
     /**
2213
-	 * Alias of self::set_first_name().
2214
-	 *
2215
-	 * @since 1.0.19
2216
-	 * @param  string $value first name.
2217
-	 */
2218
-	public function set_customer_first_name( $value ) {
2219
-		$this->set_first_name( $value );
2233
+     * Alias of self::set_last_name().
2234
+     *
2235
+     * @since 1.0.19
2236
+     * @param  string $value last name.
2237
+     */
2238
+    public function set_user_last_name( $value ) {
2239
+        $this->set_last_name( $value );
2220 2240
     }
2221 2241
 
2222 2242
     /**
2223
-	 * Set the customer's last name.
2224
-	 *
2225
-	 * @since 1.0.19
2226
-	 * @param  string $value last name.
2227
-	 */
2228
-	public function set_last_name( $value ) {
2229
-		$this->set_prop( 'last_name', $value );
2243
+     * Alias of self::set_last_name().
2244
+     *
2245
+     * @since 1.0.19
2246
+     * @param  string $value last name.
2247
+     */
2248
+    public function set_customer_last_name( $value ) {
2249
+        $this->set_last_name( $value );
2230 2250
     }
2231 2251
 
2232 2252
     /**
2233
-	 * Alias of self::set_last_name().
2234
-	 *
2235
-	 * @since 1.0.19
2236
-	 * @param  string $value last name.
2237
-	 */
2238
-	public function set_user_last_name( $value ) {
2239
-		$this->set_last_name( $value );
2253
+     * Set the customer's phone number.
2254
+     *
2255
+     * @since 1.0.19
2256
+     * @param  string $value phone.
2257
+     */
2258
+    public function set_phone( $value ) {
2259
+        $this->set_prop( 'phone', $value );
2240 2260
     }
2241 2261
 
2242 2262
     /**
2243
-	 * Alias of self::set_last_name().
2244
-	 *
2245
-	 * @since 1.0.19
2246
-	 * @param  string $value last name.
2247
-	 */
2248
-	public function set_customer_last_name( $value ) {
2249
-		$this->set_last_name( $value );
2263
+     * Alias of self::set_phone().
2264
+     *
2265
+     * @since 1.0.19
2266
+     * @param  string $value phone.
2267
+     */
2268
+    public function set_user_phone( $value ) {
2269
+        $this->set_phone( $value );
2270
+    }
2271
+
2272
+    /**
2273
+     * Alias of self::set_phone().
2274
+     *
2275
+     * @since 1.0.19
2276
+     * @param  string $value phone.
2277
+     */
2278
+    public function set_customer_phone( $value ) {
2279
+        $this->set_phone( $value );
2250 2280
     }
2251 2281
 
2252 2282
     /**
2253
-	 * Set the customer's phone number.
2254
-	 *
2255
-	 * @since 1.0.19
2256
-	 * @param  string $value phone.
2257
-	 */
2258
-	public function set_phone( $value ) {
2259
-		$this->set_prop( 'phone', $value );
2283
+     * Alias of self::set_phone().
2284
+     *
2285
+     * @since 1.0.19
2286
+     * @param  string $value phone.
2287
+     */
2288
+    public function set_phone_number( $value ) {
2289
+        $this->set_phone( $value );
2260 2290
     }
2261 2291
 
2262 2292
     /**
2263
-	 * Alias of self::set_phone().
2264
-	 *
2265
-	 * @since 1.0.19
2266
-	 * @param  string $value phone.
2267
-	 */
2268
-	public function set_user_phone( $value ) {
2269
-		$this->set_phone( $value );
2293
+     * Set the customer's email address.
2294
+     *
2295
+     * @since 1.0.19
2296
+     * @param  string $value email address.
2297
+     */
2298
+    public function set_email( $value ) {
2299
+        $this->set_prop( 'email', $value );
2270 2300
     }
2271 2301
 
2272 2302
     /**
2273
-	 * Alias of self::set_phone().
2274
-	 *
2275
-	 * @since 1.0.19
2276
-	 * @param  string $value phone.
2277
-	 */
2278
-	public function set_customer_phone( $value ) {
2279
-		$this->set_phone( $value );
2303
+     * Alias of self::set_email().
2304
+     *
2305
+     * @since 1.0.19
2306
+     * @param  string $value email address.
2307
+     */
2308
+    public function set_user_email( $value ) {
2309
+        $this->set_email( $value );
2280 2310
     }
2281 2311
 
2282 2312
     /**
2283
-	 * Alias of self::set_phone().
2284
-	 *
2285
-	 * @since 1.0.19
2286
-	 * @param  string $value phone.
2287
-	 */
2288
-	public function set_phone_number( $value ) {
2289
-		$this->set_phone( $value );
2313
+     * Alias of self::set_email().
2314
+     *
2315
+     * @since 1.0.19
2316
+     * @param  string $value email address.
2317
+     */
2318
+    public function set_email_address( $value ) {
2319
+        $this->set_email( $value );
2290 2320
     }
2291 2321
 
2292 2322
     /**
2293
-	 * Set the customer's email address.
2294
-	 *
2295
-	 * @since 1.0.19
2296
-	 * @param  string $value email address.
2297
-	 */
2298
-	public function set_email( $value ) {
2299
-		$this->set_prop( 'email', $value );
2323
+     * Alias of self::set_email().
2324
+     *
2325
+     * @since 1.0.19
2326
+     * @param  string $value email address.
2327
+     */
2328
+    public function set_customer_email( $value ) {
2329
+        $this->set_email( $value );
2300 2330
     }
2301 2331
 
2302 2332
     /**
2303
-	 * Alias of self::set_email().
2304
-	 *
2305
-	 * @since 1.0.19
2306
-	 * @param  string $value email address.
2307
-	 */
2308
-	public function set_user_email( $value ) {
2309
-		$this->set_email( $value );
2333
+     * Set the customer's country.
2334
+     *
2335
+     * @since 1.0.19
2336
+     * @param  string $value country.
2337
+     */
2338
+    public function set_country( $value ) {
2339
+        $this->set_prop( 'country', $value );
2310 2340
     }
2311 2341
 
2312 2342
     /**
2313
-	 * Alias of self::set_email().
2314
-	 *
2315
-	 * @since 1.0.19
2316
-	 * @param  string $value email address.
2317
-	 */
2318
-	public function set_email_address( $value ) {
2319
-		$this->set_email( $value );
2343
+     * Alias of self::set_country().
2344
+     *
2345
+     * @since 1.0.19
2346
+     * @param  string $value country.
2347
+     */
2348
+    public function set_user_country( $value ) {
2349
+        $this->set_country( $value );
2320 2350
     }
2321 2351
 
2322 2352
     /**
2323
-	 * Alias of self::set_email().
2324
-	 *
2325
-	 * @since 1.0.19
2326
-	 * @param  string $value email address.
2327
-	 */
2328
-	public function set_customer_email( $value ) {
2329
-		$this->set_email( $value );
2353
+     * Alias of self::set_country().
2354
+     *
2355
+     * @since 1.0.19
2356
+     * @param  string $value country.
2357
+     */
2358
+    public function set_customer_country( $value ) {
2359
+        $this->set_country( $value );
2330 2360
     }
2331 2361
 
2332 2362
     /**
2333
-	 * Set the customer's country.
2334
-	 *
2335
-	 * @since 1.0.19
2336
-	 * @param  string $value country.
2337
-	 */
2338
-	public function set_country( $value ) {
2339
-		$this->set_prop( 'country', $value );
2363
+     * Set the customer's state.
2364
+     *
2365
+     * @since 1.0.19
2366
+     * @param  string $value state.
2367
+     */
2368
+    public function set_state( $value ) {
2369
+        $this->set_prop( 'state', $value );
2340 2370
     }
2341 2371
 
2342 2372
     /**
2343
-	 * Alias of self::set_country().
2344
-	 *
2345
-	 * @since 1.0.19
2346
-	 * @param  string $value country.
2347
-	 */
2348
-	public function set_user_country( $value ) {
2349
-		$this->set_country( $value );
2373
+     * Alias of self::set_state().
2374
+     *
2375
+     * @since 1.0.19
2376
+     * @param  string $value state.
2377
+     */
2378
+    public function set_user_state( $value ) {
2379
+        $this->set_state( $value );
2350 2380
     }
2351 2381
 
2352 2382
     /**
2353
-	 * Alias of self::set_country().
2354
-	 *
2355
-	 * @since 1.0.19
2356
-	 * @param  string $value country.
2357
-	 */
2358
-	public function set_customer_country( $value ) {
2359
-		$this->set_country( $value );
2383
+     * Alias of self::set_state().
2384
+     *
2385
+     * @since 1.0.19
2386
+     * @param  string $value state.
2387
+     */
2388
+    public function set_customer_state( $value ) {
2389
+        $this->set_state( $value );
2360 2390
     }
2361 2391
 
2362 2392
     /**
2363
-	 * Set the customer's state.
2364
-	 *
2365
-	 * @since 1.0.19
2366
-	 * @param  string $value state.
2367
-	 */
2368
-	public function set_state( $value ) {
2369
-		$this->set_prop( 'state', $value );
2393
+     * Set the customer's city.
2394
+     *
2395
+     * @since 1.0.19
2396
+     * @param  string $value city.
2397
+     */
2398
+    public function set_city( $value ) {
2399
+        $this->set_prop( 'city', $value );
2370 2400
     }
2371 2401
 
2372 2402
     /**
2373
-	 * Alias of self::set_state().
2374
-	 *
2375
-	 * @since 1.0.19
2376
-	 * @param  string $value state.
2377
-	 */
2378
-	public function set_user_state( $value ) {
2379
-		$this->set_state( $value );
2403
+     * Alias of self::set_city().
2404
+     *
2405
+     * @since 1.0.19
2406
+     * @param  string $value city.
2407
+     */
2408
+    public function set_user_city( $value ) {
2409
+        $this->set_city( $value );
2380 2410
     }
2381 2411
 
2382 2412
     /**
2383
-	 * Alias of self::set_state().
2384
-	 *
2385
-	 * @since 1.0.19
2386
-	 * @param  string $value state.
2387
-	 */
2388
-	public function set_customer_state( $value ) {
2389
-		$this->set_state( $value );
2413
+     * Alias of self::set_city().
2414
+     *
2415
+     * @since 1.0.19
2416
+     * @param  string $value city.
2417
+     */
2418
+    public function set_customer_city( $value ) {
2419
+        $this->set_city( $value );
2390 2420
     }
2391 2421
 
2392 2422
     /**
2393
-	 * Set the customer's city.
2394
-	 *
2395
-	 * @since 1.0.19
2396
-	 * @param  string $value city.
2397
-	 */
2398
-	public function set_city( $value ) {
2399
-		$this->set_prop( 'city', $value );
2423
+     * Set the customer's zip code.
2424
+     *
2425
+     * @since 1.0.19
2426
+     * @param  string $value zip.
2427
+     */
2428
+    public function set_zip( $value ) {
2429
+        $this->set_prop( 'zip', $value );
2400 2430
     }
2401 2431
 
2402 2432
     /**
2403
-	 * Alias of self::set_city().
2404
-	 *
2405
-	 * @since 1.0.19
2406
-	 * @param  string $value city.
2407
-	 */
2408
-	public function set_user_city( $value ) {
2409
-		$this->set_city( $value );
2433
+     * Alias of self::set_zip().
2434
+     *
2435
+     * @since 1.0.19
2436
+     * @param  string $value zip.
2437
+     */
2438
+    public function set_user_zip( $value ) {
2439
+        $this->set_zip( $value );
2410 2440
     }
2411 2441
 
2412 2442
     /**
2413
-	 * Alias of self::set_city().
2414
-	 *
2415
-	 * @since 1.0.19
2416
-	 * @param  string $value city.
2417
-	 */
2418
-	public function set_customer_city( $value ) {
2419
-		$this->set_city( $value );
2443
+     * Alias of self::set_zip().
2444
+     *
2445
+     * @since 1.0.19
2446
+     * @param  string $value zip.
2447
+     */
2448
+    public function set_customer_zip( $value ) {
2449
+        $this->set_zip( $value );
2420 2450
     }
2421 2451
 
2422 2452
     /**
2423
-	 * Set the customer's zip code.
2424
-	 *
2425
-	 * @since 1.0.19
2426
-	 * @param  string $value zip.
2427
-	 */
2428
-	public function set_zip( $value ) {
2429
-		$this->set_prop( 'zip', $value );
2453
+     * Set the customer's company.
2454
+     *
2455
+     * @since 1.0.19
2456
+     * @param  string $value company.
2457
+     */
2458
+    public function set_company( $value ) {
2459
+        $this->set_prop( 'company', $value );
2430 2460
     }
2431 2461
 
2432 2462
     /**
2433
-	 * Alias of self::set_zip().
2434
-	 *
2435
-	 * @since 1.0.19
2436
-	 * @param  string $value zip.
2437
-	 */
2438
-	public function set_user_zip( $value ) {
2439
-		$this->set_zip( $value );
2463
+     * Alias of self::set_company().
2464
+     *
2465
+     * @since 1.0.19
2466
+     * @param  string $value company.
2467
+     */
2468
+    public function set_user_company( $value ) {
2469
+        $this->set_company( $value );
2440 2470
     }
2441 2471
 
2442 2472
     /**
2443
-	 * Alias of self::set_zip().
2444
-	 *
2445
-	 * @since 1.0.19
2446
-	 * @param  string $value zip.
2447
-	 */
2448
-	public function set_customer_zip( $value ) {
2449
-		$this->set_zip( $value );
2473
+     * Alias of self::set_company().
2474
+     *
2475
+     * @since 1.0.19
2476
+     * @param  string $value company.
2477
+     */
2478
+    public function set_customer_company( $value ) {
2479
+        $this->set_company( $value );
2450 2480
     }
2451 2481
 
2452 2482
     /**
2453
-	 * Set the customer's company.
2454
-	 *
2455
-	 * @since 1.0.19
2456
-	 * @param  string $value company.
2457
-	 */
2458
-	public function set_company( $value ) {
2459
-		$this->set_prop( 'company', $value );
2483
+     * Set the customer's var number.
2484
+     *
2485
+     * @since 1.0.19
2486
+     * @param  string $value var number.
2487
+     */
2488
+    public function set_vat_number( $value ) {
2489
+        $this->set_prop( 'vat_number', $value );
2460 2490
     }
2461 2491
 
2462 2492
     /**
2463
-	 * Alias of self::set_company().
2464
-	 *
2465
-	 * @since 1.0.19
2466
-	 * @param  string $value company.
2467
-	 */
2468
-	public function set_user_company( $value ) {
2469
-		$this->set_company( $value );
2493
+     * Alias of self::set_vat_number().
2494
+     *
2495
+     * @since 1.0.19
2496
+     * @param  string $value var number.
2497
+     */
2498
+    public function set_user_vat_number( $value ) {
2499
+        $this->set_vat_number( $value );
2470 2500
     }
2471 2501
 
2472 2502
     /**
2473
-	 * Alias of self::set_company().
2474
-	 *
2475
-	 * @since 1.0.19
2476
-	 * @param  string $value company.
2477
-	 */
2478
-	public function set_customer_company( $value ) {
2479
-		$this->set_company( $value );
2503
+     * Alias of self::set_vat_number().
2504
+     *
2505
+     * @since 1.0.19
2506
+     * @param  string $value var number.
2507
+     */
2508
+    public function set_customer_vat_number( $value ) {
2509
+        $this->set_vat_number( $value );
2480 2510
     }
2481 2511
 
2482 2512
     /**
2483
-	 * Set the customer's var number.
2484
-	 *
2485
-	 * @since 1.0.19
2486
-	 * @param  string $value var number.
2487
-	 */
2488
-	public function set_vat_number( $value ) {
2489
-		$this->set_prop( 'vat_number', $value );
2513
+     * Set the customer's vat rate.
2514
+     *
2515
+     * @since 1.0.19
2516
+     * @param  string $value var rate.
2517
+     */
2518
+    public function set_vat_rate( $value ) {
2519
+        $this->set_prop( 'vat_rate', $value );
2490 2520
     }
2491 2521
 
2492 2522
     /**
2493
-	 * Alias of self::set_vat_number().
2494
-	 *
2495
-	 * @since 1.0.19
2496
-	 * @param  string $value var number.
2497
-	 */
2498
-	public function set_user_vat_number( $value ) {
2499
-		$this->set_vat_number( $value );
2523
+     * Alias of self::set_vat_rate().
2524
+     *
2525
+     * @since 1.0.19
2526
+     * @param  string $value var number.
2527
+     */
2528
+    public function set_user_vat_rate( $value ) {
2529
+        $this->set_vat_rate( $value );
2500 2530
     }
2501 2531
 
2502 2532
     /**
2503
-	 * Alias of self::set_vat_number().
2504
-	 *
2505
-	 * @since 1.0.19
2506
-	 * @param  string $value var number.
2507
-	 */
2508
-	public function set_customer_vat_number( $value ) {
2509
-		$this->set_vat_number( $value );
2533
+     * Alias of self::set_vat_rate().
2534
+     *
2535
+     * @since 1.0.19
2536
+     * @param  string $value var number.
2537
+     */
2538
+    public function set_customer_vat_rate( $value ) {
2539
+        $this->set_vat_rate( $value );
2510 2540
     }
2511 2541
 
2512 2542
     /**
2513
-	 * Set the customer's vat rate.
2514
-	 *
2515
-	 * @since 1.0.19
2516
-	 * @param  string $value var rate.
2517
-	 */
2518
-	public function set_vat_rate( $value ) {
2519
-		$this->set_prop( 'vat_rate', $value );
2543
+     * Set the customer's address.
2544
+     *
2545
+     * @since 1.0.19
2546
+     * @param  string $value address.
2547
+     */
2548
+    public function set_address( $value ) {
2549
+        $this->set_prop( 'address', $value );
2520 2550
     }
2521 2551
 
2522 2552
     /**
2523
-	 * Alias of self::set_vat_rate().
2524
-	 *
2525
-	 * @since 1.0.19
2526
-	 * @param  string $value var number.
2527
-	 */
2528
-	public function set_user_vat_rate( $value ) {
2529
-		$this->set_vat_rate( $value );
2553
+     * Alias of self::set_address().
2554
+     *
2555
+     * @since 1.0.19
2556
+     * @param  string $value address.
2557
+     */
2558
+    public function set_user_address( $value ) {
2559
+        $this->set_address( $value );
2530 2560
     }
2531 2561
 
2532 2562
     /**
2533
-	 * Alias of self::set_vat_rate().
2534
-	 *
2535
-	 * @since 1.0.19
2536
-	 * @param  string $value var number.
2537
-	 */
2538
-	public function set_customer_vat_rate( $value ) {
2539
-		$this->set_vat_rate( $value );
2563
+     * Alias of self::set_address().
2564
+     *
2565
+     * @since 1.0.19
2566
+     * @param  string $value address.
2567
+     */
2568
+    public function set_customer_address( $value ) {
2569
+        $this->set_address( $value );
2540 2570
     }
2541 2571
 
2542 2572
     /**
2543
-	 * Set the customer's address.
2544
-	 *
2545
-	 * @since 1.0.19
2546
-	 * @param  string $value address.
2547
-	 */
2548
-	public function set_address( $value ) {
2549
-		$this->set_prop( 'address', $value );
2573
+     * Set whether the customer has viewed the invoice or not.
2574
+     *
2575
+     * @since 1.0.19
2576
+     * @param  int|bool $value confirmed.
2577
+     */
2578
+    public function set_is_viewed( $value ) {
2579
+        $this->set_prop( 'is_viewed', $value );
2550 2580
     }
2551 2581
 
2552 2582
     /**
2553
-	 * Alias of self::set_address().
2554
-	 *
2555
-	 * @since 1.0.19
2556
-	 * @param  string $value address.
2557
-	 */
2558
-	public function set_user_address( $value ) {
2559
-		$this->set_address( $value );
2583
+     * Set extra email recipients.
2584
+     *
2585
+     * @since 1.0.19
2586
+     * @param  string $value email recipients.
2587
+     */
2588
+    public function set_email_cc( $value ) {
2589
+        $this->set_prop( 'email_cc', $value );
2560 2590
     }
2561 2591
 
2562 2592
     /**
2563
-	 * Alias of self::set_address().
2564
-	 *
2565
-	 * @since 1.0.19
2566
-	 * @param  string $value address.
2567
-	 */
2568
-	public function set_customer_address( $value ) {
2569
-		$this->set_address( $value );
2593
+     * Set the invoice template.
2594
+     *
2595
+     * @since 1.0.19
2596
+     * @param  string $value email recipients.
2597
+     */
2598
+    public function set_template( $value ) {
2599
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2600
+            $this->set_prop( 'template', $value );
2601
+        }
2570 2602
     }
2571 2603
 
2572 2604
     /**
2573
-	 * Set whether the customer has viewed the invoice or not.
2574
-	 *
2575
-	 * @since 1.0.19
2576
-	 * @param  int|bool $value confirmed.
2577
-	 */
2578
-	public function set_is_viewed( $value ) {
2579
-		$this->set_prop( 'is_viewed', $value );
2580
-	}
2581
-
2582
-	/**
2583
-	 * Set extra email recipients.
2584
-	 *
2585
-	 * @since 1.0.19
2586
-	 * @param  string $value email recipients.
2587
-	 */
2588
-	public function set_email_cc( $value ) {
2589
-		$this->set_prop( 'email_cc', $value );
2590
-	}
2591
-
2592
-	/**
2593
-	 * Set the invoice template.
2594
-	 *
2595
-	 * @since 1.0.19
2596
-	 * @param  string $value email recipients.
2597
-	 */
2598
-	public function set_template( $value ) {
2599
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2600
-			$this->set_prop( 'template', $value );
2601
-		}
2602
-	}
2603
-
2604
-	/**
2605
-	 * Set the customer's address confirmed status.
2606
-	 *
2607
-	 * @since 1.0.19
2608
-	 * @param  int|bool $value confirmed.
2609
-	 */
2610
-	public function set_address_confirmed( $value ) {
2611
-		$this->set_prop( 'address_confirmed', $value );
2605
+     * Set the customer's address confirmed status.
2606
+     *
2607
+     * @since 1.0.19
2608
+     * @param  int|bool $value confirmed.
2609
+     */
2610
+    public function set_address_confirmed( $value ) {
2611
+        $this->set_prop( 'address_confirmed', $value );
2612 2612
     }
2613 2613
 
2614 2614
     /**
2615
-	 * Alias of self::set_address_confirmed().
2616
-	 *
2617
-	 * @since 1.0.19
2618
-	 * @param  int|bool $value confirmed.
2619
-	 */
2620
-	public function set_user_address_confirmed( $value ) {
2621
-		$this->set_address_confirmed( $value );
2615
+     * Alias of self::set_address_confirmed().
2616
+     *
2617
+     * @since 1.0.19
2618
+     * @param  int|bool $value confirmed.
2619
+     */
2620
+    public function set_user_address_confirmed( $value ) {
2621
+        $this->set_address_confirmed( $value );
2622 2622
     }
2623 2623
 
2624 2624
     /**
2625
-	 * Alias of self::set_address_confirmed().
2626
-	 *
2627
-	 * @since 1.0.19
2628
-	 * @param  int|bool $value confirmed.
2629
-	 */
2630
-	public function set_customer_address_confirmed( $value ) {
2631
-		$this->set_address_confirmed( $value );
2625
+     * Alias of self::set_address_confirmed().
2626
+     *
2627
+     * @since 1.0.19
2628
+     * @param  int|bool $value confirmed.
2629
+     */
2630
+    public function set_customer_address_confirmed( $value ) {
2631
+        $this->set_address_confirmed( $value );
2632 2632
     }
2633 2633
 
2634 2634
     /**
2635
-	 * Set the invoice sub total.
2636
-	 *
2637
-	 * @since 1.0.19
2638
-	 * @param  float $value sub total.
2639
-	 */
2640
-	public function set_subtotal( $value ) {
2641
-		$this->set_prop( 'subtotal', $value );
2635
+     * Set the invoice sub total.
2636
+     *
2637
+     * @since 1.0.19
2638
+     * @param  float $value sub total.
2639
+     */
2640
+    public function set_subtotal( $value ) {
2641
+        $this->set_prop( 'subtotal', $value );
2642 2642
     }
2643 2643
 
2644 2644
     /**
2645
-	 * Set the invoice discount amount.
2646
-	 *
2647
-	 * @since 1.0.19
2648
-	 * @param  float $value discount total.
2649
-	 */
2650
-	public function set_total_discount( $value ) {
2651
-		$this->set_prop( 'total_discount', $value );
2645
+     * Set the invoice discount amount.
2646
+     *
2647
+     * @since 1.0.19
2648
+     * @param  float $value discount total.
2649
+     */
2650
+    public function set_total_discount( $value ) {
2651
+        $this->set_prop( 'total_discount', $value );
2652 2652
     }
2653 2653
 
2654 2654
     /**
2655
-	 * Alias of self::set_total_discount().
2656
-	 *
2657
-	 * @since 1.0.19
2658
-	 * @param  float $value discount total.
2659
-	 */
2660
-	public function set_discount( $value ) {
2661
-		$this->set_total_discount( $value );
2655
+     * Alias of self::set_total_discount().
2656
+     *
2657
+     * @since 1.0.19
2658
+     * @param  float $value discount total.
2659
+     */
2660
+    public function set_discount( $value ) {
2661
+        $this->set_total_discount( $value );
2662 2662
     }
2663 2663
 
2664 2664
     /**
2665
-	 * Set the invoice tax amount.
2666
-	 *
2667
-	 * @since 1.0.19
2668
-	 * @param  float $value tax total.
2669
-	 */
2670
-	public function set_total_tax( $value ) {
2671
-		$this->set_prop( 'total_tax', $value );
2665
+     * Set the invoice tax amount.
2666
+     *
2667
+     * @since 1.0.19
2668
+     * @param  float $value tax total.
2669
+     */
2670
+    public function set_total_tax( $value ) {
2671
+        $this->set_prop( 'total_tax', $value );
2672 2672
     }
2673 2673
 
2674 2674
     /**
2675
-	 * Alias of self::set_total_tax().
2676
-	 *
2677
-	 * @since 1.0.19
2678
-	 * @param  float $value tax total.
2679
-	 */
2680
-	public function set_tax_total( $value ) {
2681
-		$this->set_total_tax( $value );
2675
+     * Alias of self::set_total_tax().
2676
+     *
2677
+     * @since 1.0.19
2678
+     * @param  float $value tax total.
2679
+     */
2680
+    public function set_tax_total( $value ) {
2681
+        $this->set_total_tax( $value );
2682 2682
     }
2683 2683
 
2684 2684
     /**
2685
-	 * Set the invoice fees amount.
2686
-	 *
2687
-	 * @since 1.0.19
2688
-	 * @param  float $value fees total.
2689
-	 */
2690
-	public function set_total_fees( $value ) {
2691
-		$this->set_prop( 'total_fees', $value );
2685
+     * Set the invoice fees amount.
2686
+     *
2687
+     * @since 1.0.19
2688
+     * @param  float $value fees total.
2689
+     */
2690
+    public function set_total_fees( $value ) {
2691
+        $this->set_prop( 'total_fees', $value );
2692 2692
     }
2693 2693
 
2694 2694
     /**
2695
-	 * Alias of self::set_total_fees().
2696
-	 *
2697
-	 * @since 1.0.19
2698
-	 * @param  float $value fees total.
2699
-	 */
2700
-	public function set_fees_total( $value ) {
2701
-		$this->set_total_fees( $value );
2695
+     * Alias of self::set_total_fees().
2696
+     *
2697
+     * @since 1.0.19
2698
+     * @param  float $value fees total.
2699
+     */
2700
+    public function set_fees_total( $value ) {
2701
+        $this->set_total_fees( $value );
2702 2702
     }
2703 2703
 
2704 2704
     /**
2705
-	 * Set the invoice fees.
2706
-	 *
2707
-	 * @since 1.0.19
2708
-	 * @param  array $value fees.
2709
-	 */
2710
-	public function set_fees( $value ) {
2705
+     * Set the invoice fees.
2706
+     *
2707
+     * @since 1.0.19
2708
+     * @param  array $value fees.
2709
+     */
2710
+    public function set_fees( $value ) {
2711 2711
 
2712 2712
         $this->set_prop( 'fees', array() );
2713 2713
 
@@ -2725,23 +2725,23 @@  discard block
 block discarded – undo
2725 2725
     }
2726 2726
 
2727 2727
     /**
2728
-	 * Set the invoice taxes.
2729
-	 *
2730
-	 * @since 1.0.19
2731
-	 * @param  array $value taxes.
2732
-	 */
2733
-	public function set_taxes( $value ) {
2734
-		$this->set_prop( 'taxes', $value );
2728
+     * Set the invoice taxes.
2729
+     *
2730
+     * @since 1.0.19
2731
+     * @param  array $value taxes.
2732
+     */
2733
+    public function set_taxes( $value ) {
2734
+        $this->set_prop( 'taxes', $value );
2735 2735
     }
2736 2736
 
2737 2737
     /**
2738
-	 * Set the invoice discounts.
2739
-	 *
2740
-	 * @since 1.0.19
2741
-	 * @param  array $value discounts.
2742
-	 */
2743
-	public function set_discounts( $value ) {
2744
-		$this->set_prop( 'discounts', array() );
2738
+     * Set the invoice discounts.
2739
+     *
2740
+     * @since 1.0.19
2741
+     * @param  array $value discounts.
2742
+     */
2743
+    public function set_discounts( $value ) {
2744
+        $this->set_prop( 'discounts', array() );
2745 2745
 
2746 2746
         // Ensure that we have an array.
2747 2747
         if ( ! is_array( $value ) ) {
@@ -2756,12 +2756,12 @@  discard block
 block discarded – undo
2756 2756
     }
2757 2757
 
2758 2758
     /**
2759
-	 * Set the invoice items.
2760
-	 *
2761
-	 * @since 1.0.19
2762
-	 * @param  GetPaid_Form_Item[] $value items.
2763
-	 */
2764
-	public function set_items( $value ) {
2759
+     * Set the invoice items.
2760
+     *
2761
+     * @since 1.0.19
2762
+     * @param  GetPaid_Form_Item[] $value items.
2763
+     */
2764
+    public function set_items( $value ) {
2765 2765
 
2766 2766
         // Remove existing items.
2767 2767
         $this->set_prop( 'items', array() );
@@ -2778,85 +2778,85 @@  discard block
 block discarded – undo
2778 2778
     }
2779 2779
 
2780 2780
     /**
2781
-	 * Set the payment form.
2782
-	 *
2783
-	 * @since 1.0.19
2784
-	 * @param  int $value payment form.
2785
-	 */
2786
-	public function set_payment_form( $value ) {
2787
-		$this->set_prop( 'payment_form', $value );
2781
+     * Set the payment form.
2782
+     *
2783
+     * @since 1.0.19
2784
+     * @param  int $value payment form.
2785
+     */
2786
+    public function set_payment_form( $value ) {
2787
+        $this->set_prop( 'payment_form', $value );
2788 2788
     }
2789 2789
 
2790 2790
     /**
2791
-	 * Set the submission id.
2792
-	 *
2793
-	 * @since 1.0.19
2794
-	 * @param  string $value submission id.
2795
-	 */
2796
-	public function set_submission_id( $value ) {
2797
-		$this->set_prop( 'submission_id', $value );
2791
+     * Set the submission id.
2792
+     *
2793
+     * @since 1.0.19
2794
+     * @param  string $value submission id.
2795
+     */
2796
+    public function set_submission_id( $value ) {
2797
+        $this->set_prop( 'submission_id', $value );
2798 2798
     }
2799 2799
 
2800 2800
     /**
2801
-	 * Set the discount code.
2802
-	 *
2803
-	 * @since 1.0.19
2804
-	 * @param  string $value discount code.
2805
-	 */
2806
-	public function set_discount_code( $value ) {
2807
-		$this->set_prop( 'discount_code', $value );
2801
+     * Set the discount code.
2802
+     *
2803
+     * @since 1.0.19
2804
+     * @param  string $value discount code.
2805
+     */
2806
+    public function set_discount_code( $value ) {
2807
+        $this->set_prop( 'discount_code', $value );
2808 2808
     }
2809 2809
 
2810 2810
     /**
2811
-	 * Set the gateway.
2812
-	 *
2813
-	 * @since 1.0.19
2814
-	 * @param  string $value gateway.
2815
-	 */
2816
-	public function set_gateway( $value ) {
2817
-		$this->set_prop( 'gateway', $value );
2811
+     * Set the gateway.
2812
+     *
2813
+     * @since 1.0.19
2814
+     * @param  string $value gateway.
2815
+     */
2816
+    public function set_gateway( $value ) {
2817
+        $this->set_prop( 'gateway', $value );
2818 2818
     }
2819 2819
 
2820 2820
     /**
2821
-	 * Set the transaction id.
2822
-	 *
2823
-	 * @since 1.0.19
2824
-	 * @param  string $value transaction id.
2825
-	 */
2826
-	public function set_transaction_id( $value ) {
2827
-		if ( ! empty( $value ) ) {
2828
-			$this->set_prop( 'transaction_id', $value );
2829
-		}
2821
+     * Set the transaction id.
2822
+     *
2823
+     * @since 1.0.19
2824
+     * @param  string $value transaction id.
2825
+     */
2826
+    public function set_transaction_id( $value ) {
2827
+        if ( ! empty( $value ) ) {
2828
+            $this->set_prop( 'transaction_id', $value );
2829
+        }
2830 2830
     }
2831 2831
 
2832 2832
     /**
2833
-	 * Set the currency id.
2834
-	 *
2835
-	 * @since 1.0.19
2836
-	 * @param  string $value currency id.
2837
-	 */
2838
-	public function set_currency( $value ) {
2839
-		$this->set_prop( 'currency', $value );
2833
+     * Set the currency id.
2834
+     *
2835
+     * @since 1.0.19
2836
+     * @param  string $value currency id.
2837
+     */
2838
+    public function set_currency( $value ) {
2839
+        $this->set_prop( 'currency', $value );
2840 2840
     }
2841 2841
 
2842
-	/**
2843
-	 * Set whether to disable taxes.
2844
-	 *
2845
-	 * @since 1.0.19
2846
-	 * @param  bool $value value.
2847
-	 */
2848
-	public function set_disable_taxes( $value ) {
2849
-		$this->set_prop( 'disable_taxes', (bool) $value );
2850
-	}
2842
+    /**
2843
+     * Set whether to disable taxes.
2844
+     *
2845
+     * @since 1.0.19
2846
+     * @param  bool $value value.
2847
+     */
2848
+    public function set_disable_taxes( $value ) {
2849
+        $this->set_prop( 'disable_taxes', (bool) $value );
2850
+    }
2851 2851
 
2852 2852
     /**
2853
-	 * Set the subscription id.
2854
-	 *
2855
-	 * @since 1.0.19
2856
-	 * @param  string $value subscription id.
2857
-	 */
2858
-	public function set_subscription_id( $value ) {
2859
-		$this->set_prop( 'subscription_id', $value );
2853
+     * Set the subscription id.
2854
+     *
2855
+     * @since 1.0.19
2856
+     * @param  string $value subscription id.
2857
+     */
2858
+    public function set_subscription_id( $value ) {
2859
+        $this->set_prop( 'subscription_id', $value );
2860 2860
     }
2861 2861
 
2862 2862
     /*
@@ -2895,12 +2895,12 @@  discard block
 block discarded – undo
2895 2895
      */
2896 2896
     public function is_taxable() {
2897 2897
         return ! $this->get_disable_taxes();
2898
-	}
2898
+    }
2899 2899
 
2900
-	/**
2901
-	 * @deprecated
2902
-	 */
2903
-	public function has_vat() {
2900
+    /**
2901
+     * @deprecated
2902
+     */
2903
+    public function has_vat() {
2904 2904
         global $wpinv_euvat, $wpi_country;
2905 2905
 
2906 2906
         $requires_vat = false;
@@ -2911,17 +2911,17 @@  discard block
 block discarded – undo
2911 2911
         }
2912 2912
 
2913 2913
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2914
-	}
2914
+    }
2915 2915
 
2916
-	/**
2917
-	 * Checks to see if the invoice requires payment.
2918
-	 */
2919
-	public function is_free() {
2916
+    /**
2917
+     * Checks to see if the invoice requires payment.
2918
+     */
2919
+    public function is_free() {
2920 2920
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2921 2921
 
2922
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2923
-			$is_free = false;
2924
-		}
2922
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2923
+            $is_free = false;
2924
+        }
2925 2925
 
2926 2926
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2927 2927
     }
@@ -2932,46 +2932,46 @@  discard block
 block discarded – undo
2932 2932
     public function is_paid() {
2933 2933
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2934 2934
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2935
-	}
2935
+    }
2936 2936
 
2937
-	/**
2937
+    /**
2938 2938
      * Checks if the invoice needs payment.
2939 2939
      */
2940
-	public function needs_payment() {
2941
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2940
+    public function needs_payment() {
2941
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2942 2942
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2943 2943
     }
2944 2944
 
2945
-	/**
2945
+    /**
2946 2946
      * Checks if the invoice is refunded.
2947 2947
      */
2948
-	public function is_refunded() {
2948
+    public function is_refunded() {
2949 2949
         $is_refunded = $this->has_status( 'wpi-refunded' );
2950 2950
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2951
-	}
2951
+    }
2952 2952
 
2953
-	/**
2953
+    /**
2954 2954
      * Checks if the invoice is held.
2955 2955
      */
2956
-	public function is_held() {
2956
+    public function is_held() {
2957 2957
         $is_held = $this->has_status( 'wpi-onhold' );
2958 2958
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2959
-	}
2959
+    }
2960 2960
 
2961
-	/**
2961
+    /**
2962 2962
      * Checks if the invoice is due.
2963 2963
      */
2964
-	public function is_due() {
2965
-		$due_date = $this->get_due_date();
2966
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2967
-	}
2964
+    public function is_due() {
2965
+        $due_date = $this->get_due_date();
2966
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2967
+    }
2968 2968
 
2969
-	/**
2969
+    /**
2970 2970
      * Checks if the invoice is draft.
2971 2971
      */
2972
-	public function is_draft() {
2972
+    public function is_draft() {
2973 2973
         return $this->has_status( 'draft, auto-draft' );
2974
-	}
2974
+    }
2975 2975
 
2976 2976
     /**
2977 2977
      * Checks if the invoice has a given status.
@@ -2979,9 +2979,9 @@  discard block
 block discarded – undo
2979 2979
     public function has_status( $status ) {
2980 2980
         $status = wpinv_parse_list( $status );
2981 2981
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2982
-	}
2982
+    }
2983 2983
 
2984
-	/**
2984
+    /**
2985 2985
      * Checks if the invoice is of a given type.
2986 2986
      */
2987 2987
     public function is_type( $type ) {
@@ -3004,25 +3004,25 @@  discard block
 block discarded – undo
3004 3004
      */
3005 3005
     public function has_free_trial() {
3006 3006
         return $this->is_recurring() && 0 == $this->get_initial_total();
3007
-	}
3007
+    }
3008 3008
 
3009
-	/**
3009
+    /**
3010 3010
      * @deprecated
3011 3011
      */
3012 3012
     public function is_free_trial() {
3013 3013
         $this->has_free_trial();
3014 3014
     }
3015 3015
 
3016
-	/**
3016
+    /**
3017 3017
      * Check if the initial payment if 0.
3018 3018
      *
3019 3019
      */
3020
-	public function is_initial_free() {
3020
+    public function is_initial_free() {
3021 3021
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3022 3022
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3023 3023
     }
3024 3024
 	
3025
-	/**
3025
+    /**
3026 3026
      * Check if the recurring item has a free trial.
3027 3027
      *
3028 3028
      */
@@ -3035,21 +3035,21 @@  discard block
 block discarded – undo
3035 3035
 
3036 3036
         $item = $this->get_recurring( true );
3037 3037
         return $item->has_free_trial();
3038
-	}
3038
+    }
3039 3039
 
3040
-	/**
3040
+    /**
3041 3041
      * Check if the free trial is a result of a discount.
3042 3042
      */
3043 3043
     public function is_free_trial_from_discount() {
3044
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3045
-	}
3044
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3045
+    }
3046 3046
 	
3047
-	/**
3047
+    /**
3048 3048
      * @deprecated
3049 3049
      */
3050 3050
     public function discount_first_payment_only() {
3051 3051
 
3052
-		$discount_code = $this->get_discount_code();
3052
+        $discount_code = $this->get_discount_code();
3053 3053
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3054 3054
             return true;
3055 3055
         }
@@ -3080,28 +3080,28 @@  discard block
 block discarded – undo
3080 3080
      */
3081 3081
     public function add_item( $item ) {
3082 3082
 
3083
-		if ( is_array( $item ) ) {
3084
-			$item = $this->process_array_item( $item );
3085
-		}
3083
+        if ( is_array( $item ) ) {
3084
+            $item = $this->process_array_item( $item );
3085
+        }
3086 3086
 
3087
-		if ( is_numeric( $item ) ) {
3088
-			$item = new GetPaid_Form_Item( $item );
3089
-		}
3087
+        if ( is_numeric( $item ) ) {
3088
+            $item = new GetPaid_Form_Item( $item );
3089
+        }
3090 3090
 
3091 3091
         // Make sure that it is available for purchase.
3092
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3093
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3092
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3093
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3094 3094
         }
3095 3095
 
3096 3096
         // Do we have a recurring item?
3097
-		if ( $item->is_recurring() ) {
3097
+        if ( $item->is_recurring() ) {
3098 3098
 
3099
-			// An invoice can only contain one recurring item.
3100
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3101
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3102
-			}
3099
+            // An invoice can only contain one recurring item.
3100
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3101
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3102
+            }
3103 3103
 
3104
-			$this->recurring_item = $item->get_id();
3104
+            $this->recurring_item = $item->get_id();
3105 3105
         }
3106 3106
 
3107 3107
         // Invoice id.
@@ -3112,60 +3112,60 @@  discard block
 block discarded – undo
3112 3112
         $items[ (int) $item->get_id() ] = $item;
3113 3113
 
3114 3114
         $this->set_prop( 'items', $items );
3115
-		return true;
3116
-	}
3115
+        return true;
3116
+    }
3117 3117
 	
3118
-	/**
3119
-	 * Converts an array to an item.
3120
-	 *
3121
-	 * @since 1.0.19
3122
-	 * @return GetPaid_Form_Item
3123
-	 */
3124
-	protected function process_array_item( $array ) {
3125
-
3126
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3127
-		$item    = new GetPaid_Form_Item( $item_id );
3128
-
3129
-		// Set item data.
3130
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3131
-			if ( isset( $array[ "item_$key" ] ) ) {
3132
-				$method = "set_$key";
3133
-				$item->$method( $array[ "item_$key" ] );
3134
-			}
3135
-		}
3136
-
3137
-		if ( isset( $array['quantity'] ) ) {
3138
-			$item->set_quantity( $array['quantity'] );
3139
-		}
3140
-
3141
-		// Set item meta.
3142
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3143
-			$item->set_item_meta( $array['meta'] );
3144
-		}
3145
-
3146
-		return $item;
3147
-
3148
-	}
3149
-
3150
-    /**
3151
-	 * Retrieves a specific item.
3152
-	 *
3153
-	 * @since 1.0.19
3154
-	 */
3155
-	public function get_item( $item_id ) {
3156
-		$items   = $this->get_items();
3157
-		$item_id = (int) $item_id;
3158
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3159
-    }
3160
-
3161
-    /**
3162
-	 * Removes a specific item.
3163
-	 *
3164
-	 * @since 1.0.19
3165
-	 */
3166
-	public function remove_item( $item_id ) {
3167
-		$items   = $this->get_items();
3168
-		$item_id = (int) $item_id;
3118
+    /**
3119
+     * Converts an array to an item.
3120
+     *
3121
+     * @since 1.0.19
3122
+     * @return GetPaid_Form_Item
3123
+     */
3124
+    protected function process_array_item( $array ) {
3125
+
3126
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3127
+        $item    = new GetPaid_Form_Item( $item_id );
3128
+
3129
+        // Set item data.
3130
+        foreach( array( 'name', 'price', 'description' ) as $key ) {
3131
+            if ( isset( $array[ "item_$key" ] ) ) {
3132
+                $method = "set_$key";
3133
+                $item->$method( $array[ "item_$key" ] );
3134
+            }
3135
+        }
3136
+
3137
+        if ( isset( $array['quantity'] ) ) {
3138
+            $item->set_quantity( $array['quantity'] );
3139
+        }
3140
+
3141
+        // Set item meta.
3142
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3143
+            $item->set_item_meta( $array['meta'] );
3144
+        }
3145
+
3146
+        return $item;
3147
+
3148
+    }
3149
+
3150
+    /**
3151
+     * Retrieves a specific item.
3152
+     *
3153
+     * @since 1.0.19
3154
+     */
3155
+    public function get_item( $item_id ) {
3156
+        $items   = $this->get_items();
3157
+        $item_id = (int) $item_id;
3158
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3159
+    }
3160
+
3161
+    /**
3162
+     * Removes a specific item.
3163
+     *
3164
+     * @since 1.0.19
3165
+     */
3166
+    public function remove_item( $item_id ) {
3167
+        $items   = $this->get_items();
3168
+        $item_id = (int) $item_id;
3169 3169
 
3170 3170
         if ( $item_id == $this->recurring_item ) {
3171 3171
             $this->recurring_item = null;
@@ -3192,38 +3192,38 @@  discard block
 block discarded – undo
3192 3192
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3193 3193
 
3194 3194
             $amount = $fees[ $fee ]['amount'] += $amount;
3195
-			$fees[ $fee ] = array(
3196
-				'amount'    => $amount,
3195
+            $fees[ $fee ] = array(
3196
+                'amount'    => $amount,
3197 3197
                 'recurring' => (bool) $recurring,
3198 3198
             );
3199 3199
 
3200
-		} else {
3201
-			$fees[ $fee ] = array(
3200
+        } else {
3201
+            $fees[ $fee ] = array(
3202 3202
                 'amount'    => $amount,
3203 3203
                 'recurring' => (bool) $recurring,
3204 3204
             );
3205
-		}
3205
+        }
3206 3206
 
3207 3207
         $this->set_prop( 'fees', $fee );
3208 3208
 
3209 3209
     }
3210 3210
 
3211 3211
     /**
3212
-	 * Retrieves a specific fee.
3213
-	 *
3214
-	 * @since 1.0.19
3215
-	 */
3216
-	public function get_fee( $fee ) {
3212
+     * Retrieves a specific fee.
3213
+     *
3214
+     * @since 1.0.19
3215
+     */
3216
+    public function get_fee( $fee ) {
3217 3217
         $fees = $this->get_fees();
3218
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3218
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3219 3219
     }
3220 3220
 
3221 3221
     /**
3222
-	 * Removes a specific fee.
3223
-	 *
3224
-	 * @since 1.0.19
3225
-	 */
3226
-	public function remove_fee( $fee ) {
3222
+     * Removes a specific fee.
3223
+     *
3224
+     * @since 1.0.19
3225
+     */
3226
+    public function remove_fee( $fee ) {
3227 3227
         $fees = $this->get_fees();
3228 3228
         if ( isset( $fees[ $fee ] ) ) {
3229 3229
             unset( $fees[ $fee ] );
@@ -3246,44 +3246,44 @@  discard block
 block discarded – undo
3246 3246
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3247 3247
 
3248 3248
             $amount = $discounts[ $discount ]['amount'] += $amount;
3249
-			$discounts[ $discount ] = array(
3249
+            $discounts[ $discount ] = array(
3250 3250
                 'amount'    => $amount,
3251 3251
                 'recurring' => (bool) $recurring,
3252 3252
             );
3253 3253
 
3254
-		} else {
3255
-			$discounts[ $discount ] = array(
3254
+        } else {
3255
+            $discounts[ $discount ] = array(
3256 3256
                 'amount'    => $amount,
3257 3257
                 'recurring' => (bool) $recurring,
3258 3258
             );
3259
-		}
3259
+        }
3260 3260
 
3261 3261
         $this->set_prop( 'discounts', $discount );
3262 3262
 
3263 3263
     }
3264 3264
 
3265 3265
     /**
3266
-	 * Retrieves a specific discount.
3267
-	 *
3268
-	 * @since 1.0.19
3269
-	 */
3270
-	public function get_discount( $discount = false ) {
3266
+     * Retrieves a specific discount.
3267
+     *
3268
+     * @since 1.0.19
3269
+     */
3270
+    public function get_discount( $discount = false ) {
3271 3271
 
3272
-		// Backwards compatibilty.
3273
-		if ( empty( $discount ) ) {
3274
-			return $this->get_total_discount();
3275
-		}
3272
+        // Backwards compatibilty.
3273
+        if ( empty( $discount ) ) {
3274
+            return $this->get_total_discount();
3275
+        }
3276 3276
 
3277 3277
         $discounts = $this->get_discounts();
3278
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3278
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3279 3279
     }
3280 3280
 
3281 3281
     /**
3282
-	 * Removes a specific discount.
3283
-	 *
3284
-	 * @since 1.0.19
3285
-	 */
3286
-	public function remove_discount( $discount ) {
3282
+     * Removes a specific discount.
3283
+     *
3284
+     * @since 1.0.19
3285
+     */
3286
+    public function remove_discount( $discount ) {
3287 3287
         $discounts = $this->get_discounts();
3288 3288
         if ( isset( $discounts[ $discount ] ) ) {
3289 3289
             unset( $discounts[ $discount ] );
@@ -3309,44 +3309,44 @@  discard block
 block discarded – undo
3309 3309
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3310 3310
 
3311 3311
             $amount = $taxes[ $tax ]['amount'] += $amount;
3312
-			$taxes[ $tax ] = array(
3312
+            $taxes[ $tax ] = array(
3313 3313
                 'amount'    => $amount,
3314 3314
                 'recurring' => (bool) $recurring,
3315 3315
             );
3316 3316
 
3317
-		} else {
3318
-			$taxes[ $tax ] = array(
3317
+        } else {
3318
+            $taxes[ $tax ] = array(
3319 3319
                 'amount'    => $amount,
3320 3320
                 'recurring' => (bool) $recurring,
3321 3321
             );
3322
-		}
3322
+        }
3323 3323
 
3324 3324
         $this->set_prop( 'taxes', $tax );
3325 3325
 
3326 3326
     }
3327 3327
 
3328 3328
     /**
3329
-	 * Retrieves a specific tax.
3330
-	 *
3331
-	 * @since 1.0.19
3332
-	 */
3333
-	public function get_tax( $tax = null ) {
3329
+     * Retrieves a specific tax.
3330
+     *
3331
+     * @since 1.0.19
3332
+     */
3333
+    public function get_tax( $tax = null ) {
3334 3334
 
3335
-		// Backwards compatility.
3336
-		if ( empty( $tax ) ) {
3337
-			return $this->get_total_tax();
3338
-		}
3335
+        // Backwards compatility.
3336
+        if ( empty( $tax ) ) {
3337
+            return $this->get_total_tax();
3338
+        }
3339 3339
 
3340 3340
         $taxes = $this->get_taxes();
3341
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3341
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3342 3342
     }
3343 3343
 
3344 3344
     /**
3345
-	 * Removes a specific tax.
3346
-	 *
3347
-	 * @since 1.0.19
3348
-	 */
3349
-	public function remove_tax( $tax ) {
3345
+     * Removes a specific tax.
3346
+     *
3347
+     * @since 1.0.19
3348
+     */
3349
+    public function remove_tax( $tax ) {
3350 3350
         $taxes = $this->get_discounts();
3351 3351
         if ( isset( $taxes[ $tax ] ) ) {
3352 3352
             unset( $taxes[ $tax ] );
@@ -3355,160 +3355,160 @@  discard block
 block discarded – undo
3355 3355
     }
3356 3356
 
3357 3357
     /**
3358
-	 * Recalculates the invoice subtotal.
3359
-	 *
3360
-	 * @since 1.0.19
3361
-	 * @return float The recalculated subtotal
3362
-	 */
3363
-	public function recalculate_subtotal() {
3358
+     * Recalculates the invoice subtotal.
3359
+     *
3360
+     * @since 1.0.19
3361
+     * @return float The recalculated subtotal
3362
+     */
3363
+    public function recalculate_subtotal() {
3364 3364
         $items     = $this->get_items();
3365
-		$subtotal  = 0;
3366
-		$recurring = 0;
3365
+        $subtotal  = 0;
3366
+        $recurring = 0;
3367 3367
 
3368 3368
         foreach ( $items as $item ) {
3369
-			$subtotal  += $item->get_sub_total();
3370
-			$recurring += $item->get_recurring_sub_total();
3369
+            $subtotal  += $item->get_sub_total();
3370
+            $recurring += $item->get_recurring_sub_total();
3371 3371
         }
3372 3372
 
3373
-		if ( $this->is_renewal() ) {
3374
-			$this->set_subtotal( $recurring );
3375
-		} else {
3376
-			$this->set_subtotal( $subtotal );
3377
-		}
3373
+        if ( $this->is_renewal() ) {
3374
+            $this->set_subtotal( $recurring );
3375
+        } else {
3376
+            $this->set_subtotal( $subtotal );
3377
+        }
3378 3378
 
3379
-		$this->totals['subtotal'] = array(
3380
-			'initial'   => $subtotal,
3381
-			'recurring' => $recurring,
3382
-		);
3379
+        $this->totals['subtotal'] = array(
3380
+            'initial'   => $subtotal,
3381
+            'recurring' => $recurring,
3382
+        );
3383 3383
 
3384 3384
         return $this->is_renewal() ? $recurring : $subtotal;
3385 3385
     }
3386 3386
 
3387 3387
     /**
3388
-	 * Recalculates the invoice discount total.
3389
-	 *
3390
-	 * @since 1.0.19
3391
-	 * @return float The recalculated discount
3392
-	 */
3393
-	public function recalculate_total_discount() {
3388
+     * Recalculates the invoice discount total.
3389
+     *
3390
+     * @since 1.0.19
3391
+     * @return float The recalculated discount
3392
+     */
3393
+    public function recalculate_total_discount() {
3394 3394
         $discounts = $this->get_discounts();
3395
-		$discount  = 0;
3396
-		$recurring = 0;
3395
+        $discount  = 0;
3396
+        $recurring = 0;
3397 3397
 
3398 3398
         foreach ( $discounts as $data ) {
3399 3399
 
3400
-			if ( $data['recurring'] ) {
3401
-				$recurring += $data['amount'];
3402
-			} else {
3403
-				$discount += $data['amount'];
3404
-			}
3400
+            if ( $data['recurring'] ) {
3401
+                $recurring += $data['amount'];
3402
+            } else {
3403
+                $discount += $data['amount'];
3404
+            }
3405 3405
 
3406
-		}
3406
+        }
3407 3407
 
3408
-		if ( $this->is_renewal() ) {
3409
-			$this->set_total_discount( $recurring );
3410
-		} else {
3411
-			$this->set_total_discount( $discount );
3412
-		}
3408
+        if ( $this->is_renewal() ) {
3409
+            $this->set_total_discount( $recurring );
3410
+        } else {
3411
+            $this->set_total_discount( $discount );
3412
+        }
3413 3413
 
3414
-		$this->totals['discount'] = array(
3415
-			'initial'   => $discount,
3416
-			'recurring' => $recurring,
3417
-		);
3414
+        $this->totals['discount'] = array(
3415
+            'initial'   => $discount,
3416
+            'recurring' => $recurring,
3417
+        );
3418 3418
 
3419
-		return $this->is_renewal() ? $recurring : $discount;
3419
+        return $this->is_renewal() ? $recurring : $discount;
3420 3420
 
3421 3421
     }
3422 3422
 
3423 3423
     /**
3424
-	 * Recalculates the invoice tax total.
3425
-	 *
3426
-	 * @since 1.0.19
3427
-	 * @return float The recalculated tax
3428
-	 */
3429
-	public function recalculate_total_tax() {
3424
+     * Recalculates the invoice tax total.
3425
+     *
3426
+     * @since 1.0.19
3427
+     * @return float The recalculated tax
3428
+     */
3429
+    public function recalculate_total_tax() {
3430 3430
         $taxes     = $this->get_taxes();
3431
-		$tax       = 0;
3432
-		$recurring = 0;
3431
+        $tax       = 0;
3432
+        $recurring = 0;
3433 3433
 
3434 3434
         foreach ( $taxes as $data ) {
3435 3435
 
3436
-			if ( $data['recurring'] ) {
3437
-				$recurring += $data['amount'];
3438
-			} else {
3439
-				$tax += $data['amount'];
3440
-			}
3436
+            if ( $data['recurring'] ) {
3437
+                $recurring += $data['amount'];
3438
+            } else {
3439
+                $tax += $data['amount'];
3440
+            }
3441 3441
 
3442
-		}
3442
+        }
3443 3443
 
3444
-		if ( $this->is_renewal() ) {
3445
-			$this->set_total_tax( $recurring );
3446
-		} else {
3447
-			$this->set_total_tax( $tax );
3448
-		}
3444
+        if ( $this->is_renewal() ) {
3445
+            $this->set_total_tax( $recurring );
3446
+        } else {
3447
+            $this->set_total_tax( $tax );
3448
+        }
3449 3449
 
3450
-		$this->totals['tax'] = array(
3451
-			'initial'   => $tax,
3452
-			'recurring' => $recurring,
3453
-		);
3450
+        $this->totals['tax'] = array(
3451
+            'initial'   => $tax,
3452
+            'recurring' => $recurring,
3453
+        );
3454 3454
 
3455
-		return $this->is_renewal() ? $recurring : $tax;
3455
+        return $this->is_renewal() ? $recurring : $tax;
3456 3456
 
3457 3457
     }
3458 3458
 
3459 3459
     /**
3460
-	 * Recalculates the invoice fees total.
3461
-	 *
3462
-	 * @since 1.0.19
3463
-	 * @return float The recalculated fee
3464
-	 */
3465
-	public function recalculate_total_fees() {
3466
-		$fees      = $this->get_fees();
3467
-		$fee       = 0;
3468
-		$recurring = 0;
3460
+     * Recalculates the invoice fees total.
3461
+     *
3462
+     * @since 1.0.19
3463
+     * @return float The recalculated fee
3464
+     */
3465
+    public function recalculate_total_fees() {
3466
+        $fees      = $this->get_fees();
3467
+        $fee       = 0;
3468
+        $recurring = 0;
3469 3469
 
3470 3470
         foreach ( $fees as $data ) {
3471 3471
 
3472
-			if ( $data['recurring'] ) {
3473
-				$recurring += $data['amount'];
3474
-			} else {
3475
-				$fee += $data['amount'];
3476
-			}
3472
+            if ( $data['recurring'] ) {
3473
+                $recurring += $data['amount'];
3474
+            } else {
3475
+                $fee += $data['amount'];
3476
+            }
3477 3477
 
3478
-		}
3478
+        }
3479 3479
 
3480 3480
         if ( $this->is_renewal() ) {
3481
-			$this->set_total_fees( $recurring );
3482
-		} else {
3483
-			$this->set_total_fees( $fee );
3484
-		}
3481
+            $this->set_total_fees( $recurring );
3482
+        } else {
3483
+            $this->set_total_fees( $fee );
3484
+        }
3485 3485
 
3486
-		$this->totals['fee'] = array(
3487
-			'initial'   => $fee,
3488
-			'recurring' => $recurring,
3489
-		);
3486
+        $this->totals['fee'] = array(
3487
+            'initial'   => $fee,
3488
+            'recurring' => $recurring,
3489
+        );
3490 3490
 
3491 3491
         $this->set_total_fees( $fee );
3492 3492
         return $this->is_renewal() ? $recurring : $fee;
3493 3493
     }
3494 3494
 
3495 3495
     /**
3496
-	 * Recalculates the invoice total.
3497
-	 *
3498
-	 * @since 1.0.19
3496
+     * Recalculates the invoice total.
3497
+     *
3498
+     * @since 1.0.19
3499 3499
      * @return float The invoice total
3500
-	 */
3501
-	public function recalculate_total() {
3500
+     */
3501
+    public function recalculate_total() {
3502 3502
         $this->recalculate_subtotal();
3503 3503
         $this->recalculate_total_fees();
3504 3504
         $this->recalculate_total_discount();
3505 3505
         $this->recalculate_total_tax();
3506
-		return $this->get_total();
3507
-	}
3506
+        return $this->get_total();
3507
+    }
3508 3508
 
3509
-	/**
3510
-	 * @deprecated
3511
-	 */
3509
+    /**
3510
+     * @deprecated
3511
+     */
3512 3512
     public function recalculate_totals( $temp = false ) {
3513 3513
         $this->update_items( $temp );
3514 3514
         $this->save( true );
@@ -3526,7 +3526,7 @@  discard block
 block discarded – undo
3526 3526
      * Adds a note to an invoice.
3527 3527
      *
3528 3528
      * @param string $note The note being added.
3529
-	 * @return int|false The new note's ID on success, false on failure.
3529
+     * @return int|false The new note's ID on success, false on failure.
3530 3530
      *
3531 3531
      */
3532 3532
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3536,23 +3536,23 @@  discard block
 block discarded – undo
3536 3536
             return false;
3537 3537
         }
3538 3538
 
3539
-		// If this is an admin comment or it has been added by the user.
3540
-		if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3541
-			$user         = get_user_by( 'id', get_current_user_id() );
3539
+        // If this is an admin comment or it has been added by the user.
3540
+        if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3541
+            $user         = get_user_by( 'id', get_current_user_id() );
3542 3542
             $author       = $user->display_name;
3543 3543
             $author_email = $user->user_email;
3544
-		} 
3544
+        } 
3545 3545
 
3546
-		if ( $system ) {
3547
-			$author       = 'System';
3546
+        if ( $system ) {
3547
+            $author       = 'System';
3548 3548
             $author_email = '[email protected]';
3549
-		}
3549
+        }
3550 3550
 
3551
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3551
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3552 3552
 
3553
-	}
3553
+    }
3554 3554
 
3555
-	/**
3555
+    /**
3556 3556
      * Generates a unique key for the invoice.
3557 3557
      */
3558 3558
     public function generate_key( $string = '' ) {
@@ -3572,106 +3572,106 @@  discard block
 block discarded – undo
3572 3572
             $number = wpinv_get_next_invoice_number( $this->post_type );
3573 3573
         }
3574 3574
 
3575
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3575
+        $number = wpinv_format_invoice_number( $number, $this->post_type );
3576 3576
 
3577
-		return $number;
3578
-	}
3577
+        return $number;
3578
+    }
3579 3579
 
3580
-	/**
3581
-	 * Handle the status transition.
3582
-	 */
3583
-	protected function status_transition() {
3584
-		$status_transition = $this->status_transition;
3580
+    /**
3581
+     * Handle the status transition.
3582
+     */
3583
+    protected function status_transition() {
3584
+        $status_transition = $this->status_transition;
3585 3585
 
3586
-		// Reset status transition variable.
3587
-		$this->status_transition = false;
3586
+        // Reset status transition variable.
3587
+        $this->status_transition = false;
3588 3588
 
3589
-		if ( $status_transition ) {
3590
-			try {
3589
+        if ( $status_transition ) {
3590
+            try {
3591 3591
 
3592
-				// Fire a hook for the status change.
3593
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3592
+                // Fire a hook for the status change.
3593
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3594 3594
 
3595
-				// @deprecated this is deprecated and will be removed in the future.
3596
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3595
+                // @deprecated this is deprecated and will be removed in the future.
3596
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3597 3597
 
3598
-				if ( ! empty( $status_transition['from'] ) ) {
3598
+                if ( ! empty( $status_transition['from'] ) ) {
3599 3599
 
3600
-					/* translators: 1: old invoice status 2: new invoice status */
3601
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3600
+                    /* translators: 1: old invoice status 2: new invoice status */
3601
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3602 3602
 
3603
-					// Fire another hook.
3604
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3605
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3603
+                    // Fire another hook.
3604
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3605
+                    do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3606 3606
 
3607
-					// @deprecated this is deprecated and will be removed in the future.
3608
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3607
+                    // @deprecated this is deprecated and will be removed in the future.
3608
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3609 3609
 
3610
-					// Note the transition occurred.
3611
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3610
+                    // Note the transition occurred.
3611
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3612 3612
 
3613
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3614
-					if (
3615
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3616
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3617
-					) {
3618
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3619
-					}
3620
-				} else {
3621
-					/* translators: %s: new invoice status */
3622
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3613
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3614
+                    if (
3615
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3616
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3617
+                    ) {
3618
+                        do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3619
+                    }
3620
+                } else {
3621
+                    /* translators: %s: new invoice status */
3622
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3623 3623
 
3624
-					// Note the transition occurred.
3625
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3624
+                    // Note the transition occurred.
3625
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3626 3626
 
3627
-				}
3628
-			} catch ( Exception $e ) {
3629
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3630
-			}
3631
-		}
3632
-	}
3627
+                }
3628
+            } catch ( Exception $e ) {
3629
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3630
+            }
3631
+        }
3632
+    }
3633 3633
 
3634
-	/**
3635
-	 * Updates an invoice status.
3636
-	 */
3637
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3634
+    /**
3635
+     * Updates an invoice status.
3636
+     */
3637
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3638 3638
 
3639
-		// Fires before updating a status.
3640
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3639
+        // Fires before updating a status.
3640
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3641 3641
 
3642
-		// Update the status.
3643
-		$this->set_status( $new_status, $note, $manual );
3642
+        // Update the status.
3643
+        $this->set_status( $new_status, $note, $manual );
3644 3644
 
3645
-		// Save the order.
3646
-		return $this->save();
3645
+        // Save the order.
3646
+        return $this->save();
3647 3647
 
3648
-	}
3648
+    }
3649 3649
 
3650
-	/**
3651
-	 * @deprecated
3652
-	 */
3653
-	public function refresh_item_ids() {
3650
+    /**
3651
+     * @deprecated
3652
+     */
3653
+    public function refresh_item_ids() {
3654 3654
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3655 3655
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3656
-	}
3656
+    }
3657 3657
 
3658
-	/**
3659
-	 * @deprecated
3660
-	 */
3661
-	public function update_items( $temp = false ) {
3658
+    /**
3659
+     * @deprecated
3660
+     */
3661
+    public function update_items( $temp = false ) {
3662 3662
 
3663
-		$this->set_items( $this->get_items() );
3663
+        $this->set_items( $this->get_items() );
3664 3664
 
3665
-		if ( ! $temp ) {
3666
-			$this->save();
3667
-		}
3665
+        if ( ! $temp ) {
3666
+            $this->save();
3667
+        }
3668 3668
 
3669 3669
         return $this;
3670
-	}
3670
+    }
3671 3671
 
3672
-	/**
3673
-	 * @deprecated
3674
-	 */
3672
+    /**
3673
+     * @deprecated
3674
+     */
3675 3675
     public function validate_discount() {
3676 3676
 
3677 3677
         $discount_code = $this->get_discount_code();
@@ -3687,86 +3687,86 @@  discard block
 block discarded – undo
3687 3687
 
3688 3688
     }
3689 3689
 
3690
-	/**
3691
-	 * Refunds an invoice.
3692
-	 */
3690
+    /**
3691
+     * Refunds an invoice.
3692
+     */
3693 3693
     public function refund() {
3694
-		$this->set_status( 'wpi-refunded' );
3694
+        $this->set_status( 'wpi-refunded' );
3695 3695
         $this->save();
3696
-	}
3696
+    }
3697 3697
 
3698
-	/**
3699
-	 * Marks an invoice as paid.
3700
-	 * 
3701
-	 * @param string $transaction_id
3702
-	 */
3698
+    /**
3699
+     * Marks an invoice as paid.
3700
+     * 
3701
+     * @param string $transaction_id
3702
+     */
3703 3703
     public function mark_paid( $transaction_id = null, $note = '' ) {
3704 3704
 
3705
-		// Set the transaction id.
3706
-		if ( empty( $transaction_id ) ) {
3707
-			$transaction_id = $this->generate_key('trans_');
3708
-		}
3705
+        // Set the transaction id.
3706
+        if ( empty( $transaction_id ) ) {
3707
+            $transaction_id = $this->generate_key('trans_');
3708
+        }
3709 3709
 
3710
-		if ( ! $this->get_transaction_id() ) {
3711
-			$this->set_transaction_id( $transaction_id );
3712
-		}
3710
+        if ( ! $this->get_transaction_id() ) {
3711
+            $this->set_transaction_id( $transaction_id );
3712
+        }
3713 3713
 
3714
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3715
-			return $this->save();
3716
-		}
3714
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3715
+            return $this->save();
3716
+        }
3717 3717
 
3718
-		// Set the completed date.
3719
-		$this->set_date_completed( current_time( 'mysql' ) );
3718
+        // Set the completed date.
3719
+        $this->set_date_completed( current_time( 'mysql' ) );
3720 3720
 
3721
-		// Set the new status.
3722
-		if ( $this->is_renewal() ) {
3721
+        // Set the new status.
3722
+        if ( $this->is_renewal() ) {
3723 3723
 
3724
-			$_note = sprintf(
3725
-				__( 'Renewed via %s', 'invoicing' ),
3726
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3727
-			);
3724
+            $_note = sprintf(
3725
+                __( 'Renewed via %s', 'invoicing' ),
3726
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3727
+            );
3728 3728
 
3729
-			if ( 'none' == $this->get_gateway() ) {
3730
-				$_note = $note;
3731
-			}
3729
+            if ( 'none' == $this->get_gateway() ) {
3730
+                $_note = $note;
3731
+            }
3732 3732
 
3733
-			$this->set_status( 'wpi-renewal', $_note );
3733
+            $this->set_status( 'wpi-renewal', $_note );
3734 3734
 
3735
-		} else {
3735
+        } else {
3736 3736
 
3737
-			$_note = sprintf(
3738
-				__( 'Paid via %s', 'invoicing' ),
3739
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3740
-			);
3737
+            $_note = sprintf(
3738
+                __( 'Paid via %s', 'invoicing' ),
3739
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3740
+            );
3741 3741
 
3742
-			if ( 'none' == $this->get_gateway() ) {
3743
-				$_note = $note;
3744
-			}
3742
+            if ( 'none' == $this->get_gateway() ) {
3743
+                $_note = $note;
3744
+            }
3745 3745
 
3746
-			$this->set_status( 'publish',$_note );
3746
+            $this->set_status( 'publish',$_note );
3747 3747
 
3748
-		}
3748
+        }
3749 3749
 
3750
-		// Set checkout mode.
3751
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3752
-		$this->set_mode( $mode );
3750
+        // Set checkout mode.
3751
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3752
+        $this->set_mode( $mode );
3753 3753
 
3754
-		// Save the invoice.
3754
+        // Save the invoice.
3755 3755
         $this->save();
3756
-	}
3757
-
3758
-
3759
-	/**
3760
-	 * Save data to the database.
3761
-	 *
3762
-	 * @since 1.0.19
3763
-	 * @return int invoice ID
3764
-	 */
3765
-	public function save() {
3766
-		$this->maybe_set_date_paid();
3767
-		parent::save();
3768
-		$this->status_transition();
3769
-		return $this->get_id();
3770
-	}
3756
+    }
3757
+
3758
+
3759
+    /**
3760
+     * Save data to the database.
3761
+     *
3762
+     * @since 1.0.19
3763
+     * @return int invoice ID
3764
+     */
3765
+    public function save() {
3766
+        $this->maybe_set_date_paid();
3767
+        parent::save();
3768
+        $this->status_transition();
3769
+        return $this->get_id();
3770
+    }
3771 3771
 
3772 3772
 }
Please login to merge, or discard this patch.
Spacing   +753 added lines, -753 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -133,40 +133,40 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135 135
 	 */
136
-    public function __construct( $invoice = false ) {
136
+    public function __construct($invoice = false) {
137 137
 
138
-        parent::__construct( $invoice );
138
+        parent::__construct($invoice);
139 139
 
140
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
-			$this->set_id( $invoice );
142
-		} elseif ( $invoice instanceof self ) {
143
-			$this->set_id( $invoice->get_id() );
144
-		} elseif ( ! empty( $invoice->ID ) ) {
145
-			$this->set_id( $invoice->ID );
146
-		} elseif ( is_array( $invoice ) ) {
147
-			$this->set_props( $invoice );
140
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) {
141
+			$this->set_id($invoice);
142
+		} elseif ($invoice instanceof self) {
143
+			$this->set_id($invoice->get_id());
144
+		} elseif (!empty($invoice->ID)) {
145
+			$this->set_id($invoice->ID);
146
+		} elseif (is_array($invoice)) {
147
+			$this->set_props($invoice);
148 148
 
149
-			if ( isset( $invoice['ID'] ) ) {
150
-				$this->set_id( $invoice['ID'] );
149
+			if (isset($invoice['ID'])) {
150
+				$this->set_id($invoice['ID']);
151 151
 			}
152 152
 
153
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
-			$this->set_id( $invoice_id );
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		}else {
160
-			$this->set_object_read( true );
153
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
154
+			$this->set_id($invoice_id);
155
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
156
+			$this->set_id($invoice_id);
157
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
158
+			$this->set_id($invoice_id);
159
+		} else {
160
+			$this->set_object_read(true);
161 161
 		}
162 162
 
163 163
         // Load the datastore.
164
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
164
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
165 165
 
166
-		if ( $this->get_id() > 0 ) {
167
-            $this->post = get_post( $this->get_id() );
166
+		if ($this->get_id() > 0) {
167
+            $this->post = get_post($this->get_id());
168 168
             $this->ID   = $this->get_id();
169
-			$this->data_store->read( $this );
169
+			$this->data_store->read($this);
170 170
         }
171 171
 
172 172
     }
@@ -181,42 +181,42 @@  discard block
 block discarded – undo
181 181
 	 * @since 1.0.15
182 182
 	 * @return int
183 183
 	 */
184
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
184
+	public static function get_invoice_id_by_field($value, $field = 'key') {
185 185
         global $wpdb;
186 186
 
187 187
 		// Trim the value.
188
-		$value = trim( $value );
188
+		$value = trim($value);
189 189
 
190
-		if ( empty( $value ) ) {
190
+		if (empty($value)) {
191 191
 			return 0;
192 192
 		}
193 193
 
194 194
         // Valid fields.
195
-        $fields = array( 'key', 'number', 'transaction_id' );
195
+        $fields = array('key', 'number', 'transaction_id');
196 196
 
197 197
 		// Ensure a field has been passed.
198
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
198
+		if (empty($field) || !in_array($field, $fields)) {
199 199
 			return 0;
200 200
 		}
201 201
 
202 202
 		// Maybe retrieve from the cache.
203
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
-		if ( ! empty( $invoice_id ) ) {
203
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
204
+		if (!empty($invoice_id)) {
205 205
 			return $invoice_id;
206 206
 		}
207 207
 
208 208
         // Fetch from the db.
209 209
         $table       = $wpdb->prefix . 'getpaid_invoices';
210 210
         $invoice_id  = $wpdb->get_var(
211
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
211
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
212 212
         );
213 213
 
214
-		if ( empty( $invoice_id ) ) {
214
+		if (empty($invoice_id)) {
215 215
 			return 0;
216 216
 		}
217 217
 
218 218
 		// Update the cache with our data
219
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
219
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
220 220
 
221 221
 		return $invoice_id;
222 222
     }
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
     /**
225 225
      * Checks if an invoice key is set.
226 226
      */
227
-    public function _isset( $key ) {
228
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
227
+    public function _isset($key) {
228
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
229 229
     }
230 230
 
231 231
     /*
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	 * @param  string $context View or edit context.
251 251
 	 * @return int
252 252
 	 */
253
-	public function get_parent_id( $context = 'view' ) {
254
-		return (int) $this->get_prop( 'parent_id', $context );
253
+	public function get_parent_id($context = 'view') {
254
+		return (int) $this->get_prop('parent_id', $context);
255 255
     }
256 256
 
257 257
     /**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @return WPInv_Invoice
262 262
 	 */
263 263
     public function get_parent_payment() {
264
-        return new WPInv_Invoice( $this->get_parent_id() );
264
+        return new WPInv_Invoice($this->get_parent_id());
265 265
     }
266 266
 
267 267
     /**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return string
283 283
 	 */
284
-	public function get_status( $context = 'view' ) {
285
-		return $this->get_prop( 'status', $context );
284
+	public function get_status($context = 'view') {
285
+		return $this->get_prop('status', $context);
286 286
 	}
287 287
 	
288 288
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	public function get_all_statuses() {
295 295
 
296
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
296
+		$statuses = wpinv_get_invoice_statuses(true, true, $this);
297 297
 
298 298
 		// For backwards compatibility.
299
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
299
+		if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
300 300
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
301 301
 		}
302 302
 
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
     public function get_status_nicename() {
313 313
 		$statuses = $this->get_all_statuses();
314 314
 
315
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
316 316
 
317
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
318 318
     }
319 319
 
320 320
     /**
@@ -324,27 +324,27 @@  discard block
 block discarded – undo
324 324
 	 * @param  string $context View or edit context.
325 325
 	 * @return string
326 326
 	 */
327
-	public function get_version( $context = 'view' ) {
328
-		return $this->get_prop( 'version', $context );
327
+	public function get_version($context = 'view') {
328
+		return $this->get_prop('version', $context);
329 329
 	}
330 330
 
331 331
 	/**
332 332
 	 * @deprecated
333 333
 	 */
334
-	public function get_invoice_date( $formatted = true ) {
334
+	public function get_invoice_date($formatted = true) {
335 335
         $date_completed = $this->get_date_completed();
336 336
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
337 337
 
338
-        if ( $invoice_date == '' ) {
338
+        if ($invoice_date == '') {
339 339
             $date_created   = $this->get_date_created();
340 340
             $invoice_date   = $date_created != '0000-00-00 00:00:00' ? $date_created : '';
341 341
         }
342 342
 
343
-        if ( $formatted && $invoice_date ) {
344
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
343
+        if ($formatted && $invoice_date) {
344
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
345 345
         }
346 346
 
347
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this );
347
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_date_created( $context = 'view' ) {
358
-		return $this->get_prop( 'date_created', $context );
357
+	public function get_date_created($context = 'view') {
358
+		return $this->get_prop('date_created', $context);
359 359
 	}
360 360
 	
361 361
 	/**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_created_date( $context = 'view' ) {
369
-		return $this->get_date_created( $context );
368
+	public function get_created_date($context = 'view') {
369
+		return $this->get_date_created($context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_date_created_gmt( $context = 'view' ) {
380
-        $date = $this->get_date_created( $context );
379
+	public function get_date_created_gmt($context = 'view') {
380
+        $date = $this->get_date_created($context);
381 381
 
382
-        if ( $date ) {
383
-            $date = get_gmt_from_date( $date );
382
+        if ($date) {
383
+            $date = get_gmt_from_date($date);
384 384
         }
385 385
 		return $date;
386 386
     }
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 	 * @param  string $context View or edit context.
393 393
 	 * @return string
394 394
 	 */
395
-	public function get_date_modified( $context = 'view' ) {
396
-		return $this->get_prop( 'date_modified', $context );
395
+	public function get_date_modified($context = 'view') {
396
+		return $this->get_prop('date_modified', $context);
397 397
 	}
398 398
 
399 399
 	/**
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	 * @param  string $context View or edit context.
404 404
 	 * @return string
405 405
 	 */
406
-	public function get_modified_date( $context = 'view' ) {
407
-		return $this->get_date_modified( $context );
406
+	public function get_modified_date($context = 'view') {
407
+		return $this->get_date_modified($context);
408 408
     }
409 409
 
410 410
     /**
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 	 * @param  string $context View or edit context.
415 415
 	 * @return string
416 416
 	 */
417
-	public function get_date_modified_gmt( $context = 'view' ) {
418
-        $date = $this->get_date_modified( $context );
417
+	public function get_date_modified_gmt($context = 'view') {
418
+        $date = $this->get_date_modified($context);
419 419
 
420
-        if ( $date ) {
421
-            $date = get_gmt_from_date( $date );
420
+        if ($date) {
421
+            $date = get_gmt_from_date($date);
422 422
         }
423 423
 		return $date;
424 424
     }
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 	 * @param  string $context View or edit context.
431 431
 	 * @return string
432 432
 	 */
433
-	public function get_due_date( $context = 'view' ) {
434
-		return $this->get_prop( 'due_date', $context );
433
+	public function get_due_date($context = 'view') {
434
+		return $this->get_prop('due_date', $context);
435 435
     }
436 436
 
437 437
     /**
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param  string $context View or edit context.
442 442
 	 * @return string
443 443
 	 */
444
-	public function get_date_due( $context = 'view' ) {
445
-		return $this->get_due_date( $context );
444
+	public function get_date_due($context = 'view') {
445
+		return $this->get_due_date($context);
446 446
     }
447 447
 
448 448
     /**
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
 	 * @param  string $context View or edit context.
453 453
 	 * @return string
454 454
 	 */
455
-	public function get_due_date_gmt( $context = 'view' ) {
456
-        $date = $this->get_due_date( $context );
455
+	public function get_due_date_gmt($context = 'view') {
456
+        $date = $this->get_due_date($context);
457 457
 
458
-        if ( $date ) {
459
-            $date = get_gmt_from_date( $date );
458
+        if ($date) {
459
+            $date = get_gmt_from_date($date);
460 460
         }
461 461
 		return $date;
462 462
     }
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 	 * @param  string $context View or edit context.
469 469
 	 * @return string
470 470
 	 */
471
-	public function get_gmt_date_due( $context = 'view' ) {
472
-		return $this->get_due_date_gmt( $context );
471
+	public function get_gmt_date_due($context = 'view') {
472
+		return $this->get_due_date_gmt($context);
473 473
     }
474 474
 
475 475
     /**
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param  string $context View or edit context.
480 480
 	 * @return string
481 481
 	 */
482
-	public function get_completed_date( $context = 'view' ) {
483
-		return $this->get_prop( 'completed_date', $context );
482
+	public function get_completed_date($context = 'view') {
483
+		return $this->get_prop('completed_date', $context);
484 484
     }
485 485
 
486 486
     /**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_date_completed( $context = 'view' ) {
494
-		return $this->get_completed_date( $context );
493
+	public function get_date_completed($context = 'view') {
494
+		return $this->get_completed_date($context);
495 495
     }
496 496
 
497 497
     /**
@@ -501,11 +501,11 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_completed_date_gmt( $context = 'view' ) {
505
-        $date = $this->get_completed_date( $context );
504
+	public function get_completed_date_gmt($context = 'view') {
505
+        $date = $this->get_completed_date($context);
506 506
 
507
-        if ( $date ) {
508
-            $date = get_gmt_from_date( $date );
507
+        if ($date) {
508
+            $date = get_gmt_from_date($date);
509 509
         }
510 510
 		return $date;
511 511
     }
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 * @param  string $context View or edit context.
518 518
 	 * @return string
519 519
 	 */
520
-	public function get_gmt_completed_date( $context = 'view' ) {
521
-		return $this->get_completed_date_gmt( $context );
520
+	public function get_gmt_completed_date($context = 'view') {
521
+		return $this->get_completed_date_gmt($context);
522 522
     }
523 523
 
524 524
     /**
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
 	 * @param  string $context View or edit context.
529 529
 	 * @return string
530 530
 	 */
531
-	public function get_number( $context = 'view' ) {
532
-        $number = $this->get_prop( 'number', $context );
531
+	public function get_number($context = 'view') {
532
+        $number = $this->get_prop('number', $context);
533 533
 
534
-        if ( empty( $number ) ) {
534
+        if (empty($number)) {
535 535
             $number = $this->generate_number();
536
-            $this->set_number( $number );
536
+            $this->set_number($number);
537 537
         }
538 538
 
539 539
 		return $number;
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
 	 * @param  string $context View or edit context.
547 547
 	 * @return string
548 548
 	 */
549
-	public function get_key( $context = 'view' ) {
550
-        $key = $this->get_prop( 'key', $context );
549
+	public function get_key($context = 'view') {
550
+        $key = $this->get_prop('key', $context);
551 551
 
552
-        if ( empty( $key ) ) {
553
-            $key = $this->generate_key( $this->get_type() . '_' );
554
-            $this->set_key( $key );
552
+        if (empty($key)) {
553
+            $key = $this->generate_key($this->get_type() . '_');
554
+            $this->set_key($key);
555 555
         }
556 556
 
557 557
 		return $key;
@@ -564,23 +564,23 @@  discard block
 block discarded – undo
564 564
 	 * @param  string $context View or edit context.
565 565
 	 * @return string
566 566
 	 */
567
-	public function get_type( $context = 'view' ) {
568
-        return $this->get_prop( 'type', $context );
567
+	public function get_type($context = 'view') {
568
+        return $this->get_prop('type', $context);
569 569
 	}
570 570
 
571 571
 	/**
572 572
 	 * @deprecated
573 573
 	 */
574
-	public function get_invoice_quote_type( $post_id ) {
575
-        if ( empty( $post_id ) ) {
574
+	public function get_invoice_quote_type($post_id) {
575
+        if (empty($post_id)) {
576 576
             return '';
577 577
         }
578 578
 
579
-        $type = get_post_type( $post_id );
579
+        $type = get_post_type($post_id);
580 580
 
581
-        if ( 'wpi_invoice' === $type ) {
581
+        if ('wpi_invoice' === $type) {
582 582
             $post_type = __('Invoice', 'invoicing');
583
-        } else{
583
+        } else {
584 584
             $post_type = __('Quote', 'invoicing');
585 585
         }
586 586
 
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
 	 * @param  string $context View or edit context.
595 595
 	 * @return string
596 596
 	 */
597
-	public function get_post_type( $context = 'view' ) {
598
-        return $this->get_prop( 'post_type', $context );
597
+	public function get_post_type($context = 'view') {
598
+        return $this->get_prop('post_type', $context);
599 599
     }
600 600
 
601 601
     /**
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
 	 * @param  string $context View or edit context.
606 606
 	 * @return string
607 607
 	 */
608
-	public function get_mode( $context = 'view' ) {
609
-        return $this->get_prop( 'mode', $context );
608
+	public function get_mode($context = 'view') {
609
+        return $this->get_prop('mode', $context);
610 610
     }
611 611
 
612 612
     /**
@@ -616,12 +616,12 @@  discard block
 block discarded – undo
616 616
 	 * @param  string $context View or edit context.
617 617
 	 * @return string
618 618
 	 */
619
-	public function get_path( $context = 'view' ) {
620
-        $path = $this->get_prop( 'path', $context );
619
+	public function get_path($context = 'view') {
620
+        $path = $this->get_prop('path', $context);
621 621
 
622
-        if ( empty( $path ) ) {
623
-            $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type );
624
-            $path   = sanitize_title( $prefix . $this->get_id() );
622
+        if (empty($path)) {
623
+            $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type);
624
+            $path   = sanitize_title($prefix . $this->get_id());
625 625
         }
626 626
 
627 627
 		return $path;
@@ -634,10 +634,10 @@  discard block
 block discarded – undo
634 634
 	 * @param  string $context View or edit context.
635 635
 	 * @return string
636 636
 	 */
637
-	public function get_name( $context = 'view' ) {
638
-        $name = $this->get_prop( 'title', $context );
637
+	public function get_name($context = 'view') {
638
+        $name = $this->get_prop('title', $context);
639 639
 
640
-		return empty( $name ) ? $this->get_number( $context ) : $name;
640
+		return empty($name) ? $this->get_number($context) : $name;
641 641
     }
642 642
 
643 643
     /**
@@ -647,8 +647,8 @@  discard block
 block discarded – undo
647 647
 	 * @param  string $context View or edit context.
648 648
 	 * @return string
649 649
 	 */
650
-	public function get_title( $context = 'view' ) {
651
-		return $this->get_name( $context );
650
+	public function get_title($context = 'view') {
651
+		return $this->get_name($context);
652 652
     }
653 653
 
654 654
     /**
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
 	 * @param  string $context View or edit context.
659 659
 	 * @return string
660 660
 	 */
661
-	public function get_description( $context = 'view' ) {
662
-		return $this->get_prop( 'description', $context );
661
+	public function get_description($context = 'view') {
662
+		return $this->get_prop('description', $context);
663 663
     }
664 664
 
665 665
     /**
@@ -669,8 +669,8 @@  discard block
 block discarded – undo
669 669
 	 * @param  string $context View or edit context.
670 670
 	 * @return string
671 671
 	 */
672
-	public function get_excerpt( $context = 'view' ) {
673
-		return $this->get_description( $context );
672
+	public function get_excerpt($context = 'view') {
673
+		return $this->get_description($context);
674 674
     }
675 675
 
676 676
     /**
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
 	 * @param  string $context View or edit context.
681 681
 	 * @return string
682 682
 	 */
683
-	public function get_summary( $context = 'view' ) {
684
-		return $this->get_description( $context );
683
+	public function get_summary($context = 'view') {
684
+		return $this->get_description($context);
685 685
     }
686 686
 
687 687
     /**
@@ -691,25 +691,25 @@  discard block
 block discarded – undo
691 691
      * @param  string $context View or edit context.
692 692
 	 * @return array
693 693
 	 */
694
-    public function get_user_info( $context = 'view' ) {
694
+    public function get_user_info($context = 'view') {
695 695
 
696 696
         $user_info = array(
697
-            'user_id'    => $this->get_user_id( $context ),
698
-            'email'      => $this->get_email( $context ),
699
-            'first_name' => $this->get_first_name( $context ),
700
-            'last_name'  => $this->get_last_name( $context ),
701
-            'address'    => $this->get_address( $context ),
702
-            'phone'      => $this->get_phone( $context ),
703
-            'city'       => $this->get_city( $context ),
704
-            'country'    => $this->get_country( $context ),
705
-            'state'      => $this->get_state( $context ),
706
-            'zip'        => $this->get_zip( $context ),
707
-            'company'    => $this->get_company( $context ),
708
-            'vat_number' => $this->get_vat_number( $context ),
709
-            'discount'   => $this->get_discount_code( $context ),
697
+            'user_id'    => $this->get_user_id($context),
698
+            'email'      => $this->get_email($context),
699
+            'first_name' => $this->get_first_name($context),
700
+            'last_name'  => $this->get_last_name($context),
701
+            'address'    => $this->get_address($context),
702
+            'phone'      => $this->get_phone($context),
703
+            'city'       => $this->get_city($context),
704
+            'country'    => $this->get_country($context),
705
+            'state'      => $this->get_state($context),
706
+            'zip'        => $this->get_zip($context),
707
+            'company'    => $this->get_company($context),
708
+            'vat_number' => $this->get_vat_number($context),
709
+            'discount'   => $this->get_discount_code($context),
710 710
 		);
711 711
 
712
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
712
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
713 713
 
714 714
     }
715 715
 
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 	 * @param  string $context View or edit context.
721 721
 	 * @return int
722 722
 	 */
723
-	public function get_author( $context = 'view' ) {
724
-		return (int) $this->get_prop( 'author', $context );
723
+	public function get_author($context = 'view') {
724
+		return (int) $this->get_prop('author', $context);
725 725
     }
726 726
 
727 727
     /**
@@ -731,8 +731,8 @@  discard block
 block discarded – undo
731 731
 	 * @param  string $context View or edit context.
732 732
 	 * @return int
733 733
 	 */
734
-	public function get_user_id( $context = 'view' ) {
735
-		return $this->get_author( $context );
734
+	public function get_user_id($context = 'view') {
735
+		return $this->get_author($context);
736 736
     }
737 737
 
738 738
      /**
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 	 * @param  string $context View or edit context.
743 743
 	 * @return int
744 744
 	 */
745
-	public function get_customer_id( $context = 'view' ) {
746
-		return $this->get_author( $context );
745
+	public function get_customer_id($context = 'view') {
746
+		return $this->get_author($context);
747 747
     }
748 748
 
749 749
     /**
@@ -753,8 +753,8 @@  discard block
 block discarded – undo
753 753
 	 * @param  string $context View or edit context.
754 754
 	 * @return string
755 755
 	 */
756
-	public function get_ip( $context = 'view' ) {
757
-		return $this->get_prop( 'user_ip', $context );
756
+	public function get_ip($context = 'view') {
757
+		return $this->get_prop('user_ip', $context);
758 758
     }
759 759
 
760 760
     /**
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 	 * @param  string $context View or edit context.
765 765
 	 * @return string
766 766
 	 */
767
-	public function get_user_ip( $context = 'view' ) {
768
-		return $this->get_ip( $context );
767
+	public function get_user_ip($context = 'view') {
768
+		return $this->get_ip($context);
769 769
     }
770 770
 
771 771
      /**
@@ -775,8 +775,8 @@  discard block
 block discarded – undo
775 775
 	 * @param  string $context View or edit context.
776 776
 	 * @return string
777 777
 	 */
778
-	public function get_customer_ip( $context = 'view' ) {
779
-		return $this->get_ip( $context );
778
+	public function get_customer_ip($context = 'view') {
779
+		return $this->get_ip($context);
780 780
     }
781 781
 
782 782
     /**
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
 	 * @param  string $context View or edit context.
787 787
 	 * @return string
788 788
 	 */
789
-	public function get_first_name( $context = 'view' ) {
790
-		return $this->get_prop( 'first_name', $context );
789
+	public function get_first_name($context = 'view') {
790
+		return $this->get_prop('first_name', $context);
791 791
     }
792 792
 
793 793
     /**
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
 	 * @param  string $context View or edit context.
798 798
 	 * @return int
799 799
 	 */
800
-	public function get_user_first_name( $context = 'view' ) {
801
-		return $this->get_first_name( $context );
800
+	public function get_user_first_name($context = 'view') {
801
+		return $this->get_first_name($context);
802 802
     }
803 803
 
804 804
      /**
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 	 * @param  string $context View or edit context.
809 809
 	 * @return int
810 810
 	 */
811
-	public function get_customer_first_name( $context = 'view' ) {
812
-		return $this->get_first_name( $context );
811
+	public function get_customer_first_name($context = 'view') {
812
+		return $this->get_first_name($context);
813 813
     }
814 814
 
815 815
     /**
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 	 * @param  string $context View or edit context.
820 820
 	 * @return string
821 821
 	 */
822
-	public function get_last_name( $context = 'view' ) {
823
-		return $this->get_prop( 'last_name', $context );
822
+	public function get_last_name($context = 'view') {
823
+		return $this->get_prop('last_name', $context);
824 824
     }
825 825
 
826 826
     /**
@@ -830,8 +830,8 @@  discard block
 block discarded – undo
830 830
 	 * @param  string $context View or edit context.
831 831
 	 * @return int
832 832
 	 */
833
-	public function get_user_last_name( $context = 'view' ) {
834
-		return $this->get_last_name( $context );
833
+	public function get_user_last_name($context = 'view') {
834
+		return $this->get_last_name($context);
835 835
     }
836 836
 
837 837
     /**
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 	 * @param  string $context View or edit context.
842 842
 	 * @return int
843 843
 	 */
844
-	public function get_customer_last_name( $context = 'view' ) {
845
-		return $this->get_last_name( $context );
844
+	public function get_customer_last_name($context = 'view') {
845
+		return $this->get_last_name($context);
846 846
     }
847 847
 
848 848
     /**
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 	 * @param  string $context View or edit context.
853 853
 	 * @return string
854 854
 	 */
855
-	public function get_full_name( $context = 'view' ) {
856
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
855
+	public function get_full_name($context = 'view') {
856
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
857 857
     }
858 858
 
859 859
     /**
@@ -863,8 +863,8 @@  discard block
 block discarded – undo
863 863
 	 * @param  string $context View or edit context.
864 864
 	 * @return int
865 865
 	 */
866
-	public function get_user_full_name( $context = 'view' ) {
867
-		return $this->get_full_name( $context );
866
+	public function get_user_full_name($context = 'view') {
867
+		return $this->get_full_name($context);
868 868
     }
869 869
 
870 870
     /**
@@ -874,8 +874,8 @@  discard block
 block discarded – undo
874 874
 	 * @param  string $context View or edit context.
875 875
 	 * @return int
876 876
 	 */
877
-	public function get_customer_full_name( $context = 'view' ) {
878
-		return $this->get_full_name( $context );
877
+	public function get_customer_full_name($context = 'view') {
878
+		return $this->get_full_name($context);
879 879
     }
880 880
 
881 881
     /**
@@ -885,8 +885,8 @@  discard block
 block discarded – undo
885 885
 	 * @param  string $context View or edit context.
886 886
 	 * @return string
887 887
 	 */
888
-	public function get_phone( $context = 'view' ) {
889
-		return $this->get_prop( 'phone', $context );
888
+	public function get_phone($context = 'view') {
889
+		return $this->get_prop('phone', $context);
890 890
     }
891 891
 
892 892
     /**
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
 	 * @param  string $context View or edit context.
897 897
 	 * @return int
898 898
 	 */
899
-	public function get_phone_number( $context = 'view' ) {
900
-		return $this->get_phone( $context );
899
+	public function get_phone_number($context = 'view') {
900
+		return $this->get_phone($context);
901 901
     }
902 902
 
903 903
     /**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 	 * @param  string $context View or edit context.
908 908
 	 * @return int
909 909
 	 */
910
-	public function get_user_phone( $context = 'view' ) {
911
-		return $this->get_phone( $context );
910
+	public function get_user_phone($context = 'view') {
911
+		return $this->get_phone($context);
912 912
     }
913 913
 
914 914
     /**
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 	 * @param  string $context View or edit context.
919 919
 	 * @return int
920 920
 	 */
921
-	public function get_customer_phone( $context = 'view' ) {
922
-		return $this->get_phone( $context );
921
+	public function get_customer_phone($context = 'view') {
922
+		return $this->get_phone($context);
923 923
     }
924 924
 
925 925
     /**
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
 	 * @param  string $context View or edit context.
930 930
 	 * @return string
931 931
 	 */
932
-	public function get_email( $context = 'view' ) {
933
-		return $this->get_prop( 'email', $context );
932
+	public function get_email($context = 'view') {
933
+		return $this->get_prop('email', $context);
934 934
     }
935 935
 
936 936
     /**
@@ -940,8 +940,8 @@  discard block
 block discarded – undo
940 940
 	 * @param  string $context View or edit context.
941 941
 	 * @return string
942 942
 	 */
943
-	public function get_email_address( $context = 'view' ) {
944
-		return $this->get_email( $context );
943
+	public function get_email_address($context = 'view') {
944
+		return $this->get_email($context);
945 945
     }
946 946
 
947 947
     /**
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 	 * @param  string $context View or edit context.
952 952
 	 * @return int
953 953
 	 */
954
-	public function get_user_email( $context = 'view' ) {
955
-		return $this->get_email( $context );
954
+	public function get_user_email($context = 'view') {
955
+		return $this->get_email($context);
956 956
     }
957 957
 
958 958
     /**
@@ -962,8 +962,8 @@  discard block
 block discarded – undo
962 962
 	 * @param  string $context View or edit context.
963 963
 	 * @return int
964 964
 	 */
965
-	public function get_customer_email( $context = 'view' ) {
966
-		return $this->get_email( $context );
965
+	public function get_customer_email($context = 'view') {
966
+		return $this->get_email($context);
967 967
     }
968 968
 
969 969
     /**
@@ -973,9 +973,9 @@  discard block
 block discarded – undo
973 973
 	 * @param  string $context View or edit context.
974 974
 	 * @return string
975 975
 	 */
976
-	public function get_country( $context = 'view' ) {
977
-		$country = $this->get_prop( 'country', $context );
978
-		return empty( $country ) ? wpinv_get_default_country() : $country;
976
+	public function get_country($context = 'view') {
977
+		$country = $this->get_prop('country', $context);
978
+		return empty($country) ? wpinv_get_default_country() : $country;
979 979
     }
980 980
 
981 981
     /**
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
 	 * @param  string $context View or edit context.
986 986
 	 * @return int
987 987
 	 */
988
-	public function get_user_country( $context = 'view' ) {
989
-		return $this->get_country( $context );
988
+	public function get_user_country($context = 'view') {
989
+		return $this->get_country($context);
990 990
     }
991 991
 
992 992
     /**
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
 	 * @param  string $context View or edit context.
997 997
 	 * @return int
998 998
 	 */
999
-	public function get_customer_country( $context = 'view' ) {
1000
-		return $this->get_country( $context );
999
+	public function get_customer_country($context = 'view') {
1000
+		return $this->get_country($context);
1001 1001
     }
1002 1002
 
1003 1003
     /**
@@ -1007,9 +1007,9 @@  discard block
 block discarded – undo
1007 1007
 	 * @param  string $context View or edit context.
1008 1008
 	 * @return string
1009 1009
 	 */
1010
-	public function get_state( $context = 'view' ) {
1011
-		$state = $this->get_prop( 'state', $context );
1012
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1010
+	public function get_state($context = 'view') {
1011
+		$state = $this->get_prop('state', $context);
1012
+		return empty($state) ? wpinv_get_default_state() : $state;
1013 1013
     }
1014 1014
 
1015 1015
     /**
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
 	 * @param  string $context View or edit context.
1020 1020
 	 * @return int
1021 1021
 	 */
1022
-	public function get_user_state( $context = 'view' ) {
1023
-		return $this->get_state( $context );
1022
+	public function get_user_state($context = 'view') {
1023
+		return $this->get_state($context);
1024 1024
     }
1025 1025
 
1026 1026
     /**
@@ -1030,8 +1030,8 @@  discard block
 block discarded – undo
1030 1030
 	 * @param  string $context View or edit context.
1031 1031
 	 * @return int
1032 1032
 	 */
1033
-	public function get_customer_state( $context = 'view' ) {
1034
-		return $this->get_state( $context );
1033
+	public function get_customer_state($context = 'view') {
1034
+		return $this->get_state($context);
1035 1035
     }
1036 1036
 
1037 1037
     /**
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
 	 * @param  string $context View or edit context.
1042 1042
 	 * @return string
1043 1043
 	 */
1044
-	public function get_city( $context = 'view' ) {
1045
-		return $this->get_prop( 'city', $context );
1044
+	public function get_city($context = 'view') {
1045
+		return $this->get_prop('city', $context);
1046 1046
     }
1047 1047
 
1048 1048
     /**
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
 	 * @param  string $context View or edit context.
1053 1053
 	 * @return string
1054 1054
 	 */
1055
-	public function get_user_city( $context = 'view' ) {
1056
-		return $this->get_city( $context );
1055
+	public function get_user_city($context = 'view') {
1056
+		return $this->get_city($context);
1057 1057
     }
1058 1058
 
1059 1059
     /**
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 	 * @param  string $context View or edit context.
1064 1064
 	 * @return string
1065 1065
 	 */
1066
-	public function get_customer_city( $context = 'view' ) {
1067
-		return $this->get_city( $context );
1066
+	public function get_customer_city($context = 'view') {
1067
+		return $this->get_city($context);
1068 1068
     }
1069 1069
 
1070 1070
     /**
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
 	 * @param  string $context View or edit context.
1075 1075
 	 * @return string
1076 1076
 	 */
1077
-	public function get_zip( $context = 'view' ) {
1078
-		return $this->get_prop( 'zip', $context );
1077
+	public function get_zip($context = 'view') {
1078
+		return $this->get_prop('zip', $context);
1079 1079
     }
1080 1080
 
1081 1081
     /**
@@ -1085,8 +1085,8 @@  discard block
 block discarded – undo
1085 1085
 	 * @param  string $context View or edit context.
1086 1086
 	 * @return string
1087 1087
 	 */
1088
-	public function get_user_zip( $context = 'view' ) {
1089
-		return $this->get_zip( $context );
1088
+	public function get_user_zip($context = 'view') {
1089
+		return $this->get_zip($context);
1090 1090
     }
1091 1091
 
1092 1092
     /**
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
 	 * @param  string $context View or edit context.
1097 1097
 	 * @return string
1098 1098
 	 */
1099
-	public function get_customer_zip( $context = 'view' ) {
1100
-		return $this->get_zip( $context );
1099
+	public function get_customer_zip($context = 'view') {
1100
+		return $this->get_zip($context);
1101 1101
     }
1102 1102
 
1103 1103
     /**
@@ -1107,8 +1107,8 @@  discard block
 block discarded – undo
1107 1107
 	 * @param  string $context View or edit context.
1108 1108
 	 * @return string
1109 1109
 	 */
1110
-	public function get_company( $context = 'view' ) {
1111
-		return $this->get_prop( 'company', $context );
1110
+	public function get_company($context = 'view') {
1111
+		return $this->get_prop('company', $context);
1112 1112
     }
1113 1113
 
1114 1114
     /**
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
 	 * @param  string $context View or edit context.
1119 1119
 	 * @return string
1120 1120
 	 */
1121
-	public function get_user_company( $context = 'view' ) {
1122
-		return $this->get_company( $context );
1121
+	public function get_user_company($context = 'view') {
1122
+		return $this->get_company($context);
1123 1123
     }
1124 1124
 
1125 1125
     /**
@@ -1129,8 +1129,8 @@  discard block
 block discarded – undo
1129 1129
 	 * @param  string $context View or edit context.
1130 1130
 	 * @return string
1131 1131
 	 */
1132
-	public function get_customer_company( $context = 'view' ) {
1133
-		return $this->get_company( $context );
1132
+	public function get_customer_company($context = 'view') {
1133
+		return $this->get_company($context);
1134 1134
     }
1135 1135
 
1136 1136
     /**
@@ -1140,8 +1140,8 @@  discard block
 block discarded – undo
1140 1140
 	 * @param  string $context View or edit context.
1141 1141
 	 * @return string
1142 1142
 	 */
1143
-	public function get_vat_number( $context = 'view' ) {
1144
-		return $this->get_prop( 'vat_number', $context );
1143
+	public function get_vat_number($context = 'view') {
1144
+		return $this->get_prop('vat_number', $context);
1145 1145
     }
1146 1146
 
1147 1147
     /**
@@ -1151,8 +1151,8 @@  discard block
 block discarded – undo
1151 1151
 	 * @param  string $context View or edit context.
1152 1152
 	 * @return string
1153 1153
 	 */
1154
-	public function get_user_vat_number( $context = 'view' ) {
1155
-		return $this->get_vat_number( $context );
1154
+	public function get_user_vat_number($context = 'view') {
1155
+		return $this->get_vat_number($context);
1156 1156
     }
1157 1157
 
1158 1158
     /**
@@ -1162,8 +1162,8 @@  discard block
 block discarded – undo
1162 1162
 	 * @param  string $context View or edit context.
1163 1163
 	 * @return string
1164 1164
 	 */
1165
-	public function get_customer_vat_number( $context = 'view' ) {
1166
-		return $this->get_vat_number( $context );
1165
+	public function get_customer_vat_number($context = 'view') {
1166
+		return $this->get_vat_number($context);
1167 1167
     }
1168 1168
 
1169 1169
     /**
@@ -1173,8 +1173,8 @@  discard block
 block discarded – undo
1173 1173
 	 * @param  string $context View or edit context.
1174 1174
 	 * @return string
1175 1175
 	 */
1176
-	public function get_vat_rate( $context = 'view' ) {
1177
-		return $this->get_prop( 'vat_rate', $context );
1176
+	public function get_vat_rate($context = 'view') {
1177
+		return $this->get_prop('vat_rate', $context);
1178 1178
     }
1179 1179
 
1180 1180
     /**
@@ -1184,8 +1184,8 @@  discard block
 block discarded – undo
1184 1184
 	 * @param  string $context View or edit context.
1185 1185
 	 * @return string
1186 1186
 	 */
1187
-	public function get_user_vat_rate( $context = 'view' ) {
1188
-		return $this->get_vat_rate( $context );
1187
+	public function get_user_vat_rate($context = 'view') {
1188
+		return $this->get_vat_rate($context);
1189 1189
     }
1190 1190
 
1191 1191
     /**
@@ -1195,8 +1195,8 @@  discard block
 block discarded – undo
1195 1195
 	 * @param  string $context View or edit context.
1196 1196
 	 * @return string
1197 1197
 	 */
1198
-	public function get_customer_vat_rate( $context = 'view' ) {
1199
-		return $this->get_vat_rate( $context );
1198
+	public function get_customer_vat_rate($context = 'view') {
1199
+		return $this->get_vat_rate($context);
1200 1200
     }
1201 1201
 
1202 1202
     /**
@@ -1206,8 +1206,8 @@  discard block
 block discarded – undo
1206 1206
 	 * @param  string $context View or edit context.
1207 1207
 	 * @return string
1208 1208
 	 */
1209
-	public function get_address( $context = 'view' ) {
1210
-		return $this->get_prop( 'address', $context );
1209
+	public function get_address($context = 'view') {
1210
+		return $this->get_prop('address', $context);
1211 1211
     }
1212 1212
 
1213 1213
     /**
@@ -1217,8 +1217,8 @@  discard block
 block discarded – undo
1217 1217
 	 * @param  string $context View or edit context.
1218 1218
 	 * @return string
1219 1219
 	 */
1220
-	public function get_user_address( $context = 'view' ) {
1221
-		return $this->get_address( $context );
1220
+	public function get_user_address($context = 'view') {
1221
+		return $this->get_address($context);
1222 1222
     }
1223 1223
 
1224 1224
     /**
@@ -1228,8 +1228,8 @@  discard block
 block discarded – undo
1228 1228
 	 * @param  string $context View or edit context.
1229 1229
 	 * @return string
1230 1230
 	 */
1231
-	public function get_customer_address( $context = 'view' ) {
1232
-		return $this->get_address( $context );
1231
+	public function get_customer_address($context = 'view') {
1232
+		return $this->get_address($context);
1233 1233
     }
1234 1234
 
1235 1235
     /**
@@ -1239,8 +1239,8 @@  discard block
 block discarded – undo
1239 1239
 	 * @param  string $context View or edit context.
1240 1240
 	 * @return bool
1241 1241
 	 */
1242
-	public function get_is_viewed( $context = 'view' ) {
1243
-		return (bool) $this->get_prop( 'is_viewed', $context );
1242
+	public function get_is_viewed($context = 'view') {
1243
+		return (bool) $this->get_prop('is_viewed', $context);
1244 1244
 	}
1245 1245
 
1246 1246
 	/**
@@ -1250,8 +1250,8 @@  discard block
 block discarded – undo
1250 1250
 	 * @param  string $context View or edit context.
1251 1251
 	 * @return bool
1252 1252
 	 */
1253
-	public function get_email_cc( $context = 'view' ) {
1254
-		return $this->get_prop( 'email_cc', $context );
1253
+	public function get_email_cc($context = 'view') {
1254
+		return $this->get_prop('email_cc', $context);
1255 1255
 	}
1256 1256
 
1257 1257
 	/**
@@ -1261,8 +1261,8 @@  discard block
 block discarded – undo
1261 1261
 	 * @param  string $context View or edit context.
1262 1262
 	 * @return bool
1263 1263
 	 */
1264
-	public function get_template( $context = 'view' ) {
1265
-		return $this->get_prop( 'template', $context );
1264
+	public function get_template($context = 'view') {
1265
+		return $this->get_prop('template', $context);
1266 1266
 	}
1267 1267
 
1268 1268
 	/**
@@ -1272,8 +1272,8 @@  discard block
 block discarded – undo
1272 1272
 	 * @param  string $context View or edit context.
1273 1273
 	 * @return bool
1274 1274
 	 */
1275
-	public function get_address_confirmed( $context = 'view' ) {
1276
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1275
+	public function get_address_confirmed($context = 'view') {
1276
+		return (bool) $this->get_prop('address_confirmed', $context);
1277 1277
     }
1278 1278
 
1279 1279
     /**
@@ -1283,8 +1283,8 @@  discard block
 block discarded – undo
1283 1283
 	 * @param  string $context View or edit context.
1284 1284
 	 * @return bool
1285 1285
 	 */
1286
-	public function get_user_address_confirmed( $context = 'view' ) {
1287
-		return $this->get_address_confirmed( $context );
1286
+	public function get_user_address_confirmed($context = 'view') {
1287
+		return $this->get_address_confirmed($context);
1288 1288
     }
1289 1289
 
1290 1290
     /**
@@ -1294,8 +1294,8 @@  discard block
 block discarded – undo
1294 1294
 	 * @param  string $context View or edit context.
1295 1295
 	 * @return bool
1296 1296
 	 */
1297
-	public function get_customer_address_confirmed( $context = 'view' ) {
1298
-		return $this->get_address_confirmed( $context );
1297
+	public function get_customer_address_confirmed($context = 'view') {
1298
+		return $this->get_address_confirmed($context);
1299 1299
     }
1300 1300
 
1301 1301
     /**
@@ -1305,12 +1305,12 @@  discard block
 block discarded – undo
1305 1305
 	 * @param  string $context View or edit context.
1306 1306
 	 * @return float
1307 1307
 	 */
1308
-	public function get_subtotal( $context = 'view' ) {
1309
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1308
+	public function get_subtotal($context = 'view') {
1309
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1310 1310
 
1311 1311
         // Backwards compatibility.
1312
-        if ( is_bool( $context ) && $context ) {
1313
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1312
+        if (is_bool($context) && $context) {
1313
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1314 1314
         }
1315 1315
 
1316 1316
         return $subtotal;
@@ -1323,8 +1323,8 @@  discard block
 block discarded – undo
1323 1323
 	 * @param  string $context View or edit context.
1324 1324
 	 * @return float
1325 1325
 	 */
1326
-	public function get_total_discount( $context = 'view' ) {
1327
-		return (float) $this->get_prop( 'total_discount', $context );
1326
+	public function get_total_discount($context = 'view') {
1327
+		return (float) $this->get_prop('total_discount', $context);
1328 1328
     }
1329 1329
 
1330 1330
     /**
@@ -1334,18 +1334,18 @@  discard block
 block discarded – undo
1334 1334
 	 * @param  string $context View or edit context.
1335 1335
 	 * @return float
1336 1336
 	 */
1337
-	public function get_total_tax( $context = 'view' ) {
1338
-		return (float) $this->get_prop( 'total_tax', $context );
1337
+	public function get_total_tax($context = 'view') {
1338
+		return (float) $this->get_prop('total_tax', $context);
1339 1339
 	}
1340 1340
 
1341 1341
 	/**
1342 1342
 	 * @deprecated
1343 1343
 	 */
1344
-	public function get_final_tax( $currency = false ) {
1344
+	public function get_final_tax($currency = false) {
1345 1345
 		$tax = $this->get_total_tax();
1346 1346
 
1347
-        if ( $currency ) {
1348
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1347
+        if ($currency) {
1348
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1349 1349
         }
1350 1350
 
1351 1351
         return $tax;
@@ -1358,8 +1358,8 @@  discard block
 block discarded – undo
1358 1358
 	 * @param  string $context View or edit context.
1359 1359
 	 * @return float
1360 1360
 	 */
1361
-	public function get_total_fees( $context = 'view' ) {
1362
-		return (float) $this->get_prop( 'total_fees', $context );
1361
+	public function get_total_fees($context = 'view') {
1362
+		return (float) $this->get_prop('total_fees', $context);
1363 1363
     }
1364 1364
 
1365 1365
     /**
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
 	 * @param  string $context View or edit context.
1370 1370
 	 * @return float
1371 1371
 	 */
1372
-	public function get_fees_total( $context = 'view' ) {
1373
-		return $this->get_total_fees( $context );
1372
+	public function get_fees_total($context = 'view') {
1373
+		return $this->get_total_fees($context);
1374 1374
     }
1375 1375
 
1376 1376
     /**
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 	 */
1382 1382
 	public function get_total() {
1383 1383
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1384
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1385 1385
 	}
1386 1386
 	
1387 1387
 	/**
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 	 */
1404 1404
     public function get_initial_total() {
1405 1405
 
1406
-		if ( empty( $this->totals ) ) {
1406
+		if (empty($this->totals)) {
1407 1407
 			$this->recalculate_total();
1408 1408
 		}
1409 1409
 
@@ -1413,11 +1413,11 @@  discard block
 block discarded – undo
1413 1413
 		$subtotal = $this->totals['subtotal']['initial'];
1414 1414
 		$total    = $tax + $fee - $discount + $subtotal;
1415 1415
 
1416
-		if ( 0 > $total ) {
1416
+		if (0 > $total) {
1417 1417
 			$total = 0;
1418 1418
 		}
1419 1419
 
1420
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1420
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1421 1421
 	}
1422 1422
 
1423 1423
 	/**
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 	 */
1430 1430
     public function get_recurring_total() {
1431 1431
 
1432
-		if ( empty( $this->totals ) ) {
1432
+		if (empty($this->totals)) {
1433 1433
 			$this->recalculate_total();
1434 1434
 		}
1435 1435
 
@@ -1439,11 +1439,11 @@  discard block
 block discarded – undo
1439 1439
 		$subtotal = $this->totals['subtotal']['recurring'];
1440 1440
 		$total    = $tax + $fee - $discount + $subtotal;
1441 1441
 
1442
-		if ( 0 > $total ) {
1442
+		if (0 > $total) {
1443 1443
 			$total = 0;
1444 1444
 		}
1445 1445
 
1446
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1446
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1447 1447
 	}
1448 1448
 
1449 1449
 	/**
@@ -1454,10 +1454,10 @@  discard block
 block discarded – undo
1454 1454
 	 * @param string $currency Whether to include the currency.
1455 1455
      * @return float
1456 1456
 	 */
1457
-    public function get_recurring_details( $field = '', $currency = false ) {
1457
+    public function get_recurring_details($field = '', $currency = false) {
1458 1458
 
1459 1459
 		// Maybe recalculate totals.
1460
-		if ( empty( $this->totals ) ) {
1460
+		if (empty($this->totals)) {
1461 1461
 			$this->recalculate_total();
1462 1462
 		}
1463 1463
 
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
 			$currency
1478 1478
 		);
1479 1479
 
1480
-        if ( isset( $data[$field] ) ) {
1481
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1480
+        if (isset($data[$field])) {
1481
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1482 1482
         }
1483 1483
 
1484 1484
         return $data;
@@ -1491,8 +1491,8 @@  discard block
 block discarded – undo
1491 1491
 	 * @param  string $context View or edit context.
1492 1492
 	 * @return array
1493 1493
 	 */
1494
-	public function get_fees( $context = 'view' ) {
1495
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1494
+	public function get_fees($context = 'view') {
1495
+		return wpinv_parse_list($this->get_prop('fees', $context));
1496 1496
     }
1497 1497
 
1498 1498
     /**
@@ -1502,8 +1502,8 @@  discard block
 block discarded – undo
1502 1502
 	 * @param  string $context View or edit context.
1503 1503
 	 * @return array
1504 1504
 	 */
1505
-	public function get_discounts( $context = 'view' ) {
1506
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1505
+	public function get_discounts($context = 'view') {
1506
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1507 1507
     }
1508 1508
 
1509 1509
     /**
@@ -1513,8 +1513,8 @@  discard block
 block discarded – undo
1513 1513
 	 * @param  string $context View or edit context.
1514 1514
 	 * @return array
1515 1515
 	 */
1516
-	public function get_taxes( $context = 'view' ) {
1517
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1516
+	public function get_taxes($context = 'view') {
1517
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1518 1518
     }
1519 1519
 
1520 1520
     /**
@@ -1524,8 +1524,8 @@  discard block
 block discarded – undo
1524 1524
 	 * @param  string $context View or edit context.
1525 1525
 	 * @return GetPaid_Form_Item[]
1526 1526
 	 */
1527
-	public function get_items( $context = 'view' ) {
1528
-        return $this->get_prop( 'items', $context );
1527
+	public function get_items($context = 'view') {
1528
+        return $this->get_prop('items', $context);
1529 1529
     }
1530 1530
 
1531 1531
     /**
@@ -1535,8 +1535,8 @@  discard block
 block discarded – undo
1535 1535
 	 * @param  string $context View or edit context.
1536 1536
 	 * @return int
1537 1537
 	 */
1538
-	public function get_payment_form( $context = 'view' ) {
1539
-		return intval( $this->get_prop( 'payment_form', $context ) );
1538
+	public function get_payment_form($context = 'view') {
1539
+		return intval($this->get_prop('payment_form', $context));
1540 1540
     }
1541 1541
 
1542 1542
     /**
@@ -1546,8 +1546,8 @@  discard block
 block discarded – undo
1546 1546
 	 * @param  string $context View or edit context.
1547 1547
 	 * @return string
1548 1548
 	 */
1549
-	public function get_submission_id( $context = 'view' ) {
1550
-		return $this->get_prop( 'submission_id', $context );
1549
+	public function get_submission_id($context = 'view') {
1550
+		return $this->get_prop('submission_id', $context);
1551 1551
     }
1552 1552
 
1553 1553
     /**
@@ -1557,8 +1557,8 @@  discard block
 block discarded – undo
1557 1557
 	 * @param  string $context View or edit context.
1558 1558
 	 * @return string
1559 1559
 	 */
1560
-	public function get_discount_code( $context = 'view' ) {
1561
-		return $this->get_prop( 'discount_code', $context );
1560
+	public function get_discount_code($context = 'view') {
1561
+		return $this->get_prop('discount_code', $context);
1562 1562
     }
1563 1563
 
1564 1564
     /**
@@ -1568,8 +1568,8 @@  discard block
 block discarded – undo
1568 1568
 	 * @param  string $context View or edit context.
1569 1569
 	 * @return string
1570 1570
 	 */
1571
-	public function get_gateway( $context = 'view' ) {
1572
-		return $this->get_prop( 'gateway', $context );
1571
+	public function get_gateway($context = 'view') {
1572
+		return $this->get_prop('gateway', $context);
1573 1573
     }
1574 1574
 
1575 1575
     /**
@@ -1579,8 +1579,8 @@  discard block
 block discarded – undo
1579 1579
 	 * @return string
1580 1580
 	 */
1581 1581
     public function get_gateway_title() {
1582
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1583
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1582
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1583
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1584 1584
     }
1585 1585
 
1586 1586
     /**
@@ -1590,8 +1590,8 @@  discard block
 block discarded – undo
1590 1590
 	 * @param  string $context View or edit context.
1591 1591
 	 * @return string
1592 1592
 	 */
1593
-	public function get_transaction_id( $context = 'view' ) {
1594
-		return $this->get_prop( 'transaction_id', $context );
1593
+	public function get_transaction_id($context = 'view') {
1594
+		return $this->get_prop('transaction_id', $context);
1595 1595
     }
1596 1596
 
1597 1597
     /**
@@ -1601,9 +1601,9 @@  discard block
 block discarded – undo
1601 1601
 	 * @param  string $context View or edit context.
1602 1602
 	 * @return string
1603 1603
 	 */
1604
-	public function get_currency( $context = 'view' ) {
1605
-        $currency = $this->get_prop( 'currency', $context );
1606
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1604
+	public function get_currency($context = 'view') {
1605
+        $currency = $this->get_prop('currency', $context);
1606
+        return empty($currency) ? wpinv_get_currency() : $currency;
1607 1607
     }
1608 1608
 
1609 1609
     /**
@@ -1613,8 +1613,8 @@  discard block
 block discarded – undo
1613 1613
 	 * @param  string $context View or edit context.
1614 1614
 	 * @return bool
1615 1615
 	 */
1616
-	public function get_disable_taxes( $context = 'view' ) {
1617
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1616
+	public function get_disable_taxes($context = 'view') {
1617
+        return (bool) $this->get_prop('disable_taxes', $context);
1618 1618
     }
1619 1619
 
1620 1620
     /**
@@ -1624,12 +1624,12 @@  discard block
 block discarded – undo
1624 1624
 	 * @param  string $context View or edit context.
1625 1625
 	 * @return int
1626 1626
 	 */
1627
-    public function get_subscription_id( $context = 'view' ) {
1628
-        $subscription_id = $this->get_prop( 'subscription_id', $context );
1627
+    public function get_subscription_id($context = 'view') {
1628
+        $subscription_id = $this->get_prop('subscription_id', $context);
1629 1629
 
1630
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1630
+        if (empty($subscription_id) && $this->is_renewal()) {
1631 1631
             $parent = $this->get_parent();
1632
-            return $parent->get_subscription_id( $context );
1632
+            return $parent->get_subscription_id($context);
1633 1633
         }
1634 1634
 
1635 1635
         return $subscription_id;
@@ -1642,20 +1642,20 @@  discard block
 block discarded – undo
1642 1642
 	 * @param  string $context View or edit context.
1643 1643
 	 * @return array
1644 1644
 	 */
1645
-    public function get_payment_meta( $context = 'view' ) {
1645
+    public function get_payment_meta($context = 'view') {
1646 1646
 
1647 1647
         return array(
1648
-            'price'        => $this->get_total( $context ),
1649
-            'date'         => $this->get_date_created( $context ),
1650
-            'user_email'   => $this->get_email( $context ),
1651
-            'invoice_key'  => $this->get_key( $context ),
1652
-            'currency'     => $this->get_currency( $context ),
1653
-            'items'        => $this->get_items( $context ),
1654
-            'user_info'    => $this->get_user_info( $context ),
1648
+            'price'        => $this->get_total($context),
1649
+            'date'         => $this->get_date_created($context),
1650
+            'user_email'   => $this->get_email($context),
1651
+            'invoice_key'  => $this->get_key($context),
1652
+            'currency'     => $this->get_currency($context),
1653
+            'items'        => $this->get_items($context),
1654
+            'user_info'    => $this->get_user_info($context),
1655 1655
             'cart_details' => $this->get_cart_details(),
1656
-            'status'       => $this->get_status( $context ),
1657
-            'fees'         => $this->get_fees( $context ),
1658
-            'taxes'        => $this->get_taxes( $context ),
1656
+            'status'       => $this->get_status($context),
1657
+            'fees'         => $this->get_fees($context),
1658
+            'taxes'        => $this->get_taxes($context),
1659 1659
         );
1660 1660
 
1661 1661
     }
@@ -1670,7 +1670,7 @@  discard block
 block discarded – undo
1670 1670
         $items        = $this->get_items();
1671 1671
         $cart_details = array();
1672 1672
 
1673
-        foreach ( $items as $item_id => $item ) {
1673
+        foreach ($items as $item_id => $item) {
1674 1674
             $cart_details[] = $item->prepare_data_for_saving();
1675 1675
         }
1676 1676
 
@@ -1682,11 +1682,11 @@  discard block
 block discarded – undo
1682 1682
 	 *
1683 1683
 	 * @return null|GetPaid_Form_Item|int
1684 1684
 	 */
1685
-	public function get_recurring( $object = false ) {
1685
+	public function get_recurring($object = false) {
1686 1686
 
1687 1687
 		// Are we returning an object?
1688
-        if ( $object ) {
1689
-            return $this->get_item( $this->recurring_item );
1688
+        if ($object) {
1689
+            return $this->get_item($this->recurring_item);
1690 1690
         }
1691 1691
 
1692 1692
         return $this->recurring_item;
@@ -1701,15 +1701,15 @@  discard block
 block discarded – undo
1701 1701
 	public function get_subscription_name() {
1702 1702
 
1703 1703
 		// Retrieve the recurring name
1704
-        $item = $this->get_recurring( true );
1704
+        $item = $this->get_recurring(true);
1705 1705
 
1706 1706
 		// Abort if it does not exist.
1707
-        if ( empty( $item ) ) {
1707
+        if (empty($item)) {
1708 1708
             return '';
1709 1709
         }
1710 1710
 
1711 1711
 		// Return the item name.
1712
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1712
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1713 1713
 	}
1714 1714
 
1715 1715
 	/**
@@ -1719,9 +1719,9 @@  discard block
 block discarded – undo
1719 1719
 	 * @return string
1720 1720
 	 */
1721 1721
 	public function get_view_url() {
1722
-        $invoice_url = get_permalink( $this->get_id() );
1723
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1724
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1722
+        $invoice_url = get_permalink($this->get_id());
1723
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1724
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1725 1725
 	}
1726 1726
 
1727 1727
 	/**
@@ -1730,25 +1730,25 @@  discard block
 block discarded – undo
1730 1730
 	 * @since 1.0.19
1731 1731
 	 * @return string
1732 1732
 	 */
1733
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1733
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1734 1734
 
1735 1735
 		// Retrieve the checkout url.
1736 1736
         $pay_url = wpinv_get_checkout_uri();
1737 1737
 
1738 1738
 		// Maybe force ssl.
1739
-        if ( is_ssl() ) {
1740
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1739
+        if (is_ssl()) {
1740
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1741 1741
         }
1742 1742
 
1743 1743
 		// Add the invoice key.
1744
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1744
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1745 1745
 
1746 1746
 		// (Maybe?) add a secret
1747
-        if ( $secret ) {
1748
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1747
+        if ($secret) {
1748
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1749 1749
         }
1750 1750
 
1751
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1751
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1752 1752
 	}
1753 1753
 	
1754 1754
 	/**
@@ -1763,14 +1763,14 @@  discard block
 block discarded – undo
1763 1763
         $receipt_url = wpinv_get_success_page_uri();
1764 1764
 
1765 1765
 		// Maybe force ssl.
1766
-        if ( is_ssl() ) {
1767
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1766
+        if (is_ssl()) {
1767
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1768 1768
         }
1769 1769
 
1770 1770
 		// Add the invoice key.
1771
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1771
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1772 1772
 
1773
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1773
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1774 1774
     }
1775 1775
 
1776 1776
     /**
@@ -1783,8 +1783,8 @@  discard block
 block discarded – undo
1783 1783
 	 * @param  string $context View or edit context.
1784 1784
 	 * @return mixed Value of the given invoice property (if set).
1785 1785
 	 */
1786
-	public function get( $key, $context = 'view' ) {
1787
-        return $this->get_prop( $key, $context );
1786
+	public function get($key, $context = 'view') {
1787
+        return $this->get_prop($key, $context);
1788 1788
 	}
1789 1789
 
1790 1790
     /*
@@ -1807,11 +1807,11 @@  discard block
 block discarded – undo
1807 1807
 	 * @param  mixed $value new value.
1808 1808
 	 * @return mixed Value of the given invoice property (if set).
1809 1809
 	 */
1810
-	public function set( $key, $value ) {
1810
+	public function set($key, $value) {
1811 1811
 
1812 1812
         $setter = "set_$key";
1813
-        if ( is_callable( array( $this, $setter ) ) ) {
1814
-            $this->{$setter}( $value );
1813
+        if (is_callable(array($this, $setter))) {
1814
+            $this->{$setter}($value);
1815 1815
         }
1816 1816
 
1817 1817
 	}
@@ -1825,47 +1825,47 @@  discard block
 block discarded – undo
1825 1825
 	 * @param bool   $manual_update Is this a manual status change?.
1826 1826
 	 * @return array details of change.
1827 1827
 	 */
1828
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1828
+	public function set_status($new_status, $note = '', $manual_update = false) {
1829 1829
 		$old_status = $this->get_status();
1830 1830
 
1831 1831
 		$statuses = $this->get_all_statuses();
1832 1832
 
1833
-		if ( isset( $statuses[ 'draft' ] ) ) {
1834
-			unset( $statuses[ 'draft' ] );
1833
+		if (isset($statuses['draft'])) {
1834
+			unset($statuses['draft']);
1835 1835
 		}
1836 1836
 
1837
-		$this->set_prop( 'status', $new_status );
1837
+		$this->set_prop('status', $new_status);
1838 1838
 
1839 1839
 		// If setting the status, ensure it's set to a valid status.
1840
-		if ( true === $this->object_read ) {
1840
+		if (true === $this->object_read) {
1841 1841
 
1842 1842
 			// Only allow valid new status.
1843
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1843
+			if (!array_key_exists($new_status, $statuses)) {
1844 1844
 				$new_status = 'wpi-pending';
1845 1845
 			}
1846 1846
 
1847 1847
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1848
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1848
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1849 1849
 				$old_status = 'wpi-pending';
1850 1850
 			}
1851 1851
 
1852 1852
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1853
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1853
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1854 1854
 				$old_status = 'wpi-pending';
1855 1855
 			}
1856 1856
 
1857 1857
 		}
1858 1858
 
1859
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1859
+		if (true === $this->object_read && $old_status !== $new_status) {
1860 1860
 			$this->status_transition = array(
1861
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1861
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1862 1862
 				'to'     => $new_status,
1863 1863
 				'note'   => $note,
1864 1864
 				'manual' => (bool) $manual_update,
1865 1865
 			);
1866 1866
 
1867
-			if ( $manual_update ) {
1868
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1867
+			if ($manual_update) {
1868
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1869 1869
 			}
1870 1870
 
1871 1871
 			$this->maybe_set_date_paid();
@@ -1888,8 +1888,8 @@  discard block
 block discarded – undo
1888 1888
 	 */
1889 1889
 	public function maybe_set_date_paid() {
1890 1890
 
1891
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1892
-			$this->set_date_completed( current_time( 'mysql' ) );
1891
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1892
+			$this->set_date_completed(current_time('mysql'));
1893 1893
 		}
1894 1894
 	}
1895 1895
 
@@ -1898,11 +1898,11 @@  discard block
 block discarded – undo
1898 1898
 	 *
1899 1899
 	 * @since 1.0.19
1900 1900
 	 */
1901
-	public function set_parent_id( $value ) {
1902
-		if ( $value && ( $value === $this->get_id() ) ) {
1901
+	public function set_parent_id($value) {
1902
+		if ($value && ($value === $this->get_id())) {
1903 1903
 			return;
1904 1904
 		}
1905
-		$this->set_prop( 'parent_id', absint( $value ) );
1905
+		$this->set_prop('parent_id', absint($value));
1906 1906
     }
1907 1907
 
1908 1908
     /**
@@ -1910,8 +1910,8 @@  discard block
 block discarded – undo
1910 1910
 	 *
1911 1911
 	 * @since 1.0.19
1912 1912
 	 */
1913
-	public function set_version( $value ) {
1914
-		$this->set_prop( 'version', $value );
1913
+	public function set_version($value) {
1914
+		$this->set_prop('version', $value);
1915 1915
     }
1916 1916
 
1917 1917
     /**
@@ -1921,15 +1921,15 @@  discard block
 block discarded – undo
1921 1921
 	 * @param string $value Value to set.
1922 1922
      * @return bool Whether or not the date was set.
1923 1923
 	 */
1924
-	public function set_date_created( $value ) {
1925
-        $date = strtotime( $value );
1924
+	public function set_date_created($value) {
1925
+        $date = strtotime($value);
1926 1926
 
1927
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1928
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1927
+        if ($date && $value !== '0000-00-00 00:00:00') {
1928
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1929 1929
             return true;
1930 1930
         }
1931 1931
 
1932
-        return $this->set_prop( 'date_created', '' );
1932
+        return $this->set_prop('date_created', '');
1933 1933
 
1934 1934
     }
1935 1935
 
@@ -1940,15 +1940,15 @@  discard block
 block discarded – undo
1940 1940
 	 * @param string $value Value to set.
1941 1941
      * @return bool Whether or not the date was set.
1942 1942
 	 */
1943
-	public function set_due_date( $value ) {
1944
-        $date = strtotime( $value );
1943
+	public function set_due_date($value) {
1944
+        $date = strtotime($value);
1945 1945
 
1946
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1947
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1946
+        if ($date && $value !== '0000-00-00 00:00:00') {
1947
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1948 1948
             return true;
1949 1949
         }
1950 1950
 
1951
-		$this->set_prop( 'due_date', '' );
1951
+		$this->set_prop('due_date', '');
1952 1952
         return false;
1953 1953
 
1954 1954
     }
@@ -1959,8 +1959,8 @@  discard block
 block discarded – undo
1959 1959
 	 * @since 1.0.19
1960 1960
 	 * @param  string $value New name.
1961 1961
 	 */
1962
-	public function set_date_due( $value ) {
1963
-		$this->set_due_date( $value );
1962
+	public function set_date_due($value) {
1963
+		$this->set_due_date($value);
1964 1964
     }
1965 1965
 
1966 1966
     /**
@@ -1970,15 +1970,15 @@  discard block
 block discarded – undo
1970 1970
 	 * @param string $value Value to set.
1971 1971
      * @return bool Whether or not the date was set.
1972 1972
 	 */
1973
-	public function set_completed_date( $value ) {
1974
-        $date = strtotime( $value );
1973
+	public function set_completed_date($value) {
1974
+        $date = strtotime($value);
1975 1975
 
1976
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
1977
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
1976
+        if ($date && $value !== '0000-00-00 00:00:00') {
1977
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
1978 1978
             return true;
1979 1979
         }
1980 1980
 
1981
-		$this->set_prop( 'completed_date', '' );
1981
+		$this->set_prop('completed_date', '');
1982 1982
         return false;
1983 1983
 
1984 1984
     }
@@ -1989,8 +1989,8 @@  discard block
 block discarded – undo
1989 1989
 	 * @since 1.0.19
1990 1990
 	 * @param  string $value New name.
1991 1991
 	 */
1992
-	public function set_date_completed( $value ) {
1993
-		$this->set_completed_date( $value );
1992
+	public function set_date_completed($value) {
1993
+		$this->set_completed_date($value);
1994 1994
     }
1995 1995
 
1996 1996
     /**
@@ -2000,15 +2000,15 @@  discard block
 block discarded – undo
2000 2000
 	 * @param string $value Value to set.
2001 2001
      * @return bool Whether or not the date was set.
2002 2002
 	 */
2003
-	public function set_date_modified( $value ) {
2004
-        $date = strtotime( $value );
2003
+	public function set_date_modified($value) {
2004
+        $date = strtotime($value);
2005 2005
 
2006
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2007
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2006
+        if ($date && $value !== '0000-00-00 00:00:00') {
2007
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2008 2008
             return true;
2009 2009
         }
2010 2010
 
2011
-		$this->set_prop( 'date_modified', '' );
2011
+		$this->set_prop('date_modified', '');
2012 2012
         return false;
2013 2013
 
2014 2014
     }
@@ -2019,9 +2019,9 @@  discard block
 block discarded – undo
2019 2019
 	 * @since 1.0.19
2020 2020
 	 * @param  string $value New number.
2021 2021
 	 */
2022
-	public function set_number( $value ) {
2023
-        $number = sanitize_text_field( $value );
2024
-		$this->set_prop( 'number', $number );
2022
+	public function set_number($value) {
2023
+        $number = sanitize_text_field($value);
2024
+		$this->set_prop('number', $number);
2025 2025
     }
2026 2026
 
2027 2027
     /**
@@ -2030,9 +2030,9 @@  discard block
 block discarded – undo
2030 2030
 	 * @since 1.0.19
2031 2031
 	 * @param  string $value Type.
2032 2032
 	 */
2033
-	public function set_type( $value ) {
2034
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2035
-		$this->set_prop( 'type', $type );
2033
+	public function set_type($value) {
2034
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2035
+		$this->set_prop('type', $type);
2036 2036
 	}
2037 2037
 
2038 2038
     /**
@@ -2041,10 +2041,10 @@  discard block
 block discarded – undo
2041 2041
 	 * @since 1.0.19
2042 2042
 	 * @param  string $value Post type.
2043 2043
 	 */
2044
-	public function set_post_type( $value ) {
2045
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2046
-			$this->set_type( $value );
2047
-            $this->set_prop( 'post_type', $value );
2044
+	public function set_post_type($value) {
2045
+        if (getpaid_is_invoice_post_type($value)) {
2046
+			$this->set_type($value);
2047
+            $this->set_prop('post_type', $value);
2048 2048
         }
2049 2049
     }
2050 2050
 
@@ -2054,9 +2054,9 @@  discard block
 block discarded – undo
2054 2054
 	 * @since 1.0.19
2055 2055
 	 * @param  string $value New key.
2056 2056
 	 */
2057
-	public function set_key( $value ) {
2058
-        $key = sanitize_text_field( $value );
2059
-		$this->set_prop( 'key', $key );
2057
+	public function set_key($value) {
2058
+        $key = sanitize_text_field($value);
2059
+		$this->set_prop('key', $key);
2060 2060
     }
2061 2061
 
2062 2062
     /**
@@ -2065,9 +2065,9 @@  discard block
 block discarded – undo
2065 2065
 	 * @since 1.0.19
2066 2066
 	 * @param  string $value mode.
2067 2067
 	 */
2068
-	public function set_mode( $value ) {
2069
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2070
-            $this->set_prop( 'value', $value );
2068
+	public function set_mode($value) {
2069
+        if (!in_array($value, array('live', 'test'))) {
2070
+            $this->set_prop('value', $value);
2071 2071
         }
2072 2072
     }
2073 2073
 
@@ -2077,8 +2077,8 @@  discard block
 block discarded – undo
2077 2077
 	 * @since 1.0.19
2078 2078
 	 * @param  string $value path.
2079 2079
 	 */
2080
-	public function set_path( $value ) {
2081
-        $this->set_prop( 'path', $value );
2080
+	public function set_path($value) {
2081
+        $this->set_prop('path', $value);
2082 2082
     }
2083 2083
 
2084 2084
     /**
@@ -2087,9 +2087,9 @@  discard block
 block discarded – undo
2087 2087
 	 * @since 1.0.19
2088 2088
 	 * @param  string $value New name.
2089 2089
 	 */
2090
-	public function set_name( $value ) {
2091
-        $name = sanitize_text_field( $value );
2092
-		$this->set_prop( 'name', $name );
2090
+	public function set_name($value) {
2091
+        $name = sanitize_text_field($value);
2092
+		$this->set_prop('name', $name);
2093 2093
     }
2094 2094
 
2095 2095
     /**
@@ -2098,8 +2098,8 @@  discard block
 block discarded – undo
2098 2098
 	 * @since 1.0.19
2099 2099
 	 * @param  string $value New name.
2100 2100
 	 */
2101
-	public function set_title( $value ) {
2102
-		$this->set_name( $value );
2101
+	public function set_title($value) {
2102
+		$this->set_name($value);
2103 2103
     }
2104 2104
 
2105 2105
     /**
@@ -2108,9 +2108,9 @@  discard block
 block discarded – undo
2108 2108
 	 * @since 1.0.19
2109 2109
 	 * @param  string $value New description.
2110 2110
 	 */
2111
-	public function set_description( $value ) {
2112
-        $description = wp_kses_post( $value );
2113
-		return $this->set_prop( 'description', $description );
2111
+	public function set_description($value) {
2112
+        $description = wp_kses_post($value);
2113
+		return $this->set_prop('description', $description);
2114 2114
     }
2115 2115
 
2116 2116
     /**
@@ -2119,8 +2119,8 @@  discard block
 block discarded – undo
2119 2119
 	 * @since 1.0.19
2120 2120
 	 * @param  string $value New description.
2121 2121
 	 */
2122
-	public function set_excerpt( $value ) {
2123
-		$this->set_description( $value );
2122
+	public function set_excerpt($value) {
2123
+		$this->set_description($value);
2124 2124
     }
2125 2125
 
2126 2126
     /**
@@ -2129,8 +2129,8 @@  discard block
 block discarded – undo
2129 2129
 	 * @since 1.0.19
2130 2130
 	 * @param  string $value New description.
2131 2131
 	 */
2132
-	public function set_summary( $value ) {
2133
-		$this->set_description( $value );
2132
+	public function set_summary($value) {
2133
+		$this->set_description($value);
2134 2134
     }
2135 2135
 
2136 2136
     /**
@@ -2139,12 +2139,12 @@  discard block
 block discarded – undo
2139 2139
 	 * @since 1.0.19
2140 2140
 	 * @param  int $value New author.
2141 2141
 	 */
2142
-	public function set_author( $value ) {
2143
-		$user = get_user_by( 'id', (int) $value );
2142
+	public function set_author($value) {
2143
+		$user = get_user_by('id', (int) $value);
2144 2144
 
2145
-		if ( $user && $user->ID ) {
2146
-			$this->set_prop( 'author', $user->ID );
2147
-			$this->set_prop( 'email', $user->user_email );
2145
+		if ($user && $user->ID) {
2146
+			$this->set_prop('author', $user->ID);
2147
+			$this->set_prop('email', $user->user_email);
2148 2148
 		}
2149 2149
 		
2150 2150
     }
@@ -2155,8 +2155,8 @@  discard block
 block discarded – undo
2155 2155
 	 * @since 1.0.19
2156 2156
 	 * @param  int $value New user id.
2157 2157
 	 */
2158
-	public function set_user_id( $value ) {
2159
-		$this->set_author( $value );
2158
+	public function set_user_id($value) {
2159
+		$this->set_author($value);
2160 2160
     }
2161 2161
 
2162 2162
     /**
@@ -2165,8 +2165,8 @@  discard block
 block discarded – undo
2165 2165
 	 * @since 1.0.19
2166 2166
 	 * @param  int $value New user id.
2167 2167
 	 */
2168
-	public function set_customer_id( $value ) {
2169
-		$this->set_author( $value );
2168
+	public function set_customer_id($value) {
2169
+		$this->set_author($value);
2170 2170
     }
2171 2171
 
2172 2172
     /**
@@ -2175,8 +2175,8 @@  discard block
 block discarded – undo
2175 2175
 	 * @since 1.0.19
2176 2176
 	 * @param  string $value ip address.
2177 2177
 	 */
2178
-	public function set_ip( $value ) {
2179
-		$this->set_prop( 'ip', $value );
2178
+	public function set_ip($value) {
2179
+		$this->set_prop('ip', $value);
2180 2180
     }
2181 2181
 
2182 2182
     /**
@@ -2185,8 +2185,8 @@  discard block
 block discarded – undo
2185 2185
 	 * @since 1.0.19
2186 2186
 	 * @param  string $value ip address.
2187 2187
 	 */
2188
-	public function set_user_ip( $value ) {
2189
-		$this->set_ip( $value );
2188
+	public function set_user_ip($value) {
2189
+		$this->set_ip($value);
2190 2190
     }
2191 2191
 
2192 2192
     /**
@@ -2195,8 +2195,8 @@  discard block
 block discarded – undo
2195 2195
 	 * @since 1.0.19
2196 2196
 	 * @param  string $value first name.
2197 2197
 	 */
2198
-	public function set_first_name( $value ) {
2199
-		$this->set_prop( 'first_name', $value );
2198
+	public function set_first_name($value) {
2199
+		$this->set_prop('first_name', $value);
2200 2200
     }
2201 2201
 
2202 2202
     /**
@@ -2205,8 +2205,8 @@  discard block
 block discarded – undo
2205 2205
 	 * @since 1.0.19
2206 2206
 	 * @param  string $value first name.
2207 2207
 	 */
2208
-	public function set_user_first_name( $value ) {
2209
-		$this->set_first_name( $value );
2208
+	public function set_user_first_name($value) {
2209
+		$this->set_first_name($value);
2210 2210
     }
2211 2211
 
2212 2212
     /**
@@ -2215,8 +2215,8 @@  discard block
 block discarded – undo
2215 2215
 	 * @since 1.0.19
2216 2216
 	 * @param  string $value first name.
2217 2217
 	 */
2218
-	public function set_customer_first_name( $value ) {
2219
-		$this->set_first_name( $value );
2218
+	public function set_customer_first_name($value) {
2219
+		$this->set_first_name($value);
2220 2220
     }
2221 2221
 
2222 2222
     /**
@@ -2225,8 +2225,8 @@  discard block
 block discarded – undo
2225 2225
 	 * @since 1.0.19
2226 2226
 	 * @param  string $value last name.
2227 2227
 	 */
2228
-	public function set_last_name( $value ) {
2229
-		$this->set_prop( 'last_name', $value );
2228
+	public function set_last_name($value) {
2229
+		$this->set_prop('last_name', $value);
2230 2230
     }
2231 2231
 
2232 2232
     /**
@@ -2235,8 +2235,8 @@  discard block
 block discarded – undo
2235 2235
 	 * @since 1.0.19
2236 2236
 	 * @param  string $value last name.
2237 2237
 	 */
2238
-	public function set_user_last_name( $value ) {
2239
-		$this->set_last_name( $value );
2238
+	public function set_user_last_name($value) {
2239
+		$this->set_last_name($value);
2240 2240
     }
2241 2241
 
2242 2242
     /**
@@ -2245,8 +2245,8 @@  discard block
 block discarded – undo
2245 2245
 	 * @since 1.0.19
2246 2246
 	 * @param  string $value last name.
2247 2247
 	 */
2248
-	public function set_customer_last_name( $value ) {
2249
-		$this->set_last_name( $value );
2248
+	public function set_customer_last_name($value) {
2249
+		$this->set_last_name($value);
2250 2250
     }
2251 2251
 
2252 2252
     /**
@@ -2255,8 +2255,8 @@  discard block
 block discarded – undo
2255 2255
 	 * @since 1.0.19
2256 2256
 	 * @param  string $value phone.
2257 2257
 	 */
2258
-	public function set_phone( $value ) {
2259
-		$this->set_prop( 'phone', $value );
2258
+	public function set_phone($value) {
2259
+		$this->set_prop('phone', $value);
2260 2260
     }
2261 2261
 
2262 2262
     /**
@@ -2265,8 +2265,8 @@  discard block
 block discarded – undo
2265 2265
 	 * @since 1.0.19
2266 2266
 	 * @param  string $value phone.
2267 2267
 	 */
2268
-	public function set_user_phone( $value ) {
2269
-		$this->set_phone( $value );
2268
+	public function set_user_phone($value) {
2269
+		$this->set_phone($value);
2270 2270
     }
2271 2271
 
2272 2272
     /**
@@ -2275,8 +2275,8 @@  discard block
 block discarded – undo
2275 2275
 	 * @since 1.0.19
2276 2276
 	 * @param  string $value phone.
2277 2277
 	 */
2278
-	public function set_customer_phone( $value ) {
2279
-		$this->set_phone( $value );
2278
+	public function set_customer_phone($value) {
2279
+		$this->set_phone($value);
2280 2280
     }
2281 2281
 
2282 2282
     /**
@@ -2285,8 +2285,8 @@  discard block
 block discarded – undo
2285 2285
 	 * @since 1.0.19
2286 2286
 	 * @param  string $value phone.
2287 2287
 	 */
2288
-	public function set_phone_number( $value ) {
2289
-		$this->set_phone( $value );
2288
+	public function set_phone_number($value) {
2289
+		$this->set_phone($value);
2290 2290
     }
2291 2291
 
2292 2292
     /**
@@ -2295,8 +2295,8 @@  discard block
 block discarded – undo
2295 2295
 	 * @since 1.0.19
2296 2296
 	 * @param  string $value email address.
2297 2297
 	 */
2298
-	public function set_email( $value ) {
2299
-		$this->set_prop( 'email', $value );
2298
+	public function set_email($value) {
2299
+		$this->set_prop('email', $value);
2300 2300
     }
2301 2301
 
2302 2302
     /**
@@ -2305,8 +2305,8 @@  discard block
 block discarded – undo
2305 2305
 	 * @since 1.0.19
2306 2306
 	 * @param  string $value email address.
2307 2307
 	 */
2308
-	public function set_user_email( $value ) {
2309
-		$this->set_email( $value );
2308
+	public function set_user_email($value) {
2309
+		$this->set_email($value);
2310 2310
     }
2311 2311
 
2312 2312
     /**
@@ -2315,8 +2315,8 @@  discard block
 block discarded – undo
2315 2315
 	 * @since 1.0.19
2316 2316
 	 * @param  string $value email address.
2317 2317
 	 */
2318
-	public function set_email_address( $value ) {
2319
-		$this->set_email( $value );
2318
+	public function set_email_address($value) {
2319
+		$this->set_email($value);
2320 2320
     }
2321 2321
 
2322 2322
     /**
@@ -2325,8 +2325,8 @@  discard block
 block discarded – undo
2325 2325
 	 * @since 1.0.19
2326 2326
 	 * @param  string $value email address.
2327 2327
 	 */
2328
-	public function set_customer_email( $value ) {
2329
-		$this->set_email( $value );
2328
+	public function set_customer_email($value) {
2329
+		$this->set_email($value);
2330 2330
     }
2331 2331
 
2332 2332
     /**
@@ -2335,8 +2335,8 @@  discard block
 block discarded – undo
2335 2335
 	 * @since 1.0.19
2336 2336
 	 * @param  string $value country.
2337 2337
 	 */
2338
-	public function set_country( $value ) {
2339
-		$this->set_prop( 'country', $value );
2338
+	public function set_country($value) {
2339
+		$this->set_prop('country', $value);
2340 2340
     }
2341 2341
 
2342 2342
     /**
@@ -2345,8 +2345,8 @@  discard block
 block discarded – undo
2345 2345
 	 * @since 1.0.19
2346 2346
 	 * @param  string $value country.
2347 2347
 	 */
2348
-	public function set_user_country( $value ) {
2349
-		$this->set_country( $value );
2348
+	public function set_user_country($value) {
2349
+		$this->set_country($value);
2350 2350
     }
2351 2351
 
2352 2352
     /**
@@ -2355,8 +2355,8 @@  discard block
 block discarded – undo
2355 2355
 	 * @since 1.0.19
2356 2356
 	 * @param  string $value country.
2357 2357
 	 */
2358
-	public function set_customer_country( $value ) {
2359
-		$this->set_country( $value );
2358
+	public function set_customer_country($value) {
2359
+		$this->set_country($value);
2360 2360
     }
2361 2361
 
2362 2362
     /**
@@ -2365,8 +2365,8 @@  discard block
 block discarded – undo
2365 2365
 	 * @since 1.0.19
2366 2366
 	 * @param  string $value state.
2367 2367
 	 */
2368
-	public function set_state( $value ) {
2369
-		$this->set_prop( 'state', $value );
2368
+	public function set_state($value) {
2369
+		$this->set_prop('state', $value);
2370 2370
     }
2371 2371
 
2372 2372
     /**
@@ -2375,8 +2375,8 @@  discard block
 block discarded – undo
2375 2375
 	 * @since 1.0.19
2376 2376
 	 * @param  string $value state.
2377 2377
 	 */
2378
-	public function set_user_state( $value ) {
2379
-		$this->set_state( $value );
2378
+	public function set_user_state($value) {
2379
+		$this->set_state($value);
2380 2380
     }
2381 2381
 
2382 2382
     /**
@@ -2385,8 +2385,8 @@  discard block
 block discarded – undo
2385 2385
 	 * @since 1.0.19
2386 2386
 	 * @param  string $value state.
2387 2387
 	 */
2388
-	public function set_customer_state( $value ) {
2389
-		$this->set_state( $value );
2388
+	public function set_customer_state($value) {
2389
+		$this->set_state($value);
2390 2390
     }
2391 2391
 
2392 2392
     /**
@@ -2395,8 +2395,8 @@  discard block
 block discarded – undo
2395 2395
 	 * @since 1.0.19
2396 2396
 	 * @param  string $value city.
2397 2397
 	 */
2398
-	public function set_city( $value ) {
2399
-		$this->set_prop( 'city', $value );
2398
+	public function set_city($value) {
2399
+		$this->set_prop('city', $value);
2400 2400
     }
2401 2401
 
2402 2402
     /**
@@ -2405,8 +2405,8 @@  discard block
 block discarded – undo
2405 2405
 	 * @since 1.0.19
2406 2406
 	 * @param  string $value city.
2407 2407
 	 */
2408
-	public function set_user_city( $value ) {
2409
-		$this->set_city( $value );
2408
+	public function set_user_city($value) {
2409
+		$this->set_city($value);
2410 2410
     }
2411 2411
 
2412 2412
     /**
@@ -2415,8 +2415,8 @@  discard block
 block discarded – undo
2415 2415
 	 * @since 1.0.19
2416 2416
 	 * @param  string $value city.
2417 2417
 	 */
2418
-	public function set_customer_city( $value ) {
2419
-		$this->set_city( $value );
2418
+	public function set_customer_city($value) {
2419
+		$this->set_city($value);
2420 2420
     }
2421 2421
 
2422 2422
     /**
@@ -2425,8 +2425,8 @@  discard block
 block discarded – undo
2425 2425
 	 * @since 1.0.19
2426 2426
 	 * @param  string $value zip.
2427 2427
 	 */
2428
-	public function set_zip( $value ) {
2429
-		$this->set_prop( 'zip', $value );
2428
+	public function set_zip($value) {
2429
+		$this->set_prop('zip', $value);
2430 2430
     }
2431 2431
 
2432 2432
     /**
@@ -2435,8 +2435,8 @@  discard block
 block discarded – undo
2435 2435
 	 * @since 1.0.19
2436 2436
 	 * @param  string $value zip.
2437 2437
 	 */
2438
-	public function set_user_zip( $value ) {
2439
-		$this->set_zip( $value );
2438
+	public function set_user_zip($value) {
2439
+		$this->set_zip($value);
2440 2440
     }
2441 2441
 
2442 2442
     /**
@@ -2445,8 +2445,8 @@  discard block
 block discarded – undo
2445 2445
 	 * @since 1.0.19
2446 2446
 	 * @param  string $value zip.
2447 2447
 	 */
2448
-	public function set_customer_zip( $value ) {
2449
-		$this->set_zip( $value );
2448
+	public function set_customer_zip($value) {
2449
+		$this->set_zip($value);
2450 2450
     }
2451 2451
 
2452 2452
     /**
@@ -2455,8 +2455,8 @@  discard block
 block discarded – undo
2455 2455
 	 * @since 1.0.19
2456 2456
 	 * @param  string $value company.
2457 2457
 	 */
2458
-	public function set_company( $value ) {
2459
-		$this->set_prop( 'company', $value );
2458
+	public function set_company($value) {
2459
+		$this->set_prop('company', $value);
2460 2460
     }
2461 2461
 
2462 2462
     /**
@@ -2465,8 +2465,8 @@  discard block
 block discarded – undo
2465 2465
 	 * @since 1.0.19
2466 2466
 	 * @param  string $value company.
2467 2467
 	 */
2468
-	public function set_user_company( $value ) {
2469
-		$this->set_company( $value );
2468
+	public function set_user_company($value) {
2469
+		$this->set_company($value);
2470 2470
     }
2471 2471
 
2472 2472
     /**
@@ -2475,8 +2475,8 @@  discard block
 block discarded – undo
2475 2475
 	 * @since 1.0.19
2476 2476
 	 * @param  string $value company.
2477 2477
 	 */
2478
-	public function set_customer_company( $value ) {
2479
-		$this->set_company( $value );
2478
+	public function set_customer_company($value) {
2479
+		$this->set_company($value);
2480 2480
     }
2481 2481
 
2482 2482
     /**
@@ -2485,8 +2485,8 @@  discard block
 block discarded – undo
2485 2485
 	 * @since 1.0.19
2486 2486
 	 * @param  string $value var number.
2487 2487
 	 */
2488
-	public function set_vat_number( $value ) {
2489
-		$this->set_prop( 'vat_number', $value );
2488
+	public function set_vat_number($value) {
2489
+		$this->set_prop('vat_number', $value);
2490 2490
     }
2491 2491
 
2492 2492
     /**
@@ -2495,8 +2495,8 @@  discard block
 block discarded – undo
2495 2495
 	 * @since 1.0.19
2496 2496
 	 * @param  string $value var number.
2497 2497
 	 */
2498
-	public function set_user_vat_number( $value ) {
2499
-		$this->set_vat_number( $value );
2498
+	public function set_user_vat_number($value) {
2499
+		$this->set_vat_number($value);
2500 2500
     }
2501 2501
 
2502 2502
     /**
@@ -2505,8 +2505,8 @@  discard block
 block discarded – undo
2505 2505
 	 * @since 1.0.19
2506 2506
 	 * @param  string $value var number.
2507 2507
 	 */
2508
-	public function set_customer_vat_number( $value ) {
2509
-		$this->set_vat_number( $value );
2508
+	public function set_customer_vat_number($value) {
2509
+		$this->set_vat_number($value);
2510 2510
     }
2511 2511
 
2512 2512
     /**
@@ -2515,8 +2515,8 @@  discard block
 block discarded – undo
2515 2515
 	 * @since 1.0.19
2516 2516
 	 * @param  string $value var rate.
2517 2517
 	 */
2518
-	public function set_vat_rate( $value ) {
2519
-		$this->set_prop( 'vat_rate', $value );
2518
+	public function set_vat_rate($value) {
2519
+		$this->set_prop('vat_rate', $value);
2520 2520
     }
2521 2521
 
2522 2522
     /**
@@ -2525,8 +2525,8 @@  discard block
 block discarded – undo
2525 2525
 	 * @since 1.0.19
2526 2526
 	 * @param  string $value var number.
2527 2527
 	 */
2528
-	public function set_user_vat_rate( $value ) {
2529
-		$this->set_vat_rate( $value );
2528
+	public function set_user_vat_rate($value) {
2529
+		$this->set_vat_rate($value);
2530 2530
     }
2531 2531
 
2532 2532
     /**
@@ -2535,8 +2535,8 @@  discard block
 block discarded – undo
2535 2535
 	 * @since 1.0.19
2536 2536
 	 * @param  string $value var number.
2537 2537
 	 */
2538
-	public function set_customer_vat_rate( $value ) {
2539
-		$this->set_vat_rate( $value );
2538
+	public function set_customer_vat_rate($value) {
2539
+		$this->set_vat_rate($value);
2540 2540
     }
2541 2541
 
2542 2542
     /**
@@ -2545,8 +2545,8 @@  discard block
 block discarded – undo
2545 2545
 	 * @since 1.0.19
2546 2546
 	 * @param  string $value address.
2547 2547
 	 */
2548
-	public function set_address( $value ) {
2549
-		$this->set_prop( 'address', $value );
2548
+	public function set_address($value) {
2549
+		$this->set_prop('address', $value);
2550 2550
     }
2551 2551
 
2552 2552
     /**
@@ -2555,8 +2555,8 @@  discard block
 block discarded – undo
2555 2555
 	 * @since 1.0.19
2556 2556
 	 * @param  string $value address.
2557 2557
 	 */
2558
-	public function set_user_address( $value ) {
2559
-		$this->set_address( $value );
2558
+	public function set_user_address($value) {
2559
+		$this->set_address($value);
2560 2560
     }
2561 2561
 
2562 2562
     /**
@@ -2565,8 +2565,8 @@  discard block
 block discarded – undo
2565 2565
 	 * @since 1.0.19
2566 2566
 	 * @param  string $value address.
2567 2567
 	 */
2568
-	public function set_customer_address( $value ) {
2569
-		$this->set_address( $value );
2568
+	public function set_customer_address($value) {
2569
+		$this->set_address($value);
2570 2570
     }
2571 2571
 
2572 2572
     /**
@@ -2575,8 +2575,8 @@  discard block
 block discarded – undo
2575 2575
 	 * @since 1.0.19
2576 2576
 	 * @param  int|bool $value confirmed.
2577 2577
 	 */
2578
-	public function set_is_viewed( $value ) {
2579
-		$this->set_prop( 'is_viewed', $value );
2578
+	public function set_is_viewed($value) {
2579
+		$this->set_prop('is_viewed', $value);
2580 2580
 	}
2581 2581
 
2582 2582
 	/**
@@ -2585,8 +2585,8 @@  discard block
 block discarded – undo
2585 2585
 	 * @since 1.0.19
2586 2586
 	 * @param  string $value email recipients.
2587 2587
 	 */
2588
-	public function set_email_cc( $value ) {
2589
-		$this->set_prop( 'email_cc', $value );
2588
+	public function set_email_cc($value) {
2589
+		$this->set_prop('email_cc', $value);
2590 2590
 	}
2591 2591
 
2592 2592
 	/**
@@ -2595,9 +2595,9 @@  discard block
 block discarded – undo
2595 2595
 	 * @since 1.0.19
2596 2596
 	 * @param  string $value email recipients.
2597 2597
 	 */
2598
-	public function set_template( $value ) {
2599
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2600
-			$this->set_prop( 'template', $value );
2598
+	public function set_template($value) {
2599
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2600
+			$this->set_prop('template', $value);
2601 2601
 		}
2602 2602
 	}
2603 2603
 
@@ -2607,8 +2607,8 @@  discard block
 block discarded – undo
2607 2607
 	 * @since 1.0.19
2608 2608
 	 * @param  int|bool $value confirmed.
2609 2609
 	 */
2610
-	public function set_address_confirmed( $value ) {
2611
-		$this->set_prop( 'address_confirmed', $value );
2610
+	public function set_address_confirmed($value) {
2611
+		$this->set_prop('address_confirmed', $value);
2612 2612
     }
2613 2613
 
2614 2614
     /**
@@ -2617,8 +2617,8 @@  discard block
 block discarded – undo
2617 2617
 	 * @since 1.0.19
2618 2618
 	 * @param  int|bool $value confirmed.
2619 2619
 	 */
2620
-	public function set_user_address_confirmed( $value ) {
2621
-		$this->set_address_confirmed( $value );
2620
+	public function set_user_address_confirmed($value) {
2621
+		$this->set_address_confirmed($value);
2622 2622
     }
2623 2623
 
2624 2624
     /**
@@ -2627,8 +2627,8 @@  discard block
 block discarded – undo
2627 2627
 	 * @since 1.0.19
2628 2628
 	 * @param  int|bool $value confirmed.
2629 2629
 	 */
2630
-	public function set_customer_address_confirmed( $value ) {
2631
-		$this->set_address_confirmed( $value );
2630
+	public function set_customer_address_confirmed($value) {
2631
+		$this->set_address_confirmed($value);
2632 2632
     }
2633 2633
 
2634 2634
     /**
@@ -2637,8 +2637,8 @@  discard block
 block discarded – undo
2637 2637
 	 * @since 1.0.19
2638 2638
 	 * @param  float $value sub total.
2639 2639
 	 */
2640
-	public function set_subtotal( $value ) {
2641
-		$this->set_prop( 'subtotal', $value );
2640
+	public function set_subtotal($value) {
2641
+		$this->set_prop('subtotal', $value);
2642 2642
     }
2643 2643
 
2644 2644
     /**
@@ -2647,8 +2647,8 @@  discard block
 block discarded – undo
2647 2647
 	 * @since 1.0.19
2648 2648
 	 * @param  float $value discount total.
2649 2649
 	 */
2650
-	public function set_total_discount( $value ) {
2651
-		$this->set_prop( 'total_discount', $value );
2650
+	public function set_total_discount($value) {
2651
+		$this->set_prop('total_discount', $value);
2652 2652
     }
2653 2653
 
2654 2654
     /**
@@ -2657,8 +2657,8 @@  discard block
 block discarded – undo
2657 2657
 	 * @since 1.0.19
2658 2658
 	 * @param  float $value discount total.
2659 2659
 	 */
2660
-	public function set_discount( $value ) {
2661
-		$this->set_total_discount( $value );
2660
+	public function set_discount($value) {
2661
+		$this->set_total_discount($value);
2662 2662
     }
2663 2663
 
2664 2664
     /**
@@ -2667,8 +2667,8 @@  discard block
 block discarded – undo
2667 2667
 	 * @since 1.0.19
2668 2668
 	 * @param  float $value tax total.
2669 2669
 	 */
2670
-	public function set_total_tax( $value ) {
2671
-		$this->set_prop( 'total_tax', $value );
2670
+	public function set_total_tax($value) {
2671
+		$this->set_prop('total_tax', $value);
2672 2672
     }
2673 2673
 
2674 2674
     /**
@@ -2677,8 +2677,8 @@  discard block
 block discarded – undo
2677 2677
 	 * @since 1.0.19
2678 2678
 	 * @param  float $value tax total.
2679 2679
 	 */
2680
-	public function set_tax_total( $value ) {
2681
-		$this->set_total_tax( $value );
2680
+	public function set_tax_total($value) {
2681
+		$this->set_total_tax($value);
2682 2682
     }
2683 2683
 
2684 2684
     /**
@@ -2687,8 +2687,8 @@  discard block
 block discarded – undo
2687 2687
 	 * @since 1.0.19
2688 2688
 	 * @param  float $value fees total.
2689 2689
 	 */
2690
-	public function set_total_fees( $value ) {
2691
-		$this->set_prop( 'total_fees', $value );
2690
+	public function set_total_fees($value) {
2691
+		$this->set_prop('total_fees', $value);
2692 2692
     }
2693 2693
 
2694 2694
     /**
@@ -2697,8 +2697,8 @@  discard block
 block discarded – undo
2697 2697
 	 * @since 1.0.19
2698 2698
 	 * @param  float $value fees total.
2699 2699
 	 */
2700
-	public function set_fees_total( $value ) {
2701
-		$this->set_total_fees( $value );
2700
+	public function set_fees_total($value) {
2701
+		$this->set_total_fees($value);
2702 2702
     }
2703 2703
 
2704 2704
     /**
@@ -2707,18 +2707,18 @@  discard block
 block discarded – undo
2707 2707
 	 * @since 1.0.19
2708 2708
 	 * @param  array $value fees.
2709 2709
 	 */
2710
-	public function set_fees( $value ) {
2710
+	public function set_fees($value) {
2711 2711
 
2712
-        $this->set_prop( 'fees', array() );
2712
+        $this->set_prop('fees', array());
2713 2713
 
2714 2714
         // Ensure that we have an array.
2715
-        if ( ! is_array( $value ) ) {
2715
+        if (!is_array($value)) {
2716 2716
             return;
2717 2717
         }
2718 2718
 
2719
-        foreach ( $value as $name => $data ) {
2720
-            if ( isset( $data['amount'] ) ) {
2721
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2719
+        foreach ($value as $name => $data) {
2720
+            if (isset($data['amount'])) {
2721
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2722 2722
             }
2723 2723
         }
2724 2724
 
@@ -2730,8 +2730,8 @@  discard block
 block discarded – undo
2730 2730
 	 * @since 1.0.19
2731 2731
 	 * @param  array $value taxes.
2732 2732
 	 */
2733
-	public function set_taxes( $value ) {
2734
-		$this->set_prop( 'taxes', $value );
2733
+	public function set_taxes($value) {
2734
+		$this->set_prop('taxes', $value);
2735 2735
     }
2736 2736
 
2737 2737
     /**
@@ -2740,17 +2740,17 @@  discard block
 block discarded – undo
2740 2740
 	 * @since 1.0.19
2741 2741
 	 * @param  array $value discounts.
2742 2742
 	 */
2743
-	public function set_discounts( $value ) {
2744
-		$this->set_prop( 'discounts', array() );
2743
+	public function set_discounts($value) {
2744
+		$this->set_prop('discounts', array());
2745 2745
 
2746 2746
         // Ensure that we have an array.
2747
-        if ( ! is_array( $value ) ) {
2747
+        if (!is_array($value)) {
2748 2748
             return;
2749 2749
         }
2750 2750
 
2751
-        foreach ( $value as $name => $data ) {
2752
-            if ( isset( $data['amount'] ) ) {
2753
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2751
+        foreach ($value as $name => $data) {
2752
+            if (isset($data['amount'])) {
2753
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2754 2754
             }
2755 2755
         }
2756 2756
     }
@@ -2761,18 +2761,18 @@  discard block
 block discarded – undo
2761 2761
 	 * @since 1.0.19
2762 2762
 	 * @param  GetPaid_Form_Item[] $value items.
2763 2763
 	 */
2764
-	public function set_items( $value ) {
2764
+	public function set_items($value) {
2765 2765
 
2766 2766
         // Remove existing items.
2767
-        $this->set_prop( 'items', array() );
2767
+        $this->set_prop('items', array());
2768 2768
 
2769 2769
         // Ensure that we have an array.
2770
-        if ( ! is_array( $value ) ) {
2770
+        if (!is_array($value)) {
2771 2771
             return;
2772 2772
         }
2773 2773
 
2774
-        foreach ( $value as $item ) {
2775
-            $this->add_item( $item );
2774
+        foreach ($value as $item) {
2775
+            $this->add_item($item);
2776 2776
         }
2777 2777
 
2778 2778
     }
@@ -2783,8 +2783,8 @@  discard block
 block discarded – undo
2783 2783
 	 * @since 1.0.19
2784 2784
 	 * @param  int $value payment form.
2785 2785
 	 */
2786
-	public function set_payment_form( $value ) {
2787
-		$this->set_prop( 'payment_form', $value );
2786
+	public function set_payment_form($value) {
2787
+		$this->set_prop('payment_form', $value);
2788 2788
     }
2789 2789
 
2790 2790
     /**
@@ -2793,8 +2793,8 @@  discard block
 block discarded – undo
2793 2793
 	 * @since 1.0.19
2794 2794
 	 * @param  string $value submission id.
2795 2795
 	 */
2796
-	public function set_submission_id( $value ) {
2797
-		$this->set_prop( 'submission_id', $value );
2796
+	public function set_submission_id($value) {
2797
+		$this->set_prop('submission_id', $value);
2798 2798
     }
2799 2799
 
2800 2800
     /**
@@ -2803,8 +2803,8 @@  discard block
 block discarded – undo
2803 2803
 	 * @since 1.0.19
2804 2804
 	 * @param  string $value discount code.
2805 2805
 	 */
2806
-	public function set_discount_code( $value ) {
2807
-		$this->set_prop( 'discount_code', $value );
2806
+	public function set_discount_code($value) {
2807
+		$this->set_prop('discount_code', $value);
2808 2808
     }
2809 2809
 
2810 2810
     /**
@@ -2813,8 +2813,8 @@  discard block
 block discarded – undo
2813 2813
 	 * @since 1.0.19
2814 2814
 	 * @param  string $value gateway.
2815 2815
 	 */
2816
-	public function set_gateway( $value ) {
2817
-		$this->set_prop( 'gateway', $value );
2816
+	public function set_gateway($value) {
2817
+		$this->set_prop('gateway', $value);
2818 2818
     }
2819 2819
 
2820 2820
     /**
@@ -2823,9 +2823,9 @@  discard block
 block discarded – undo
2823 2823
 	 * @since 1.0.19
2824 2824
 	 * @param  string $value transaction id.
2825 2825
 	 */
2826
-	public function set_transaction_id( $value ) {
2827
-		if ( ! empty( $value ) ) {
2828
-			$this->set_prop( 'transaction_id', $value );
2826
+	public function set_transaction_id($value) {
2827
+		if (!empty($value)) {
2828
+			$this->set_prop('transaction_id', $value);
2829 2829
 		}
2830 2830
     }
2831 2831
 
@@ -2835,8 +2835,8 @@  discard block
 block discarded – undo
2835 2835
 	 * @since 1.0.19
2836 2836
 	 * @param  string $value currency id.
2837 2837
 	 */
2838
-	public function set_currency( $value ) {
2839
-		$this->set_prop( 'currency', $value );
2838
+	public function set_currency($value) {
2839
+		$this->set_prop('currency', $value);
2840 2840
     }
2841 2841
 
2842 2842
 	/**
@@ -2845,8 +2845,8 @@  discard block
 block discarded – undo
2845 2845
 	 * @since 1.0.19
2846 2846
 	 * @param  bool $value value.
2847 2847
 	 */
2848
-	public function set_disable_taxes( $value ) {
2849
-		$this->set_prop( 'disable_taxes', (bool) $value );
2848
+	public function set_disable_taxes($value) {
2849
+		$this->set_prop('disable_taxes', (bool) $value);
2850 2850
 	}
2851 2851
 
2852 2852
     /**
@@ -2855,8 +2855,8 @@  discard block
 block discarded – undo
2855 2855
 	 * @since 1.0.19
2856 2856
 	 * @param  string $value subscription id.
2857 2857
 	 */
2858
-	public function set_subscription_id( $value ) {
2859
-		$this->set_prop( 'subscription_id', $value );
2858
+	public function set_subscription_id($value) {
2859
+		$this->set_prop('subscription_id', $value);
2860 2860
     }
2861 2861
 
2862 2862
     /*
@@ -2873,28 +2873,28 @@  discard block
 block discarded – undo
2873 2873
      */
2874 2874
     public function is_parent() {
2875 2875
         $parent = $this->get_parent_id();
2876
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2876
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2877 2877
     }
2878 2878
 
2879 2879
     /**
2880 2880
      * Checks if this is a renewal invoice.
2881 2881
      */
2882 2882
     public function is_renewal() {
2883
-        return ! $this->is_parent();
2883
+        return !$this->is_parent();
2884 2884
     }
2885 2885
 
2886 2886
     /**
2887 2887
      * Checks if this is a recurring invoice.
2888 2888
      */
2889 2889
     public function is_recurring() {
2890
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2890
+        return $this->is_renewal() || !empty($this->recurring_item);
2891 2891
     }
2892 2892
 
2893 2893
     /**
2894 2894
      * Checks if this is a taxable invoice.
2895 2895
      */
2896 2896
     public function is_taxable() {
2897
-        return ! $this->get_disable_taxes();
2897
+        return !$this->get_disable_taxes();
2898 2898
 	}
2899 2899
 
2900 2900
 	/**
@@ -2905,57 +2905,57 @@  discard block
 block discarded – undo
2905 2905
 
2906 2906
         $requires_vat = false;
2907 2907
 
2908
-        if ( $this->country ) {
2908
+        if ($this->country) {
2909 2909
             $wpi_country        = $this->country;
2910
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2910
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2911 2911
         }
2912 2912
 
2913
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2913
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2914 2914
 	}
2915 2915
 
2916 2916
 	/**
2917 2917
 	 * Checks to see if the invoice requires payment.
2918 2918
 	 */
2919 2919
 	public function is_free() {
2920
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2920
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2921 2921
 
2922
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2922
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2923 2923
 			$is_free = false;
2924 2924
 		}
2925 2925
 
2926
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2926
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2927 2927
     }
2928 2928
 
2929 2929
     /**
2930 2930
      * Checks if the invoice is paid.
2931 2931
      */
2932 2932
     public function is_paid() {
2933
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2934
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2933
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2934
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2935 2935
 	}
2936 2936
 
2937 2937
 	/**
2938 2938
      * Checks if the invoice needs payment.
2939 2939
      */
2940 2940
 	public function needs_payment() {
2941
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2942
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2941
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2942
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2943 2943
     }
2944 2944
 
2945 2945
 	/**
2946 2946
      * Checks if the invoice is refunded.
2947 2947
      */
2948 2948
 	public function is_refunded() {
2949
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2950
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2949
+        $is_refunded = $this->has_status('wpi-refunded');
2950
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2951 2951
 	}
2952 2952
 
2953 2953
 	/**
2954 2954
      * Checks if the invoice is held.
2955 2955
      */
2956 2956
 	public function is_held() {
2957
-        $is_held = $this->has_status( 'wpi-onhold' );
2958
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2957
+        $is_held = $this->has_status('wpi-onhold');
2958
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2959 2959
 	}
2960 2960
 
2961 2961
 	/**
@@ -2963,30 +2963,30 @@  discard block
 block discarded – undo
2963 2963
      */
2964 2964
 	public function is_due() {
2965 2965
 		$due_date = $this->get_due_date();
2966
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2966
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
2967 2967
 	}
2968 2968
 
2969 2969
 	/**
2970 2970
      * Checks if the invoice is draft.
2971 2971
      */
2972 2972
 	public function is_draft() {
2973
-        return $this->has_status( 'draft, auto-draft' );
2973
+        return $this->has_status('draft, auto-draft');
2974 2974
 	}
2975 2975
 
2976 2976
     /**
2977 2977
      * Checks if the invoice has a given status.
2978 2978
      */
2979
-    public function has_status( $status ) {
2980
-        $status = wpinv_parse_list( $status );
2981
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2979
+    public function has_status($status) {
2980
+        $status = wpinv_parse_list($status);
2981
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
2982 2982
 	}
2983 2983
 
2984 2984
 	/**
2985 2985
      * Checks if the invoice is of a given type.
2986 2986
      */
2987
-    public function is_type( $type ) {
2988
-        $type = wpinv_parse_list( $type );
2989
-        return in_array( $this->get_type(), $type );
2987
+    public function is_type($type) {
2988
+        $type = wpinv_parse_list($type);
2989
+        return in_array($this->get_type(), $type);
2990 2990
     }
2991 2991
 
2992 2992
     /**
@@ -3018,8 +3018,8 @@  discard block
 block discarded – undo
3018 3018
      *
3019 3019
      */
3020 3020
 	public function is_initial_free() {
3021
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3022
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3021
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3022
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3023 3023
     }
3024 3024
 	
3025 3025
 	/**
@@ -3029,11 +3029,11 @@  discard block
 block discarded – undo
3029 3029
     public function item_has_free_trial() {
3030 3030
 
3031 3031
         // Ensure we have a recurring item.
3032
-        if ( ! $this->is_recurring() ) {
3032
+        if (!$this->is_recurring()) {
3033 3033
             return false;
3034 3034
         }
3035 3035
 
3036
-        $item = $this->get_recurring( true );
3036
+        $item = $this->get_recurring(true);
3037 3037
         return $item->has_free_trial();
3038 3038
 	}
3039 3039
 
@@ -3041,7 +3041,7 @@  discard block
 block discarded – undo
3041 3041
      * Check if the free trial is a result of a discount.
3042 3042
      */
3043 3043
     public function is_free_trial_from_discount() {
3044
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3044
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3045 3045
 	}
3046 3046
 	
3047 3047
 	/**
@@ -3050,17 +3050,17 @@  discard block
 block discarded – undo
3050 3050
     public function discount_first_payment_only() {
3051 3051
 
3052 3052
 		$discount_code = $this->get_discount_code();
3053
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3053
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3054 3054
             return true;
3055 3055
         }
3056 3056
 
3057
-        $discount = wpinv_get_discount_obj( $discount_code );
3057
+        $discount = wpinv_get_discount_obj($discount_code);
3058 3058
 
3059
-        if ( ! $discount || ! $discount->exists() ) {
3059
+        if (!$discount || !$discount->exists()) {
3060 3060
             return true;
3061 3061
         }
3062 3062
 
3063
-        return ! $discount->get_is_recurring();
3063
+        return !$discount->get_is_recurring();
3064 3064
     }
3065 3065
 
3066 3066
     /*
@@ -3078,27 +3078,27 @@  discard block
 block discarded – undo
3078 3078
      * @param GetPaid_Form_Item|array $item
3079 3079
      * @return WP_Error|Bool
3080 3080
      */
3081
-    public function add_item( $item ) {
3081
+    public function add_item($item) {
3082 3082
 
3083
-		if ( is_array( $item ) ) {
3084
-			$item = $this->process_array_item( $item );
3083
+		if (is_array($item)) {
3084
+			$item = $this->process_array_item($item);
3085 3085
 		}
3086 3086
 
3087
-		if ( is_numeric( $item ) ) {
3088
-			$item = new GetPaid_Form_Item( $item );
3087
+		if (is_numeric($item)) {
3088
+			$item = new GetPaid_Form_Item($item);
3089 3089
 		}
3090 3090
 
3091 3091
         // Make sure that it is available for purchase.
3092
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3093
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3092
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3093
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3094 3094
         }
3095 3095
 
3096 3096
         // Do we have a recurring item?
3097
-		if ( $item->is_recurring() ) {
3097
+		if ($item->is_recurring()) {
3098 3098
 
3099 3099
 			// An invoice can only contain one recurring item.
3100
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3101
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3100
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3101
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3102 3102
 			}
3103 3103
 
3104 3104
 			$this->recurring_item = $item->get_id();
@@ -3109,9 +3109,9 @@  discard block
 block discarded – undo
3109 3109
 
3110 3110
         // Retrieve all items.
3111 3111
         $items = $this->get_items();
3112
-        $items[ (int) $item->get_id() ] = $item;
3112
+        $items[(int) $item->get_id()] = $item;
3113 3113
 
3114
-        $this->set_prop( 'items', $items );
3114
+        $this->set_prop('items', $items);
3115 3115
 		return true;
3116 3116
 	}
3117 3117
 	
@@ -3121,26 +3121,26 @@  discard block
 block discarded – undo
3121 3121
 	 * @since 1.0.19
3122 3122
 	 * @return GetPaid_Form_Item
3123 3123
 	 */
3124
-	protected function process_array_item( $array ) {
3124
+	protected function process_array_item($array) {
3125 3125
 
3126
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3127
-		$item    = new GetPaid_Form_Item( $item_id );
3126
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3127
+		$item    = new GetPaid_Form_Item($item_id);
3128 3128
 
3129 3129
 		// Set item data.
3130
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3131
-			if ( isset( $array[ "item_$key" ] ) ) {
3130
+		foreach (array('name', 'price', 'description') as $key) {
3131
+			if (isset($array["item_$key"])) {
3132 3132
 				$method = "set_$key";
3133
-				$item->$method( $array[ "item_$key" ] );
3133
+				$item->$method($array["item_$key"]);
3134 3134
 			}
3135 3135
 		}
3136 3136
 
3137
-		if ( isset( $array['quantity'] ) ) {
3138
-			$item->set_quantity( $array['quantity'] );
3137
+		if (isset($array['quantity'])) {
3138
+			$item->set_quantity($array['quantity']);
3139 3139
 		}
3140 3140
 
3141 3141
 		// Set item meta.
3142
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3143
-			$item->set_item_meta( $array['meta'] );
3142
+		if (isset($array['meta']) && is_array($array['meta'])) {
3143
+			$item->set_item_meta($array['meta']);
3144 3144
 		}
3145 3145
 
3146 3146
 		return $item;
@@ -3152,10 +3152,10 @@  discard block
 block discarded – undo
3152 3152
 	 *
3153 3153
 	 * @since 1.0.19
3154 3154
 	 */
3155
-	public function get_item( $item_id ) {
3155
+	public function get_item($item_id) {
3156 3156
 		$items   = $this->get_items();
3157 3157
 		$item_id = (int) $item_id;
3158
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3158
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3159 3159
     }
3160 3160
 
3161 3161
     /**
@@ -3163,17 +3163,17 @@  discard block
 block discarded – undo
3163 3163
 	 *
3164 3164
 	 * @since 1.0.19
3165 3165
 	 */
3166
-	public function remove_item( $item_id ) {
3166
+	public function remove_item($item_id) {
3167 3167
 		$items   = $this->get_items();
3168 3168
 		$item_id = (int) $item_id;
3169 3169
 
3170
-        if ( $item_id == $this->recurring_item ) {
3170
+        if ($item_id == $this->recurring_item) {
3171 3171
             $this->recurring_item = null;
3172 3172
         }
3173 3173
 
3174
-        if ( isset( $items[ $item_id ] ) ) {
3175
-            unset( $items[ $item_id ] );
3176
-            $this->set_prop( 'items', $items );
3174
+        if (isset($items[$item_id])) {
3175
+            unset($items[$item_id]);
3176
+            $this->set_prop('items', $items);
3177 3177
         }
3178 3178
     }
3179 3179
 
@@ -3184,27 +3184,27 @@  discard block
 block discarded – undo
3184 3184
      * @param float $value
3185 3185
      * @return WP_Error|Bool
3186 3186
      */
3187
-    public function add_fee( $fee, $value, $recurring = false ) {
3187
+    public function add_fee($fee, $value, $recurring = false) {
3188 3188
 
3189
-        $amount = wpinv_sanitize_amount( $value );
3189
+        $amount = wpinv_sanitize_amount($value);
3190 3190
         $fees   = $this->get_fees();
3191 3191
 
3192
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3192
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3193 3193
 
3194
-            $amount = $fees[ $fee ]['amount'] += $amount;
3195
-			$fees[ $fee ] = array(
3194
+            $amount = $fees[$fee]['amount'] += $amount;
3195
+			$fees[$fee] = array(
3196 3196
 				'amount'    => $amount,
3197 3197
                 'recurring' => (bool) $recurring,
3198 3198
             );
3199 3199
 
3200 3200
 		} else {
3201
-			$fees[ $fee ] = array(
3201
+			$fees[$fee] = array(
3202 3202
                 'amount'    => $amount,
3203 3203
                 'recurring' => (bool) $recurring,
3204 3204
             );
3205 3205
 		}
3206 3206
 
3207
-        $this->set_prop( 'fees', $fee );
3207
+        $this->set_prop('fees', $fee);
3208 3208
 
3209 3209
     }
3210 3210
 
@@ -3213,9 +3213,9 @@  discard block
 block discarded – undo
3213 3213
 	 *
3214 3214
 	 * @since 1.0.19
3215 3215
 	 */
3216
-	public function get_fee( $fee ) {
3216
+	public function get_fee($fee) {
3217 3217
         $fees = $this->get_fees();
3218
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3218
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3219 3219
     }
3220 3220
 
3221 3221
     /**
@@ -3223,11 +3223,11 @@  discard block
 block discarded – undo
3223 3223
 	 *
3224 3224
 	 * @since 1.0.19
3225 3225
 	 */
3226
-	public function remove_fee( $fee ) {
3226
+	public function remove_fee($fee) {
3227 3227
         $fees = $this->get_fees();
3228
-        if ( isset( $fees[ $fee ] ) ) {
3229
-            unset( $fees[ $fee ] );
3230
-            $this->set_prop( 'fees', $fees );
3228
+        if (isset($fees[$fee])) {
3229
+            unset($fees[$fee]);
3230
+            $this->set_prop('fees', $fees);
3231 3231
         }
3232 3232
     }
3233 3233
 
@@ -3238,27 +3238,27 @@  discard block
 block discarded – undo
3238 3238
      * @param float $value
3239 3239
      * @return WP_Error|Bool
3240 3240
      */
3241
-    public function add_discount( $discount, $value, $recurring = false ) {
3241
+    public function add_discount($discount, $value, $recurring = false) {
3242 3242
 
3243
-        $amount    = wpinv_sanitize_amount( $value );
3243
+        $amount    = wpinv_sanitize_amount($value);
3244 3244
         $discounts = $this->get_discounts();
3245 3245
 
3246
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3246
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3247 3247
 
3248
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3249
-			$discounts[ $discount ] = array(
3248
+            $amount = $discounts[$discount]['amount'] += $amount;
3249
+			$discounts[$discount] = array(
3250 3250
                 'amount'    => $amount,
3251 3251
                 'recurring' => (bool) $recurring,
3252 3252
             );
3253 3253
 
3254 3254
 		} else {
3255
-			$discounts[ $discount ] = array(
3255
+			$discounts[$discount] = array(
3256 3256
                 'amount'    => $amount,
3257 3257
                 'recurring' => (bool) $recurring,
3258 3258
             );
3259 3259
 		}
3260 3260
 
3261
-        $this->set_prop( 'discounts', $discount );
3261
+        $this->set_prop('discounts', $discount);
3262 3262
 
3263 3263
     }
3264 3264
 
@@ -3267,15 +3267,15 @@  discard block
 block discarded – undo
3267 3267
 	 *
3268 3268
 	 * @since 1.0.19
3269 3269
 	 */
3270
-	public function get_discount( $discount = false ) {
3270
+	public function get_discount($discount = false) {
3271 3271
 
3272 3272
 		// Backwards compatibilty.
3273
-		if ( empty( $discount ) ) {
3273
+		if (empty($discount)) {
3274 3274
 			return $this->get_total_discount();
3275 3275
 		}
3276 3276
 
3277 3277
         $discounts = $this->get_discounts();
3278
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3278
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3279 3279
     }
3280 3280
 
3281 3281
     /**
@@ -3283,11 +3283,11 @@  discard block
 block discarded – undo
3283 3283
 	 *
3284 3284
 	 * @since 1.0.19
3285 3285
 	 */
3286
-	public function remove_discount( $discount ) {
3286
+	public function remove_discount($discount) {
3287 3287
         $discounts = $this->get_discounts();
3288
-        if ( isset( $discounts[ $discount ] ) ) {
3289
-            unset( $discounts[ $discount ] );
3290
-            $this->set_prop( 'discounts', $discounts );
3288
+        if (isset($discounts[$discount])) {
3289
+            unset($discounts[$discount]);
3290
+            $this->set_prop('discounts', $discounts);
3291 3291
         }
3292 3292
     }
3293 3293
 
@@ -3297,31 +3297,31 @@  discard block
 block discarded – undo
3297 3297
      * @param string $tax
3298 3298
      * @param float $value
3299 3299
      */
3300
-    public function add_tax( $tax, $value, $recurring = true ) {
3300
+    public function add_tax($tax, $value, $recurring = true) {
3301 3301
 
3302
-        if ( ! $this->is_taxable() ) {
3302
+        if (!$this->is_taxable()) {
3303 3303
             return;
3304 3304
         }
3305 3305
 
3306
-        $amount    = wpinv_sanitize_amount( $value );
3306
+        $amount    = wpinv_sanitize_amount($value);
3307 3307
         $taxes     = $this->get_taxes();
3308 3308
 
3309
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3309
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3310 3310
 
3311
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3312
-			$taxes[ $tax ] = array(
3311
+            $amount = $taxes[$tax]['amount'] += $amount;
3312
+			$taxes[$tax] = array(
3313 3313
                 'amount'    => $amount,
3314 3314
                 'recurring' => (bool) $recurring,
3315 3315
             );
3316 3316
 
3317 3317
 		} else {
3318
-			$taxes[ $tax ] = array(
3318
+			$taxes[$tax] = array(
3319 3319
                 'amount'    => $amount,
3320 3320
                 'recurring' => (bool) $recurring,
3321 3321
             );
3322 3322
 		}
3323 3323
 
3324
-        $this->set_prop( 'taxes', $tax );
3324
+        $this->set_prop('taxes', $tax);
3325 3325
 
3326 3326
     }
3327 3327
 
@@ -3330,15 +3330,15 @@  discard block
 block discarded – undo
3330 3330
 	 *
3331 3331
 	 * @since 1.0.19
3332 3332
 	 */
3333
-	public function get_tax( $tax = null ) {
3333
+	public function get_tax($tax = null) {
3334 3334
 
3335 3335
 		// Backwards compatility.
3336
-		if ( empty( $tax ) ) {
3336
+		if (empty($tax)) {
3337 3337
 			return $this->get_total_tax();
3338 3338
 		}
3339 3339
 
3340 3340
         $taxes = $this->get_taxes();
3341
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3341
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3342 3342
     }
3343 3343
 
3344 3344
     /**
@@ -3346,11 +3346,11 @@  discard block
 block discarded – undo
3346 3346
 	 *
3347 3347
 	 * @since 1.0.19
3348 3348
 	 */
3349
-	public function remove_tax( $tax ) {
3349
+	public function remove_tax($tax) {
3350 3350
         $taxes = $this->get_discounts();
3351
-        if ( isset( $taxes[ $tax ] ) ) {
3352
-            unset( $taxes[ $tax ] );
3353
-            $this->set_prop( 'taxes', $taxes );
3351
+        if (isset($taxes[$tax])) {
3352
+            unset($taxes[$tax]);
3353
+            $this->set_prop('taxes', $taxes);
3354 3354
         }
3355 3355
     }
3356 3356
 
@@ -3361,19 +3361,19 @@  discard block
 block discarded – undo
3361 3361
 	 * @return float The recalculated subtotal
3362 3362
 	 */
3363 3363
 	public function recalculate_subtotal() {
3364
-        $items     = $this->get_items();
3364
+        $items = $this->get_items();
3365 3365
 		$subtotal  = 0;
3366 3366
 		$recurring = 0;
3367 3367
 
3368
-        foreach ( $items as $item ) {
3368
+        foreach ($items as $item) {
3369 3369
 			$subtotal  += $item->get_sub_total();
3370 3370
 			$recurring += $item->get_recurring_sub_total();
3371 3371
         }
3372 3372
 
3373
-		if ( $this->is_renewal() ) {
3374
-			$this->set_subtotal( $recurring );
3373
+		if ($this->is_renewal()) {
3374
+			$this->set_subtotal($recurring);
3375 3375
 		} else {
3376
-			$this->set_subtotal( $subtotal );
3376
+			$this->set_subtotal($subtotal);
3377 3377
 		}
3378 3378
 
3379 3379
 		$this->totals['subtotal'] = array(
@@ -3395,9 +3395,9 @@  discard block
 block discarded – undo
3395 3395
 		$discount  = 0;
3396 3396
 		$recurring = 0;
3397 3397
 
3398
-        foreach ( $discounts as $data ) {
3398
+        foreach ($discounts as $data) {
3399 3399
 
3400
-			if ( $data['recurring'] ) {
3400
+			if ($data['recurring']) {
3401 3401
 				$recurring += $data['amount'];
3402 3402
 			} else {
3403 3403
 				$discount += $data['amount'];
@@ -3405,10 +3405,10 @@  discard block
 block discarded – undo
3405 3405
 
3406 3406
 		}
3407 3407
 
3408
-		if ( $this->is_renewal() ) {
3409
-			$this->set_total_discount( $recurring );
3408
+		if ($this->is_renewal()) {
3409
+			$this->set_total_discount($recurring);
3410 3410
 		} else {
3411
-			$this->set_total_discount( $discount );
3411
+			$this->set_total_discount($discount);
3412 3412
 		}
3413 3413
 
3414 3414
 		$this->totals['discount'] = array(
@@ -3427,13 +3427,13 @@  discard block
 block discarded – undo
3427 3427
 	 * @return float The recalculated tax
3428 3428
 	 */
3429 3429
 	public function recalculate_total_tax() {
3430
-        $taxes     = $this->get_taxes();
3430
+        $taxes = $this->get_taxes();
3431 3431
 		$tax       = 0;
3432 3432
 		$recurring = 0;
3433 3433
 
3434
-        foreach ( $taxes as $data ) {
3434
+        foreach ($taxes as $data) {
3435 3435
 
3436
-			if ( $data['recurring'] ) {
3436
+			if ($data['recurring']) {
3437 3437
 				$recurring += $data['amount'];
3438 3438
 			} else {
3439 3439
 				$tax += $data['amount'];
@@ -3441,10 +3441,10 @@  discard block
 block discarded – undo
3441 3441
 
3442 3442
 		}
3443 3443
 
3444
-		if ( $this->is_renewal() ) {
3445
-			$this->set_total_tax( $recurring );
3444
+		if ($this->is_renewal()) {
3445
+			$this->set_total_tax($recurring);
3446 3446
 		} else {
3447
-			$this->set_total_tax( $tax );
3447
+			$this->set_total_tax($tax);
3448 3448
 		}
3449 3449
 
3450 3450
 		$this->totals['tax'] = array(
@@ -3467,9 +3467,9 @@  discard block
 block discarded – undo
3467 3467
 		$fee       = 0;
3468 3468
 		$recurring = 0;
3469 3469
 
3470
-        foreach ( $fees as $data ) {
3470
+        foreach ($fees as $data) {
3471 3471
 
3472
-			if ( $data['recurring'] ) {
3472
+			if ($data['recurring']) {
3473 3473
 				$recurring += $data['amount'];
3474 3474
 			} else {
3475 3475
 				$fee += $data['amount'];
@@ -3477,10 +3477,10 @@  discard block
 block discarded – undo
3477 3477
 
3478 3478
 		}
3479 3479
 
3480
-        if ( $this->is_renewal() ) {
3481
-			$this->set_total_fees( $recurring );
3480
+        if ($this->is_renewal()) {
3481
+			$this->set_total_fees($recurring);
3482 3482
 		} else {
3483
-			$this->set_total_fees( $fee );
3483
+			$this->set_total_fees($fee);
3484 3484
 		}
3485 3485
 
3486 3486
 		$this->totals['fee'] = array(
@@ -3488,7 +3488,7 @@  discard block
 block discarded – undo
3488 3488
 			'recurring' => $recurring,
3489 3489
 		);
3490 3490
 
3491
-        $this->set_total_fees( $fee );
3491
+        $this->set_total_fees($fee);
3492 3492
         return $this->is_renewal() ? $recurring : $fee;
3493 3493
     }
3494 3494
 
@@ -3509,9 +3509,9 @@  discard block
 block discarded – undo
3509 3509
 	/**
3510 3510
 	 * @deprecated
3511 3511
 	 */
3512
-    public function recalculate_totals( $temp = false ) {
3513
-        $this->update_items( $temp );
3514
-        $this->save( true );
3512
+    public function recalculate_totals($temp = false) {
3513
+        $this->update_items($temp);
3514
+        $this->save(true);
3515 3515
         return $this;
3516 3516
     }
3517 3517
 
@@ -3529,36 +3529,36 @@  discard block
 block discarded – undo
3529 3529
 	 * @return int|false The new note's ID on success, false on failure.
3530 3530
      *
3531 3531
      */
3532
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3532
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3533 3533
 
3534 3534
         // Bail if no note specified or this invoice is not yet saved.
3535
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3535
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3536 3536
             return false;
3537 3537
         }
3538 3538
 
3539 3539
 		// If this is an admin comment or it has been added by the user.
3540
-		if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3541
-			$user         = get_user_by( 'id', get_current_user_id() );
3540
+		if (is_user_logged_in() && (wpinv_current_user_can_manage_invoicing() || $added_by_user)) {
3541
+			$user = get_user_by('id', get_current_user_id());
3542 3542
             $author       = $user->display_name;
3543 3543
             $author_email = $user->user_email;
3544 3544
 		} 
3545 3545
 
3546
-		if ( $system ) {
3547
-			$author       = 'System';
3546
+		if ($system) {
3547
+			$author = 'System';
3548 3548
             $author_email = '[email protected]';
3549 3549
 		}
3550 3550
 
3551
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3551
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3552 3552
 
3553 3553
 	}
3554 3554
 
3555 3555
 	/**
3556 3556
      * Generates a unique key for the invoice.
3557 3557
      */
3558
-    public function generate_key( $string = '' ) {
3559
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3558
+    public function generate_key($string = '') {
3559
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3560 3560
         return strtolower(
3561
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3561
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3562 3562
         );
3563 3563
     }
3564 3564
 
@@ -3568,11 +3568,11 @@  discard block
 block discarded – undo
3568 3568
     public function generate_number() {
3569 3569
         $number = $this->get_id();
3570 3570
 
3571
-        if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) {
3572
-            $number = wpinv_get_next_invoice_number( $this->post_type );
3571
+        if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) {
3572
+            $number = wpinv_get_next_invoice_number($this->post_type);
3573 3573
         }
3574 3574
 
3575
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3575
+		$number = wpinv_format_invoice_number($number, $this->post_type);
3576 3576
 
3577 3577
 		return $number;
3578 3578
 	}
@@ -3586,47 +3586,47 @@  discard block
 block discarded – undo
3586 3586
 		// Reset status transition variable.
3587 3587
 		$this->status_transition = false;
3588 3588
 
3589
-		if ( $status_transition ) {
3589
+		if ($status_transition) {
3590 3590
 			try {
3591 3591
 
3592 3592
 				// Fire a hook for the status change.
3593
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3593
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
3594 3594
 
3595 3595
 				// @deprecated this is deprecated and will be removed in the future.
3596
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3596
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3597 3597
 
3598
-				if ( ! empty( $status_transition['from'] ) ) {
3598
+				if (!empty($status_transition['from'])) {
3599 3599
 
3600 3600
 					/* translators: 1: old invoice status 2: new invoice status */
3601
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3601
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3602 3602
 
3603 3603
 					// Fire another hook.
3604
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3605
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3604
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
3605
+					do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this);
3606 3606
 
3607 3607
 					// @deprecated this is deprecated and will be removed in the future.
3608
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3608
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3609 3609
 
3610 3610
 					// Note the transition occurred.
3611
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3611
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3612 3612
 
3613 3613
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3614 3614
 					if (
3615
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3616
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3615
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3616
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3617 3617
 					) {
3618
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3618
+						do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition);
3619 3619
 					}
3620 3620
 				} else {
3621 3621
 					/* translators: %s: new invoice status */
3622
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3622
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3623 3623
 
3624 3624
 					// Note the transition occurred.
3625
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3625
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3626 3626
 
3627 3627
 				}
3628
-			} catch ( Exception $e ) {
3629
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3628
+			} catch (Exception $e) {
3629
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3630 3630
 			}
3631 3631
 		}
3632 3632
 	}
@@ -3634,13 +3634,13 @@  discard block
 block discarded – undo
3634 3634
 	/**
3635 3635
 	 * Updates an invoice status.
3636 3636
 	 */
3637
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3637
+	public function update_status($new_status = false, $note = '', $manual = false) {
3638 3638
 
3639 3639
 		// Fires before updating a status.
3640
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3640
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3641 3641
 
3642 3642
 		// Update the status.
3643
-		$this->set_status( $new_status, $note, $manual );
3643
+		$this->set_status($new_status, $note, $manual);
3644 3644
 
3645 3645
 		// Save the order.
3646 3646
 		return $this->save();
@@ -3651,18 +3651,18 @@  discard block
 block discarded – undo
3651 3651
 	 * @deprecated
3652 3652
 	 */
3653 3653
 	public function refresh_item_ids() {
3654
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3655
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3654
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3655
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3656 3656
 	}
3657 3657
 
3658 3658
 	/**
3659 3659
 	 * @deprecated
3660 3660
 	 */
3661
-	public function update_items( $temp = false ) {
3661
+	public function update_items($temp = false) {
3662 3662
 
3663
-		$this->set_items( $this->get_items() );
3663
+		$this->set_items($this->get_items());
3664 3664
 
3665
-		if ( ! $temp ) {
3665
+		if (!$temp) {
3666 3666
 			$this->save();
3667 3667
 		}
3668 3668
 
@@ -3676,11 +3676,11 @@  discard block
 block discarded – undo
3676 3676
 
3677 3677
         $discount_code = $this->get_discount_code();
3678 3678
 
3679
-        if ( empty( $discount_code ) ) {
3679
+        if (empty($discount_code)) {
3680 3680
             return false;
3681 3681
         }
3682 3682
 
3683
-        $discount = wpinv_get_discount_obj( $discount_code );
3683
+        $discount = wpinv_get_discount_obj($discount_code);
3684 3684
 
3685 3685
         // Ensure it is active.
3686 3686
         return $discount->exists();
@@ -3691,7 +3691,7 @@  discard block
 block discarded – undo
3691 3691
 	 * Refunds an invoice.
3692 3692
 	 */
3693 3693
     public function refund() {
3694
-		$this->set_status( 'wpi-refunded' );
3694
+		$this->set_status('wpi-refunded');
3695 3695
         $this->save();
3696 3696
 	}
3697 3697
 
@@ -3700,56 +3700,56 @@  discard block
 block discarded – undo
3700 3700
 	 * 
3701 3701
 	 * @param string $transaction_id
3702 3702
 	 */
3703
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3703
+    public function mark_paid($transaction_id = null, $note = '') {
3704 3704
 
3705 3705
 		// Set the transaction id.
3706
-		if ( empty( $transaction_id ) ) {
3706
+		if (empty($transaction_id)) {
3707 3707
 			$transaction_id = $this->generate_key('trans_');
3708 3708
 		}
3709 3709
 
3710
-		if ( ! $this->get_transaction_id() ) {
3711
-			$this->set_transaction_id( $transaction_id );
3710
+		if (!$this->get_transaction_id()) {
3711
+			$this->set_transaction_id($transaction_id);
3712 3712
 		}
3713 3713
 
3714
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3714
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3715 3715
 			return $this->save();
3716 3716
 		}
3717 3717
 
3718 3718
 		// Set the completed date.
3719
-		$this->set_date_completed( current_time( 'mysql' ) );
3719
+		$this->set_date_completed(current_time('mysql'));
3720 3720
 
3721 3721
 		// Set the new status.
3722
-		if ( $this->is_renewal() ) {
3722
+		if ($this->is_renewal()) {
3723 3723
 
3724 3724
 			$_note = sprintf(
3725
-				__( 'Renewed via %s', 'invoicing' ),
3726
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3725
+				__('Renewed via %s', 'invoicing'),
3726
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3727 3727
 			);
3728 3728
 
3729
-			if ( 'none' == $this->get_gateway() ) {
3729
+			if ('none' == $this->get_gateway()) {
3730 3730
 				$_note = $note;
3731 3731
 			}
3732 3732
 
3733
-			$this->set_status( 'wpi-renewal', $_note );
3733
+			$this->set_status('wpi-renewal', $_note);
3734 3734
 
3735 3735
 		} else {
3736 3736
 
3737 3737
 			$_note = sprintf(
3738
-				__( 'Paid via %s', 'invoicing' ),
3739
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3738
+				__('Paid via %s', 'invoicing'),
3739
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3740 3740
 			);
3741 3741
 
3742
-			if ( 'none' == $this->get_gateway() ) {
3742
+			if ('none' == $this->get_gateway()) {
3743 3743
 				$_note = $note;
3744 3744
 			}
3745 3745
 
3746
-			$this->set_status( 'publish',$_note );
3746
+			$this->set_status('publish', $_note);
3747 3747
 
3748 3748
 		}
3749 3749
 
3750 3750
 		// Set checkout mode.
3751
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3752
-		$this->set_mode( $mode );
3751
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3752
+		$this->set_mode($mode);
3753 3753
 
3754 3754
 		// Save the invoice.
3755 3755
         $this->save();
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -7,86 +7,86 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_item_quantities_enabled() {
15
-    $ret = wpinv_get_option( 'item_quantities', true );
15
+    $ret = wpinv_get_option('item_quantities', true);
16 16
 
17
-    return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret );
17
+    return (bool) apply_filters('wpinv_item_quantities_enabled', $ret);
18 18
 }
19 19
 
20 20
 function wpinv_get_ip() {
21 21
     $ip = '127.0.0.1';
22 22
 
23
-    if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
24
-        $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
25
-    } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
26
-        $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
27
-    } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) {
28
-        $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
23
+    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
24
+        $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']);
25
+    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
26
+        $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']);
27
+    } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
28
+        $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']);
29 29
     }
30 30
 
31
-    return apply_filters( 'wpinv_get_ip', $ip );
31
+    return apply_filters('wpinv_get_ip', $ip);
32 32
 }
33 33
 
34 34
 function wpinv_get_user_agent() {
35
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
36
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
35
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
36
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
37 37
     } else {
38 38
         $user_agent = '';
39 39
     }
40 40
 
41
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
41
+    return apply_filters('wpinv_get_user_agent', $user_agent);
42 42
 }
43 43
 
44
-function wpinv_sanitize_amount( $amount, $decimals = NULL ) {
44
+function wpinv_sanitize_amount($amount, $decimals = NULL) {
45 45
     $is_negative   = false;
46 46
     $thousands_sep = wpinv_thousands_separator();
47 47
     $decimal_sep   = wpinv_decimal_separator();
48
-    if ( $decimals === NULL ) {
48
+    if ($decimals === NULL) {
49 49
         $decimals = wpinv_decimals();
50 50
     }
51 51
 
52 52
     // Sanitize the amount
53
-    if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) {
54
-        if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
55
-            $amount = str_replace( $thousands_sep, '', $amount );
56
-        } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) {
57
-            $amount = str_replace( '.', '', $amount );
53
+    if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) {
54
+        if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) {
55
+            $amount = str_replace($thousands_sep, '', $amount);
56
+        } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) {
57
+            $amount = str_replace('.', '', $amount);
58 58
         }
59 59
 
60
-        $amount = str_replace( $decimal_sep, '.', $amount );
61
-    } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
62
-        $amount = str_replace( $thousands_sep, '', $amount );
60
+        $amount = str_replace($decimal_sep, '.', $amount);
61
+    } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
62
+        $amount = str_replace($thousands_sep, '', $amount);
63 63
     }
64 64
 
65
-    if( $amount < 0 ) {
65
+    if ($amount < 0) {
66 66
         $is_negative = true;
67 67
     }
68 68
 
69
-    $amount   = preg_replace( '/[^0-9\.]/', '', $amount );
69
+    $amount   = preg_replace('/[^0-9\.]/', '', $amount);
70 70
 
71
-    $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount );
72
-    $amount   = number_format( (double) $amount, absint( $decimals ), '.', '' );
71
+    $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount);
72
+    $amount   = number_format((double) $amount, absint($decimals), '.', '');
73 73
 
74
-    if( $is_negative ) {
74
+    if ($is_negative) {
75 75
         $amount *= -1;
76 76
     }
77 77
 
78
-    return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals );
78
+    return apply_filters('wpinv_sanitize_amount', $amount, $decimals);
79 79
 }
80
-add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
80
+add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1);
81 81
 
82
-function wpinv_round_amount( $amount, $decimals = NULL ) {
83
-    if ( $decimals === NULL ) {
82
+function wpinv_round_amount($amount, $decimals = NULL) {
83
+    if ($decimals === NULL) {
84 84
         $decimals = wpinv_decimals();
85 85
     }
86 86
     
87
-    $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) );
87
+    $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals)));
88 88
 
89
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
89
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
90 90
 }
91 91
 
92 92
 /**
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
  * @since 1.0.19
96 96
  * @return array
97 97
  */
98
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
98
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
99 99
 	$invoice_statuses = array(
100
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
101
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
102
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
103
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
104
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
105
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
106
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
107
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
100
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
101
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
102
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
103
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
104
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
105
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
106
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
107
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
108 108
     );
109 109
 
110
-    if ( $draft ) {
111
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
110
+    if ($draft) {
111
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
112 112
     }
113 113
 
114
-    if ( $trashed ) {
115
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
114
+    if ($trashed) {
115
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
116 116
     }
117 117
 
118
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
118
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
119 119
 }
120 120
 
121
-function wpinv_status_nicename( $status ) {
122
-    $statuses = wpinv_get_invoice_statuses( true, true );
123
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' );
121
+function wpinv_status_nicename($status) {
122
+    $statuses = wpinv_get_invoice_statuses(true, true);
123
+    $status   = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing');
124 124
 
125 125
     return $status;
126 126
 }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  * Retrieves the default currency code.
130 130
  */
131 131
 function wpinv_get_currency() {
132
-    return apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
132
+    return apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
133 133
 }
134 134
 
135 135
 /**
@@ -137,61 +137,61 @@  discard block
 block discarded – undo
137 137
  * 
138 138
  * @param string|null $currency The currency code. Defaults to the default currency.
139 139
  */
140
-function wpinv_currency_symbol( $currency = null ) {
140
+function wpinv_currency_symbol($currency = null) {
141 141
 
142 142
     // Prepare the currency.
143
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
143
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
144 144
 
145 145
     // Fetch all symbols.
146 146
     $symbols = wpinv_get_currency_symbols();
147 147
 
148 148
     // Fetch this currencies symbol.
149
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
149
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
150 150
 
151 151
     // Filter the symbol.
152
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
152
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
153 153
 }
154 154
 
155 155
 function wpinv_currency_position() {
156
-    $position = wpinv_get_option( 'currency_position', 'left' );
156
+    $position = wpinv_get_option('currency_position', 'left');
157 157
     
158
-    return apply_filters( 'wpinv_currency_position', $position );
158
+    return apply_filters('wpinv_currency_position', $position);
159 159
 }
160 160
 
161 161
 function wpinv_thousands_separator() {
162
-    $thousand_sep = wpinv_get_option( 'thousands_separator', ',' );
162
+    $thousand_sep = wpinv_get_option('thousands_separator', ',');
163 163
     
164
-    return apply_filters( 'wpinv_thousands_separator', $thousand_sep );
164
+    return apply_filters('wpinv_thousands_separator', $thousand_sep);
165 165
 }
166 166
 
167 167
 function wpinv_decimal_separator() {
168
-    $decimal_sep = wpinv_get_option( 'decimal_separator', '.' );
168
+    $decimal_sep = wpinv_get_option('decimal_separator', '.');
169 169
     
170
-    return apply_filters( 'wpinv_decimal_separator', $decimal_sep );
170
+    return apply_filters('wpinv_decimal_separator', $decimal_sep);
171 171
 }
172 172
 
173 173
 function wpinv_decimals() {
174
-    $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) );
174
+    $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2));
175 175
     
176
-    return absint( $decimals );
176
+    return absint($decimals);
177 177
 }
178 178
 
179 179
 /**
180 180
  * Retrieves a list of all supported currencies.
181 181
  */
182 182
 function wpinv_get_currencies() {
183
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
183
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
184 184
 }
185 185
 
186 186
 /**
187 187
  * Retrieves a list of all currency symbols.
188 188
  */
189 189
 function wpinv_get_currency_symbols() {
190
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
190
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
191 191
 }
192 192
 
193
-function wpinv_price( $amount = '', $currency = '' ) {
194
-    if( empty( $currency ) ) {
193
+function wpinv_price($amount = '', $currency = '') {
194
+    if (empty($currency)) {
195 195
         $currency = wpinv_get_currency();
196 196
     }
197 197
 
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 
200 200
     $negative = $amount < 0;
201 201
 
202
-    if ( $negative ) {
203
-        $amount = substr( $amount, 1 );
202
+    if ($negative) {
203
+        $amount = substr($amount, 1);
204 204
     }
205 205
 
206
-    $symbol = wpinv_currency_symbol( $currency );
206
+    $symbol = wpinv_currency_symbol($currency);
207 207
 
208
-    if ( $position == 'left' || $position == 'left_space' ) {
209
-        switch ( $currency ) {
208
+    if ($position == 'left' || $position == 'left_space') {
209
+        switch ($currency) {
210 210
             case "GBP" :
211 211
             case "BRL" :
212 212
             case "EUR" :
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
             case "NZD" :
219 219
             case "SGD" :
220 220
             case "JPY" :
221
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
221
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
222 222
                 break;
223 223
             default :
224 224
                 //$price = $currency . ' ' . $amount;
225
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
225
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
226 226
                 break;
227 227
         }
228 228
     } else {
229
-        switch ( $currency ) {
229
+        switch ($currency) {
230 230
             case "GBP" :
231 231
             case "BRL" :
232 232
             case "EUR" :
@@ -237,83 +237,83 @@  discard block
 block discarded – undo
237 237
             case "MXN" :
238 238
             case "SGD" :
239 239
             case "JPY" :
240
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
240
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
241 241
                 break;
242 242
             default :
243 243
                 //$price = $amount . ' ' . $currency;
244
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
244
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
245 245
                 break;
246 246
         }
247 247
     }
248 248
     
249
-    if ( $negative ) {
249
+    if ($negative) {
250 250
         $price = '-' . $price;
251 251
     }
252 252
     
253
-    $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount );
253
+    $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount);
254 254
 
255 255
     return $price;
256 256
 }
257 257
 
258
-function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) {
258
+function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) {
259 259
     $thousands_sep = wpinv_thousands_separator();
260 260
     $decimal_sep   = wpinv_decimal_separator();
261 261
 
262
-    if ( $decimals === NULL ) {
262
+    if ($decimals === NULL) {
263 263
         $decimals = wpinv_decimals();
264 264
     }
265 265
 
266
-    if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) {
267
-        $whole = substr( $amount, 0, $sep_found );
268
-        $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
266
+    if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) {
267
+        $whole = substr($amount, 0, $sep_found);
268
+        $part = substr($amount, $sep_found + 1, (strlen($amount) - 1));
269 269
         $amount = $whole . '.' . $part;
270 270
     }
271 271
 
272
-    if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
273
-        $amount = str_replace( ',', '', $amount );
272
+    if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
273
+        $amount = str_replace(',', '', $amount);
274 274
     }
275 275
 
276
-    if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
277
-        $amount = str_replace( ' ', '', $amount );
276
+    if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) {
277
+        $amount = str_replace(' ', '', $amount);
278 278
     }
279 279
 
280
-    if ( empty( $amount ) ) {
280
+    if (empty($amount)) {
281 281
         $amount = 0;
282 282
     }
283 283
     
284
-    $decimals  = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate );
285
-    $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep );
284
+    $decimals  = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate);
285
+    $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep);
286 286
     
287
-    if ( $calculate ) {
288
-        if ( $thousands_sep === "," ) {
289
-            $formatted = str_replace( ",", "", $formatted );
287
+    if ($calculate) {
288
+        if ($thousands_sep === ",") {
289
+            $formatted = str_replace(",", "", $formatted);
290 290
         }
291 291
         
292
-        if ( $decimal_sep === "," ) {
293
-            $formatted = str_replace( ",", ".", $formatted );
292
+        if ($decimal_sep === ",") {
293
+            $formatted = str_replace(",", ".", $formatted);
294 294
         }
295 295
     }
296 296
 
297
-    return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate );
297
+    return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate);
298 298
 }
299
-add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
299
+add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1);
300 300
 
301
-function wpinv_sanitize_key( $key ) {
301
+function wpinv_sanitize_key($key) {
302 302
     $raw_key = $key;
303
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
303
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
304 304
 
305
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
305
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
306 306
 }
307 307
 
308
-function wpinv_get_file_extension( $str ) {
309
-    $parts = explode( '.', $str );
310
-    return end( $parts );
308
+function wpinv_get_file_extension($str) {
309
+    $parts = explode('.', $str);
310
+    return end($parts);
311 311
 }
312 312
 
313
-function wpinv_string_is_image_url( $str ) {
314
-    $ext = wpinv_get_file_extension( $str );
313
+function wpinv_string_is_image_url($str) {
314
+    $ext = wpinv_get_file_extension($str);
315 315
 
316
-    switch ( strtolower( $ext ) ) {
316
+    switch (strtolower($ext)) {
317 317
         case 'jpeg';
318 318
         case 'jpg';
319 319
             $return = true;
@@ -329,33 +329,33 @@  discard block
 block discarded – undo
329 329
             break;
330 330
     }
331 331
 
332
-    return (bool)apply_filters( 'wpinv_string_is_image', $return, $str );
332
+    return (bool) apply_filters('wpinv_string_is_image', $return, $str);
333 333
 }
334 334
 
335
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
336
-    $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG );
335
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
336
+    $should_log = apply_filters('wpinv_log_errors', WP_DEBUG);
337 337
     
338
-    if ( true === $should_log ) {
338
+    if (true === $should_log) {
339 339
         $label = '';
340
-        if ( $file && $file !== '' ) {
341
-            $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' );
340
+        if ($file && $file !== '') {
341
+            $label .= basename($file) . ($line ? '(' . $line . ')' : '');
342 342
         }
343 343
         
344
-        if ( $title && $title !== '' ) {
344
+        if ($title && $title !== '') {
345 345
             $label = $label !== '' ? $label . ' ' : '';
346 346
             $label .= $title . ' ';
347 347
         }
348 348
         
349
-        $label = $label !== '' ? trim( $label ) . ' : ' : '';
349
+        $label = $label !== '' ? trim($label) . ' : ' : '';
350 350
         
351
-        if ( is_array( $log ) || is_object( $log ) ) {
352
-            error_log( $label . print_r( $log, true ) );
351
+        if (is_array($log) || is_object($log)) {
352
+            error_log($label . print_r($log, true));
353 353
         } else {
354
-            error_log( $label . $log );
354
+            error_log($label . $log);
355 355
         }
356 356
 
357
-        error_log( wp_debug_backtrace_summary() );
358
-        if ( $exit ) {
357
+        error_log(wp_debug_backtrace_summary());
358
+        if ($exit) {
359 359
             exit;
360 360
         }
361 361
     }
@@ -363,32 +363,32 @@  discard block
 block discarded – undo
363 363
 
364 364
 function wpinv_is_ajax_disabled() {
365 365
     $retval = false;
366
-    return apply_filters( 'wpinv_is_ajax_disabled', $retval );
366
+    return apply_filters('wpinv_is_ajax_disabled', $retval);
367 367
 }
368 368
 
369
-function wpinv_get_current_page_url( $nocache = false ) {
369
+function wpinv_get_current_page_url($nocache = false) {
370 370
     global $wp;
371 371
 
372
-    if ( get_option( 'permalink_structure' ) ) {
373
-        $base = trailingslashit( home_url( $wp->request ) );
372
+    if (get_option('permalink_structure')) {
373
+        $base = trailingslashit(home_url($wp->request));
374 374
     } else {
375
-        $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
376
-        $base = remove_query_arg( array( 'post_type', 'name' ), $base );
375
+        $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
376
+        $base = remove_query_arg(array('post_type', 'name'), $base);
377 377
     }
378 378
 
379 379
     $scheme = is_ssl() ? 'https' : 'http';
380
-    $uri    = set_url_scheme( $base, $scheme );
380
+    $uri    = set_url_scheme($base, $scheme);
381 381
 
382
-    if ( is_front_page() ) {
383
-        $uri = home_url( '/' );
384
-    } elseif ( wpinv_is_checkout( array(), false ) ) {
382
+    if (is_front_page()) {
383
+        $uri = home_url('/');
384
+    } elseif (wpinv_is_checkout(array(), false)) {
385 385
         $uri = wpinv_get_checkout_uri();
386 386
     }
387 387
 
388
-    $uri = apply_filters( 'wpinv_get_current_page_url', $uri );
388
+    $uri = apply_filters('wpinv_get_current_page_url', $uri);
389 389
 
390
-    if ( $nocache ) {
391
-        $uri = wpinv_add_cache_busting( $uri );
390
+    if ($nocache) {
391
+        $uri = wpinv_add_cache_busting($uri);
392 392
     }
393 393
 
394 394
     return $uri;
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
  * @param string $name  Constant name.
402 402
  * @param mixed  $value Value.
403 403
  */
404
-function getpaid_maybe_define_constant( $name, $value ) {
405
-	if ( ! defined( $name ) ) {
406
-		define( $name, $value );
404
+function getpaid_maybe_define_constant($name, $value) {
405
+	if (!defined($name)) {
406
+		define($name, $value);
407 407
 	}
408 408
 }
409 409
 
410 410
 function wpinv_get_php_arg_separator_output() {
411
-	return ini_get( 'arg_separator.output' );
411
+	return ini_get('arg_separator.output');
412 412
 }
413 413
 
414
-function wpinv_rgb_from_hex( $color ) {
415
-    $color = str_replace( '#', '', $color );
414
+function wpinv_rgb_from_hex($color) {
415
+    $color = str_replace('#', '', $color);
416 416
 
417 417
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
418
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
419
-    if ( empty( $color ) ) {
418
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
419
+    if (empty($color)) {
420 420
         return NULL;
421 421
     }
422 422
 
423
-    $color = str_split( $color );
423
+    $color = str_split($color);
424 424
 
425 425
     $rgb      = array();
426
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
427
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
428
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
426
+    $rgb['R'] = hexdec($color[0] . $color[1]);
427
+    $rgb['G'] = hexdec($color[2] . $color[3]);
428
+    $rgb['B'] = hexdec($color[4] . $color[5]);
429 429
 
430 430
     return $rgb;
431 431
 }
432 432
 
433
-function wpinv_hex_darker( $color, $factor = 30 ) {
434
-    $base  = wpinv_rgb_from_hex( $color );
433
+function wpinv_hex_darker($color, $factor = 30) {
434
+    $base  = wpinv_rgb_from_hex($color);
435 435
     $color = '#';
436 436
 
437
-    foreach ( $base as $k => $v ) {
437
+    foreach ($base as $k => $v) {
438 438
         $amount      = $v / 100;
439
-        $amount      = round( $amount * $factor );
439
+        $amount      = round($amount * $factor);
440 440
         $new_decimal = $v - $amount;
441 441
 
442
-        $new_hex_component = dechex( $new_decimal );
443
-        if ( strlen( $new_hex_component ) < 2 ) {
442
+        $new_hex_component = dechex($new_decimal);
443
+        if (strlen($new_hex_component) < 2) {
444 444
             $new_hex_component = "0" . $new_hex_component;
445 445
         }
446 446
         $color .= $new_hex_component;
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
     return $color;
450 450
 }
451 451
 
452
-function wpinv_hex_lighter( $color, $factor = 30 ) {
453
-    $base  = wpinv_rgb_from_hex( $color );
452
+function wpinv_hex_lighter($color, $factor = 30) {
453
+    $base  = wpinv_rgb_from_hex($color);
454 454
     $color = '#';
455 455
 
456
-    foreach ( $base as $k => $v ) {
456
+    foreach ($base as $k => $v) {
457 457
         $amount      = 255 - $v;
458 458
         $amount      = $amount / 100;
459
-        $amount      = round( $amount * $factor );
459
+        $amount      = round($amount * $factor);
460 460
         $new_decimal = $v + $amount;
461 461
 
462
-        $new_hex_component = dechex( $new_decimal );
463
-        if ( strlen( $new_hex_component ) < 2 ) {
462
+        $new_hex_component = dechex($new_decimal);
463
+        if (strlen($new_hex_component) < 2) {
464 464
             $new_hex_component = "0" . $new_hex_component;
465 465
         }
466 466
         $color .= $new_hex_component;
@@ -469,22 +469,22 @@  discard block
 block discarded – undo
469 469
     return $color;
470 470
 }
471 471
 
472
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
473
-    $hex = str_replace( '#', '', $color );
472
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
473
+    $hex = str_replace('#', '', $color);
474 474
 
475
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
476
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
477
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
475
+    $c_r = hexdec(substr($hex, 0, 2));
476
+    $c_g = hexdec(substr($hex, 2, 2));
477
+    $c_b = hexdec(substr($hex, 4, 2));
478 478
 
479
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
479
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
480 480
 
481 481
     return $brightness > 155 ? $dark : $light;
482 482
 }
483 483
 
484
-function wpinv_format_hex( $hex ) {
485
-    $hex = trim( str_replace( '#', '', $hex ) );
484
+function wpinv_format_hex($hex) {
485
+    $hex = trim(str_replace('#', '', $hex));
486 486
 
487
-    if ( strlen( $hex ) == 3 ) {
487
+    if (strlen($hex) == 3) {
488 488
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
489 489
     }
490 490
 
@@ -504,12 +504,12 @@  discard block
 block discarded – undo
504 504
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
505 505
  * @return string
506 506
  */
507
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
508
-    if ( function_exists( 'mb_strimwidth' ) ) {
509
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
507
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
508
+    if (function_exists('mb_strimwidth')) {
509
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
510 510
     }
511 511
     
512
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
512
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
513 513
 }
514 514
 
515 515
 /**
@@ -521,28 +521,28 @@  discard block
 block discarded – undo
521 521
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
522 522
  * @return int Returns the number of characters in string.
523 523
  */
524
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
525
-    if ( function_exists( 'mb_strlen' ) ) {
526
-        return mb_strlen( $str, $encoding );
524
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
525
+    if (function_exists('mb_strlen')) {
526
+        return mb_strlen($str, $encoding);
527 527
     }
528 528
         
529
-    return strlen( $str );
529
+    return strlen($str);
530 530
 }
531 531
 
532
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
533
-    if ( function_exists( 'mb_strtolower' ) ) {
534
-        return mb_strtolower( $str, $encoding );
532
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
533
+    if (function_exists('mb_strtolower')) {
534
+        return mb_strtolower($str, $encoding);
535 535
     }
536 536
     
537
-    return strtolower( $str );
537
+    return strtolower($str);
538 538
 }
539 539
 
540
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
541
-    if ( function_exists( 'mb_strtoupper' ) ) {
542
-        return mb_strtoupper( $str, $encoding );
540
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
541
+    if (function_exists('mb_strtoupper')) {
542
+        return mb_strtoupper($str, $encoding);
543 543
     }
544 544
     
545
-    return strtoupper( $str );
545
+    return strtoupper($str);
546 546
 }
547 547
 
548 548
 /**
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
557 557
  * @return int Returns the position of the first occurrence of search in the string.
558 558
  */
559
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
560
-    if ( function_exists( 'mb_strpos' ) ) {
561
-        return mb_strpos( $str, $find, $offset, $encoding );
559
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
560
+    if (function_exists('mb_strpos')) {
561
+        return mb_strpos($str, $find, $offset, $encoding);
562 562
     }
563 563
         
564
-    return strpos( $str, $find, $offset );
564
+    return strpos($str, $find, $offset);
565 565
 }
566 566
 
567 567
 /**
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
576 576
  * @return int Returns the position of the last occurrence of search.
577 577
  */
578
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
579
-    if ( function_exists( 'mb_strrpos' ) ) {
580
-        return mb_strrpos( $str, $find, $offset, $encoding );
578
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
579
+    if (function_exists('mb_strrpos')) {
580
+        return mb_strrpos($str, $find, $offset, $encoding);
581 581
     }
582 582
         
583
-    return strrpos( $str, $find, $offset );
583
+    return strrpos($str, $find, $offset);
584 584
 }
585 585
 
586 586
 /**
@@ -595,16 +595,16 @@  discard block
 block discarded – undo
595 595
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
596 596
  * @return string
597 597
  */
598
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
599
-    if ( function_exists( 'mb_substr' ) ) {
600
-        if ( $length === null ) {
601
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
598
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
599
+    if (function_exists('mb_substr')) {
600
+        if ($length === null) {
601
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
602 602
         } else {
603
-            return mb_substr( $str, $start, $length, $encoding );
603
+            return mb_substr($str, $start, $length, $encoding);
604 604
         }
605 605
     }
606 606
         
607
-    return substr( $str, $start, $length );
607
+    return substr($str, $start, $length);
608 608
 }
609 609
 
610 610
 /**
@@ -616,48 +616,48 @@  discard block
 block discarded – undo
616 616
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
617 617
  * @return string The width of string.
618 618
  */
619
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
620
-    if ( function_exists( 'mb_strwidth' ) ) {
621
-        return mb_strwidth( $str, $encoding );
619
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
620
+    if (function_exists('mb_strwidth')) {
621
+        return mb_strwidth($str, $encoding);
622 622
     }
623 623
     
624
-    return wpinv_utf8_strlen( $str, $encoding );
624
+    return wpinv_utf8_strlen($str, $encoding);
625 625
 }
626 626
 
627
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
628
-    if ( function_exists( 'mb_strlen' ) ) {
629
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
627
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
628
+    if (function_exists('mb_strlen')) {
629
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
630 630
         $str_end = "";
631 631
         
632
-        if ( $lower_str_end ) {
633
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
632
+        if ($lower_str_end) {
633
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
634 634
         } else {
635
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
635
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
636 636
         }
637 637
 
638 638
         return $first_letter . $str_end;
639 639
     }
640 640
     
641
-    return ucfirst( $str );
641
+    return ucfirst($str);
642 642
 }
643 643
 
644
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
645
-    if ( function_exists( 'mb_convert_case' ) ) {
646
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
644
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
645
+    if (function_exists('mb_convert_case')) {
646
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
647 647
     }
648 648
     
649
-    return ucwords( $str );
649
+    return ucwords($str);
650 650
 }
651 651
 
652
-function wpinv_period_in_days( $period, $unit ) {
653
-    $period = absint( $period );
652
+function wpinv_period_in_days($period, $unit) {
653
+    $period = absint($period);
654 654
     
655
-    if ( $period > 0 ) {
656
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
655
+    if ($period > 0) {
656
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
657 657
             $period = $period * 7;
658
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
658
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
659 659
             $period = $period * 30;
660
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
660
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
661 661
             $period = $period * 365;
662 662
         }
663 663
     }
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
     return $period;
666 666
 }
667 667
 
668
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
669
-    if ( function_exists( 'cal_days_in_month' ) ) {
670
-        return cal_days_in_month( $calendar, $month, $year );
668
+function wpinv_cal_days_in_month($calendar, $month, $year) {
669
+    if (function_exists('cal_days_in_month')) {
670
+        return cal_days_in_month($calendar, $month, $year);
671 671
     }
672 672
 
673 673
     // Fallback in case the calendar extension is not loaded in PHP
674 674
     // Only supports Gregorian calendar
675
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
675
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
676 676
 }
677 677
 
678 678
 /**
@@ -683,11 +683,11 @@  discard block
 block discarded – undo
683 683
  *
684 684
  * @return string
685 685
  */
686
-function wpi_help_tip( $tip, $allow_html = false ) {
687
-    if ( $allow_html ) {
688
-        $tip = wpi_sanitize_tooltip( $tip );
686
+function wpi_help_tip($tip, $allow_html = false) {
687
+    if ($allow_html) {
688
+        $tip = wpi_sanitize_tooltip($tip);
689 689
     } else {
690
-        $tip = esc_attr( $tip );
690
+        $tip = esc_attr($tip);
691 691
     }
692 692
 
693 693
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -701,8 +701,8 @@  discard block
 block discarded – undo
701 701
  * @param string $var
702 702
  * @return string
703 703
  */
704
-function wpi_sanitize_tooltip( $var ) {
705
-    return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
704
+function wpi_sanitize_tooltip($var) {
705
+    return htmlspecialchars(wp_kses(html_entity_decode($var), array(
706 706
         'br'     => array(),
707 707
         'em'     => array(),
708 708
         'strong' => array(),
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
         'li'     => array(),
713 713
         'ol'     => array(),
714 714
         'p'      => array(),
715
-    ) ) );
715
+    )));
716 716
 }
717 717
 
718 718
 /**
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
  */
723 723
 function wpinv_get_screen_ids() {
724 724
 
725
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
725
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
726 726
 
727 727
     $screen_ids = array(
728 728
         'toplevel_page_' . $screen_id,
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
         'invoicing_page_wpi-addons',
741 741
     );
742 742
 
743
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
743
+    return apply_filters('wpinv_screen_ids', $screen_ids);
744 744
 }
745 745
 
746 746
 /**
@@ -751,14 +751,14 @@  discard block
 block discarded – undo
751 751
  * @param array|string $list List of values.
752 752
  * @return array Sanitized array of values.
753 753
  */
754
-function wpinv_parse_list( $list ) {
754
+function wpinv_parse_list($list) {
755 755
 
756
-    if ( empty( $list ) ) {
756
+    if (empty($list)) {
757 757
         $list = array();
758 758
     }
759 759
 
760
-	if ( ! is_array( $list ) ) {
761
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
760
+	if (!is_array($list)) {
761
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
762 762
 	}
763 763
 
764 764
 	return $list;
@@ -772,16 +772,16 @@  discard block
 block discarded – undo
772 772
  * @param string $key Type of data to fetch.
773 773
  * @return mixed Fetched data.
774 774
  */
775
-function wpinv_get_data( $key ) {
775
+function wpinv_get_data($key) {
776 776
 
777 777
     // Try fetching it from the cache.
778
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
779
-    if( $data ) {
778
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
779
+    if ($data) {
780 780
         return $data;
781 781
     }
782 782
 
783
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
784
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
783
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
784
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
785 785
 
786 786
 	return $data;
787 787
 }
@@ -795,10 +795,10 @@  discard block
 block discarded – undo
795 795
  * @param bool $first_empty Whether or not the first item in the list should be empty
796 796
  * @return mixed Fetched data.
797 797
  */
798
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
798
+function wpinv_maybe_add_empty_option($options, $first_empty) {
799 799
 
800
-    if ( ! empty( $options ) && $first_empty ) {
801
-        return array_merge( array( '' => '' ), $options );
800
+    if (!empty($options) && $first_empty) {
801
+        return array_merge(array('' => ''), $options);
802 802
     }
803 803
     return $options;
804 804
 
@@ -810,21 +810,21 @@  discard block
 block discarded – undo
810 810
  * @param mixed $var Data to sanitize.
811 811
  * @return string|array
812 812
  */
813
-function wpinv_clean( $var ) {
813
+function wpinv_clean($var) {
814 814
 
815
-	if ( is_array( $var ) ) {
816
-		return array_map( 'wpinv_clean', $var );
815
+	if (is_array($var)) {
816
+		return array_map('wpinv_clean', $var);
817 817
     }
818 818
 
819
-    if ( is_object( $var ) ) {
820
-		$object_vars = get_object_vars( $var );
821
-		foreach ( $object_vars as $property_name => $property_value ) {
822
-			$var->$property_name = wpinv_clean( $property_value );
819
+    if (is_object($var)) {
820
+		$object_vars = get_object_vars($var);
821
+		foreach ($object_vars as $property_name => $property_value) {
822
+			$var->$property_name = wpinv_clean($property_value);
823 823
         }
824 824
         return $var;
825 825
 	}
826 826
     
827
-    return is_string( $var ) ? sanitize_text_field( $var ) : $var;
827
+    return is_string($var) ? sanitize_text_field($var) : $var;
828 828
 }
829 829
 
830 830
 /**
@@ -833,43 +833,43 @@  discard block
 block discarded – undo
833 833
  * @param string $str Data to convert.
834 834
  * @return string|array
835 835
  */
836
-function getpaid_convert_price_string_to_options( $str ) {
836
+function getpaid_convert_price_string_to_options($str) {
837 837
 
838
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
839
-    $options     = array();
838
+	$raw_options = array_map('trim', explode(',', $str));
839
+    $options = array();
840 840
 
841
-    foreach ( $raw_options as $option ) {
841
+    foreach ($raw_options as $option) {
842 842
 
843
-        if ( '' == $option ) {
843
+        if ('' == $option) {
844 844
             continue;
845 845
         }
846 846
 
847
-        $option = array_map( 'trim', explode( '|', $option ) );
847
+        $option = array_map('trim', explode('|', $option));
848 848
 
849 849
         $price = null;
850 850
         $label = null;
851 851
 
852
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
853
-            $label  = $option[0];
852
+        if (isset($option[0]) && '' != $option[0]) {
853
+            $label = $option[0];
854 854
         }
855 855
 
856
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
856
+        if (isset($option[1]) && '' != $option[1]) {
857 857
             $price = $option[1];
858 858
         }
859 859
 
860
-        if ( ! isset( $price ) ) {
860
+        if (!isset($price)) {
861 861
             $price = $label;
862 862
         }
863 863
 
864
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
864
+        if (!isset($price) || !is_numeric($price)) {
865 865
             continue;
866 866
         }
867 867
 
868
-        if ( ! isset( $label ) ) {
868
+        if (!isset($label)) {
869 869
             $label = $price;
870 870
         }
871 871
 
872
-        $options[ $price ] = $label;
872
+        $options[$price] = $label;
873 873
     }
874 874
 
875 875
     return $options;
@@ -878,23 +878,23 @@  discard block
 block discarded – undo
878 878
 /**
879 879
  * Returns the help tip.
880 880
  */
881
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
882
-    $additional_classes = sanitize_html_class( $additional_classes );
883
-    $tip                = esc_attr__( $tip );
881
+function getpaid_get_help_tip($tip, $additional_classes = '') {
882
+    $additional_classes = sanitize_html_class($additional_classes);
883
+    $tip                = esc_attr__($tip);
884 884
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
885 885
 }
886 886
 
887 887
 /**
888 888
  * Formats a date
889 889
  */
890
-function getpaid_format_date( $date ) {
890
+function getpaid_format_date($date) {
891 891
 
892
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
892
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
893 893
         return '';
894 894
     }
895 895
 
896 896
 
897
-    return date_i18n( get_option( 'date_format' ), strtotime( $date ) );
897
+    return date_i18n(get_option('date_format'), strtotime($date));
898 898
 
899 899
 }
900 900
 
@@ -905,16 +905,16 @@  discard block
 block discarded – undo
905 905
  * @param  integer $limit Limit size in characters.
906 906
  * @return string
907 907
  */
908
-function getpaid_limit_length( $string, $limit ) {
908
+function getpaid_limit_length($string, $limit) {
909 909
     $str_limit = $limit - 3;
910 910
 
911
-	if ( function_exists( 'mb_strimwidth' ) ) {
912
-		if ( mb_strlen( $string ) > $limit ) {
913
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
911
+	if (function_exists('mb_strimwidth')) {
912
+		if (mb_strlen($string) > $limit) {
913
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
914 914
 		}
915 915
 	} else {
916
-		if ( strlen( $string ) > $limit ) {
917
-			$string = substr( $string, 0, $str_limit ) . '...';
916
+		if (strlen($string) > $limit) {
917
+			$string = substr($string, 0, $str_limit) . '...';
918 918
 		}
919 919
 	}
920 920
     return $string;
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
  * @since 1.0.19
929 929
  */
930 930
 function getpaid_api() {
931
-    return getpaid()->get( 'api' );
931
+    return getpaid()->get('api');
932 932
 }
933 933
 
934 934
 /**
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
  * @since 1.0.19
939 939
  */
940 940
 function getpaid_post_types() {
941
-    return getpaid()->get( 'post_types' );
941
+    return getpaid()->get('post_types');
942 942
 }
943 943
 
944 944
 /**
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
  * @since 1.0.19
949 949
  */
950 950
 function getpaid_session() {
951
-    return getpaid()->get( 'session' );
951
+    return getpaid()->get('session');
952 952
 }
953 953
 
954 954
 /**
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
  * @since 1.0.19
959 959
  */
960 960
 function getpaid_notes() {
961
-    return getpaid()->get( 'notes' );
961
+    return getpaid()->get('notes');
962 962
 }
963 963
 
964 964
 /**
@@ -970,15 +970,15 @@  discard block
 block discarded – undo
970 970
  * 
971 971
  * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query
972 972
  */
973
-function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
973
+function getpaid_get_subscriptions($args = array(), $return = 'results') {
974 974
 
975
-    $query = new GetPaid_Subscriptions_Query( $args );
975
+    $query = new GetPaid_Subscriptions_Query($args);
976 976
 
977
-    if ( 'results' == $return ) {
977
+    if ('results' == $return) {
978 978
         return $query->get_results();
979 979
     }
980 980
 
981
-    if ( 'count' == $return ) {
981
+    if ('count' == $return) {
982 982
         return $query->get_total();
983 983
     }
984 984
 
@@ -995,13 +995,13 @@  discard block
 block discarded – undo
995 995
     return apply_filters(
996 996
         'getpaid_get_subscription_statuses',
997 997
         array(
998
-            'pending'    => __( 'Pending', 'invoicing' ),
999
-            'trialling'  => __( 'Trialing', 'invoicing' ),
1000
-            'active'     => __( 'Active', 'invoicing' ),
1001
-            'failing'    => __( 'Failing', 'invoicing' ),
1002
-            'expired'    => __( 'Expired', 'invoicing' ),
1003
-            'completed'  => __( 'Complete', 'invoicing' ),
1004
-            'cancelled'  =>__( 'Cancelled', 'invoicing' ),
998
+            'pending'    => __('Pending', 'invoicing'),
999
+            'trialling'  => __('Trialing', 'invoicing'),
1000
+            'active'     => __('Active', 'invoicing'),
1001
+            'failing'    => __('Failing', 'invoicing'),
1002
+            'expired'    => __('Expired', 'invoicing'),
1003
+            'completed'  => __('Complete', 'invoicing'),
1004
+            'cancelled'  =>__('Cancelled', 'invoicing'),
1005 1005
         )
1006 1006
     );
1007 1007
 
@@ -1012,9 +1012,9 @@  discard block
 block discarded – undo
1012 1012
  * 
1013 1013
  * @return string
1014 1014
  */
1015
-function getpaid_get_subscription_status_label( $status ) {
1015
+function getpaid_get_subscription_status_label($status) {
1016 1016
     $statuses = getpaid_get_subscription_statuses();
1017
-    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( $status );
1017
+    return isset($statuses[$status]) ? $statuses[$status] : ucfirst($status);
1018 1018
 }
1019 1019
 
1020 1020
 /**
Please login to merge, or discard this patch.