Passed
Push — master ( 1ce22f...41fbb9 )
by Brian
09:44 queued 04:28
created
includes/data-stores/class-getpaid-data.php 2 patches
Indentation   +860 added lines, -860 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 if ( ! defined( 'ABSPATH' ) ) {
12
-	exit;
12
+    exit;
13 13
 }
14 14
 
15 15
 /**
@@ -21,356 +21,356 @@  discard block
 block discarded – undo
21 21
  */
22 22
 abstract class GetPaid_Data {
23 23
 
24
-	/**
25
-	 * ID for this object.
26
-	 *
27
-	 * @since 1.0.19
28
-	 * @var int
29
-	 */
30
-	protected $id = 0;
31
-
32
-	/**
33
-	 * Core data for this object. Name value pairs (name + default value).
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array();
39
-
40
-	/**
41
-	 * Core data changes for this object.
42
-	 *
43
-	 * @since 1.0.19
44
-	 * @var array
45
-	 */
46
-	protected $changes = array();
47
-
48
-	/**
49
-	 * This is false until the object is read from the DB.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @var bool
53
-	 */
54
-	protected $object_read = false;
55
-
56
-	/**
57
-	 * This is the name of this object type.
58
-	 *
59
-	 * @since 1.0.19
60
-	 * @var string
61
-	 */
62
-	protected $object_type = 'data';
63
-
64
-	/**
65
-	 * Extra data for this object. Name value pairs (name + default value).
66
-	 * Used as a standard way for sub classes (like item types) to add
67
-	 * additional information to an inherited class.
68
-	 *
69
-	 * @since 1.0.19
70
-	 * @var array
71
-	 */
72
-	protected $extra_data = array();
73
-
74
-	/**
75
-	 * Set to _data on construct so we can track and reset data if needed.
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @var array
79
-	 */
80
-	protected $default_data = array();
81
-
82
-	/**
83
-	 * Contains a reference to the data store for this class.
84
-	 *
85
-	 * @since 1.0.19
86
-	 * @var GetPaid_Data_Store
87
-	 */
88
-	protected $data_store;
89
-
90
-	/**
91
-	 * Stores meta in cache for future reads.
92
-	 * A group must be set to to enable caching.
93
-	 *
94
-	 * @since 1.0.19
95
-	 * @var string
96
-	 */
97
-	protected $cache_group = '';
98
-
99
-	/**
100
-	 * Stores the last error.
101
-	 *
102
-	 * @since 1.0.19
103
-	 * @var string
104
-	 */
105
-	public $last_error = '';
106
-
107
-	/**
108
-	 * Stores additional meta data.
109
-	 *
110
-	 * @since 1.0.19
111
-	 * @var array
112
-	 */
113
-	protected $meta_data = null;
114
-
115
-	/**
116
-	 * Default constructor.
117
-	 *
118
-	 * @param int|object|array|string $read ID to load from the DB (optional) or already queried data.
119
-	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
122
-		$this->default_data = $this->data;
123
-	}
124
-
125
-	/**
126
-	 * Only store the object ID to avoid serializing the data object instance.
127
-	 *
128
-	 * @return array
129
-	 */
130
-	public function __sleep() {
131
-		return array( 'id' );
132
-	}
133
-
134
-	/**
135
-	 * Re-run the constructor with the object ID.
136
-	 *
137
-	 * If the object no longer exists, remove the ID.
138
-	 */
139
-	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
141
-
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
144
-		}
145
-
146
-	}
147
-
148
-	/**
149
-	 * When the object is cloned, make sure meta is duplicated correctly.
150
-	 *
151
-	 * @since 1.0.19
152
-	 */
153
-	public function __clone() {
154
-		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
160
-				}
161
-			}
162
-		}
163
-	}
164
-
165
-	/**
166
-	 * Get the data store.
167
-	 *
168
-	 * @since  1.0.19
169
-	 * @return object
170
-	 */
171
-	public function get_data_store() {
172
-		return $this->data_store;
173
-	}
174
-
175
-	/**
176
-	 * Get the object type.
177
-	 *
178
-	 * @since  1.0.19
179
-	 * @return string
180
-	 */
181
-	public function get_object_type() {
182
-		return $this->object_type;
183
-	}
184
-
185
-	/**
186
-	 * Returns the unique ID for this object.
187
-	 *
188
-	 * @since  1.0.19
189
-	 * @return int
190
-	 */
191
-	public function get_id() {
192
-		return $this->id;
193
-	}
194
-
195
-	/**
196
-	 * Get form status.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
204
-    }
205
-
206
-	/**
207
-	 * Delete an object, set the ID to 0, and return result.
208
-	 *
209
-	 * @since  1.0.19
210
-	 * @param  bool $force_delete Should the data be deleted permanently.
211
-	 * @return bool result
212
-	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->get_id() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
217
-			return true;
218
-		}
219
-		return false;
220
-	}
221
-
222
-	/**
223
-	 * Save should create or update based on object existence.
224
-	 *
225
-	 * @since  1.0.19
226
-	 * @return int
227
-	 */
228
-	public function save() {
229
-		if ( ! $this->data_store ) {
230
-			return $this->get_id();
231
-		}
232
-
233
-		/**
234
-		 * Trigger action before saving to the DB. Allows you to adjust object props before save.
235
-		 *
236
-		 * @param GetPaid_Data          $this The object being saved.
237
-		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238
-		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
240
-
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
243
-		} else {
244
-			$this->data_store->create( $this );
245
-		}
246
-
247
-		/**
248
-		 * Trigger action after saving to the DB.
249
-		 *
250
-		 * @param GetPaid_Data          $this The object being saved.
251
-		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252
-		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
254
-
255
-		return $this->get_id();
256
-	}
257
-
258
-	/**
259
-	 * Change data to JSON format.
260
-	 *
261
-	 * @since  1.0.19
262
-	 * @return string Data in JSON format.
263
-	 */
264
-	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
266
-	}
267
-
268
-	/**
269
-	 * Returns all data for this object.
270
-	 *
271
-	 * @since  1.0.19
272
-	 * @return array
273
-	 */
274
-	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
276
-	}
277
-
278
-	/**
279
-	 * Returns array of expected data keys for this object.
280
-	 *
281
-	 * @since   1.0.19
282
-	 * @return array
283
-	 */
284
-	public function get_data_keys() {
285
-		return array_keys( $this->data );
286
-	}
287
-
288
-	/**
289
-	 * Returns all "extra" data keys for an object (for sub objects like item types).
290
-	 *
291
-	 * @since  1.0.19
292
-	 * @return array
293
-	 */
294
-	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
296
-	}
297
-
298
-	/**
299
-	 * Filter null meta values from array.
300
-	 *
301
-	 * @since  1.0.19
302
-	 * @param mixed $meta Meta value to check.
303
-	 * @return bool
304
-	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
307
-	}
308
-
309
-	/**
310
-	 * Get All Meta Data.
311
-	 *
312
-	 * @since 1.0.19
313
-	 * @return array of objects.
314
-	 */
315
-	public function get_meta_data() {
316
-		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
318
-	}
319
-
320
-	/**
321
-	 * Check if the key is an internal one.
322
-	 *
323
-	 * @since  1.0.19
324
-	 * @param  string $key Key to check.
325
-	 * @return bool   true if it's an internal key, false otherwise
326
-	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
329
-
330
-		if ( ! $internal_meta_key ) {
331
-			return false;
332
-		}
333
-
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
335
-
336
-		if ( ! $has_setter_or_getter ) {
337
-			return false;
338
-		}
339
-
340
-		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
342
-
343
-		return true;
344
-	}
345
-
346
-	/**
347
-	 * Magic method for setting data fields.
348
-	 *
349
-	 * This method does not update custom fields in the database.
350
-	 *
351
-	 * @since 1.0.19
352
-	 * @access public
353
-	 *
354
-	 */
355
-	public function __set( $key, $value ) {
356
-
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
359
-		}
360
-
361
-		if ( method_exists( $this, "set_$key") ) {
362
-
363
-			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
365
-
366
-			call_user_func( array( $this, "set_$key" ), $value );
367
-		} else {
368
-			$this->set_prop( $key, $value );
369
-		}
370
-
371
-	}
372
-
373
-	/**
24
+    /**
25
+     * ID for this object.
26
+     *
27
+     * @since 1.0.19
28
+     * @var int
29
+     */
30
+    protected $id = 0;
31
+
32
+    /**
33
+     * Core data for this object. Name value pairs (name + default value).
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array();
39
+
40
+    /**
41
+     * Core data changes for this object.
42
+     *
43
+     * @since 1.0.19
44
+     * @var array
45
+     */
46
+    protected $changes = array();
47
+
48
+    /**
49
+     * This is false until the object is read from the DB.
50
+     *
51
+     * @since 1.0.19
52
+     * @var bool
53
+     */
54
+    protected $object_read = false;
55
+
56
+    /**
57
+     * This is the name of this object type.
58
+     *
59
+     * @since 1.0.19
60
+     * @var string
61
+     */
62
+    protected $object_type = 'data';
63
+
64
+    /**
65
+     * Extra data for this object. Name value pairs (name + default value).
66
+     * Used as a standard way for sub classes (like item types) to add
67
+     * additional information to an inherited class.
68
+     *
69
+     * @since 1.0.19
70
+     * @var array
71
+     */
72
+    protected $extra_data = array();
73
+
74
+    /**
75
+     * Set to _data on construct so we can track and reset data if needed.
76
+     *
77
+     * @since 1.0.19
78
+     * @var array
79
+     */
80
+    protected $default_data = array();
81
+
82
+    /**
83
+     * Contains a reference to the data store for this class.
84
+     *
85
+     * @since 1.0.19
86
+     * @var GetPaid_Data_Store
87
+     */
88
+    protected $data_store;
89
+
90
+    /**
91
+     * Stores meta in cache for future reads.
92
+     * A group must be set to to enable caching.
93
+     *
94
+     * @since 1.0.19
95
+     * @var string
96
+     */
97
+    protected $cache_group = '';
98
+
99
+    /**
100
+     * Stores the last error.
101
+     *
102
+     * @since 1.0.19
103
+     * @var string
104
+     */
105
+    public $last_error = '';
106
+
107
+    /**
108
+     * Stores additional meta data.
109
+     *
110
+     * @since 1.0.19
111
+     * @var array
112
+     */
113
+    protected $meta_data = null;
114
+
115
+    /**
116
+     * Default constructor.
117
+     *
118
+     * @param int|object|array|string $read ID to load from the DB (optional) or already queried data.
119
+     */
120
+    public function __construct( $read = 0 ) {
121
+        $this->data         = array_merge( $this->data, $this->extra_data );
122
+        $this->default_data = $this->data;
123
+    }
124
+
125
+    /**
126
+     * Only store the object ID to avoid serializing the data object instance.
127
+     *
128
+     * @return array
129
+     */
130
+    public function __sleep() {
131
+        return array( 'id' );
132
+    }
133
+
134
+    /**
135
+     * Re-run the constructor with the object ID.
136
+     *
137
+     * If the object no longer exists, remove the ID.
138
+     */
139
+    public function __wakeup() {
140
+        $this->__construct( absint( $this->id ) );
141
+
142
+        if ( ! empty( $this->last_error ) ) {
143
+            $this->set_id( 0 );
144
+        }
145
+
146
+    }
147
+
148
+    /**
149
+     * When the object is cloned, make sure meta is duplicated correctly.
150
+     *
151
+     * @since 1.0.19
152
+     */
153
+    public function __clone() {
154
+        $this->maybe_read_meta_data();
155
+        if ( ! empty( $this->meta_data ) ) {
156
+            foreach ( $this->meta_data as $array_key => $meta ) {
157
+                $this->meta_data[ $array_key ] = clone $meta;
158
+                if ( ! empty( $meta->id ) ) {
159
+                    $this->meta_data[ $array_key ]->id = null;
160
+                }
161
+            }
162
+        }
163
+    }
164
+
165
+    /**
166
+     * Get the data store.
167
+     *
168
+     * @since  1.0.19
169
+     * @return object
170
+     */
171
+    public function get_data_store() {
172
+        return $this->data_store;
173
+    }
174
+
175
+    /**
176
+     * Get the object type.
177
+     *
178
+     * @since  1.0.19
179
+     * @return string
180
+     */
181
+    public function get_object_type() {
182
+        return $this->object_type;
183
+    }
184
+
185
+    /**
186
+     * Returns the unique ID for this object.
187
+     *
188
+     * @since  1.0.19
189
+     * @return int
190
+     */
191
+    public function get_id() {
192
+        return $this->id;
193
+    }
194
+
195
+    /**
196
+     * Get form status.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_status( $context = 'view' ) {
203
+        return $this->get_prop( 'status', $context );
204
+    }
205
+
206
+    /**
207
+     * Delete an object, set the ID to 0, and return result.
208
+     *
209
+     * @since  1.0.19
210
+     * @param  bool $force_delete Should the data be deleted permanently.
211
+     * @return bool result
212
+     */
213
+    public function delete( $force_delete = false ) {
214
+        if ( $this->data_store && $this->get_id() ) {
215
+            $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
+            $this->set_id( 0 );
217
+            return true;
218
+        }
219
+        return false;
220
+    }
221
+
222
+    /**
223
+     * Save should create or update based on object existence.
224
+     *
225
+     * @since  1.0.19
226
+     * @return int
227
+     */
228
+    public function save() {
229
+        if ( ! $this->data_store ) {
230
+            return $this->get_id();
231
+        }
232
+
233
+        /**
234
+         * Trigger action before saving to the DB. Allows you to adjust object props before save.
235
+         *
236
+         * @param GetPaid_Data          $this The object being saved.
237
+         * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238
+         */
239
+        do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
240
+
241
+        if ( $this->get_id() ) {
242
+            $this->data_store->update( $this );
243
+        } else {
244
+            $this->data_store->create( $this );
245
+        }
246
+
247
+        /**
248
+         * Trigger action after saving to the DB.
249
+         *
250
+         * @param GetPaid_Data          $this The object being saved.
251
+         * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252
+         */
253
+        do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
254
+
255
+        return $this->get_id();
256
+    }
257
+
258
+    /**
259
+     * Change data to JSON format.
260
+     *
261
+     * @since  1.0.19
262
+     * @return string Data in JSON format.
263
+     */
264
+    public function __toString() {
265
+        return wp_json_encode( $this->get_data() );
266
+    }
267
+
268
+    /**
269
+     * Returns all data for this object.
270
+     *
271
+     * @since  1.0.19
272
+     * @return array
273
+     */
274
+    public function get_data() {
275
+        return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
276
+    }
277
+
278
+    /**
279
+     * Returns array of expected data keys for this object.
280
+     *
281
+     * @since   1.0.19
282
+     * @return array
283
+     */
284
+    public function get_data_keys() {
285
+        return array_keys( $this->data );
286
+    }
287
+
288
+    /**
289
+     * Returns all "extra" data keys for an object (for sub objects like item types).
290
+     *
291
+     * @since  1.0.19
292
+     * @return array
293
+     */
294
+    public function get_extra_data_keys() {
295
+        return array_keys( $this->extra_data );
296
+    }
297
+
298
+    /**
299
+     * Filter null meta values from array.
300
+     *
301
+     * @since  1.0.19
302
+     * @param mixed $meta Meta value to check.
303
+     * @return bool
304
+     */
305
+    protected function filter_null_meta( $meta ) {
306
+        return ! is_null( $meta->value );
307
+    }
308
+
309
+    /**
310
+     * Get All Meta Data.
311
+     *
312
+     * @since 1.0.19
313
+     * @return array of objects.
314
+     */
315
+    public function get_meta_data() {
316
+        $this->maybe_read_meta_data();
317
+        return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
318
+    }
319
+
320
+    /**
321
+     * Check if the key is an internal one.
322
+     *
323
+     * @since  1.0.19
324
+     * @param  string $key Key to check.
325
+     * @return bool   true if it's an internal key, false otherwise
326
+     */
327
+    protected function is_internal_meta_key( $key ) {
328
+        $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
329
+
330
+        if ( ! $internal_meta_key ) {
331
+            return false;
332
+        }
333
+
334
+        $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
335
+
336
+        if ( ! $has_setter_or_getter ) {
337
+            return false;
338
+        }
339
+
340
+        /* translators: %s: $key Key to check */
341
+        getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
342
+
343
+        return true;
344
+    }
345
+
346
+    /**
347
+     * Magic method for setting data fields.
348
+     *
349
+     * This method does not update custom fields in the database.
350
+     *
351
+     * @since 1.0.19
352
+     * @access public
353
+     *
354
+     */
355
+    public function __set( $key, $value ) {
356
+
357
+        if ( 'id' == strtolower( $key ) ) {
358
+            return $this->set_id( $value );
359
+        }
360
+
361
+        if ( method_exists( $this, "set_$key") ) {
362
+
363
+            /* translators: %s: $key Key to set */
364
+            getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
365
+
366
+            call_user_func( array( $this, "set_$key" ), $value );
367
+        } else {
368
+            $this->set_prop( $key, $value );
369
+        }
370
+
371
+    }
372
+
373
+    /**
374 374
      * Margic method for retrieving a property.
375 375
      */
376 376
     public function __get( $key ) {
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
         // Check if we have a helper method for that.
379 379
         if ( method_exists( $this, 'get_' . $key ) ) {
380 380
 
381
-			if ( 'post_type' != $key ) {
382
-				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
384
-			}
381
+            if ( 'post_type' != $key ) {
382
+                /* translators: %s: $key Key to set */
383
+                getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
384
+            }
385 385
 
386 386
             return call_user_func( array( $this, 'get_' . $key ) );
387 387
         }
@@ -391,512 +391,512 @@  discard block
 block discarded – undo
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
395
-
396
-    }
397
-
398
-	/**
399
-	 * Get Meta Data by Key.
400
-	 *
401
-	 * @since  1.0.19
402
-	 * @param  string $key Meta Key.
403
-	 * @param  bool   $single return first found meta with key, or all with $key.
404
-	 * @param  string $context What the value is for. Valid values are view and edit.
405
-	 * @return mixed
406
-	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
408
-
409
-		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $_key ) ) {
413
-			$function = 'get_' . $_key;
414
-
415
-			if ( is_callable( array( $this, $function ) ) ) {
416
-				return $this->{$function}();
417
-			}
418
-		}
419
-
420
-		// Read the meta data if not yet read.
421
-		$this->maybe_read_meta_data();
422
-		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
424
-		$value      = $single ? '' : array();
425
-
426
-		if ( ! empty( $array_keys ) ) {
427
-			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
430
-			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
432
-			}
433
-		}
434
-
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
437
-		}
438
-
439
-		return $value;
440
-	}
441
-
442
-	/**
443
-	 * See if meta data exists, since get_meta always returns a '' or array().
444
-	 *
445
-	 * @since  1.0.19
446
-	 * @param  string $key Meta Key.
447
-	 * @return boolean
448
-	 */
449
-	public function meta_exists( $key = '' ) {
450
-		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
453
-	}
454
-
455
-	/**
456
-	 * Set all meta data from array.
457
-	 *
458
-	 * @since 1.0.19
459
-	 * @param array $data Key/Value pairs.
460
-	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
463
-			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
465
-				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
467
-					$this->meta_data[] = new GetPaid_Meta_Data(
468
-						array(
469
-							'id'    => $meta['id'],
470
-							'key'   => $meta['key'],
471
-							'value' => $meta['value'],
472
-						)
473
-					);
474
-				}
475
-			}
476
-		}
477
-	}
478
-
479
-	/**
480
-	 * Add meta data.
481
-	 *
482
-	 * @since 1.0.19
483
-	 *
484
-	 * @param string       $key Meta key.
485
-	 * @param string|array $value Meta value.
486
-	 * @param bool         $unique Should this be a unique key?.
487
-	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
490
-			$function = 'set_' . $key;
491
-
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
494
-			}
495
-		}
496
-
497
-		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
500
-		}
501
-		$this->meta_data[] = new GetPaid_Meta_Data(
502
-			array(
503
-				'key'   => $key,
504
-				'value' => $value,
505
-			)
506
-		);
507
-	}
508
-
509
-	/**
510
-	 * Update meta data by key or ID, if provided.
511
-	 *
512
-	 * @since  1.0.19
513
-	 *
514
-	 * @param  string       $key Meta key.
515
-	 * @param  string|array $value Meta value.
516
-	 * @param  int          $meta_id Meta ID.
517
-	 */
518
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
519
-		if ( $this->is_internal_meta_key( $key ) ) {
520
-			$function = 'set_' . $key;
521
-
522
-			if ( is_callable( array( $this, $function ) ) ) {
523
-				return $this->{$function}( $value );
524
-			}
525
-		}
526
-
527
-		$this->maybe_read_meta_data();
528
-
529
-		$array_key = false;
530
-
531
-		if ( $meta_id ) {
532
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
533
-			$array_key  = $array_keys ? current( $array_keys ) : false;
534
-		} else {
535
-			// Find matches by key.
536
-			$matches = array();
537
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
538
-				if ( $meta->key === $key ) {
539
-					$matches[] = $meta_data_array_key;
540
-				}
541
-			}
542
-
543
-			if ( ! empty( $matches ) ) {
544
-				// Set matches to null so only one key gets the new value.
545
-				foreach ( $matches as $meta_data_array_key ) {
546
-					$this->meta_data[ $meta_data_array_key ]->value = null;
547
-				}
548
-				$array_key = current( $matches );
549
-			}
550
-		}
551
-
552
-		if ( false !== $array_key ) {
553
-			$meta        = $this->meta_data[ $array_key ];
554
-			$meta->key   = $key;
555
-			$meta->value = $value;
556
-		} else {
557
-			$this->add_meta_data( $key, $value, true );
558
-		}
559
-	}
560
-
561
-	/**
562
-	 * Delete meta data.
563
-	 *
564
-	 * @since 1.0.19
565
-	 * @param string $key Meta key.
566
-	 */
567
-	public function delete_meta_data( $key ) {
568
-		$this->maybe_read_meta_data();
569
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
570
-
571
-		if ( $array_keys ) {
572
-			foreach ( $array_keys as $array_key ) {
573
-				$this->meta_data[ $array_key ]->value = null;
574
-			}
575
-		}
576
-	}
577
-
578
-	/**
579
-	 * Delete meta data.
580
-	 *
581
-	 * @since 1.0.19
582
-	 * @param int $mid Meta ID.
583
-	 */
584
-	public function delete_meta_data_by_mid( $mid ) {
585
-		$this->maybe_read_meta_data();
586
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
587
-
588
-		if ( $array_keys ) {
589
-			foreach ( $array_keys as $array_key ) {
590
-				$this->meta_data[ $array_key ]->value = null;
591
-			}
592
-		}
593
-	}
594
-
595
-	/**
596
-	 * Read meta data if null.
597
-	 *
598
-	 * @since 1.0.19
599
-	 */
600
-	protected function maybe_read_meta_data() {
601
-		if ( is_null( $this->meta_data ) ) {
602
-			$this->read_meta_data();
603
-		}
604
-	}
605
-
606
-	/**
607
-	 * Read Meta Data from the database. Ignore any internal properties.
608
-	 * Uses it's own caches because get_metadata does not provide meta_ids.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @param bool $force_read True to force a new DB read (and update cache).
612
-	 */
613
-	public function read_meta_data( $force_read = false ) {
614
-
615
-		// Reset meta data.
616
-		$this->meta_data = array();
617
-
618
-		// Maybe abort early.
619
-		if ( ! $this->get_id() || ! $this->data_store ) {
620
-			return;
621
-		}
622
-
623
-		// Only read from cache if the cache key is set.
624
-		$cache_key = null;
625
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
626
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
627
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
628
-		}
629
-
630
-		// Should we force read?
631
-		if ( empty( $raw_meta_data ) ) {
632
-			$raw_meta_data = $this->data_store->read_meta( $this );
633
-
634
-			if ( ! empty( $cache_key ) ) {
635
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
636
-			}
637
-
638
-		}
639
-
640
-		// Set meta data.
641
-		if ( is_array( $raw_meta_data ) ) {
642
-
643
-			foreach ( $raw_meta_data as $meta ) {
644
-				$this->meta_data[] = new GetPaid_Meta_Data(
645
-					array(
646
-						'id'    => (int) $meta->meta_id,
647
-						'key'   => $meta->meta_key,
648
-						'value' => maybe_unserialize( $meta->meta_value ),
649
-					)
650
-				);
651
-			}
652
-
653
-		}
654
-
655
-	}
656
-
657
-	/**
658
-	 * Update Meta Data in the database.
659
-	 *
660
-	 * @since 1.0.19
661
-	 */
662
-	public function save_meta_data() {
663
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
664
-			return;
665
-		}
666
-		foreach ( $this->meta_data as $array_key => $meta ) {
667
-			if ( is_null( $meta->value ) ) {
668
-				if ( ! empty( $meta->id ) ) {
669
-					$this->data_store->delete_meta( $this, $meta );
670
-					unset( $this->meta_data[ $array_key ] );
671
-				}
672
-			} elseif ( empty( $meta->id ) ) {
673
-				$meta->id = $this->data_store->add_meta( $this, $meta );
674
-				$meta->apply_changes();
675
-			} else {
676
-				if ( $meta->get_changes() ) {
677
-					$this->data_store->update_meta( $this, $meta );
678
-					$meta->apply_changes();
679
-				}
680
-			}
681
-		}
682
-		if ( ! empty( $this->cache_group ) ) {
683
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
684
-			wp_cache_delete( $cache_key, $this->cache_group );
685
-		}
686
-	}
687
-
688
-	/**
689
-	 * Set ID.
690
-	 *
691
-	 * @since 1.0.19
692
-	 * @param int $id ID.
693
-	 */
694
-	public function set_id( $id ) {
695
-		$this->id = absint( $id );
696
-	}
697
-
698
-	/**
699
-	 * Sets item status.
700
-	 *
701
-	 * @since 1.0.19
702
-	 * @param string $status New status.
703
-	 * @return array details of change.
704
-	 */
705
-	public function set_status( $status ) {
394
+        return $this->get_prop( $key );
395
+
396
+    }
397
+
398
+    /**
399
+     * Get Meta Data by Key.
400
+     *
401
+     * @since  1.0.19
402
+     * @param  string $key Meta Key.
403
+     * @param  bool   $single return first found meta with key, or all with $key.
404
+     * @param  string $context What the value is for. Valid values are view and edit.
405
+     * @return mixed
406
+     */
407
+    public function get_meta( $key = '', $single = true, $context = 'view' ) {
408
+
409
+        // Check if this is an internal meta key.
410
+        $_key = str_replace( '_wpinv', '', $key );
411
+        $_key = str_replace( 'wpinv', '', $_key );
412
+        if ( $this->is_internal_meta_key( $_key ) ) {
413
+            $function = 'get_' . $_key;
414
+
415
+            if ( is_callable( array( $this, $function ) ) ) {
416
+                return $this->{$function}();
417
+            }
418
+        }
419
+
420
+        // Read the meta data if not yet read.
421
+        $this->maybe_read_meta_data();
422
+        $meta_data  = $this->get_meta_data();
423
+        $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
424
+        $value      = $single ? '' : array();
425
+
426
+        if ( ! empty( $array_keys ) ) {
427
+            // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
+            if ( $single ) {
429
+                $value = $meta_data[ current( $array_keys ) ]->value;
430
+            } else {
431
+                $value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
432
+            }
433
+        }
434
+
435
+        if ( 'view' === $context ) {
436
+            $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
437
+        }
438
+
439
+        return $value;
440
+    }
441
+
442
+    /**
443
+     * See if meta data exists, since get_meta always returns a '' or array().
444
+     *
445
+     * @since  1.0.19
446
+     * @param  string $key Meta Key.
447
+     * @return boolean
448
+     */
449
+    public function meta_exists( $key = '' ) {
450
+        $this->maybe_read_meta_data();
451
+        $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
+        return in_array( $key, $array_keys, true );
453
+    }
454
+
455
+    /**
456
+     * Set all meta data from array.
457
+     *
458
+     * @since 1.0.19
459
+     * @param array $data Key/Value pairs.
460
+     */
461
+    public function set_meta_data( $data ) {
462
+        if ( ! empty( $data ) && is_array( $data ) ) {
463
+            $this->maybe_read_meta_data();
464
+            foreach ( $data as $meta ) {
465
+                $meta = (array) $meta;
466
+                if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
467
+                    $this->meta_data[] = new GetPaid_Meta_Data(
468
+                        array(
469
+                            'id'    => $meta['id'],
470
+                            'key'   => $meta['key'],
471
+                            'value' => $meta['value'],
472
+                        )
473
+                    );
474
+                }
475
+            }
476
+        }
477
+    }
478
+
479
+    /**
480
+     * Add meta data.
481
+     *
482
+     * @since 1.0.19
483
+     *
484
+     * @param string       $key Meta key.
485
+     * @param string|array $value Meta value.
486
+     * @param bool         $unique Should this be a unique key?.
487
+     */
488
+    public function add_meta_data( $key, $value, $unique = false ) {
489
+        if ( $this->is_internal_meta_key( $key ) ) {
490
+            $function = 'set_' . $key;
491
+
492
+            if ( is_callable( array( $this, $function ) ) ) {
493
+                return $this->{$function}( $value );
494
+            }
495
+        }
496
+
497
+        $this->maybe_read_meta_data();
498
+        if ( $unique ) {
499
+            $this->delete_meta_data( $key );
500
+        }
501
+        $this->meta_data[] = new GetPaid_Meta_Data(
502
+            array(
503
+                'key'   => $key,
504
+                'value' => $value,
505
+            )
506
+        );
507
+    }
508
+
509
+    /**
510
+     * Update meta data by key or ID, if provided.
511
+     *
512
+     * @since  1.0.19
513
+     *
514
+     * @param  string       $key Meta key.
515
+     * @param  string|array $value Meta value.
516
+     * @param  int          $meta_id Meta ID.
517
+     */
518
+    public function update_meta_data( $key, $value, $meta_id = 0 ) {
519
+        if ( $this->is_internal_meta_key( $key ) ) {
520
+            $function = 'set_' . $key;
521
+
522
+            if ( is_callable( array( $this, $function ) ) ) {
523
+                return $this->{$function}( $value );
524
+            }
525
+        }
526
+
527
+        $this->maybe_read_meta_data();
528
+
529
+        $array_key = false;
530
+
531
+        if ( $meta_id ) {
532
+            $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
533
+            $array_key  = $array_keys ? current( $array_keys ) : false;
534
+        } else {
535
+            // Find matches by key.
536
+            $matches = array();
537
+            foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
538
+                if ( $meta->key === $key ) {
539
+                    $matches[] = $meta_data_array_key;
540
+                }
541
+            }
542
+
543
+            if ( ! empty( $matches ) ) {
544
+                // Set matches to null so only one key gets the new value.
545
+                foreach ( $matches as $meta_data_array_key ) {
546
+                    $this->meta_data[ $meta_data_array_key ]->value = null;
547
+                }
548
+                $array_key = current( $matches );
549
+            }
550
+        }
551
+
552
+        if ( false !== $array_key ) {
553
+            $meta        = $this->meta_data[ $array_key ];
554
+            $meta->key   = $key;
555
+            $meta->value = $value;
556
+        } else {
557
+            $this->add_meta_data( $key, $value, true );
558
+        }
559
+    }
560
+
561
+    /**
562
+     * Delete meta data.
563
+     *
564
+     * @since 1.0.19
565
+     * @param string $key Meta key.
566
+     */
567
+    public function delete_meta_data( $key ) {
568
+        $this->maybe_read_meta_data();
569
+        $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
570
+
571
+        if ( $array_keys ) {
572
+            foreach ( $array_keys as $array_key ) {
573
+                $this->meta_data[ $array_key ]->value = null;
574
+            }
575
+        }
576
+    }
577
+
578
+    /**
579
+     * Delete meta data.
580
+     *
581
+     * @since 1.0.19
582
+     * @param int $mid Meta ID.
583
+     */
584
+    public function delete_meta_data_by_mid( $mid ) {
585
+        $this->maybe_read_meta_data();
586
+        $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
587
+
588
+        if ( $array_keys ) {
589
+            foreach ( $array_keys as $array_key ) {
590
+                $this->meta_data[ $array_key ]->value = null;
591
+            }
592
+        }
593
+    }
594
+
595
+    /**
596
+     * Read meta data if null.
597
+     *
598
+     * @since 1.0.19
599
+     */
600
+    protected function maybe_read_meta_data() {
601
+        if ( is_null( $this->meta_data ) ) {
602
+            $this->read_meta_data();
603
+        }
604
+    }
605
+
606
+    /**
607
+     * Read Meta Data from the database. Ignore any internal properties.
608
+     * Uses it's own caches because get_metadata does not provide meta_ids.
609
+     *
610
+     * @since 1.0.19
611
+     * @param bool $force_read True to force a new DB read (and update cache).
612
+     */
613
+    public function read_meta_data( $force_read = false ) {
614
+
615
+        // Reset meta data.
616
+        $this->meta_data = array();
617
+
618
+        // Maybe abort early.
619
+        if ( ! $this->get_id() || ! $this->data_store ) {
620
+            return;
621
+        }
622
+
623
+        // Only read from cache if the cache key is set.
624
+        $cache_key = null;
625
+        if ( ! $force_read && ! empty( $this->cache_group ) ) {
626
+            $cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
627
+            $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
628
+        }
629
+
630
+        // Should we force read?
631
+        if ( empty( $raw_meta_data ) ) {
632
+            $raw_meta_data = $this->data_store->read_meta( $this );
633
+
634
+            if ( ! empty( $cache_key ) ) {
635
+                wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
636
+            }
637
+
638
+        }
639
+
640
+        // Set meta data.
641
+        if ( is_array( $raw_meta_data ) ) {
642
+
643
+            foreach ( $raw_meta_data as $meta ) {
644
+                $this->meta_data[] = new GetPaid_Meta_Data(
645
+                    array(
646
+                        'id'    => (int) $meta->meta_id,
647
+                        'key'   => $meta->meta_key,
648
+                        'value' => maybe_unserialize( $meta->meta_value ),
649
+                    )
650
+                );
651
+            }
652
+
653
+        }
654
+
655
+    }
656
+
657
+    /**
658
+     * Update Meta Data in the database.
659
+     *
660
+     * @since 1.0.19
661
+     */
662
+    public function save_meta_data() {
663
+        if ( ! $this->data_store || is_null( $this->meta_data ) ) {
664
+            return;
665
+        }
666
+        foreach ( $this->meta_data as $array_key => $meta ) {
667
+            if ( is_null( $meta->value ) ) {
668
+                if ( ! empty( $meta->id ) ) {
669
+                    $this->data_store->delete_meta( $this, $meta );
670
+                    unset( $this->meta_data[ $array_key ] );
671
+                }
672
+            } elseif ( empty( $meta->id ) ) {
673
+                $meta->id = $this->data_store->add_meta( $this, $meta );
674
+                $meta->apply_changes();
675
+            } else {
676
+                if ( $meta->get_changes() ) {
677
+                    $this->data_store->update_meta( $this, $meta );
678
+                    $meta->apply_changes();
679
+                }
680
+            }
681
+        }
682
+        if ( ! empty( $this->cache_group ) ) {
683
+            $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
684
+            wp_cache_delete( $cache_key, $this->cache_group );
685
+        }
686
+    }
687
+
688
+    /**
689
+     * Set ID.
690
+     *
691
+     * @since 1.0.19
692
+     * @param int $id ID.
693
+     */
694
+    public function set_id( $id ) {
695
+        $this->id = absint( $id );
696
+    }
697
+
698
+    /**
699
+     * Sets item status.
700
+     *
701
+     * @since 1.0.19
702
+     * @param string $status New status.
703
+     * @return array details of change.
704
+     */
705
+    public function set_status( $status ) {
706 706
         $old_status = $this->get_status();
707 707
 
708
-		$this->set_prop( 'status', $status );
709
-
710
-		return array(
711
-			'from' => $old_status,
712
-			'to'   => $status,
713
-		);
714
-    }
715
-
716
-	/**
717
-	 * Set all props to default values.
718
-	 *
719
-	 * @since 1.0.19
720
-	 */
721
-	public function set_defaults() {
722
-		$this->data    = $this->default_data;
723
-		$this->changes = array();
724
-		$this->set_object_read( false );
725
-	}
726
-
727
-	/**
728
-	 * Set object read property.
729
-	 *
730
-	 * @since 1.0.19
731
-	 * @param boolean $read Should read?.
732
-	 */
733
-	public function set_object_read( $read = true ) {
734
-		$this->object_read = (bool) $read;
735
-	}
736
-
737
-	/**
738
-	 * Get object read property.
739
-	 *
740
-	 * @since  1.0.19
741
-	 * @return boolean
742
-	 */
743
-	public function get_object_read() {
744
-		return (bool) $this->object_read;
745
-	}
746
-
747
-	/**
748
-	 * Set a collection of props in one go, collect any errors, and return the result.
749
-	 * Only sets using public methods.
750
-	 *
751
-	 * @since  1.0.19
752
-	 *
753
-	 * @param array  $props Key value pairs to set. Key is the prop and should map to a setter function name.
754
-	 * @param string $context In what context to run this.
755
-	 *
756
-	 * @return bool|WP_Error
757
-	 */
758
-	public function set_props( $props, $context = 'set' ) {
759
-		$errors = false;
760
-
761
-		foreach ( $props as $prop => $value ) {
762
-			try {
763
-				/**
764
-				 * Checks if the prop being set is allowed, and the value is not null.
765
-				 */
766
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
767
-					continue;
768
-				}
769
-				$setter = "set_$prop";
770
-
771
-				if ( is_callable( array( $this, $setter ) ) ) {
772
-					$this->{$setter}( $value );
773
-				}
774
-			} catch ( Exception $e ) {
775
-				if ( ! $errors ) {
776
-					$errors = new WP_Error();
777
-				}
778
-				$errors->add( $e->getCode(), $e->getMessage() );
779
-				$this->last_error = $e->getMessage();
780
-			}
781
-		}
782
-
783
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
784
-	}
785
-
786
-	/**
787
-	 * Sets a prop for a setter method.
788
-	 *
789
-	 * This stores changes in a special array so we can track what needs saving
790
-	 * the the DB later.
791
-	 *
792
-	 * @since 1.0.19
793
-	 * @param string $prop Name of prop to set.
794
-	 * @param mixed  $value Value of the prop.
795
-	 */
796
-	protected function set_prop( $prop, $value ) {
797
-		if ( array_key_exists( $prop, $this->data ) ) {
798
-			if ( true === $this->object_read ) {
799
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
800
-					$this->changes[ $prop ] = $value;
801
-				}
802
-			} else {
803
-				$this->data[ $prop ] = $value;
804
-			}
805
-		}
806
-	}
807
-
808
-	/**
809
-	 * Return data changes only.
810
-	 *
811
-	 * @since 1.0.19
812
-	 * @return array
813
-	 */
814
-	public function get_changes() {
815
-		return $this->changes;
816
-	}
817
-
818
-	/**
819
-	 * Merge changes with data and clear.
820
-	 *
821
-	 * @since 1.0.19
822
-	 */
823
-	public function apply_changes() {
824
-		$this->data    = array_replace_recursive( $this->data, $this->changes );
825
-		$this->changes = array();
826
-	}
827
-
828
-	/**
829
-	 * Prefix for action and filter hooks on data.
830
-	 *
831
-	 * @since  1.0.19
832
-	 * @return string
833
-	 */
834
-	protected function get_hook_prefix() {
835
-		return 'wpinv_get_' . $this->object_type . '_';
836
-	}
837
-
838
-	/**
839
-	 * Gets a prop for a getter method.
840
-	 *
841
-	 * Gets the value from either current pending changes, or the data itself.
842
-	 * Context controls what happens to the value before it's returned.
843
-	 *
844
-	 * @since  1.0.19
845
-	 * @param  string $prop Name of prop to get.
846
-	 * @param  string $context What the value is for. Valid values are view and edit.
847
-	 * @return mixed
848
-	 */
849
-	protected function get_prop( $prop, $context = 'view' ) {
850
-		$value = null;
851
-
852
-		if ( array_key_exists( $prop, $this->data ) ) {
853
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
854
-
855
-			if ( 'view' === $context ) {
856
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
857
-			}
858
-		}
859
-
860
-		return $value;
861
-	}
862
-
863
-	/**
864
-	 * Sets a date prop whilst handling formatting and datetime objects.
865
-	 *
866
-	 * @since 1.0.19
867
-	 * @param string         $prop Name of prop to set.
868
-	 * @param string|integer $value Value of the prop.
869
-	 */
870
-	protected function set_date_prop( $prop, $value ) {
871
-
872
-		if ( empty( $value ) ) {
873
-			$this->set_prop( $prop, null );
874
-			return;
875
-		}
876
-		$this->set_prop( $prop, $value );
877
-
878
-	}
879
-
880
-	/**
881
-	 * When invalid data is found, throw an exception unless reading from the DB.
882
-	 *
883
-	 * @since 1.0.19
884
-	 * @param string $code             Error code.
885
-	 * @param string $message          Error message.
886
-	 */
887
-	protected function error( $code, $message ) {
888
-		$this->last_error = $message;
889
-	}
890
-
891
-	/**
892
-	 * Checks if the object is saved in the database
893
-	 *
894
-	 * @since 1.0.19
895
-	 * @return bool
896
-	 */
897
-	public function exists() {
898
-		$id = $this->get_id();
899
-		return ! empty( $id );
900
-	}
708
+        $this->set_prop( 'status', $status );
709
+
710
+        return array(
711
+            'from' => $old_status,
712
+            'to'   => $status,
713
+        );
714
+    }
715
+
716
+    /**
717
+     * Set all props to default values.
718
+     *
719
+     * @since 1.0.19
720
+     */
721
+    public function set_defaults() {
722
+        $this->data    = $this->default_data;
723
+        $this->changes = array();
724
+        $this->set_object_read( false );
725
+    }
726
+
727
+    /**
728
+     * Set object read property.
729
+     *
730
+     * @since 1.0.19
731
+     * @param boolean $read Should read?.
732
+     */
733
+    public function set_object_read( $read = true ) {
734
+        $this->object_read = (bool) $read;
735
+    }
736
+
737
+    /**
738
+     * Get object read property.
739
+     *
740
+     * @since  1.0.19
741
+     * @return boolean
742
+     */
743
+    public function get_object_read() {
744
+        return (bool) $this->object_read;
745
+    }
746
+
747
+    /**
748
+     * Set a collection of props in one go, collect any errors, and return the result.
749
+     * Only sets using public methods.
750
+     *
751
+     * @since  1.0.19
752
+     *
753
+     * @param array  $props Key value pairs to set. Key is the prop and should map to a setter function name.
754
+     * @param string $context In what context to run this.
755
+     *
756
+     * @return bool|WP_Error
757
+     */
758
+    public function set_props( $props, $context = 'set' ) {
759
+        $errors = false;
760
+
761
+        foreach ( $props as $prop => $value ) {
762
+            try {
763
+                /**
764
+                 * Checks if the prop being set is allowed, and the value is not null.
765
+                 */
766
+                if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
767
+                    continue;
768
+                }
769
+                $setter = "set_$prop";
770
+
771
+                if ( is_callable( array( $this, $setter ) ) ) {
772
+                    $this->{$setter}( $value );
773
+                }
774
+            } catch ( Exception $e ) {
775
+                if ( ! $errors ) {
776
+                    $errors = new WP_Error();
777
+                }
778
+                $errors->add( $e->getCode(), $e->getMessage() );
779
+                $this->last_error = $e->getMessage();
780
+            }
781
+        }
782
+
783
+        return $errors && count( $errors->get_error_codes() ) ? $errors : true;
784
+    }
785
+
786
+    /**
787
+     * Sets a prop for a setter method.
788
+     *
789
+     * This stores changes in a special array so we can track what needs saving
790
+     * the the DB later.
791
+     *
792
+     * @since 1.0.19
793
+     * @param string $prop Name of prop to set.
794
+     * @param mixed  $value Value of the prop.
795
+     */
796
+    protected function set_prop( $prop, $value ) {
797
+        if ( array_key_exists( $prop, $this->data ) ) {
798
+            if ( true === $this->object_read ) {
799
+                if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
800
+                    $this->changes[ $prop ] = $value;
801
+                }
802
+            } else {
803
+                $this->data[ $prop ] = $value;
804
+            }
805
+        }
806
+    }
807
+
808
+    /**
809
+     * Return data changes only.
810
+     *
811
+     * @since 1.0.19
812
+     * @return array
813
+     */
814
+    public function get_changes() {
815
+        return $this->changes;
816
+    }
817
+
818
+    /**
819
+     * Merge changes with data and clear.
820
+     *
821
+     * @since 1.0.19
822
+     */
823
+    public function apply_changes() {
824
+        $this->data    = array_replace_recursive( $this->data, $this->changes );
825
+        $this->changes = array();
826
+    }
827
+
828
+    /**
829
+     * Prefix for action and filter hooks on data.
830
+     *
831
+     * @since  1.0.19
832
+     * @return string
833
+     */
834
+    protected function get_hook_prefix() {
835
+        return 'wpinv_get_' . $this->object_type . '_';
836
+    }
837
+
838
+    /**
839
+     * Gets a prop for a getter method.
840
+     *
841
+     * Gets the value from either current pending changes, or the data itself.
842
+     * Context controls what happens to the value before it's returned.
843
+     *
844
+     * @since  1.0.19
845
+     * @param  string $prop Name of prop to get.
846
+     * @param  string $context What the value is for. Valid values are view and edit.
847
+     * @return mixed
848
+     */
849
+    protected function get_prop( $prop, $context = 'view' ) {
850
+        $value = null;
851
+
852
+        if ( array_key_exists( $prop, $this->data ) ) {
853
+            $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
854
+
855
+            if ( 'view' === $context ) {
856
+                $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
857
+            }
858
+        }
859
+
860
+        return $value;
861
+    }
862
+
863
+    /**
864
+     * Sets a date prop whilst handling formatting and datetime objects.
865
+     *
866
+     * @since 1.0.19
867
+     * @param string         $prop Name of prop to set.
868
+     * @param string|integer $value Value of the prop.
869
+     */
870
+    protected function set_date_prop( $prop, $value ) {
871
+
872
+        if ( empty( $value ) ) {
873
+            $this->set_prop( $prop, null );
874
+            return;
875
+        }
876
+        $this->set_prop( $prop, $value );
877
+
878
+    }
879
+
880
+    /**
881
+     * When invalid data is found, throw an exception unless reading from the DB.
882
+     *
883
+     * @since 1.0.19
884
+     * @param string $code             Error code.
885
+     * @param string $message          Error message.
886
+     */
887
+    protected function error( $code, $message ) {
888
+        $this->last_error = $message;
889
+    }
890
+
891
+    /**
892
+     * Checks if the object is saved in the database
893
+     *
894
+     * @since 1.0.19
895
+     * @return bool
896
+     */
897
+    public function exists() {
898
+        $id = $this->get_id();
899
+        return ! empty( $id );
900
+    }
901 901
 
902 902
 }
Please login to merge, or discard this patch.
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if (!defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param int|object|array|string $read ID to load from the DB (optional) or already queried data.
119 119
 	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
120
+	public function __construct($read = 0) {
121
+		$this->data         = array_merge($this->data, $this->extra_data);
122 122
 		$this->default_data = $this->data;
123 123
 	}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array
129 129
 	 */
130 130
 	public function __sleep() {
131
-		return array( 'id' );
131
+		return array('id');
132 132
 	}
133 133
 
134 134
 	/**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 	 * If the object no longer exists, remove the ID.
138 138
 	 */
139 139
 	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
140
+		$this->__construct(absint($this->id));
141 141
 
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
142
+		if (!empty($this->last_error)) {
143
+			$this->set_id(0);
144 144
 		}
145 145
 
146 146
 	}
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function __clone() {
154 154
 		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
155
+		if (!empty($this->meta_data)) {
156
+			foreach ($this->meta_data as $array_key => $meta) {
157
+				$this->meta_data[$array_key] = clone $meta;
158
+				if (!empty($meta->id)) {
159
+					$this->meta_data[$array_key]->id = null;
160 160
 				}
161 161
 			}
162 162
 		}
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
202
+	public function get_status($context = 'view') {
203
+		return $this->get_prop('status', $context);
204 204
     }
205 205
 
206 206
 	/**
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 * @param  bool $force_delete Should the data be deleted permanently.
211 211
 	 * @return bool result
212 212
 	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->get_id() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
213
+	public function delete($force_delete = false) {
214
+		if ($this->data_store && $this->get_id()) {
215
+			$this->data_store->delete($this, array('force_delete' => $force_delete));
216
+			$this->set_id(0);
217 217
 			return true;
218 218
 		}
219 219
 		return false;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return int
227 227
 	 */
228 228
 	public function save() {
229
-		if ( ! $this->data_store ) {
229
+		if (!$this->data_store) {
230 230
 			return $this->get_id();
231 231
 		}
232 232
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 		 * @param GetPaid_Data          $this The object being saved.
237 237
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238 238
 		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
239
+		do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store);
240 240
 
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
241
+		if ($this->get_id()) {
242
+			$this->data_store->update($this);
243 243
 		} else {
244
-			$this->data_store->create( $this );
244
+			$this->data_store->create($this);
245 245
 		}
246 246
 
247 247
 		/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * @param GetPaid_Data          $this The object being saved.
251 251
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252 252
 		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
253
+		do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store);
254 254
 
255 255
 		return $this->get_id();
256 256
 	}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @return string Data in JSON format.
263 263
 	 */
264 264
 	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
265
+		return wp_json_encode($this->get_data());
266 266
 	}
267 267
 
268 268
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return array
273 273
 	 */
274 274
 	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
275
+		return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data()));
276 276
 	}
277 277
 
278 278
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @return array
283 283
 	 */
284 284
 	public function get_data_keys() {
285
-		return array_keys( $this->data );
285
+		return array_keys($this->data);
286 286
 	}
287 287
 
288 288
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @return array
293 293
 	 */
294 294
 	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
295
+		return array_keys($this->extra_data);
296 296
 	}
297 297
 
298 298
 	/**
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param mixed $meta Meta value to check.
303 303
 	 * @return bool
304 304
 	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
305
+	protected function filter_null_meta($meta) {
306
+		return !is_null($meta->value);
307 307
 	}
308 308
 
309 309
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function get_meta_data() {
316 316
 		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
317
+		return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta')));
318 318
 	}
319 319
 
320 320
 	/**
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 	 * @param  string $key Key to check.
325 325
 	 * @return bool   true if it's an internal key, false otherwise
326 326
 	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
327
+	protected function is_internal_meta_key($key) {
328
+		$internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true);
329 329
 
330
-		if ( ! $internal_meta_key ) {
330
+		if (!$internal_meta_key) {
331 331
 			return false;
332 332
 		}
333 333
 
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
334
+		$has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key));
335 335
 
336
-		if ( ! $has_setter_or_getter ) {
336
+		if (!$has_setter_or_getter) {
337 337
 			return false;
338 338
 		}
339 339
 
340 340
 		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
341
+		getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid'), $key), '1.0.19');
342 342
 
343 343
 		return true;
344 344
 	}
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
 	 * @access public
353 353
 	 *
354 354
 	 */
355
-	public function __set( $key, $value ) {
355
+	public function __set($key, $value) {
356 356
 
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
357
+		if ('id' == strtolower($key)) {
358
+			return $this->set_id($value);
359 359
 		}
360 360
 
361
-		if ( method_exists( $this, "set_$key") ) {
361
+		if (method_exists($this, "set_$key")) {
362 362
 
363 363
 			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
364
+			getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19');
365 365
 
366
-			call_user_func( array( $this, "set_$key" ), $value );
366
+			call_user_func(array($this, "set_$key"), $value);
367 367
 		} else {
368
-			$this->set_prop( $key, $value );
368
+			$this->set_prop($key, $value);
369 369
 		}
370 370
 
371 371
 	}
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	/**
374 374
      * Margic method for retrieving a property.
375 375
      */
376
-    public function __get( $key ) {
376
+    public function __get($key) {
377 377
 
378 378
         // Check if we have a helper method for that.
379
-        if ( method_exists( $this, 'get_' . $key ) ) {
379
+        if (method_exists($this, 'get_' . $key)) {
380 380
 
381
-			if ( 'post_type' != $key ) {
381
+			if ('post_type' != $key) {
382 382
 				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
383
+				getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19');
384 384
 			}
385 385
 
386
-            return call_user_func( array( $this, 'get_' . $key ) );
386
+            return call_user_func(array($this, 'get_' . $key));
387 387
         }
388 388
 
389 389
         // Check if the key is in the associated $post object.
390
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
390
+        if (!empty($this->post) && isset($this->post->$key)) {
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
394
+		return $this->get_prop($key);
395 395
 
396 396
     }
397 397
 
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context What the value is for. Valid values are view and edit.
405 405
 	 * @return mixed
406 406
 	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
407
+	public function get_meta($key = '', $single = true, $context = 'view') {
408 408
 
409 409
 		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $_key ) ) {
410
+		$_key = str_replace('_wpinv', '', $key);
411
+		$_key = str_replace('wpinv', '', $_key);
412
+		if ($this->is_internal_meta_key($_key)) {
413 413
 			$function = 'get_' . $_key;
414 414
 
415
-			if ( is_callable( array( $this, $function ) ) ) {
415
+			if (is_callable(array($this, $function))) {
416 416
 				return $this->{$function}();
417 417
 			}
418 418
 		}
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 		// Read the meta data if not yet read.
421 421
 		$this->maybe_read_meta_data();
422 422
 		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
423
+		$array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true);
424 424
 		$value      = $single ? '' : array();
425 425
 
426
-		if ( ! empty( $array_keys ) ) {
426
+		if (!empty($array_keys)) {
427 427
 			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
428
+			if ($single) {
429
+				$value = $meta_data[current($array_keys)]->value;
430 430
 			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
431
+				$value = array_intersect_key($meta_data, array_flip($array_keys));
432 432
 			}
433 433
 		}
434 434
 
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
435
+		if ('view' === $context) {
436
+			$value = apply_filters($this->get_hook_prefix() . $key, $value, $this);
437 437
 		}
438 438
 
439 439
 		return $value;
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
 	 * @param  string $key Meta Key.
447 447
 	 * @return boolean
448 448
 	 */
449
-	public function meta_exists( $key = '' ) {
449
+	public function meta_exists($key = '') {
450 450
 		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
451
+		$array_keys = wp_list_pluck($this->get_meta_data(), 'key');
452
+		return in_array($key, $array_keys, true);
453 453
 	}
454 454
 
455 455
 	/**
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 	 * @since 1.0.19
459 459
 	 * @param array $data Key/Value pairs.
460 460
 	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
461
+	public function set_meta_data($data) {
462
+		if (!empty($data) && is_array($data)) {
463 463
 			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
464
+			foreach ($data as $meta) {
465 465
 				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
466
+				if (isset($meta['key'], $meta['value'], $meta['id'])) {
467 467
 					$this->meta_data[] = new GetPaid_Meta_Data(
468 468
 						array(
469 469
 							'id'    => $meta['id'],
@@ -485,18 +485,18 @@  discard block
 block discarded – undo
485 485
 	 * @param string|array $value Meta value.
486 486
 	 * @param bool         $unique Should this be a unique key?.
487 487
 	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
488
+	public function add_meta_data($key, $value, $unique = false) {
489
+		if ($this->is_internal_meta_key($key)) {
490 490
 			$function = 'set_' . $key;
491 491
 
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
492
+			if (is_callable(array($this, $function))) {
493
+				return $this->{$function}($value);
494 494
 			}
495 495
 		}
496 496
 
497 497
 		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
498
+		if ($unique) {
499
+			$this->delete_meta_data($key);
500 500
 		}
501 501
 		$this->meta_data[] = new GetPaid_Meta_Data(
502 502
 			array(
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 	 * @param  string|array $value Meta value.
516 516
 	 * @param  int          $meta_id Meta ID.
517 517
 	 */
518
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
519
-		if ( $this->is_internal_meta_key( $key ) ) {
518
+	public function update_meta_data($key, $value, $meta_id = 0) {
519
+		if ($this->is_internal_meta_key($key)) {
520 520
 			$function = 'set_' . $key;
521 521
 
522
-			if ( is_callable( array( $this, $function ) ) ) {
523
-				return $this->{$function}( $value );
522
+			if (is_callable(array($this, $function))) {
523
+				return $this->{$function}($value);
524 524
 			}
525 525
 		}
526 526
 
@@ -528,33 +528,33 @@  discard block
 block discarded – undo
528 528
 
529 529
 		$array_key = false;
530 530
 
531
-		if ( $meta_id ) {
532
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
533
-			$array_key  = $array_keys ? current( $array_keys ) : false;
531
+		if ($meta_id) {
532
+			$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true);
533
+			$array_key  = $array_keys ? current($array_keys) : false;
534 534
 		} else {
535 535
 			// Find matches by key.
536 536
 			$matches = array();
537
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
538
-				if ( $meta->key === $key ) {
537
+			foreach ($this->meta_data as $meta_data_array_key => $meta) {
538
+				if ($meta->key === $key) {
539 539
 					$matches[] = $meta_data_array_key;
540 540
 				}
541 541
 			}
542 542
 
543
-			if ( ! empty( $matches ) ) {
543
+			if (!empty($matches)) {
544 544
 				// Set matches to null so only one key gets the new value.
545
-				foreach ( $matches as $meta_data_array_key ) {
546
-					$this->meta_data[ $meta_data_array_key ]->value = null;
545
+				foreach ($matches as $meta_data_array_key) {
546
+					$this->meta_data[$meta_data_array_key]->value = null;
547 547
 				}
548
-				$array_key = current( $matches );
548
+				$array_key = current($matches);
549 549
 			}
550 550
 		}
551 551
 
552
-		if ( false !== $array_key ) {
553
-			$meta        = $this->meta_data[ $array_key ];
552
+		if (false !== $array_key) {
553
+			$meta        = $this->meta_data[$array_key];
554 554
 			$meta->key   = $key;
555 555
 			$meta->value = $value;
556 556
 		} else {
557
-			$this->add_meta_data( $key, $value, true );
557
+			$this->add_meta_data($key, $value, true);
558 558
 		}
559 559
 	}
560 560
 
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	 * @since 1.0.19
565 565
 	 * @param string $key Meta key.
566 566
 	 */
567
-	public function delete_meta_data( $key ) {
567
+	public function delete_meta_data($key) {
568 568
 		$this->maybe_read_meta_data();
569
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
569
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true);
570 570
 
571
-		if ( $array_keys ) {
572
-			foreach ( $array_keys as $array_key ) {
573
-				$this->meta_data[ $array_key ]->value = null;
571
+		if ($array_keys) {
572
+			foreach ($array_keys as $array_key) {
573
+				$this->meta_data[$array_key]->value = null;
574 574
 			}
575 575
 		}
576 576
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 * @since 1.0.19
582 582
 	 * @param int $mid Meta ID.
583 583
 	 */
584
-	public function delete_meta_data_by_mid( $mid ) {
584
+	public function delete_meta_data_by_mid($mid) {
585 585
 		$this->maybe_read_meta_data();
586
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
586
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true);
587 587
 
588
-		if ( $array_keys ) {
589
-			foreach ( $array_keys as $array_key ) {
590
-				$this->meta_data[ $array_key ]->value = null;
588
+		if ($array_keys) {
589
+			foreach ($array_keys as $array_key) {
590
+				$this->meta_data[$array_key]->value = null;
591 591
 			}
592 592
 		}
593 593
 	}
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	 * @since 1.0.19
599 599
 	 */
600 600
 	protected function maybe_read_meta_data() {
601
-		if ( is_null( $this->meta_data ) ) {
601
+		if (is_null($this->meta_data)) {
602 602
 			$this->read_meta_data();
603 603
 		}
604 604
 	}
@@ -610,42 +610,42 @@  discard block
 block discarded – undo
610 610
 	 * @since 1.0.19
611 611
 	 * @param bool $force_read True to force a new DB read (and update cache).
612 612
 	 */
613
-	public function read_meta_data( $force_read = false ) {
613
+	public function read_meta_data($force_read = false) {
614 614
 
615 615
 		// Reset meta data.
616 616
 		$this->meta_data = array();
617 617
 
618 618
 		// Maybe abort early.
619
-		if ( ! $this->get_id() || ! $this->data_store ) {
619
+		if (!$this->get_id() || !$this->data_store) {
620 620
 			return;
621 621
 		}
622 622
 
623 623
 		// Only read from cache if the cache key is set.
624 624
 		$cache_key = null;
625
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
626
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
627
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
625
+		if (!$force_read && !empty($this->cache_group)) {
626
+			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
627
+			$raw_meta_data = wp_cache_get($cache_key, $this->cache_group);
628 628
 		}
629 629
 
630 630
 		// Should we force read?
631
-		if ( empty( $raw_meta_data ) ) {
632
-			$raw_meta_data = $this->data_store->read_meta( $this );
631
+		if (empty($raw_meta_data)) {
632
+			$raw_meta_data = $this->data_store->read_meta($this);
633 633
 
634
-			if ( ! empty( $cache_key ) ) {
635
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
634
+			if (!empty($cache_key)) {
635
+				wp_cache_set($cache_key, $raw_meta_data, $this->cache_group);
636 636
 			}
637 637
 
638 638
 		}
639 639
 
640 640
 		// Set meta data.
641
-		if ( is_array( $raw_meta_data ) ) {
641
+		if (is_array($raw_meta_data)) {
642 642
 
643
-			foreach ( $raw_meta_data as $meta ) {
643
+			foreach ($raw_meta_data as $meta) {
644 644
 				$this->meta_data[] = new GetPaid_Meta_Data(
645 645
 					array(
646 646
 						'id'    => (int) $meta->meta_id,
647 647
 						'key'   => $meta->meta_key,
648
-						'value' => maybe_unserialize( $meta->meta_value ),
648
+						'value' => maybe_unserialize($meta->meta_value),
649 649
 					)
650 650
 				);
651 651
 			}
@@ -660,28 +660,28 @@  discard block
 block discarded – undo
660 660
 	 * @since 1.0.19
661 661
 	 */
662 662
 	public function save_meta_data() {
663
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
663
+		if (!$this->data_store || is_null($this->meta_data)) {
664 664
 			return;
665 665
 		}
666
-		foreach ( $this->meta_data as $array_key => $meta ) {
667
-			if ( is_null( $meta->value ) ) {
668
-				if ( ! empty( $meta->id ) ) {
669
-					$this->data_store->delete_meta( $this, $meta );
670
-					unset( $this->meta_data[ $array_key ] );
666
+		foreach ($this->meta_data as $array_key => $meta) {
667
+			if (is_null($meta->value)) {
668
+				if (!empty($meta->id)) {
669
+					$this->data_store->delete_meta($this, $meta);
670
+					unset($this->meta_data[$array_key]);
671 671
 				}
672
-			} elseif ( empty( $meta->id ) ) {
673
-				$meta->id = $this->data_store->add_meta( $this, $meta );
672
+			} elseif (empty($meta->id)) {
673
+				$meta->id = $this->data_store->add_meta($this, $meta);
674 674
 				$meta->apply_changes();
675 675
 			} else {
676
-				if ( $meta->get_changes() ) {
677
-					$this->data_store->update_meta( $this, $meta );
676
+				if ($meta->get_changes()) {
677
+					$this->data_store->update_meta($this, $meta);
678 678
 					$meta->apply_changes();
679 679
 				}
680 680
 			}
681 681
 		}
682
-		if ( ! empty( $this->cache_group ) ) {
683
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
684
-			wp_cache_delete( $cache_key, $this->cache_group );
682
+		if (!empty($this->cache_group)) {
683
+			$cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
684
+			wp_cache_delete($cache_key, $this->cache_group);
685 685
 		}
686 686
 	}
687 687
 
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
 	 * @since 1.0.19
692 692
 	 * @param int $id ID.
693 693
 	 */
694
-	public function set_id( $id ) {
695
-		$this->id = absint( $id );
694
+	public function set_id($id) {
695
+		$this->id = absint($id);
696 696
 	}
697 697
 
698 698
 	/**
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
 	 * @param string $status New status.
703 703
 	 * @return array details of change.
704 704
 	 */
705
-	public function set_status( $status ) {
705
+	public function set_status($status) {
706 706
         $old_status = $this->get_status();
707 707
 
708
-		$this->set_prop( 'status', $status );
708
+		$this->set_prop('status', $status);
709 709
 
710 710
 		return array(
711 711
 			'from' => $old_status,
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	public function set_defaults() {
722 722
 		$this->data    = $this->default_data;
723 723
 		$this->changes = array();
724
-		$this->set_object_read( false );
724
+		$this->set_object_read(false);
725 725
 	}
726 726
 
727 727
 	/**
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	 * @since 1.0.19
731 731
 	 * @param boolean $read Should read?.
732 732
 	 */
733
-	public function set_object_read( $read = true ) {
733
+	public function set_object_read($read = true) {
734 734
 		$this->object_read = (bool) $read;
735 735
 	}
736 736
 
@@ -755,32 +755,32 @@  discard block
 block discarded – undo
755 755
 	 *
756 756
 	 * @return bool|WP_Error
757 757
 	 */
758
-	public function set_props( $props, $context = 'set' ) {
758
+	public function set_props($props, $context = 'set') {
759 759
 		$errors = false;
760 760
 
761
-		foreach ( $props as $prop => $value ) {
761
+		foreach ($props as $prop => $value) {
762 762
 			try {
763 763
 				/**
764 764
 				 * Checks if the prop being set is allowed, and the value is not null.
765 765
 				 */
766
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
766
+				if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) {
767 767
 					continue;
768 768
 				}
769 769
 				$setter = "set_$prop";
770 770
 
771
-				if ( is_callable( array( $this, $setter ) ) ) {
772
-					$this->{$setter}( $value );
771
+				if (is_callable(array($this, $setter))) {
772
+					$this->{$setter}($value);
773 773
 				}
774
-			} catch ( Exception $e ) {
775
-				if ( ! $errors ) {
774
+			} catch (Exception $e) {
775
+				if (!$errors) {
776 776
 					$errors = new WP_Error();
777 777
 				}
778
-				$errors->add( $e->getCode(), $e->getMessage() );
778
+				$errors->add($e->getCode(), $e->getMessage());
779 779
 				$this->last_error = $e->getMessage();
780 780
 			}
781 781
 		}
782 782
 
783
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
783
+		return $errors && count($errors->get_error_codes()) ? $errors : true;
784 784
 	}
785 785
 
786 786
 	/**
@@ -793,14 +793,14 @@  discard block
 block discarded – undo
793 793
 	 * @param string $prop Name of prop to set.
794 794
 	 * @param mixed  $value Value of the prop.
795 795
 	 */
796
-	protected function set_prop( $prop, $value ) {
797
-		if ( array_key_exists( $prop, $this->data ) ) {
798
-			if ( true === $this->object_read ) {
799
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
800
-					$this->changes[ $prop ] = $value;
796
+	protected function set_prop($prop, $value) {
797
+		if (array_key_exists($prop, $this->data)) {
798
+			if (true === $this->object_read) {
799
+				if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) {
800
+					$this->changes[$prop] = $value;
801 801
 				}
802 802
 			} else {
803
-				$this->data[ $prop ] = $value;
803
+				$this->data[$prop] = $value;
804 804
 			}
805 805
 		}
806 806
 	}
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 * @since 1.0.19
822 822
 	 */
823 823
 	public function apply_changes() {
824
-		$this->data    = array_replace_recursive( $this->data, $this->changes );
824
+		$this->data    = array_replace_recursive($this->data, $this->changes);
825 825
 		$this->changes = array();
826 826
 	}
827 827
 
@@ -846,14 +846,14 @@  discard block
 block discarded – undo
846 846
 	 * @param  string $context What the value is for. Valid values are view and edit.
847 847
 	 * @return mixed
848 848
 	 */
849
-	protected function get_prop( $prop, $context = 'view' ) {
849
+	protected function get_prop($prop, $context = 'view') {
850 850
 		$value = null;
851 851
 
852
-		if ( array_key_exists( $prop, $this->data ) ) {
853
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
852
+		if (array_key_exists($prop, $this->data)) {
853
+			$value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop];
854 854
 
855
-			if ( 'view' === $context ) {
856
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
855
+			if ('view' === $context) {
856
+				$value = apply_filters($this->get_hook_prefix() . $prop, $value, $this);
857 857
 			}
858 858
 		}
859 859
 
@@ -867,13 +867,13 @@  discard block
 block discarded – undo
867 867
 	 * @param string         $prop Name of prop to set.
868 868
 	 * @param string|integer $value Value of the prop.
869 869
 	 */
870
-	protected function set_date_prop( $prop, $value ) {
870
+	protected function set_date_prop($prop, $value) {
871 871
 
872
-		if ( empty( $value ) ) {
873
-			$this->set_prop( $prop, null );
872
+		if (empty($value)) {
873
+			$this->set_prop($prop, null);
874 874
 			return;
875 875
 		}
876
-		$this->set_prop( $prop, $value );
876
+		$this->set_prop($prop, $value);
877 877
 
878 878
 	}
879 879
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	 * @param string $code             Error code.
885 885
 	 * @param string $message          Error message.
886 886
 	 */
887
-	protected function error( $code, $message ) {
887
+	protected function error($code, $message) {
888 888
 		$this->last_error = $message;
889 889
 	}
890 890
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 */
897 897
 	public function exists() {
898 898
 		$id = $this->get_id();
899
-		return ! empty( $id );
899
+		return !empty($id);
900 900
 	}
901 901
 
902 902
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 3 patches
Indentation   +2348 added lines, -2348 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'remote_subscription_id' => null,
84
-		'is_viewed'            => false,
85
-		'email_cc'             => '',
86
-		'template'             => 'quantity', // hours, amount only
87
-		'created_via'          => null,
82
+        'subscription_id'      => null,
83
+        'remote_subscription_id' => null,
84
+        'is_viewed'            => false,
85
+        'email_cc'             => '',
86
+        'template'             => 'quantity', // hours, amount only
87
+        'created_via'          => null,
88 88
     );
89 89
 
90 90
     /**
91
-	 * Stores meta in cache for future reads.
92
-	 *
93
-	 * A group must be set to to enable caching.
94
-	 *
95
-	 * @var string
96
-	 */
97
-	protected $cache_group = 'getpaid_invoices';
91
+     * Stores meta in cache for future reads.
92
+     *
93
+     * A group must be set to to enable caching.
94
+     *
95
+     * @var string
96
+     */
97
+    protected $cache_group = 'getpaid_invoices';
98 98
 
99 99
     /**
100 100
      * Stores a reference to the original WP_Post object
@@ -108,104 +108,104 @@  discard block
 block discarded – undo
108 108
      *
109 109
      * @var int
110 110
      */
111
-	protected $recurring_item = null;
111
+    protected $recurring_item = null;
112 112
 
113
-	/**
113
+    /**
114 114
      * Stores an array of item totals.
115
-	 *
116
-	 * e.g $totals['discount'] = array(
117
-	 * 		'initial'   => 10,
118
-	 * 		'recurring' => 10,
119
-	 * )
115
+     *
116
+     * e.g $totals['discount'] = array(
117
+     * 		'initial'   => 10,
118
+     * 		'recurring' => 10,
119
+     * )
120 120
      *
121 121
      * @var array
122 122
      */
123
-	protected $totals = array();
123
+    protected $totals = array();
124 124
 
125
-	/**
126
-	 * Stores the status transition information.
127
-	 *
128
-	 * @since 1.0.19
129
-	 * @var bool|array
130
-	 */
131
-	protected $status_transition = false;
125
+    /**
126
+     * Stores the status transition information.
127
+     *
128
+     * @since 1.0.19
129
+     * @var bool|array
130
+     */
131
+    protected $status_transition = false;
132 132
 
133 133
     /**
134
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
135
-	 *
136
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137
-	 */
134
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
135
+     *
136
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137
+     */
138 138
     public function __construct( $invoice = 0 ) {
139 139
 
140 140
         parent::__construct( $invoice );
141 141
 
142
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
143
-			$this->set_id( (int) $invoice );
144
-		} elseif ( $invoice instanceof self ) {
145
-			$this->set_id( $invoice->get_id() );
146
-		} elseif ( ! empty( $invoice->ID ) ) {
147
-			$this->set_id( $invoice->ID );
148
-		} elseif ( is_array( $invoice ) ) {
149
-			$this->set_props( $invoice );
150
-
151
-			if ( isset( $invoice['ID'] ) ) {
152
-				$this->set_id( $invoice['ID'] );
153
-			}
154
-
155
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
-			$this->set_id( $invoice_id );
161
-		}else {
162
-			$this->set_object_read( true );
163
-		}
142
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
143
+            $this->set_id( (int) $invoice );
144
+        } elseif ( $invoice instanceof self ) {
145
+            $this->set_id( $invoice->get_id() );
146
+        } elseif ( ! empty( $invoice->ID ) ) {
147
+            $this->set_id( $invoice->ID );
148
+        } elseif ( is_array( $invoice ) ) {
149
+            $this->set_props( $invoice );
150
+
151
+            if ( isset( $invoice['ID'] ) ) {
152
+                $this->set_id( $invoice['ID'] );
153
+            }
154
+
155
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
+            $this->set_id( $invoice_id );
157
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
+            $this->set_id( $invoice_id );
159
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
+            $this->set_id( $invoice_id );
161
+        }else {
162
+            $this->set_object_read( true );
163
+        }
164 164
 
165 165
         // Load the datastore.
166
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
167 167
 
168
-		if ( $this->get_id() > 0 ) {
168
+        if ( $this->get_id() > 0 ) {
169 169
             $this->post = get_post( $this->get_id() );
170 170
             $this->ID   = $this->get_id();
171
-			$this->data_store->read( $this );
171
+            $this->data_store->read( $this );
172 172
         }
173 173
 
174 174
     }
175 175
 
176 176
     /**
177
-	 * Given an invoice key/number, it returns its id.
178
-	 *
179
-	 *
180
-	 * @static
181
-	 * @param string $value The invoice key or number
182
-	 * @param string $field Either key, transaction_id or number.
183
-	 * @since 1.0.15
184
-	 * @return int
185
-	 */
186
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
177
+     * Given an invoice key/number, it returns its id.
178
+     *
179
+     *
180
+     * @static
181
+     * @param string $value The invoice key or number
182
+     * @param string $field Either key, transaction_id or number.
183
+     * @since 1.0.15
184
+     * @return int
185
+     */
186
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
187 187
         global $wpdb;
188 188
 
189
-		// Trim the value.
190
-		$value = trim( $value );
189
+        // Trim the value.
190
+        $value = trim( $value );
191 191
 
192
-		if ( empty( $value ) ) {
193
-			return 0;
194
-		}
192
+        if ( empty( $value ) ) {
193
+            return 0;
194
+        }
195 195
 
196 196
         // Valid fields.
197 197
         $fields = array( 'key', 'number', 'transaction_id' );
198 198
 
199
-		// Ensure a field has been passed.
200
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
201
-			return 0;
202
-		}
199
+        // Ensure a field has been passed.
200
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
201
+            return 0;
202
+        }
203 203
 
204
-		// Maybe retrieve from the cache.
205
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
-		if ( false !== $invoice_id ) {
207
-			return $invoice_id;
208
-		}
204
+        // Maybe retrieve from the cache.
205
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
+        if ( false !== $invoice_id ) {
207
+            return $invoice_id;
208
+        }
209 209
 
210 210
         // Fetch from the db.
211 211
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
214 214
         );
215 215
 
216
-		// Update the cache with our data
217
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+        // Update the cache with our data
217
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
218 218
 
219
-		return $invoice_id;
219
+        return $invoice_id;
220 220
     }
221 221
 
222 222
     /**
@@ -242,72 +242,72 @@  discard block
 block discarded – undo
242 242
     */
243 243
 
244 244
     /**
245
-	 * Get parent invoice ID.
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return int
250
-	 */
251
-	public function get_parent_id( $context = 'view' ) {
252
-		return (int) $this->get_prop( 'parent_id', $context );
245
+     * Get parent invoice ID.
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return int
250
+     */
251
+    public function get_parent_id( $context = 'view' ) {
252
+        return (int) $this->get_prop( 'parent_id', $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Get parent invoice.
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @return WPInv_Invoice
260
-	 */
256
+     * Get parent invoice.
257
+     *
258
+     * @since 1.0.19
259
+     * @return WPInv_Invoice
260
+     */
261 261
     public function get_parent_payment() {
262 262
         return new WPInv_Invoice( $this->get_parent_id() );
263 263
     }
264 264
 
265 265
     /**
266
-	 * Alias for self::get_parent_payment().
267
-	 *
268
-	 * @since 1.0.19
269
-	 * @return WPInv_Invoice
270
-	 */
266
+     * Alias for self::get_parent_payment().
267
+     *
268
+     * @since 1.0.19
269
+     * @return WPInv_Invoice
270
+     */
271 271
     public function get_parent() {
272 272
         return $this->get_parent_payment();
273 273
     }
274 274
 
275 275
     /**
276
-	 * Get invoice status.
277
-	 *
278
-	 * @since 1.0.19
279
-	 * @param  string $context View or edit context.
280
-	 * @return string
281
-	 */
282
-	public function get_status( $context = 'view' ) {
283
-		return $this->get_prop( 'status', $context );
284
-	}
276
+     * Get invoice status.
277
+     *
278
+     * @since 1.0.19
279
+     * @param  string $context View or edit context.
280
+     * @return string
281
+     */
282
+    public function get_status( $context = 'view' ) {
283
+        return $this->get_prop( 'status', $context );
284
+    }
285 285
 	
286
-	/**
287
-	 * Retrieves an array of possible invoice statuses.
288
-	 *
289
-	 * @since 1.0.19
290
-	 * @return array
291
-	 */
292
-	public function get_all_statuses() {
293
-		return wpinv_get_invoice_statuses( true, true, $this );
294
-    }
295
-
296
-    /**
297
-	 * Get invoice status nice name.
298
-	 *
299
-	 * @since 1.0.19
300
-	 * @return string
301
-	 */
286
+    /**
287
+     * Retrieves an array of possible invoice statuses.
288
+     *
289
+     * @since 1.0.19
290
+     * @return array
291
+     */
292
+    public function get_all_statuses() {
293
+        return wpinv_get_invoice_statuses( true, true, $this );
294
+    }
295
+
296
+    /**
297
+     * Get invoice status nice name.
298
+     *
299
+     * @since 1.0.19
300
+     * @return string
301
+     */
302 302
     public function get_status_nicename() {
303
-		$statuses = $this->get_all_statuses();
303
+        $statuses = $this->get_all_statuses();
304 304
 
305 305
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
306 306
 
307 307
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
308 308
     }
309 309
 
310
-	/**
310
+    /**
311 311
      * Retrieves the invoice status label html
312 312
      *
313 313
      * @since  1.0.0
@@ -315,262 +315,262 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function get_status_label_html() {
317 317
 
318
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
319
-		$status       = sanitize_html_class( $this->get_status() );
318
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
319
+        $status       = sanitize_html_class( $this->get_status() );
320 320
 
321
-		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
322
-	}
321
+        return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
322
+    }
323 323
 
324 324
     /**
325
-	 * Get plugin version when the invoice was created.
326
-	 *
327
-	 * @since 1.0.19
328
-	 * @param  string $context View or edit context.
329
-	 * @return string
330
-	 */
331
-	public function get_version( $context = 'view' ) {
332
-		return $this->get_prop( 'version', $context );
333
-	}
325
+     * Get plugin version when the invoice was created.
326
+     *
327
+     * @since 1.0.19
328
+     * @param  string $context View or edit context.
329
+     * @return string
330
+     */
331
+    public function get_version( $context = 'view' ) {
332
+        return $this->get_prop( 'version', $context );
333
+    }
334 334
 
335
-	/**
336
-	 * @deprecated
337
-	 */
338
-	public function get_invoice_date( $format = true ) {
339
-		$date      = getpaid_format_date( $this->get_date_completed() );
340
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
341
-		$formatted = getpaid_format_date( $date );
335
+    /**
336
+     * @deprecated
337
+     */
338
+    public function get_invoice_date( $format = true ) {
339
+        $date      = getpaid_format_date( $this->get_date_completed() );
340
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
341
+        $formatted = getpaid_format_date( $date );
342 342
 
343
-		if ( $format ) {
344
-			return $formatted;
345
-		}
343
+        if ( $format ) {
344
+            return $formatted;
345
+        }
346 346
 
347
-		return empty( $formatted ) ? '' : $date;
347
+        return empty( $formatted ) ? '' : $date;
348 348
 
349 349
     }
350 350
 
351 351
     /**
352
-	 * Get date when the invoice was created.
353
-	 *
354
-	 * @since 1.0.19
355
-	 * @param  string $context View or edit context.
356
-	 * @return string
357
-	 */
358
-	public function get_date_created( $context = 'view' ) {
359
-		return $this->get_prop( 'date_created', $context );
360
-	}
352
+     * Get date when the invoice was created.
353
+     *
354
+     * @since 1.0.19
355
+     * @param  string $context View or edit context.
356
+     * @return string
357
+     */
358
+    public function get_date_created( $context = 'view' ) {
359
+        return $this->get_prop( 'date_created', $context );
360
+    }
361 361
 	
362
-	/**
363
-	 * Alias for self::get_date_created().
364
-	 *
365
-	 * @since 1.0.19
366
-	 * @param  string $context View or edit context.
367
-	 * @return string
368
-	 */
369
-	public function get_created_date( $context = 'view' ) {
370
-		return $this->get_date_created( $context );
371
-    }
372
-
373
-    /**
374
-	 * Get GMT date when the invoice was created.
375
-	 *
376
-	 * @since 1.0.19
377
-	 * @param  string $context View or edit context.
378
-	 * @return string
379
-	 */
380
-	public function get_date_created_gmt( $context = 'view' ) {
362
+    /**
363
+     * Alias for self::get_date_created().
364
+     *
365
+     * @since 1.0.19
366
+     * @param  string $context View or edit context.
367
+     * @return string
368
+     */
369
+    public function get_created_date( $context = 'view' ) {
370
+        return $this->get_date_created( $context );
371
+    }
372
+
373
+    /**
374
+     * Get GMT date when the invoice was created.
375
+     *
376
+     * @since 1.0.19
377
+     * @param  string $context View or edit context.
378
+     * @return string
379
+     */
380
+    public function get_date_created_gmt( $context = 'view' ) {
381 381
         $date = $this->get_date_created( $context );
382 382
 
383 383
         if ( $date ) {
384 384
             $date = get_gmt_from_date( $date );
385 385
         }
386
-		return $date;
386
+        return $date;
387 387
     }
388 388
 
389 389
     /**
390
-	 * Get date when the invoice was last modified.
391
-	 *
392
-	 * @since 1.0.19
393
-	 * @param  string $context View or edit context.
394
-	 * @return string
395
-	 */
396
-	public function get_date_modified( $context = 'view' ) {
397
-		return $this->get_prop( 'date_modified', $context );
398
-	}
390
+     * Get date when the invoice was last modified.
391
+     *
392
+     * @since 1.0.19
393
+     * @param  string $context View or edit context.
394
+     * @return string
395
+     */
396
+    public function get_date_modified( $context = 'view' ) {
397
+        return $this->get_prop( 'date_modified', $context );
398
+    }
399 399
 
400
-	/**
401
-	 * Alias for self::get_date_modified().
402
-	 *
403
-	 * @since 1.0.19
404
-	 * @param  string $context View or edit context.
405
-	 * @return string
406
-	 */
407
-	public function get_modified_date( $context = 'view' ) {
408
-		return $this->get_date_modified( $context );
400
+    /**
401
+     * Alias for self::get_date_modified().
402
+     *
403
+     * @since 1.0.19
404
+     * @param  string $context View or edit context.
405
+     * @return string
406
+     */
407
+    public function get_modified_date( $context = 'view' ) {
408
+        return $this->get_date_modified( $context );
409 409
     }
410 410
 
411 411
     /**
412
-	 * Get GMT date when the invoice was last modified.
413
-	 *
414
-	 * @since 1.0.19
415
-	 * @param  string $context View or edit context.
416
-	 * @return string
417
-	 */
418
-	public function get_date_modified_gmt( $context = 'view' ) {
412
+     * Get GMT date when the invoice was last modified.
413
+     *
414
+     * @since 1.0.19
415
+     * @param  string $context View or edit context.
416
+     * @return string
417
+     */
418
+    public function get_date_modified_gmt( $context = 'view' ) {
419 419
         $date = $this->get_date_modified( $context );
420 420
 
421 421
         if ( $date ) {
422 422
             $date = get_gmt_from_date( $date );
423 423
         }
424
-		return $date;
424
+        return $date;
425 425
     }
426 426
 
427 427
     /**
428
-	 * Get the invoice due date.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return string
433
-	 */
434
-	public function get_due_date( $context = 'view' ) {
435
-		return $this->get_prop( 'due_date', $context );
428
+     * Get the invoice due date.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return string
433
+     */
434
+    public function get_due_date( $context = 'view' ) {
435
+        return $this->get_prop( 'due_date', $context );
436 436
     }
437 437
 
438 438
     /**
439
-	 * Alias for self::get_due_date().
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return string
444
-	 */
445
-	public function get_date_due( $context = 'view' ) {
446
-		return $this->get_due_date( $context );
439
+     * Alias for self::get_due_date().
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return string
444
+     */
445
+    public function get_date_due( $context = 'view' ) {
446
+        return $this->get_due_date( $context );
447 447
     }
448 448
 
449 449
     /**
450
-	 * Get the invoice GMT due date.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return string
455
-	 */
456
-	public function get_due_date_gmt( $context = 'view' ) {
450
+     * Get the invoice GMT due date.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return string
455
+     */
456
+    public function get_due_date_gmt( $context = 'view' ) {
457 457
         $date = $this->get_due_date( $context );
458 458
 
459 459
         if ( $date ) {
460 460
             $date = get_gmt_from_date( $date );
461 461
         }
462
-		return $date;
462
+        return $date;
463 463
     }
464 464
 
465 465
     /**
466
-	 * Alias for self::get_due_date_gmt().
467
-	 *
468
-	 * @since 1.0.19
469
-	 * @param  string $context View or edit context.
470
-	 * @return string
471
-	 */
472
-	public function get_gmt_date_due( $context = 'view' ) {
473
-		return $this->get_due_date_gmt( $context );
466
+     * Alias for self::get_due_date_gmt().
467
+     *
468
+     * @since 1.0.19
469
+     * @param  string $context View or edit context.
470
+     * @return string
471
+     */
472
+    public function get_gmt_date_due( $context = 'view' ) {
473
+        return $this->get_due_date_gmt( $context );
474 474
     }
475 475
 
476 476
     /**
477
-	 * Get date when the invoice was completed.
478
-	 *
479
-	 * @since 1.0.19
480
-	 * @param  string $context View or edit context.
481
-	 * @return string
482
-	 */
483
-	public function get_completed_date( $context = 'view' ) {
484
-		return $this->get_prop( 'completed_date', $context );
477
+     * Get date when the invoice was completed.
478
+     *
479
+     * @since 1.0.19
480
+     * @param  string $context View or edit context.
481
+     * @return string
482
+     */
483
+    public function get_completed_date( $context = 'view' ) {
484
+        return $this->get_prop( 'completed_date', $context );
485 485
     }
486 486
 
487 487
     /**
488
-	 * Alias for self::get_completed_date().
489
-	 *
490
-	 * @since 1.0.19
491
-	 * @param  string $context View or edit context.
492
-	 * @return string
493
-	 */
494
-	public function get_date_completed( $context = 'view' ) {
495
-		return $this->get_completed_date( $context );
488
+     * Alias for self::get_completed_date().
489
+     *
490
+     * @since 1.0.19
491
+     * @param  string $context View or edit context.
492
+     * @return string
493
+     */
494
+    public function get_date_completed( $context = 'view' ) {
495
+        return $this->get_completed_date( $context );
496 496
     }
497 497
 
498 498
     /**
499
-	 * Get GMT date when the invoice was was completed.
500
-	 *
501
-	 * @since 1.0.19
502
-	 * @param  string $context View or edit context.
503
-	 * @return string
504
-	 */
505
-	public function get_completed_date_gmt( $context = 'view' ) {
499
+     * Get GMT date when the invoice was was completed.
500
+     *
501
+     * @since 1.0.19
502
+     * @param  string $context View or edit context.
503
+     * @return string
504
+     */
505
+    public function get_completed_date_gmt( $context = 'view' ) {
506 506
         $date = $this->get_completed_date( $context );
507 507
 
508 508
         if ( $date ) {
509 509
             $date = get_gmt_from_date( $date );
510 510
         }
511
-		return $date;
511
+        return $date;
512 512
     }
513 513
 
514 514
     /**
515
-	 * Alias for self::get_completed_date_gmt().
516
-	 *
517
-	 * @since 1.0.19
518
-	 * @param  string $context View or edit context.
519
-	 * @return string
520
-	 */
521
-	public function get_gmt_completed_date( $context = 'view' ) {
522
-		return $this->get_completed_date_gmt( $context );
515
+     * Alias for self::get_completed_date_gmt().
516
+     *
517
+     * @since 1.0.19
518
+     * @param  string $context View or edit context.
519
+     * @return string
520
+     */
521
+    public function get_gmt_completed_date( $context = 'view' ) {
522
+        return $this->get_completed_date_gmt( $context );
523 523
     }
524 524
 
525 525
     /**
526
-	 * Get the invoice number.
527
-	 *
528
-	 * @since 1.0.19
529
-	 * @param  string $context View or edit context.
530
-	 * @return string
531
-	 */
532
-	public function get_number( $context = 'view' ) {
533
-		$number = $this->get_prop( 'number', $context );
526
+     * Get the invoice number.
527
+     *
528
+     * @since 1.0.19
529
+     * @param  string $context View or edit context.
530
+     * @return string
531
+     */
532
+    public function get_number( $context = 'view' ) {
533
+        $number = $this->get_prop( 'number', $context );
534 534
 
535
-		if ( empty( $number ) ) {
536
-			$number = $this->generate_number();
537
-			$this->set_number( $this->generate_number() );
538
-		}
535
+        if ( empty( $number ) ) {
536
+            $number = $this->generate_number();
537
+            $this->set_number( $this->generate_number() );
538
+        }
539 539
 
540
-		return $number;
540
+        return $number;
541 541
     }
542 542
 
543
-	/**
544
-	 * Set the invoice number.
545
-	 *
546
-	 * @since 1.0.19
547
-	 */
548
-	public function maybe_set_number() {
543
+    /**
544
+     * Set the invoice number.
545
+     *
546
+     * @since 1.0.19
547
+     */
548
+    public function maybe_set_number() {
549 549
         $number = $this->get_number();
550 550
 
551 551
         if ( empty( $number ) || $this->get_id() == $number ) {
552
-			$this->set_number( $this->generate_number() );
552
+            $this->set_number( $this->generate_number() );
553 553
         }
554 554
 
555
-	}
555
+    }
556 556
 
557 557
     /**
558
-	 * Get the invoice key.
559
-	 *
560
-	 * @since 1.0.19
561
-	 * @param  string $context View or edit context.
562
-	 * @return string
563
-	 */
564
-	public function get_key( $context = 'view' ) {
558
+     * Get the invoice key.
559
+     *
560
+     * @since 1.0.19
561
+     * @param  string $context View or edit context.
562
+     * @return string
563
+     */
564
+    public function get_key( $context = 'view' ) {
565 565
         return $this->get_prop( 'key', $context );
566
-	}
567
-
568
-	/**
569
-	 * Set the invoice key.
570
-	 *
571
-	 * @since 1.0.19
572
-	 */
573
-	public function maybe_set_key() {
566
+    }
567
+
568
+    /**
569
+     * Set the invoice key.
570
+     *
571
+     * @since 1.0.19
572
+     */
573
+    public function maybe_set_key() {
574 574
         $key = $this->get_key();
575 575
 
576 576
         if ( empty( $key ) ) {
@@ -581,126 +581,126 @@  discard block
 block discarded – undo
581 581
     }
582 582
 
583 583
     /**
584
-	 * Get the invoice type.
585
-	 *
586
-	 * @since 1.0.19
587
-	 * @param  string $context View or edit context.
588
-	 * @return string
589
-	 */
590
-	public function get_type( $context = 'view' ) {
584
+     * Get the invoice type.
585
+     *
586
+     * @since 1.0.19
587
+     * @param  string $context View or edit context.
588
+     * @return string
589
+     */
590
+    public function get_type( $context = 'view' ) {
591 591
         return $this->get_prop( 'type', $context );
592
-	}
592
+    }
593 593
 
594
-	/**
595
-	 * @deprecated
596
-	 */
597
-	public function get_invoice_quote_type() {
594
+    /**
595
+     * @deprecated
596
+     */
597
+    public function get_invoice_quote_type() {
598 598
         ucfirst( $this->get_type() );
599 599
     }
600 600
 
601 601
     /**
602
-	 * Get the invoice post type.
603
-	 *
604
-	 * @since 1.0.19
605
-	 * @param  string $context View or edit context.
606
-	 * @return string
607
-	 */
608
-	public function get_post_type( $context = 'view' ) {
602
+     * Get the invoice post type.
603
+     *
604
+     * @since 1.0.19
605
+     * @param  string $context View or edit context.
606
+     * @return string
607
+     */
608
+    public function get_post_type( $context = 'view' ) {
609 609
         return $this->get_prop( 'post_type', $context );
610 610
     }
611 611
 
612 612
     /**
613
-	 * Get the invoice mode.
614
-	 *
615
-	 * @since 1.0.19
616
-	 * @param  string $context View or edit context.
617
-	 * @return string
618
-	 */
619
-	public function get_mode( $context = 'view' ) {
613
+     * Get the invoice mode.
614
+     *
615
+     * @since 1.0.19
616
+     * @param  string $context View or edit context.
617
+     * @return string
618
+     */
619
+    public function get_mode( $context = 'view' ) {
620 620
         return $this->get_prop( 'mode', $context );
621 621
     }
622 622
 
623 623
     /**
624
-	 * Get the invoice path.
625
-	 *
626
-	 * @since 1.0.19
627
-	 * @param  string $context View or edit context.
628
-	 * @return string
629
-	 */
630
-	public function get_path( $context = 'view' ) {
624
+     * Get the invoice path.
625
+     *
626
+     * @since 1.0.19
627
+     * @param  string $context View or edit context.
628
+     * @return string
629
+     */
630
+    public function get_path( $context = 'view' ) {
631 631
         $path   = $this->get_prop( 'path', $context );
632
-		$prefix = $this->get_type();
632
+        $prefix = $this->get_type();
633 633
 
634
-		if ( 0 !== strpos( $path, $prefix ) ) {
635
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
636
-			$this->set_path( $path );
637
-		}
634
+        if ( 0 !== strpos( $path, $prefix ) ) {
635
+            $path = sanitize_title(  $prefix . '-' . $this->get_id()  );
636
+            $this->set_path( $path );
637
+        }
638 638
 
639
-		return $path;
639
+        return $path;
640 640
     }
641 641
 
642 642
     /**
643
-	 * Get the invoice name/title.
644
-	 *
645
-	 * @since 1.0.19
646
-	 * @param  string $context View or edit context.
647
-	 * @return string
648
-	 */
649
-	public function get_name( $context = 'view' ) {
643
+     * Get the invoice name/title.
644
+     *
645
+     * @since 1.0.19
646
+     * @param  string $context View or edit context.
647
+     * @return string
648
+     */
649
+    public function get_name( $context = 'view' ) {
650 650
         return $this->get_prop( 'title', $context );
651 651
     }
652 652
 
653 653
     /**
654
-	 * Alias of self::get_name().
655
-	 *
656
-	 * @since 1.0.19
657
-	 * @param  string $context View or edit context.
658
-	 * @return string
659
-	 */
660
-	public function get_title( $context = 'view' ) {
661
-		return $this->get_name( $context );
654
+     * Alias of self::get_name().
655
+     *
656
+     * @since 1.0.19
657
+     * @param  string $context View or edit context.
658
+     * @return string
659
+     */
660
+    public function get_title( $context = 'view' ) {
661
+        return $this->get_name( $context );
662 662
     }
663 663
 
664 664
     /**
665
-	 * Get the invoice description.
666
-	 *
667
-	 * @since 1.0.19
668
-	 * @param  string $context View or edit context.
669
-	 * @return string
670
-	 */
671
-	public function get_description( $context = 'view' ) {
672
-		return $this->get_prop( 'description', $context );
665
+     * Get the invoice description.
666
+     *
667
+     * @since 1.0.19
668
+     * @param  string $context View or edit context.
669
+     * @return string
670
+     */
671
+    public function get_description( $context = 'view' ) {
672
+        return $this->get_prop( 'description', $context );
673 673
     }
674 674
 
675 675
     /**
676
-	 * Alias of self::get_description().
677
-	 *
678
-	 * @since 1.0.19
679
-	 * @param  string $context View or edit context.
680
-	 * @return string
681
-	 */
682
-	public function get_excerpt( $context = 'view' ) {
683
-		return $this->get_description( $context );
676
+     * Alias of self::get_description().
677
+     *
678
+     * @since 1.0.19
679
+     * @param  string $context View or edit context.
680
+     * @return string
681
+     */
682
+    public function get_excerpt( $context = 'view' ) {
683
+        return $this->get_description( $context );
684 684
     }
685 685
 
686 686
     /**
687
-	 * Alias of self::get_description().
688
-	 *
689
-	 * @since 1.0.19
690
-	 * @param  string $context View or edit context.
691
-	 * @return string
692
-	 */
693
-	public function get_summary( $context = 'view' ) {
694
-		return $this->get_description( $context );
687
+     * Alias of self::get_description().
688
+     *
689
+     * @since 1.0.19
690
+     * @param  string $context View or edit context.
691
+     * @return string
692
+     */
693
+    public function get_summary( $context = 'view' ) {
694
+        return $this->get_description( $context );
695 695
     }
696 696
 
697 697
     /**
698
-	 * Returns the user info.
699
-	 *
700
-	 * @since 1.0.19
698
+     * Returns the user info.
699
+     *
700
+     * @since 1.0.19
701 701
      * @param  string $context View or edit context.
702
-	 * @return array
703
-	 */
702
+     * @return array
703
+     */
704 704
     public function get_user_info( $context = 'view' ) {
705 705
 
706 706
         $user_info = array(
@@ -717,616 +717,616 @@  discard block
 block discarded – undo
717 717
             'company'    => $this->get_company( $context ),
718 718
             'vat_number' => $this->get_vat_number( $context ),
719 719
             'discount'   => $this->get_discount_code( $context ),
720
-		);
720
+        );
721 721
 
722
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
722
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
723 723
 
724 724
     }
725 725
 
726 726
     /**
727
-	 * Get the customer id.
728
-	 *
729
-	 * @since 1.0.19
730
-	 * @param  string $context View or edit context.
731
-	 * @return int
732
-	 */
733
-	public function get_author( $context = 'view' ) {
734
-		return (int) $this->get_prop( 'author', $context );
727
+     * Get the customer id.
728
+     *
729
+     * @since 1.0.19
730
+     * @param  string $context View or edit context.
731
+     * @return int
732
+     */
733
+    public function get_author( $context = 'view' ) {
734
+        return (int) $this->get_prop( 'author', $context );
735 735
     }
736 736
 
737 737
     /**
738
-	 * Alias of self::get_author().
739
-	 *
740
-	 * @since 1.0.19
741
-	 * @param  string $context View or edit context.
742
-	 * @return int
743
-	 */
744
-	public function get_user_id( $context = 'view' ) {
745
-		return $this->get_author( $context );
738
+     * Alias of self::get_author().
739
+     *
740
+     * @since 1.0.19
741
+     * @param  string $context View or edit context.
742
+     * @return int
743
+     */
744
+    public function get_user_id( $context = 'view' ) {
745
+        return $this->get_author( $context );
746 746
     }
747 747
 
748
-     /**
749
-	 * Alias of self::get_author().
750
-	 *
751
-	 * @since 1.0.19
752
-	 * @param  string $context View or edit context.
753
-	 * @return int
754
-	 */
755
-	public function get_customer_id( $context = 'view' ) {
756
-		return $this->get_author( $context );
748
+        /**
749
+         * Alias of self::get_author().
750
+         *
751
+         * @since 1.0.19
752
+         * @param  string $context View or edit context.
753
+         * @return int
754
+         */
755
+    public function get_customer_id( $context = 'view' ) {
756
+        return $this->get_author( $context );
757 757
     }
758 758
 
759 759
     /**
760
-	 * Get the customer's ip.
761
-	 *
762
-	 * @since 1.0.19
763
-	 * @param  string $context View or edit context.
764
-	 * @return string
765
-	 */
766
-	public function get_ip( $context = 'view' ) {
767
-		return $this->get_prop( 'user_ip', $context );
760
+     * Get the customer's ip.
761
+     *
762
+     * @since 1.0.19
763
+     * @param  string $context View or edit context.
764
+     * @return string
765
+     */
766
+    public function get_ip( $context = 'view' ) {
767
+        return $this->get_prop( 'user_ip', $context );
768 768
     }
769 769
 
770 770
     /**
771
-	 * Alias of self::get_ip().
772
-	 *
773
-	 * @since 1.0.19
774
-	 * @param  string $context View or edit context.
775
-	 * @return string
776
-	 */
777
-	public function get_user_ip( $context = 'view' ) {
778
-		return $this->get_ip( $context );
771
+     * Alias of self::get_ip().
772
+     *
773
+     * @since 1.0.19
774
+     * @param  string $context View or edit context.
775
+     * @return string
776
+     */
777
+    public function get_user_ip( $context = 'view' ) {
778
+        return $this->get_ip( $context );
779 779
     }
780 780
 
781
-     /**
782
-	 * Alias of self::get_ip().
783
-	 *
784
-	 * @since 1.0.19
785
-	 * @param  string $context View or edit context.
786
-	 * @return string
787
-	 */
788
-	public function get_customer_ip( $context = 'view' ) {
789
-		return $this->get_ip( $context );
781
+        /**
782
+         * Alias of self::get_ip().
783
+         *
784
+         * @since 1.0.19
785
+         * @param  string $context View or edit context.
786
+         * @return string
787
+         */
788
+    public function get_customer_ip( $context = 'view' ) {
789
+        return $this->get_ip( $context );
790 790
     }
791 791
 
792 792
     /**
793
-	 * Get the customer's first name.
794
-	 *
795
-	 * @since 1.0.19
796
-	 * @param  string $context View or edit context.
797
-	 * @return string
798
-	 */
799
-	public function get_first_name( $context = 'view' ) {
800
-		return $this->get_prop( 'first_name', $context );
793
+     * Get the customer's first name.
794
+     *
795
+     * @since 1.0.19
796
+     * @param  string $context View or edit context.
797
+     * @return string
798
+     */
799
+    public function get_first_name( $context = 'view' ) {
800
+        return $this->get_prop( 'first_name', $context );
801 801
     }
802 802
 
803 803
     /**
804
-	 * Alias of self::get_first_name().
805
-	 *
806
-	 * @since 1.0.19
807
-	 * @param  string $context View or edit context.
808
-	 * @return string
809
-	 */
810
-	public function get_user_first_name( $context = 'view' ) {
811
-		return $this->get_first_name( $context );
804
+     * Alias of self::get_first_name().
805
+     *
806
+     * @since 1.0.19
807
+     * @param  string $context View or edit context.
808
+     * @return string
809
+     */
810
+    public function get_user_first_name( $context = 'view' ) {
811
+        return $this->get_first_name( $context );
812 812
     }
813 813
 
814
-     /**
815
-	 * Alias of self::get_first_name().
816
-	 *
817
-	 * @since 1.0.19
818
-	 * @param  string $context View or edit context.
819
-	 * @return string
820
-	 */
821
-	public function get_customer_first_name( $context = 'view' ) {
822
-		return $this->get_first_name( $context );
814
+        /**
815
+         * Alias of self::get_first_name().
816
+         *
817
+         * @since 1.0.19
818
+         * @param  string $context View or edit context.
819
+         * @return string
820
+         */
821
+    public function get_customer_first_name( $context = 'view' ) {
822
+        return $this->get_first_name( $context );
823 823
     }
824 824
 
825 825
     /**
826
-	 * Get the customer's last name.
827
-	 *
828
-	 * @since 1.0.19
829
-	 * @param  string $context View or edit context.
830
-	 * @return string
831
-	 */
832
-	public function get_last_name( $context = 'view' ) {
833
-		return $this->get_prop( 'last_name', $context );
826
+     * Get the customer's last name.
827
+     *
828
+     * @since 1.0.19
829
+     * @param  string $context View or edit context.
830
+     * @return string
831
+     */
832
+    public function get_last_name( $context = 'view' ) {
833
+        return $this->get_prop( 'last_name', $context );
834 834
     }
835 835
 
836 836
     /**
837
-	 * Alias of self::get_last_name().
838
-	 *
839
-	 * @since 1.0.19
840
-	 * @param  string $context View or edit context.
841
-	 * @return string
842
-	 */
843
-	public function get_user_last_name( $context = 'view' ) {
844
-		return $this->get_last_name( $context );
837
+     * Alias of self::get_last_name().
838
+     *
839
+     * @since 1.0.19
840
+     * @param  string $context View or edit context.
841
+     * @return string
842
+     */
843
+    public function get_user_last_name( $context = 'view' ) {
844
+        return $this->get_last_name( $context );
845 845
     }
846 846
 
847 847
     /**
848
-	 * Alias of self::get_last_name().
849
-	 *
850
-	 * @since 1.0.19
851
-	 * @param  string $context View or edit context.
852
-	 * @return string
853
-	 */
854
-	public function get_customer_last_name( $context = 'view' ) {
855
-		return $this->get_last_name( $context );
848
+     * Alias of self::get_last_name().
849
+     *
850
+     * @since 1.0.19
851
+     * @param  string $context View or edit context.
852
+     * @return string
853
+     */
854
+    public function get_customer_last_name( $context = 'view' ) {
855
+        return $this->get_last_name( $context );
856
+    }
857
+
858
+    /**
859
+     * Get the customer's full name.
860
+     *
861
+     * @since 1.0.19
862
+     * @param  string $context View or edit context.
863
+     * @return string
864
+     */
865
+    public function get_full_name( $context = 'view' ) {
866
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
867
+    }
868
+
869
+    /**
870
+     * Alias of self::get_full_name().
871
+     *
872
+     * @since 1.0.19
873
+     * @param  string $context View or edit context.
874
+     * @return string
875
+     */
876
+    public function get_user_full_name( $context = 'view' ) {
877
+        return $this->get_full_name( $context );
878
+    }
879
+
880
+    /**
881
+     * Alias of self::get_full_name().
882
+     *
883
+     * @since 1.0.19
884
+     * @param  string $context View or edit context.
885
+     * @return string
886
+     */
887
+    public function get_customer_full_name( $context = 'view' ) {
888
+        return $this->get_full_name( $context );
889
+    }
890
+
891
+    /**
892
+     * Get the customer's phone number.
893
+     *
894
+     * @since 1.0.19
895
+     * @param  string $context View or edit context.
896
+     * @return string
897
+     */
898
+    public function get_phone( $context = 'view' ) {
899
+        return $this->get_prop( 'phone', $context );
856 900
     }
857 901
 
858 902
     /**
859
-	 * Get the customer's full name.
860
-	 *
861
-	 * @since 1.0.19
862
-	 * @param  string $context View or edit context.
863
-	 * @return string
864
-	 */
865
-	public function get_full_name( $context = 'view' ) {
866
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
903
+     * Alias of self::get_phone().
904
+     *
905
+     * @since 1.0.19
906
+     * @param  string $context View or edit context.
907
+     * @return string
908
+     */
909
+    public function get_phone_number( $context = 'view' ) {
910
+        return $this->get_phone( $context );
867 911
     }
868 912
 
869 913
     /**
870
-	 * Alias of self::get_full_name().
871
-	 *
872
-	 * @since 1.0.19
873
-	 * @param  string $context View or edit context.
874
-	 * @return string
875
-	 */
876
-	public function get_user_full_name( $context = 'view' ) {
877
-		return $this->get_full_name( $context );
914
+     * Alias of self::get_phone().
915
+     *
916
+     * @since 1.0.19
917
+     * @param  string $context View or edit context.
918
+     * @return string
919
+     */
920
+    public function get_user_phone( $context = 'view' ) {
921
+        return $this->get_phone( $context );
878 922
     }
879 923
 
880 924
     /**
881
-	 * Alias of self::get_full_name().
882
-	 *
883
-	 * @since 1.0.19
884
-	 * @param  string $context View or edit context.
885
-	 * @return string
886
-	 */
887
-	public function get_customer_full_name( $context = 'view' ) {
888
-		return $this->get_full_name( $context );
925
+     * Alias of self::get_phone().
926
+     *
927
+     * @since 1.0.19
928
+     * @param  string $context View or edit context.
929
+     * @return string
930
+     */
931
+    public function get_customer_phone( $context = 'view' ) {
932
+        return $this->get_phone( $context );
889 933
     }
890 934
 
891 935
     /**
892
-	 * Get the customer's phone number.
893
-	 *
894
-	 * @since 1.0.19
895
-	 * @param  string $context View or edit context.
896
-	 * @return string
897
-	 */
898
-	public function get_phone( $context = 'view' ) {
899
-		return $this->get_prop( 'phone', $context );
936
+     * Get the customer's email address.
937
+     *
938
+     * @since 1.0.19
939
+     * @param  string $context View or edit context.
940
+     * @return string
941
+     */
942
+    public function get_email( $context = 'view' ) {
943
+        return $this->get_prop( 'email', $context );
944
+    }
945
+
946
+    /**
947
+     * Alias of self::get_email().
948
+     *
949
+     * @since 1.0.19
950
+     * @param  string $context View or edit context.
951
+     * @return string
952
+     */
953
+    public function get_email_address( $context = 'view' ) {
954
+        return $this->get_email( $context );
955
+    }
956
+
957
+    /**
958
+     * Alias of self::get_email().
959
+     *
960
+     * @since 1.0.19
961
+     * @param  string $context View or edit context.
962
+     * @return string
963
+     */
964
+    public function get_user_email( $context = 'view' ) {
965
+        return $this->get_email( $context );
966
+    }
967
+
968
+    /**
969
+     * Alias of self::get_email().
970
+     *
971
+     * @since 1.0.19
972
+     * @param  string $context View or edit context.
973
+     * @return string
974
+     */
975
+    public function get_customer_email( $context = 'view' ) {
976
+        return $this->get_email( $context );
977
+    }
978
+
979
+    /**
980
+     * Get the customer's country.
981
+     *
982
+     * @since 1.0.19
983
+     * @param  string $context View or edit context.
984
+     * @return string
985
+     */
986
+    public function get_country( $context = 'view' ) {
987
+        $country = $this->get_prop( 'country', $context );
988
+        return empty( $country ) ? wpinv_get_default_country() : $country;
989
+    }
990
+
991
+    /**
992
+     * Alias of self::get_country().
993
+     *
994
+     * @since 1.0.19
995
+     * @param  string $context View or edit context.
996
+     * @return string
997
+     */
998
+    public function get_user_country( $context = 'view' ) {
999
+        return $this->get_country( $context );
1000
+    }
1001
+
1002
+    /**
1003
+     * Alias of self::get_country().
1004
+     *
1005
+     * @since 1.0.19
1006
+     * @param  string $context View or edit context.
1007
+     * @return string
1008
+     */
1009
+    public function get_customer_country( $context = 'view' ) {
1010
+        return $this->get_country( $context );
1011
+    }
1012
+
1013
+    /**
1014
+     * Get the customer's state.
1015
+     *
1016
+     * @since 1.0.19
1017
+     * @param  string $context View or edit context.
1018
+     * @return string
1019
+     */
1020
+    public function get_state( $context = 'view' ) {
1021
+        $state = $this->get_prop( 'state', $context );
1022
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1023
+    }
1024
+
1025
+    /**
1026
+     * Alias of self::get_state().
1027
+     *
1028
+     * @since 1.0.19
1029
+     * @param  string $context View or edit context.
1030
+     * @return string
1031
+     */
1032
+    public function get_user_state( $context = 'view' ) {
1033
+        return $this->get_state( $context );
1034
+    }
1035
+
1036
+    /**
1037
+     * Alias of self::get_state().
1038
+     *
1039
+     * @since 1.0.19
1040
+     * @param  string $context View or edit context.
1041
+     * @return string
1042
+     */
1043
+    public function get_customer_state( $context = 'view' ) {
1044
+        return $this->get_state( $context );
900 1045
     }
901 1046
 
902 1047
     /**
903
-	 * Alias of self::get_phone().
904
-	 *
905
-	 * @since 1.0.19
906
-	 * @param  string $context View or edit context.
907
-	 * @return string
908
-	 */
909
-	public function get_phone_number( $context = 'view' ) {
910
-		return $this->get_phone( $context );
1048
+     * Get the customer's city.
1049
+     *
1050
+     * @since 1.0.19
1051
+     * @param  string $context View or edit context.
1052
+     * @return string
1053
+     */
1054
+    public function get_city( $context = 'view' ) {
1055
+        return $this->get_prop( 'city', $context );
911 1056
     }
912 1057
 
913 1058
     /**
914
-	 * Alias of self::get_phone().
915
-	 *
916
-	 * @since 1.0.19
917
-	 * @param  string $context View or edit context.
918
-	 * @return string
919
-	 */
920
-	public function get_user_phone( $context = 'view' ) {
921
-		return $this->get_phone( $context );
1059
+     * Alias of self::get_city().
1060
+     *
1061
+     * @since 1.0.19
1062
+     * @param  string $context View or edit context.
1063
+     * @return string
1064
+     */
1065
+    public function get_user_city( $context = 'view' ) {
1066
+        return $this->get_city( $context );
922 1067
     }
923 1068
 
924 1069
     /**
925
-	 * Alias of self::get_phone().
926
-	 *
927
-	 * @since 1.0.19
928
-	 * @param  string $context View or edit context.
929
-	 * @return string
930
-	 */
931
-	public function get_customer_phone( $context = 'view' ) {
932
-		return $this->get_phone( $context );
1070
+     * Alias of self::get_city().
1071
+     *
1072
+     * @since 1.0.19
1073
+     * @param  string $context View or edit context.
1074
+     * @return string
1075
+     */
1076
+    public function get_customer_city( $context = 'view' ) {
1077
+        return $this->get_city( $context );
933 1078
     }
934 1079
 
935 1080
     /**
936
-	 * Get the customer's email address.
937
-	 *
938
-	 * @since 1.0.19
939
-	 * @param  string $context View or edit context.
940
-	 * @return string
941
-	 */
942
-	public function get_email( $context = 'view' ) {
943
-		return $this->get_prop( 'email', $context );
1081
+     * Get the customer's zip.
1082
+     *
1083
+     * @since 1.0.19
1084
+     * @param  string $context View or edit context.
1085
+     * @return string
1086
+     */
1087
+    public function get_zip( $context = 'view' ) {
1088
+        return $this->get_prop( 'zip', $context );
944 1089
     }
945 1090
 
946 1091
     /**
947
-	 * Alias of self::get_email().
948
-	 *
949
-	 * @since 1.0.19
950
-	 * @param  string $context View or edit context.
951
-	 * @return string
952
-	 */
953
-	public function get_email_address( $context = 'view' ) {
954
-		return $this->get_email( $context );
1092
+     * Alias of self::get_zip().
1093
+     *
1094
+     * @since 1.0.19
1095
+     * @param  string $context View or edit context.
1096
+     * @return string
1097
+     */
1098
+    public function get_user_zip( $context = 'view' ) {
1099
+        return $this->get_zip( $context );
955 1100
     }
956 1101
 
957 1102
     /**
958
-	 * Alias of self::get_email().
959
-	 *
960
-	 * @since 1.0.19
961
-	 * @param  string $context View or edit context.
962
-	 * @return string
963
-	 */
964
-	public function get_user_email( $context = 'view' ) {
965
-		return $this->get_email( $context );
1103
+     * Alias of self::get_zip().
1104
+     *
1105
+     * @since 1.0.19
1106
+     * @param  string $context View or edit context.
1107
+     * @return string
1108
+     */
1109
+    public function get_customer_zip( $context = 'view' ) {
1110
+        return $this->get_zip( $context );
966 1111
     }
967 1112
 
968 1113
     /**
969
-	 * Alias of self::get_email().
970
-	 *
971
-	 * @since 1.0.19
972
-	 * @param  string $context View or edit context.
973
-	 * @return string
974
-	 */
975
-	public function get_customer_email( $context = 'view' ) {
976
-		return $this->get_email( $context );
1114
+     * Get the customer's company.
1115
+     *
1116
+     * @since 1.0.19
1117
+     * @param  string $context View or edit context.
1118
+     * @return string
1119
+     */
1120
+    public function get_company( $context = 'view' ) {
1121
+        return $this->get_prop( 'company', $context );
977 1122
     }
978 1123
 
979 1124
     /**
980
-	 * Get the customer's country.
981
-	 *
982
-	 * @since 1.0.19
983
-	 * @param  string $context View or edit context.
984
-	 * @return string
985
-	 */
986
-	public function get_country( $context = 'view' ) {
987
-		$country = $this->get_prop( 'country', $context );
988
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1125
+     * Alias of self::get_company().
1126
+     *
1127
+     * @since 1.0.19
1128
+     * @param  string $context View or edit context.
1129
+     * @return string
1130
+     */
1131
+    public function get_user_company( $context = 'view' ) {
1132
+        return $this->get_company( $context );
989 1133
     }
990 1134
 
991 1135
     /**
992
-	 * Alias of self::get_country().
993
-	 *
994
-	 * @since 1.0.19
995
-	 * @param  string $context View or edit context.
996
-	 * @return string
997
-	 */
998
-	public function get_user_country( $context = 'view' ) {
999
-		return $this->get_country( $context );
1136
+     * Alias of self::get_company().
1137
+     *
1138
+     * @since 1.0.19
1139
+     * @param  string $context View or edit context.
1140
+     * @return string
1141
+     */
1142
+    public function get_customer_company( $context = 'view' ) {
1143
+        return $this->get_company( $context );
1000 1144
     }
1001 1145
 
1002 1146
     /**
1003
-	 * Alias of self::get_country().
1004
-	 *
1005
-	 * @since 1.0.19
1006
-	 * @param  string $context View or edit context.
1007
-	 * @return string
1008
-	 */
1009
-	public function get_customer_country( $context = 'view' ) {
1010
-		return $this->get_country( $context );
1147
+     * Get the customer's vat number.
1148
+     *
1149
+     * @since 1.0.19
1150
+     * @param  string $context View or edit context.
1151
+     * @return string
1152
+     */
1153
+    public function get_vat_number( $context = 'view' ) {
1154
+        return $this->get_prop( 'vat_number', $context );
1011 1155
     }
1012 1156
 
1013 1157
     /**
1014
-	 * Get the customer's state.
1015
-	 *
1016
-	 * @since 1.0.19
1017
-	 * @param  string $context View or edit context.
1018
-	 * @return string
1019
-	 */
1020
-	public function get_state( $context = 'view' ) {
1021
-		$state = $this->get_prop( 'state', $context );
1022
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1158
+     * Alias of self::get_vat_number().
1159
+     *
1160
+     * @since 1.0.19
1161
+     * @param  string $context View or edit context.
1162
+     * @return string
1163
+     */
1164
+    public function get_user_vat_number( $context = 'view' ) {
1165
+        return $this->get_vat_number( $context );
1023 1166
     }
1024 1167
 
1025 1168
     /**
1026
-	 * Alias of self::get_state().
1027
-	 *
1028
-	 * @since 1.0.19
1029
-	 * @param  string $context View or edit context.
1030
-	 * @return string
1031
-	 */
1032
-	public function get_user_state( $context = 'view' ) {
1033
-		return $this->get_state( $context );
1169
+     * Alias of self::get_vat_number().
1170
+     *
1171
+     * @since 1.0.19
1172
+     * @param  string $context View or edit context.
1173
+     * @return string
1174
+     */
1175
+    public function get_customer_vat_number( $context = 'view' ) {
1176
+        return $this->get_vat_number( $context );
1034 1177
     }
1035 1178
 
1036 1179
     /**
1037
-	 * Alias of self::get_state().
1038
-	 *
1039
-	 * @since 1.0.19
1040
-	 * @param  string $context View or edit context.
1041
-	 * @return string
1042
-	 */
1043
-	public function get_customer_state( $context = 'view' ) {
1044
-		return $this->get_state( $context );
1180
+     * Get the customer's vat rate.
1181
+     *
1182
+     * @since 1.0.19
1183
+     * @param  string $context View or edit context.
1184
+     * @return string
1185
+     */
1186
+    public function get_vat_rate( $context = 'view' ) {
1187
+        return $this->get_prop( 'vat_rate', $context );
1045 1188
     }
1046 1189
 
1047 1190
     /**
1048
-	 * Get the customer's city.
1049
-	 *
1050
-	 * @since 1.0.19
1051
-	 * @param  string $context View or edit context.
1052
-	 * @return string
1053
-	 */
1054
-	public function get_city( $context = 'view' ) {
1055
-		return $this->get_prop( 'city', $context );
1191
+     * Alias of self::get_vat_rate().
1192
+     *
1193
+     * @since 1.0.19
1194
+     * @param  string $context View or edit context.
1195
+     * @return string
1196
+     */
1197
+    public function get_user_vat_rate( $context = 'view' ) {
1198
+        return $this->get_vat_rate( $context );
1056 1199
     }
1057 1200
 
1058 1201
     /**
1059
-	 * Alias of self::get_city().
1060
-	 *
1061
-	 * @since 1.0.19
1062
-	 * @param  string $context View or edit context.
1063
-	 * @return string
1064
-	 */
1065
-	public function get_user_city( $context = 'view' ) {
1066
-		return $this->get_city( $context );
1202
+     * Alias of self::get_vat_rate().
1203
+     *
1204
+     * @since 1.0.19
1205
+     * @param  string $context View or edit context.
1206
+     * @return string
1207
+     */
1208
+    public function get_customer_vat_rate( $context = 'view' ) {
1209
+        return $this->get_vat_rate( $context );
1067 1210
     }
1068 1211
 
1069 1212
     /**
1070
-	 * Alias of self::get_city().
1071
-	 *
1072
-	 * @since 1.0.19
1073
-	 * @param  string $context View or edit context.
1074
-	 * @return string
1075
-	 */
1076
-	public function get_customer_city( $context = 'view' ) {
1077
-		return $this->get_city( $context );
1213
+     * Get the customer's address.
1214
+     *
1215
+     * @since 1.0.19
1216
+     * @param  string $context View or edit context.
1217
+     * @return string
1218
+     */
1219
+    public function get_address( $context = 'view' ) {
1220
+        return $this->get_prop( 'address', $context );
1078 1221
     }
1079 1222
 
1080 1223
     /**
1081
-	 * Get the customer's zip.
1082
-	 *
1083
-	 * @since 1.0.19
1084
-	 * @param  string $context View or edit context.
1085
-	 * @return string
1086
-	 */
1087
-	public function get_zip( $context = 'view' ) {
1088
-		return $this->get_prop( 'zip', $context );
1224
+     * Alias of self::get_address().
1225
+     *
1226
+     * @since 1.0.19
1227
+     * @param  string $context View or edit context.
1228
+     * @return string
1229
+     */
1230
+    public function get_user_address( $context = 'view' ) {
1231
+        return $this->get_address( $context );
1089 1232
     }
1090 1233
 
1091 1234
     /**
1092
-	 * Alias of self::get_zip().
1093
-	 *
1094
-	 * @since 1.0.19
1095
-	 * @param  string $context View or edit context.
1096
-	 * @return string
1097
-	 */
1098
-	public function get_user_zip( $context = 'view' ) {
1099
-		return $this->get_zip( $context );
1235
+     * Alias of self::get_address().
1236
+     *
1237
+     * @since 1.0.19
1238
+     * @param  string $context View or edit context.
1239
+     * @return string
1240
+     */
1241
+    public function get_customer_address( $context = 'view' ) {
1242
+        return $this->get_address( $context );
1100 1243
     }
1101 1244
 
1102 1245
     /**
1103
-	 * Alias of self::get_zip().
1104
-	 *
1105
-	 * @since 1.0.19
1106
-	 * @param  string $context View or edit context.
1107
-	 * @return string
1108
-	 */
1109
-	public function get_customer_zip( $context = 'view' ) {
1110
-		return $this->get_zip( $context );
1246
+     * Get whether the customer has viewed the invoice or not.
1247
+     *
1248
+     * @since 1.0.19
1249
+     * @param  string $context View or edit context.
1250
+     * @return bool
1251
+     */
1252
+    public function get_is_viewed( $context = 'view' ) {
1253
+        return (bool) $this->get_prop( 'is_viewed', $context );
1111 1254
     }
1112 1255
 
1113 1256
     /**
1114
-	 * Get the customer's company.
1115
-	 *
1116
-	 * @since 1.0.19
1117
-	 * @param  string $context View or edit context.
1118
-	 * @return string
1119
-	 */
1120
-	public function get_company( $context = 'view' ) {
1121
-		return $this->get_prop( 'company', $context );
1257
+     * Get other recipients for invoice communications.
1258
+     *
1259
+     * @since 1.0.19
1260
+     * @param  string $context View or edit context.
1261
+     * @return bool
1262
+     */
1263
+    public function get_email_cc( $context = 'view' ) {
1264
+        return $this->get_prop( 'email_cc', $context );
1122 1265
     }
1123 1266
 
1124 1267
     /**
1125
-	 * Alias of self::get_company().
1126
-	 *
1127
-	 * @since 1.0.19
1128
-	 * @param  string $context View or edit context.
1129
-	 * @return string
1130
-	 */
1131
-	public function get_user_company( $context = 'view' ) {
1132
-		return $this->get_company( $context );
1268
+     * Get invoice template.
1269
+     *
1270
+     * @since 1.0.19
1271
+     * @param  string $context View or edit context.
1272
+     * @return bool
1273
+     */
1274
+    public function get_template( $context = 'view' ) {
1275
+        return $this->get_prop( 'template', $context );
1133 1276
     }
1134 1277
 
1135 1278
     /**
1136
-	 * Alias of self::get_company().
1137
-	 *
1138
-	 * @since 1.0.19
1139
-	 * @param  string $context View or edit context.
1140
-	 * @return string
1141
-	 */
1142
-	public function get_customer_company( $context = 'view' ) {
1143
-		return $this->get_company( $context );
1279
+     * Get invoice source.
1280
+     *
1281
+     * @since 1.0.19
1282
+     * @param  string $context View or edit context.
1283
+     * @return bool
1284
+     */
1285
+    public function get_created_via( $context = 'view' ) {
1286
+        return $this->get_prop( 'created_via', $context );
1144 1287
     }
1145 1288
 
1146 1289
     /**
1147
-	 * Get the customer's vat number.
1148
-	 *
1149
-	 * @since 1.0.19
1150
-	 * @param  string $context View or edit context.
1151
-	 * @return string
1152
-	 */
1153
-	public function get_vat_number( $context = 'view' ) {
1154
-		return $this->get_prop( 'vat_number', $context );
1290
+     * Get whether the customer has confirmed their address.
1291
+     *
1292
+     * @since 1.0.19
1293
+     * @param  string $context View or edit context.
1294
+     * @return bool
1295
+     */
1296
+    public function get_address_confirmed( $context = 'view' ) {
1297
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1155 1298
     }
1156 1299
 
1157 1300
     /**
1158
-	 * Alias of self::get_vat_number().
1159
-	 *
1160
-	 * @since 1.0.19
1161
-	 * @param  string $context View or edit context.
1162
-	 * @return string
1163
-	 */
1164
-	public function get_user_vat_number( $context = 'view' ) {
1165
-		return $this->get_vat_number( $context );
1301
+     * Alias of self::get_address_confirmed().
1302
+     *
1303
+     * @since 1.0.19
1304
+     * @param  string $context View or edit context.
1305
+     * @return bool
1306
+     */
1307
+    public function get_user_address_confirmed( $context = 'view' ) {
1308
+        return $this->get_address_confirmed( $context );
1166 1309
     }
1167 1310
 
1168 1311
     /**
1169
-	 * Alias of self::get_vat_number().
1170
-	 *
1171
-	 * @since 1.0.19
1172
-	 * @param  string $context View or edit context.
1173
-	 * @return string
1174
-	 */
1175
-	public function get_customer_vat_number( $context = 'view' ) {
1176
-		return $this->get_vat_number( $context );
1312
+     * Alias of self::get_address().
1313
+     *
1314
+     * @since 1.0.19
1315
+     * @param  string $context View or edit context.
1316
+     * @return bool
1317
+     */
1318
+    public function get_customer_address_confirmed( $context = 'view' ) {
1319
+        return $this->get_address_confirmed( $context );
1177 1320
     }
1178 1321
 
1179 1322
     /**
1180
-	 * Get the customer's vat rate.
1181
-	 *
1182
-	 * @since 1.0.19
1183
-	 * @param  string $context View or edit context.
1184
-	 * @return string
1185
-	 */
1186
-	public function get_vat_rate( $context = 'view' ) {
1187
-		return $this->get_prop( 'vat_rate', $context );
1188
-    }
1189
-
1190
-    /**
1191
-	 * Alias of self::get_vat_rate().
1192
-	 *
1193
-	 * @since 1.0.19
1194
-	 * @param  string $context View or edit context.
1195
-	 * @return string
1196
-	 */
1197
-	public function get_user_vat_rate( $context = 'view' ) {
1198
-		return $this->get_vat_rate( $context );
1199
-    }
1200
-
1201
-    /**
1202
-	 * Alias of self::get_vat_rate().
1203
-	 *
1204
-	 * @since 1.0.19
1205
-	 * @param  string $context View or edit context.
1206
-	 * @return string
1207
-	 */
1208
-	public function get_customer_vat_rate( $context = 'view' ) {
1209
-		return $this->get_vat_rate( $context );
1210
-    }
1211
-
1212
-    /**
1213
-	 * Get the customer's address.
1214
-	 *
1215
-	 * @since 1.0.19
1216
-	 * @param  string $context View or edit context.
1217
-	 * @return string
1218
-	 */
1219
-	public function get_address( $context = 'view' ) {
1220
-		return $this->get_prop( 'address', $context );
1221
-    }
1222
-
1223
-    /**
1224
-	 * Alias of self::get_address().
1225
-	 *
1226
-	 * @since 1.0.19
1227
-	 * @param  string $context View or edit context.
1228
-	 * @return string
1229
-	 */
1230
-	public function get_user_address( $context = 'view' ) {
1231
-		return $this->get_address( $context );
1232
-    }
1233
-
1234
-    /**
1235
-	 * Alias of self::get_address().
1236
-	 *
1237
-	 * @since 1.0.19
1238
-	 * @param  string $context View or edit context.
1239
-	 * @return string
1240
-	 */
1241
-	public function get_customer_address( $context = 'view' ) {
1242
-		return $this->get_address( $context );
1243
-    }
1244
-
1245
-    /**
1246
-	 * Get whether the customer has viewed the invoice or not.
1247
-	 *
1248
-	 * @since 1.0.19
1249
-	 * @param  string $context View or edit context.
1250
-	 * @return bool
1251
-	 */
1252
-	public function get_is_viewed( $context = 'view' ) {
1253
-		return (bool) $this->get_prop( 'is_viewed', $context );
1254
-	}
1255
-
1256
-	/**
1257
-	 * Get other recipients for invoice communications.
1258
-	 *
1259
-	 * @since 1.0.19
1260
-	 * @param  string $context View or edit context.
1261
-	 * @return bool
1262
-	 */
1263
-	public function get_email_cc( $context = 'view' ) {
1264
-		return $this->get_prop( 'email_cc', $context );
1265
-	}
1266
-
1267
-	/**
1268
-	 * Get invoice template.
1269
-	 *
1270
-	 * @since 1.0.19
1271
-	 * @param  string $context View or edit context.
1272
-	 * @return bool
1273
-	 */
1274
-	public function get_template( $context = 'view' ) {
1275
-		return $this->get_prop( 'template', $context );
1276
-	}
1277
-
1278
-	/**
1279
-	 * Get invoice source.
1280
-	 *
1281
-	 * @since 1.0.19
1282
-	 * @param  string $context View or edit context.
1283
-	 * @return bool
1284
-	 */
1285
-	public function get_created_via( $context = 'view' ) {
1286
-		return $this->get_prop( 'created_via', $context );
1287
-	}
1288
-
1289
-	/**
1290
-	 * Get whether the customer has confirmed their address.
1291
-	 *
1292
-	 * @since 1.0.19
1293
-	 * @param  string $context View or edit context.
1294
-	 * @return bool
1295
-	 */
1296
-	public function get_address_confirmed( $context = 'view' ) {
1297
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1298
-    }
1299
-
1300
-    /**
1301
-	 * Alias of self::get_address_confirmed().
1302
-	 *
1303
-	 * @since 1.0.19
1304
-	 * @param  string $context View or edit context.
1305
-	 * @return bool
1306
-	 */
1307
-	public function get_user_address_confirmed( $context = 'view' ) {
1308
-		return $this->get_address_confirmed( $context );
1309
-    }
1310
-
1311
-    /**
1312
-	 * Alias of self::get_address().
1313
-	 *
1314
-	 * @since 1.0.19
1315
-	 * @param  string $context View or edit context.
1316
-	 * @return bool
1317
-	 */
1318
-	public function get_customer_address_confirmed( $context = 'view' ) {
1319
-		return $this->get_address_confirmed( $context );
1320
-    }
1321
-
1322
-    /**
1323
-	 * Get the invoice subtotal.
1324
-	 *
1325
-	 * @since 1.0.19
1326
-	 * @param  string $context View or edit context.
1327
-	 * @return float
1328
-	 */
1329
-	public function get_subtotal( $context = 'view' ) {
1323
+     * Get the invoice subtotal.
1324
+     *
1325
+     * @since 1.0.19
1326
+     * @param  string $context View or edit context.
1327
+     * @return float
1328
+     */
1329
+    public function get_subtotal( $context = 'view' ) {
1330 1330
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1331 1331
 
1332 1332
         // Backwards compatibility.
@@ -1338,165 +1338,165 @@  discard block
 block discarded – undo
1338 1338
     }
1339 1339
 
1340 1340
     /**
1341
-	 * Get the invoice discount total.
1342
-	 *
1343
-	 * @since 1.0.19
1344
-	 * @param  string $context View or edit context.
1345
-	 * @return float
1346
-	 */
1347
-	public function get_total_discount( $context = 'view' ) {
1348
-		return (float) $this->get_prop( 'total_discount', $context );
1341
+     * Get the invoice discount total.
1342
+     *
1343
+     * @since 1.0.19
1344
+     * @param  string $context View or edit context.
1345
+     * @return float
1346
+     */
1347
+    public function get_total_discount( $context = 'view' ) {
1348
+        return (float) $this->get_prop( 'total_discount', $context );
1349
+    }
1350
+
1351
+    /**
1352
+     * Get the invoice tax total.
1353
+     *
1354
+     * @since 1.0.19
1355
+     * @param  string $context View or edit context.
1356
+     * @return float
1357
+     */
1358
+    public function get_total_tax( $context = 'view' ) {
1359
+        return (float) $this->get_prop( 'total_tax', $context );
1349 1360
     }
1350 1361
 
1351 1362
     /**
1352
-	 * Get the invoice tax total.
1353
-	 *
1354
-	 * @since 1.0.19
1355
-	 * @param  string $context View or edit context.
1356
-	 * @return float
1357
-	 */
1358
-	public function get_total_tax( $context = 'view' ) {
1359
-		return (float) $this->get_prop( 'total_tax', $context );
1360
-	}
1361
-
1362
-	/**
1363
-	 * @deprecated
1364
-	 */
1365
-	public function get_final_tax( $currency = false ) {
1366
-		$tax = $this->get_total_tax();
1363
+     * @deprecated
1364
+     */
1365
+    public function get_final_tax( $currency = false ) {
1366
+        $tax = $this->get_total_tax();
1367 1367
 
1368 1368
         if ( $currency ) {
1369
-			return wpinv_price( $tax, $this->get_currency() );
1369
+            return wpinv_price( $tax, $this->get_currency() );
1370 1370
         }
1371 1371
 
1372 1372
         return $tax;
1373 1373
     }
1374 1374
 
1375 1375
     /**
1376
-	 * Get the invoice fees total.
1377
-	 *
1378
-	 * @since 1.0.19
1379
-	 * @param  string $context View or edit context.
1380
-	 * @return float
1381
-	 */
1382
-	public function get_total_fees( $context = 'view' ) {
1383
-		return (float) $this->get_prop( 'total_fees', $context );
1376
+     * Get the invoice fees total.
1377
+     *
1378
+     * @since 1.0.19
1379
+     * @param  string $context View or edit context.
1380
+     * @return float
1381
+     */
1382
+    public function get_total_fees( $context = 'view' ) {
1383
+        return (float) $this->get_prop( 'total_fees', $context );
1384 1384
     }
1385 1385
 
1386 1386
     /**
1387
-	 * Alias for self::get_total_fees().
1388
-	 *
1389
-	 * @since 1.0.19
1390
-	 * @param  string $context View or edit context.
1391
-	 * @return float
1392
-	 */
1393
-	public function get_fees_total( $context = 'view' ) {
1394
-		return $this->get_total_fees( $context );
1387
+     * Alias for self::get_total_fees().
1388
+     *
1389
+     * @since 1.0.19
1390
+     * @param  string $context View or edit context.
1391
+     * @return float
1392
+     */
1393
+    public function get_fees_total( $context = 'view' ) {
1394
+        return $this->get_total_fees( $context );
1395 1395
     }
1396 1396
 
1397 1397
     /**
1398
-	 * Get the invoice total.
1399
-	 *
1400
-	 * @since 1.0.19
1398
+     * Get the invoice total.
1399
+     *
1400
+     * @since 1.0.19
1401 1401
      * @return float
1402
-	 */
1403
-	public function get_total() {
1404
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1405
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1406
-	}
1402
+     */
1403
+    public function get_total() {
1404
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1405
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1406
+    }
1407 1407
 	
1408
-	/**
1409
-	 * Get the invoice totals.
1410
-	 *
1411
-	 * @since 1.0.19
1408
+    /**
1409
+     * Get the invoice totals.
1410
+     *
1411
+     * @since 1.0.19
1412 1412
      * @return array
1413
-	 */
1414
-	public function get_totals() {
1415
-		return $this->totals;
1413
+     */
1414
+    public function get_totals() {
1415
+        return $this->totals;
1416 1416
     }
1417 1417
 
1418 1418
     /**
1419
-	 * Get the initial invoice total.
1420
-	 *
1421
-	 * @since 1.0.19
1419
+     * Get the initial invoice total.
1420
+     *
1421
+     * @since 1.0.19
1422 1422
      * @param  string $context View or edit context.
1423 1423
      * @return float
1424
-	 */
1424
+     */
1425 1425
     public function get_initial_total() {
1426 1426
 
1427
-		if ( empty( $this->totals ) ) {
1428
-			$this->recalculate_total();
1429
-		}
1427
+        if ( empty( $this->totals ) ) {
1428
+            $this->recalculate_total();
1429
+        }
1430 1430
 
1431
-		$tax      = $this->totals['tax']['initial'];
1432
-		$fee      = $this->totals['fee']['initial'];
1433
-		$discount = $this->totals['discount']['initial'];
1434
-		$subtotal = $this->totals['subtotal']['initial'];
1435
-		$total    = $tax + $fee - $discount + $subtotal;
1431
+        $tax      = $this->totals['tax']['initial'];
1432
+        $fee      = $this->totals['fee']['initial'];
1433
+        $discount = $this->totals['discount']['initial'];
1434
+        $subtotal = $this->totals['subtotal']['initial'];
1435
+        $total    = $tax + $fee - $discount + $subtotal;
1436 1436
 
1437
-		if ( 0 > $total ) {
1438
-			$total = 0;
1439
-		}
1437
+        if ( 0 > $total ) {
1438
+            $total = 0;
1439
+        }
1440 1440
 
1441 1441
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1442
-	}
1442
+    }
1443 1443
 
1444
-	/**
1445
-	 * Get the recurring invoice total.
1446
-	 *
1447
-	 * @since 1.0.19
1444
+    /**
1445
+     * Get the recurring invoice total.
1446
+     *
1447
+     * @since 1.0.19
1448 1448
      * @param  string $context View or edit context.
1449 1449
      * @return float
1450
-	 */
1450
+     */
1451 1451
     public function get_recurring_total() {
1452 1452
 
1453
-		if ( empty( $this->totals ) ) {
1454
-			$this->recalculate_total();
1455
-		}
1453
+        if ( empty( $this->totals ) ) {
1454
+            $this->recalculate_total();
1455
+        }
1456 1456
 
1457
-		$tax      = $this->totals['tax']['recurring'];
1458
-		$fee      = $this->totals['fee']['recurring'];
1459
-		$discount = $this->totals['discount']['recurring'];
1460
-		$subtotal = $this->totals['subtotal']['recurring'];
1461
-		$total    = $tax + $fee - $discount + $subtotal;
1457
+        $tax      = $this->totals['tax']['recurring'];
1458
+        $fee      = $this->totals['fee']['recurring'];
1459
+        $discount = $this->totals['discount']['recurring'];
1460
+        $subtotal = $this->totals['subtotal']['recurring'];
1461
+        $total    = $tax + $fee - $discount + $subtotal;
1462 1462
 
1463
-		if ( 0 > $total ) {
1464
-			$total = 0;
1465
-		}
1463
+        if ( 0 > $total ) {
1464
+            $total = 0;
1465
+        }
1466 1466
 
1467 1467
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1468
-	}
1468
+    }
1469 1469
 
1470
-	/**
1471
-	 * Returns recurring payment details.
1472
-	 *
1473
-	 * @since 1.0.19
1470
+    /**
1471
+     * Returns recurring payment details.
1472
+     *
1473
+     * @since 1.0.19
1474 1474
      * @param  string $field Optionally provide a field to return.
1475
-	 * @param string $currency Whether to include the currency.
1475
+     * @param string $currency Whether to include the currency.
1476 1476
      * @return float|string
1477
-	 */
1477
+     */
1478 1478
     public function get_recurring_details( $field = '', $currency = false ) {
1479 1479
 
1480
-		// Maybe recalculate totals.
1481
-		if ( empty( $this->totals ) ) {
1482
-			$this->recalculate_total();
1483
-		}
1480
+        // Maybe recalculate totals.
1481
+        if ( empty( $this->totals ) ) {
1482
+            $this->recalculate_total();
1483
+        }
1484 1484
 
1485
-		// Prepare recurring totals.
1485
+        // Prepare recurring totals.
1486 1486
         $data = apply_filters(
1487
-			'wpinv_get_invoice_recurring_details',
1488
-			array(
1489
-				'cart_details' => $this->get_cart_details(),
1490
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1491
-				'discount'     => $this->totals['discount']['recurring'],
1492
-				'tax'          => $this->totals['tax']['recurring'],
1493
-				'fee'          => $this->totals['fee']['recurring'],
1494
-				'total'        => $this->get_recurring_total(),
1495
-			),
1496
-			$this,
1497
-			$field,
1498
-			$currency
1499
-		);
1487
+            'wpinv_get_invoice_recurring_details',
1488
+            array(
1489
+                'cart_details' => $this->get_cart_details(),
1490
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1491
+                'discount'     => $this->totals['discount']['recurring'],
1492
+                'tax'          => $this->totals['tax']['recurring'],
1493
+                'fee'          => $this->totals['fee']['recurring'],
1494
+                'total'        => $this->get_recurring_total(),
1495
+            ),
1496
+            $this,
1497
+            $field,
1498
+            $currency
1499
+        );
1500 1500
 
1501 1501
         if ( isset( $data[$field] ) ) {
1502 1502
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1506,156 +1506,156 @@  discard block
 block discarded – undo
1506 1506
     }
1507 1507
 
1508 1508
     /**
1509
-	 * Get the invoice fees.
1510
-	 *
1511
-	 * @since 1.0.19
1512
-	 * @param  string $context View or edit context.
1513
-	 * @return array
1514
-	 */
1515
-	public function get_fees( $context = 'view' ) {
1516
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1509
+     * Get the invoice fees.
1510
+     *
1511
+     * @since 1.0.19
1512
+     * @param  string $context View or edit context.
1513
+     * @return array
1514
+     */
1515
+    public function get_fees( $context = 'view' ) {
1516
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1517 1517
     }
1518 1518
 
1519 1519
     /**
1520
-	 * Get the invoice discounts.
1521
-	 *
1522
-	 * @since 1.0.19
1523
-	 * @param  string $context View or edit context.
1524
-	 * @return array
1525
-	 */
1526
-	public function get_discounts( $context = 'view' ) {
1527
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1520
+     * Get the invoice discounts.
1521
+     *
1522
+     * @since 1.0.19
1523
+     * @param  string $context View or edit context.
1524
+     * @return array
1525
+     */
1526
+    public function get_discounts( $context = 'view' ) {
1527
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1528 1528
     }
1529 1529
 
1530 1530
     /**
1531
-	 * Get the invoice taxes.
1532
-	 *
1533
-	 * @since 1.0.19
1534
-	 * @param  string $context View or edit context.
1535
-	 * @return array
1536
-	 */
1537
-	public function get_taxes( $context = 'view' ) {
1538
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1531
+     * Get the invoice taxes.
1532
+     *
1533
+     * @since 1.0.19
1534
+     * @param  string $context View or edit context.
1535
+     * @return array
1536
+     */
1537
+    public function get_taxes( $context = 'view' ) {
1538
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1539 1539
     }
1540 1540
 
1541 1541
     /**
1542
-	 * Get the invoice items.
1543
-	 *
1544
-	 * @since 1.0.19
1545
-	 * @param  string $context View or edit context.
1546
-	 * @return GetPaid_Form_Item[]
1547
-	 */
1548
-	public function get_items( $context = 'view' ) {
1542
+     * Get the invoice items.
1543
+     *
1544
+     * @since 1.0.19
1545
+     * @param  string $context View or edit context.
1546
+     * @return GetPaid_Form_Item[]
1547
+     */
1548
+    public function get_items( $context = 'view' ) {
1549 1549
         return $this->get_prop( 'items', $context );
1550 1550
     }
1551 1551
 
1552 1552
     /**
1553
-	 * Get the invoice's payment form.
1554
-	 *
1555
-	 * @since 1.0.19
1556
-	 * @param  string $context View or edit context.
1557
-	 * @return int
1558
-	 */
1559
-	public function get_payment_form( $context = 'view' ) {
1560
-		return intval( $this->get_prop( 'payment_form', $context ) );
1553
+     * Get the invoice's payment form.
1554
+     *
1555
+     * @since 1.0.19
1556
+     * @param  string $context View or edit context.
1557
+     * @return int
1558
+     */
1559
+    public function get_payment_form( $context = 'view' ) {
1560
+        return intval( $this->get_prop( 'payment_form', $context ) );
1561 1561
     }
1562 1562
 
1563 1563
     /**
1564
-	 * Get the invoice's submission id.
1565
-	 *
1566
-	 * @since 1.0.19
1567
-	 * @param  string $context View or edit context.
1568
-	 * @return string
1569
-	 */
1570
-	public function get_submission_id( $context = 'view' ) {
1571
-		return $this->get_prop( 'submission_id', $context );
1564
+     * Get the invoice's submission id.
1565
+     *
1566
+     * @since 1.0.19
1567
+     * @param  string $context View or edit context.
1568
+     * @return string
1569
+     */
1570
+    public function get_submission_id( $context = 'view' ) {
1571
+        return $this->get_prop( 'submission_id', $context );
1572 1572
     }
1573 1573
 
1574 1574
     /**
1575
-	 * Get the invoice's discount code.
1576
-	 *
1577
-	 * @since 1.0.19
1578
-	 * @param  string $context View or edit context.
1579
-	 * @return string
1580
-	 */
1581
-	public function get_discount_code( $context = 'view' ) {
1582
-		return $this->get_prop( 'discount_code', $context );
1575
+     * Get the invoice's discount code.
1576
+     *
1577
+     * @since 1.0.19
1578
+     * @param  string $context View or edit context.
1579
+     * @return string
1580
+     */
1581
+    public function get_discount_code( $context = 'view' ) {
1582
+        return $this->get_prop( 'discount_code', $context );
1583 1583
     }
1584 1584
 
1585 1585
     /**
1586
-	 * Get the invoice's gateway.
1587
-	 *
1588
-	 * @since 1.0.19
1589
-	 * @param  string $context View or edit context.
1590
-	 * @return string
1591
-	 */
1592
-	public function get_gateway( $context = 'view' ) {
1593
-		return $this->get_prop( 'gateway', $context );
1586
+     * Get the invoice's gateway.
1587
+     *
1588
+     * @since 1.0.19
1589
+     * @param  string $context View or edit context.
1590
+     * @return string
1591
+     */
1592
+    public function get_gateway( $context = 'view' ) {
1593
+        return $this->get_prop( 'gateway', $context );
1594 1594
     }
1595 1595
 
1596 1596
     /**
1597
-	 * Get the invoice's gateway display title.
1598
-	 *
1599
-	 * @since 1.0.19
1600
-	 * @return string
1601
-	 */
1597
+     * Get the invoice's gateway display title.
1598
+     *
1599
+     * @since 1.0.19
1600
+     * @return string
1601
+     */
1602 1602
     public function get_gateway_title() {
1603 1603
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1604 1604
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1605 1605
     }
1606 1606
 
1607 1607
     /**
1608
-	 * Get the invoice's transaction id.
1609
-	 *
1610
-	 * @since 1.0.19
1611
-	 * @param  string $context View or edit context.
1612
-	 * @return string
1613
-	 */
1614
-	public function get_transaction_id( $context = 'view' ) {
1615
-		return $this->get_prop( 'transaction_id', $context );
1608
+     * Get the invoice's transaction id.
1609
+     *
1610
+     * @since 1.0.19
1611
+     * @param  string $context View or edit context.
1612
+     * @return string
1613
+     */
1614
+    public function get_transaction_id( $context = 'view' ) {
1615
+        return $this->get_prop( 'transaction_id', $context );
1616 1616
     }
1617 1617
 
1618 1618
     /**
1619
-	 * Get the invoice's currency.
1620
-	 *
1621
-	 * @since 1.0.19
1622
-	 * @param  string $context View or edit context.
1623
-	 * @return string
1624
-	 */
1625
-	public function get_currency( $context = 'view' ) {
1619
+     * Get the invoice's currency.
1620
+     *
1621
+     * @since 1.0.19
1622
+     * @param  string $context View or edit context.
1623
+     * @return string
1624
+     */
1625
+    public function get_currency( $context = 'view' ) {
1626 1626
         $currency = $this->get_prop( 'currency', $context );
1627 1627
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1628 1628
     }
1629 1629
 
1630 1630
     /**
1631
-	 * Checks if we are charging taxes for this invoice.
1632
-	 *
1633
-	 * @since 1.0.19
1634
-	 * @param  string $context View or edit context.
1635
-	 * @return bool
1636
-	 */
1637
-	public function get_disable_taxes( $context = 'view' ) {
1631
+     * Checks if we are charging taxes for this invoice.
1632
+     *
1633
+     * @since 1.0.19
1634
+     * @param  string $context View or edit context.
1635
+     * @return bool
1636
+     */
1637
+    public function get_disable_taxes( $context = 'view' ) {
1638 1638
         return (bool) $this->get_prop( 'disable_taxes', $context );
1639 1639
     }
1640 1640
 
1641 1641
     /**
1642
-	 * Retrieves the subscription id for an invoice.
1643
-	 *
1644
-	 * @since 1.0.19
1645
-	 * @param  string $context View or edit context.
1646
-	 * @return int
1647
-	 */
1642
+     * Retrieves the subscription id for an invoice.
1643
+     *
1644
+     * @since 1.0.19
1645
+     * @param  string $context View or edit context.
1646
+     * @return int
1647
+     */
1648 1648
     public function get_subscription_id( $context = 'view' ) {
1649
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1650
-	}
1651
-
1652
-	/**
1653
-	 * Retrieves the remote subscription id for an invoice.
1654
-	 *
1655
-	 * @since 1.0.19
1656
-	 * @param  string $context View or edit context.
1657
-	 * @return int
1658
-	 */
1649
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1650
+    }
1651
+
1652
+    /**
1653
+     * Retrieves the remote subscription id for an invoice.
1654
+     *
1655
+     * @since 1.0.19
1656
+     * @param  string $context View or edit context.
1657
+     * @return int
1658
+     */
1659 1659
     public function get_remote_subscription_id( $context = 'view' ) {
1660 1660
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1661 1661
 
@@ -1668,12 +1668,12 @@  discard block
 block discarded – undo
1668 1668
     }
1669 1669
 
1670 1670
     /**
1671
-	 * Retrieves the payment meta for an invoice.
1672
-	 *
1673
-	 * @since 1.0.19
1674
-	 * @param  string $context View or edit context.
1675
-	 * @return array
1676
-	 */
1671
+     * Retrieves the payment meta for an invoice.
1672
+     *
1673
+     * @since 1.0.19
1674
+     * @param  string $context View or edit context.
1675
+     * @return array
1676
+     */
1677 1677
     public function get_payment_meta( $context = 'view' ) {
1678 1678
 
1679 1679
         return array(
@@ -1693,31 +1693,31 @@  discard block
 block discarded – undo
1693 1693
     }
1694 1694
 
1695 1695
     /**
1696
-	 * Retrieves the cart details for an invoice.
1697
-	 *
1698
-	 * @since 1.0.19
1699
-	 * @return array
1700
-	 */
1696
+     * Retrieves the cart details for an invoice.
1697
+     *
1698
+     * @since 1.0.19
1699
+     * @return array
1700
+     */
1701 1701
     public function get_cart_details() {
1702 1702
         $items        = $this->get_items();
1703 1703
         $cart_details = array();
1704 1704
 
1705 1705
         foreach ( $items as $item_id => $item ) {
1706
-			$item->invoice_id = $this->get_id();
1706
+            $item->invoice_id = $this->get_id();
1707 1707
             $cart_details[]   = $item->prepare_data_for_saving();
1708 1708
         }
1709 1709
 
1710 1710
         return $cart_details;
1711
-	}
1711
+    }
1712 1712
 
1713
-	/**
1714
-	 * Retrieves the recurring item.
1715
-	 *
1716
-	 * @return null|GetPaid_Form_Item|int
1717
-	 */
1718
-	public function get_recurring( $object = false ) {
1713
+    /**
1714
+     * Retrieves the recurring item.
1715
+     *
1716
+     * @return null|GetPaid_Form_Item|int
1717
+     */
1718
+    public function get_recurring( $object = false ) {
1719 1719
 
1720
-		// Are we returning an object?
1720
+        // Are we returning an object?
1721 1721
         if ( $object ) {
1722 1722
             return $this->get_item( $this->recurring_item );
1723 1723
         }
@@ -1725,114 +1725,114 @@  discard block
 block discarded – undo
1725 1725
         return $this->recurring_item;
1726 1726
     }
1727 1727
 
1728
-	/**
1729
-	 * Retrieves the subscription name.
1730
-	 *
1731
-	 * @since 1.0.19
1732
-	 * @return string
1733
-	 */
1734
-	public function get_subscription_name() {
1728
+    /**
1729
+     * Retrieves the subscription name.
1730
+     *
1731
+     * @since 1.0.19
1732
+     * @return string
1733
+     */
1734
+    public function get_subscription_name() {
1735 1735
 
1736
-		// Retrieve the recurring name
1736
+        // Retrieve the recurring name
1737 1737
         $item = $this->get_recurring( true );
1738 1738
 
1739
-		// Abort if it does not exist.
1739
+        // Abort if it does not exist.
1740 1740
         if ( empty( $item ) ) {
1741 1741
             return '';
1742 1742
         }
1743 1743
 
1744
-		// Return the item name.
1744
+        // Return the item name.
1745 1745
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1746
-	}
1747
-
1748
-	/**
1749
-	 * Retrieves the view url.
1750
-	 *
1751
-	 * @since 1.0.19
1752
-	 * @return string
1753
-	 */
1754
-	public function get_view_url() {
1746
+    }
1747
+
1748
+    /**
1749
+     * Retrieves the view url.
1750
+     *
1751
+     * @since 1.0.19
1752
+     * @return string
1753
+     */
1754
+    public function get_view_url() {
1755 1755
         $invoice_url = get_permalink( $this->get_id() );
1756
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1756
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1757 1757
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1758
-	}
1758
+    }
1759 1759
 
1760
-	/**
1761
-	 * Retrieves the payment url.
1762
-	 *
1763
-	 * @since 1.0.19
1764
-	 * @return string
1765
-	 */
1766
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1760
+    /**
1761
+     * Retrieves the payment url.
1762
+     *
1763
+     * @since 1.0.19
1764
+     * @return string
1765
+     */
1766
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1767 1767
 
1768
-		// Retrieve the checkout url.
1768
+        // Retrieve the checkout url.
1769 1769
         $pay_url = wpinv_get_checkout_uri();
1770 1770
 
1771
-		// Maybe force ssl.
1771
+        // Maybe force ssl.
1772 1772
         if ( is_ssl() ) {
1773 1773
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1774 1774
         }
1775 1775
 
1776
-		// Add the invoice key.
1777
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1776
+        // Add the invoice key.
1777
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1778 1778
 
1779
-		// (Maybe?) add a secret
1779
+        // (Maybe?) add a secret
1780 1780
         if ( $secret ) {
1781 1781
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1782 1782
         }
1783 1783
 
1784 1784
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1785
-	}
1785
+    }
1786 1786
 	
1787
-	/**
1788
-	 * Retrieves the receipt url.
1789
-	 *
1790
-	 * @since 1.0.19
1791
-	 * @return string
1792
-	 */
1793
-	public function get_receipt_url() {
1794
-
1795
-		// Retrieve the checkout url.
1787
+    /**
1788
+     * Retrieves the receipt url.
1789
+     *
1790
+     * @since 1.0.19
1791
+     * @return string
1792
+     */
1793
+    public function get_receipt_url() {
1794
+
1795
+        // Retrieve the checkout url.
1796 1796
         $receipt_url = wpinv_get_success_page_uri();
1797 1797
 
1798
-		// Maybe force ssl.
1798
+        // Maybe force ssl.
1799 1799
         if ( is_ssl() ) {
1800 1800
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1801 1801
         }
1802 1802
 
1803
-		// Add the invoice key.
1804
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1803
+        // Add the invoice key.
1804
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1805 1805
 
1806 1806
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1807
-	}
1807
+    }
1808 1808
 	
1809
-	/**
1810
-	 * Retrieves the default status.
1811
-	 *
1812
-	 * @since 1.0.19
1813
-	 * @return string
1814
-	 */
1815
-	public function get_default_status() {
1816
-
1817
-		$type   = $this->get_type();
1818
-		$status = "wpi-$type-pending";
1819
-		return str_replace( '-invoice', '', $status );
1820
-
1821
-	}
1822
-
1823
-    /**
1824
-	 * Magic method for accessing invoice properties.
1825
-	 *
1826
-	 * @since 1.0.15
1827
-	 * @access public
1828
-	 *
1829
-	 * @param string $key Discount data to retrieve
1830
-	 * @param  string $context View or edit context.
1831
-	 * @return mixed Value of the given invoice property (if set).
1832
-	 */
1833
-	public function get( $key, $context = 'view' ) {
1809
+    /**
1810
+     * Retrieves the default status.
1811
+     *
1812
+     * @since 1.0.19
1813
+     * @return string
1814
+     */
1815
+    public function get_default_status() {
1816
+
1817
+        $type   = $this->get_type();
1818
+        $status = "wpi-$type-pending";
1819
+        return str_replace( '-invoice', '', $status );
1820
+
1821
+    }
1822
+
1823
+    /**
1824
+     * Magic method for accessing invoice properties.
1825
+     *
1826
+     * @since 1.0.15
1827
+     * @access public
1828
+     *
1829
+     * @param string $key Discount data to retrieve
1830
+     * @param  string $context View or edit context.
1831
+     * @return mixed Value of the given invoice property (if set).
1832
+     */
1833
+    public function get( $key, $context = 'view' ) {
1834 1834
         return $this->get_prop( $key, $context );
1835
-	}
1835
+    }
1836 1836
 
1837 1837
     /*
1838 1838
 	|--------------------------------------------------------------------------
@@ -1845,130 +1845,130 @@  discard block
 block discarded – undo
1845 1845
     */
1846 1846
 
1847 1847
     /**
1848
-	 * Magic method for setting invoice properties.
1849
-	 *
1850
-	 * @since 1.0.19
1851
-	 * @access public
1852
-	 *
1853
-	 * @param string $key Discount data to retrieve
1854
-	 * @param  mixed $value new value.
1855
-	 * @return mixed Value of the given invoice property (if set).
1856
-	 */
1857
-	public function set( $key, $value ) {
1848
+     * Magic method for setting invoice properties.
1849
+     *
1850
+     * @since 1.0.19
1851
+     * @access public
1852
+     *
1853
+     * @param string $key Discount data to retrieve
1854
+     * @param  mixed $value new value.
1855
+     * @return mixed Value of the given invoice property (if set).
1856
+     */
1857
+    public function set( $key, $value ) {
1858 1858
 
1859 1859
         $setter = "set_$key";
1860 1860
         if ( is_callable( array( $this, $setter ) ) ) {
1861 1861
             $this->{$setter}( $value );
1862 1862
         }
1863 1863
 
1864
-	}
1864
+    }
1865 1865
 
1866
-	/**
1867
-	 * Sets item status.
1868
-	 *
1869
-	 * @since 1.0.19
1870
-	 * @param string $new_status    New status.
1871
-	 * @param string $note          Optional note to add.
1872
-	 * @param bool   $manual_update Is this a manual status change?.
1873
-	 * @return array details of change.
1874
-	 */
1875
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1876
-		$old_status = $this->get_status();
1866
+    /**
1867
+     * Sets item status.
1868
+     *
1869
+     * @since 1.0.19
1870
+     * @param string $new_status    New status.
1871
+     * @param string $note          Optional note to add.
1872
+     * @param bool   $manual_update Is this a manual status change?.
1873
+     * @return array details of change.
1874
+     */
1875
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1876
+        $old_status = $this->get_status();
1877 1877
 
1878
-		$statuses = $this->get_all_statuses();
1878
+        $statuses = $this->get_all_statuses();
1879 1879
 
1880
-		if ( isset( $statuses[ 'draft' ] ) ) {
1881
-			unset( $statuses[ 'draft' ] );
1882
-		}
1880
+        if ( isset( $statuses[ 'draft' ] ) ) {
1881
+            unset( $statuses[ 'draft' ] );
1882
+        }
1883 1883
 
1884
-		$this->set_prop( 'status', $new_status );
1884
+        $this->set_prop( 'status', $new_status );
1885 1885
 
1886
-		// If setting the status, ensure it's set to a valid status.
1887
-		if ( true === $this->object_read ) {
1886
+        // If setting the status, ensure it's set to a valid status.
1887
+        if ( true === $this->object_read ) {
1888 1888
 
1889
-			// Only allow valid new status.
1890
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1891
-				$new_status = $this->get_default_status();
1892
-			}
1889
+            // Only allow valid new status.
1890
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1891
+                $new_status = $this->get_default_status();
1892
+            }
1893 1893
 
1894
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1895
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1896
-				$old_status = $this->get_default_status();
1897
-			}
1894
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1895
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1896
+                $old_status = $this->get_default_status();
1897
+            }
1898 1898
 
1899
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1900
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1901
-				$old_status = 'wpi-pending';
1902
-			}
1899
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1900
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1901
+                $old_status = 'wpi-pending';
1902
+            }
1903 1903
 
1904
-		}
1904
+        }
1905 1905
 
1906
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1907
-			$this->status_transition = array(
1908
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1909
-				'to'     => $new_status,
1910
-				'note'   => $note,
1911
-				'manual' => (bool) $manual_update,
1912
-			);
1906
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1907
+            $this->status_transition = array(
1908
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1909
+                'to'     => $new_status,
1910
+                'note'   => $note,
1911
+                'manual' => (bool) $manual_update,
1912
+            );
1913 1913
 
1914
-			if ( $manual_update ) {
1915
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1916
-			}
1914
+            if ( $manual_update ) {
1915
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1916
+            }
1917 1917
 
1918
-			$this->maybe_set_date_paid();
1918
+            $this->maybe_set_date_paid();
1919 1919
 
1920
-		}
1920
+        }
1921 1921
 
1922
-		return array(
1923
-			'from' => $old_status,
1924
-			'to'   => $new_status,
1925
-		);
1926
-	}
1922
+        return array(
1923
+            'from' => $old_status,
1924
+            'to'   => $new_status,
1925
+        );
1926
+    }
1927 1927
 
1928
-	/**
1929
-	 * Maybe set date paid.
1930
-	 *
1931
-	 * Sets the date paid variable when transitioning to the payment complete
1932
-	 * order status.
1933
-	 *
1934
-	 * @since 1.0.19
1935
-	 */
1936
-	public function maybe_set_date_paid() {
1928
+    /**
1929
+     * Maybe set date paid.
1930
+     *
1931
+     * Sets the date paid variable when transitioning to the payment complete
1932
+     * order status.
1933
+     *
1934
+     * @since 1.0.19
1935
+     */
1936
+    public function maybe_set_date_paid() {
1937 1937
 
1938
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1939
-			$this->set_date_completed( current_time( 'mysql' ) );
1940
-		}
1941
-	}
1938
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1939
+            $this->set_date_completed( current_time( 'mysql' ) );
1940
+        }
1941
+    }
1942 1942
 
1943 1943
     /**
1944
-	 * Set parent invoice ID.
1945
-	 *
1946
-	 * @since 1.0.19
1947
-	 */
1948
-	public function set_parent_id( $value ) {
1949
-		if ( $value && ( $value === $this->get_id() ) ) {
1950
-			return;
1951
-		}
1952
-		$this->set_prop( 'parent_id', absint( $value ) );
1944
+     * Set parent invoice ID.
1945
+     *
1946
+     * @since 1.0.19
1947
+     */
1948
+    public function set_parent_id( $value ) {
1949
+        if ( $value && ( $value === $this->get_id() ) ) {
1950
+            return;
1951
+        }
1952
+        $this->set_prop( 'parent_id', absint( $value ) );
1953 1953
     }
1954 1954
 
1955 1955
     /**
1956
-	 * Set plugin version when the invoice was created.
1957
-	 *
1958
-	 * @since 1.0.19
1959
-	 */
1960
-	public function set_version( $value ) {
1961
-		$this->set_prop( 'version', $value );
1956
+     * Set plugin version when the invoice was created.
1957
+     *
1958
+     * @since 1.0.19
1959
+     */
1960
+    public function set_version( $value ) {
1961
+        $this->set_prop( 'version', $value );
1962 1962
     }
1963
-
1964
-    /**
1965
-	 * Set date when the invoice was created.
1966
-	 *
1967
-	 * @since 1.0.19
1968
-	 * @param string $value Value to set.
1963
+
1964
+    /**
1965
+     * Set date when the invoice was created.
1966
+     *
1967
+     * @since 1.0.19
1968
+     * @param string $value Value to set.
1969 1969
      * @return bool Whether or not the date was set.
1970
-	 */
1971
-	public function set_date_created( $value ) {
1970
+     */
1971
+    public function set_date_created( $value ) {
1972 1972
         $date = strtotime( $value );
1973 1973
 
1974 1974
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1976,19 +1976,19 @@  discard block
 block discarded – undo
1976 1976
             return true;
1977 1977
         }
1978 1978
 
1979
-		$this->set_prop( 'date_created', '' );
1980
-		return false;
1979
+        $this->set_prop( 'date_created', '' );
1980
+        return false;
1981 1981
 
1982 1982
     }
1983 1983
 
1984 1984
     /**
1985
-	 * Set date invoice due date.
1986
-	 *
1987
-	 * @since 1.0.19
1988
-	 * @param string $value Value to set.
1985
+     * Set date invoice due date.
1986
+     *
1987
+     * @since 1.0.19
1988
+     * @param string $value Value to set.
1989 1989
      * @return bool Whether or not the date was set.
1990
-	 */
1991
-	public function set_due_date( $value ) {
1990
+     */
1991
+    public function set_due_date( $value ) {
1992 1992
         $date = strtotime( $value );
1993 1993
 
1994 1994
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1996,29 +1996,29 @@  discard block
 block discarded – undo
1996 1996
             return true;
1997 1997
         }
1998 1998
 
1999
-		$this->set_prop( 'due_date', '' );
1999
+        $this->set_prop( 'due_date', '' );
2000 2000
         return false;
2001 2001
 
2002 2002
     }
2003 2003
 
2004 2004
     /**
2005
-	 * Alias of self::set_due_date().
2006
-	 *
2007
-	 * @since 1.0.19
2008
-	 * @param  string $value New name.
2009
-	 */
2010
-	public function set_date_due( $value ) {
2011
-		$this->set_due_date( $value );
2005
+     * Alias of self::set_due_date().
2006
+     *
2007
+     * @since 1.0.19
2008
+     * @param  string $value New name.
2009
+     */
2010
+    public function set_date_due( $value ) {
2011
+        $this->set_due_date( $value );
2012 2012
     }
2013 2013
 
2014 2014
     /**
2015
-	 * Set date invoice was completed.
2016
-	 *
2017
-	 * @since 1.0.19
2018
-	 * @param string $value Value to set.
2015
+     * Set date invoice was completed.
2016
+     *
2017
+     * @since 1.0.19
2018
+     * @param string $value Value to set.
2019 2019
      * @return bool Whether or not the date was set.
2020
-	 */
2021
-	public function set_completed_date( $value ) {
2020
+     */
2021
+    public function set_completed_date( $value ) {
2022 2022
         $date = strtotime( $value );
2023 2023
 
2024 2024
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2026,29 +2026,29 @@  discard block
 block discarded – undo
2026 2026
             return true;
2027 2027
         }
2028 2028
 
2029
-		$this->set_prop( 'completed_date', '' );
2029
+        $this->set_prop( 'completed_date', '' );
2030 2030
         return false;
2031 2031
 
2032 2032
     }
2033 2033
 
2034 2034
     /**
2035
-	 * Alias of self::set_completed_date().
2036
-	 *
2037
-	 * @since 1.0.19
2038
-	 * @param  string $value New name.
2039
-	 */
2040
-	public function set_date_completed( $value ) {
2041
-		$this->set_completed_date( $value );
2035
+     * Alias of self::set_completed_date().
2036
+     *
2037
+     * @since 1.0.19
2038
+     * @param  string $value New name.
2039
+     */
2040
+    public function set_date_completed( $value ) {
2041
+        $this->set_completed_date( $value );
2042 2042
     }
2043 2043
 
2044 2044
     /**
2045
-	 * Set date when the invoice was last modified.
2046
-	 *
2047
-	 * @since 1.0.19
2048
-	 * @param string $value Value to set.
2045
+     * Set date when the invoice was last modified.
2046
+     *
2047
+     * @since 1.0.19
2048
+     * @param string $value Value to set.
2049 2049
      * @return bool Whether or not the date was set.
2050
-	 */
2051
-	public function set_date_modified( $value ) {
2050
+     */
2051
+    public function set_date_modified( $value ) {
2052 2052
         $date = strtotime( $value );
2053 2053
 
2054 2054
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2056,763 +2056,763 @@  discard block
 block discarded – undo
2056 2056
             return true;
2057 2057
         }
2058 2058
 
2059
-		$this->set_prop( 'date_modified', '' );
2059
+        $this->set_prop( 'date_modified', '' );
2060 2060
         return false;
2061 2061
 
2062 2062
     }
2063 2063
 
2064 2064
     /**
2065
-	 * Set the invoice number.
2066
-	 *
2067
-	 * @since 1.0.19
2068
-	 * @param  string $value New number.
2069
-	 */
2070
-	public function set_number( $value ) {
2065
+     * Set the invoice number.
2066
+     *
2067
+     * @since 1.0.19
2068
+     * @param  string $value New number.
2069
+     */
2070
+    public function set_number( $value ) {
2071 2071
         $number = sanitize_text_field( $value );
2072
-		$this->set_prop( 'number', $number );
2072
+        $this->set_prop( 'number', $number );
2073 2073
     }
2074 2074
 
2075 2075
     /**
2076
-	 * Set the invoice type.
2077
-	 *
2078
-	 * @since 1.0.19
2079
-	 * @param  string $value Type.
2080
-	 */
2081
-	public function set_type( $value ) {
2076
+     * Set the invoice type.
2077
+     *
2078
+     * @since 1.0.19
2079
+     * @param  string $value Type.
2080
+     */
2081
+    public function set_type( $value ) {
2082 2082
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2083
-		$this->set_prop( 'type', $type );
2084
-	}
2083
+        $this->set_prop( 'type', $type );
2084
+    }
2085 2085
 
2086 2086
     /**
2087
-	 * Set the invoice post type.
2088
-	 *
2089
-	 * @since 1.0.19
2090
-	 * @param  string $value Post type.
2091
-	 */
2092
-	public function set_post_type( $value ) {
2087
+     * Set the invoice post type.
2088
+     *
2089
+     * @since 1.0.19
2090
+     * @param  string $value Post type.
2091
+     */
2092
+    public function set_post_type( $value ) {
2093 2093
         if ( getpaid_is_invoice_post_type( $value ) ) {
2094
-			$this->set_type( $value );
2094
+            $this->set_type( $value );
2095 2095
             $this->set_prop( 'post_type', $value );
2096 2096
         }
2097 2097
     }
2098 2098
 
2099 2099
     /**
2100
-	 * Set the invoice key.
2101
-	 *
2102
-	 * @since 1.0.19
2103
-	 * @param  string $value New key.
2104
-	 */
2105
-	public function set_key( $value ) {
2100
+     * Set the invoice key.
2101
+     *
2102
+     * @since 1.0.19
2103
+     * @param  string $value New key.
2104
+     */
2105
+    public function set_key( $value ) {
2106 2106
         $key = sanitize_text_field( $value );
2107
-		$this->set_prop( 'key', $key );
2107
+        $this->set_prop( 'key', $key );
2108 2108
     }
2109 2109
 
2110 2110
     /**
2111
-	 * Set the invoice mode.
2112
-	 *
2113
-	 * @since 1.0.19
2114
-	 * @param  string $value mode.
2115
-	 */
2116
-	public function set_mode( $value ) {
2111
+     * Set the invoice mode.
2112
+     *
2113
+     * @since 1.0.19
2114
+     * @param  string $value mode.
2115
+     */
2116
+    public function set_mode( $value ) {
2117 2117
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2118 2118
             $this->set_prop( 'value', $value );
2119 2119
         }
2120 2120
     }
2121 2121
 
2122 2122
     /**
2123
-	 * Set the invoice path.
2124
-	 *
2125
-	 * @since 1.0.19
2126
-	 * @param  string $value path.
2127
-	 */
2128
-	public function set_path( $value ) {
2123
+     * Set the invoice path.
2124
+     *
2125
+     * @since 1.0.19
2126
+     * @param  string $value path.
2127
+     */
2128
+    public function set_path( $value ) {
2129 2129
         $this->set_prop( 'path', $value );
2130 2130
     }
2131 2131
 
2132 2132
     /**
2133
-	 * Set the invoice name.
2134
-	 *
2135
-	 * @since 1.0.19
2136
-	 * @param  string $value New name.
2137
-	 */
2138
-	public function set_name( $value ) {
2133
+     * Set the invoice name.
2134
+     *
2135
+     * @since 1.0.19
2136
+     * @param  string $value New name.
2137
+     */
2138
+    public function set_name( $value ) {
2139 2139
         $name = sanitize_text_field( $value );
2140
-		$this->set_prop( 'name', $name );
2140
+        $this->set_prop( 'name', $name );
2141 2141
     }
2142 2142
 
2143 2143
     /**
2144
-	 * Alias of self::set_name().
2145
-	 *
2146
-	 * @since 1.0.19
2147
-	 * @param  string $value New name.
2148
-	 */
2149
-	public function set_title( $value ) {
2150
-		$this->set_name( $value );
2144
+     * Alias of self::set_name().
2145
+     *
2146
+     * @since 1.0.19
2147
+     * @param  string $value New name.
2148
+     */
2149
+    public function set_title( $value ) {
2150
+        $this->set_name( $value );
2151 2151
     }
2152 2152
 
2153 2153
     /**
2154
-	 * Set the invoice description.
2155
-	 *
2156
-	 * @since 1.0.19
2157
-	 * @param  string $value New description.
2158
-	 */
2159
-	public function set_description( $value ) {
2154
+     * Set the invoice description.
2155
+     *
2156
+     * @since 1.0.19
2157
+     * @param  string $value New description.
2158
+     */
2159
+    public function set_description( $value ) {
2160 2160
         $description = wp_kses_post( $value );
2161
-		$this->set_prop( 'description', $description );
2161
+        $this->set_prop( 'description', $description );
2162
+    }
2163
+
2164
+    /**
2165
+     * Alias of self::set_description().
2166
+     *
2167
+     * @since 1.0.19
2168
+     * @param  string $value New description.
2169
+     */
2170
+    public function set_excerpt( $value ) {
2171
+        $this->set_description( $value );
2172
+    }
2173
+
2174
+    /**
2175
+     * Alias of self::set_description().
2176
+     *
2177
+     * @since 1.0.19
2178
+     * @param  string $value New description.
2179
+     */
2180
+    public function set_summary( $value ) {
2181
+        $this->set_description( $value );
2162 2182
     }
2163 2183
 
2164 2184
     /**
2165
-	 * Alias of self::set_description().
2166
-	 *
2167
-	 * @since 1.0.19
2168
-	 * @param  string $value New description.
2169
-	 */
2170
-	public function set_excerpt( $value ) {
2171
-		$this->set_description( $value );
2185
+     * Set the receiver of the invoice.
2186
+     *
2187
+     * @since 1.0.19
2188
+     * @param  int $value New author.
2189
+     */
2190
+    public function set_author( $value ) {
2191
+        $user = get_user_by( 'id', (int) $value );
2192
+
2193
+        if ( $user && $user->ID ) {
2194
+            $this->set_prop( 'author', $user->ID );
2195
+            $this->set_prop( 'email', $user->user_email );
2196
+        }
2197
+
2172 2198
     }
2173 2199
 
2174 2200
     /**
2175
-	 * Alias of self::set_description().
2176
-	 *
2177
-	 * @since 1.0.19
2178
-	 * @param  string $value New description.
2179
-	 */
2180
-	public function set_summary( $value ) {
2181
-		$this->set_description( $value );
2201
+     * Alias of self::set_author().
2202
+     *
2203
+     * @since 1.0.19
2204
+     * @param  int $value New user id.
2205
+     */
2206
+    public function set_user_id( $value ) {
2207
+        $this->set_author( $value );
2182 2208
     }
2183 2209
 
2184 2210
     /**
2185
-	 * Set the receiver of the invoice.
2186
-	 *
2187
-	 * @since 1.0.19
2188
-	 * @param  int $value New author.
2189
-	 */
2190
-	public function set_author( $value ) {
2191
-		$user = get_user_by( 'id', (int) $value );
2211
+     * Alias of self::set_author().
2212
+     *
2213
+     * @since 1.0.19
2214
+     * @param  int $value New user id.
2215
+     */
2216
+    public function set_customer_id( $value ) {
2217
+        $this->set_author( $value );
2218
+    }
2192 2219
 
2193
-		if ( $user && $user->ID ) {
2194
-			$this->set_prop( 'author', $user->ID );
2195
-			$this->set_prop( 'email', $user->user_email );
2196
-		}
2220
+    /**
2221
+     * Set the customer's ip.
2222
+     *
2223
+     * @since 1.0.19
2224
+     * @param  string $value ip address.
2225
+     */
2226
+    public function set_ip( $value ) {
2227
+        $this->set_prop( 'ip', $value );
2228
+    }
2197 2229
 
2230
+    /**
2231
+     * Alias of self::set_ip().
2232
+     *
2233
+     * @since 1.0.19
2234
+     * @param  string $value ip address.
2235
+     */
2236
+    public function set_user_ip( $value ) {
2237
+        $this->set_ip( $value );
2198 2238
     }
2199 2239
 
2200 2240
     /**
2201
-	 * Alias of self::set_author().
2202
-	 *
2203
-	 * @since 1.0.19
2204
-	 * @param  int $value New user id.
2205
-	 */
2206
-	public function set_user_id( $value ) {
2207
-		$this->set_author( $value );
2241
+     * Set the customer's first name.
2242
+     *
2243
+     * @since 1.0.19
2244
+     * @param  string $value first name.
2245
+     */
2246
+    public function set_first_name( $value ) {
2247
+        $this->set_prop( 'first_name', $value );
2208 2248
     }
2209 2249
 
2210 2250
     /**
2211
-	 * Alias of self::set_author().
2212
-	 *
2213
-	 * @since 1.0.19
2214
-	 * @param  int $value New user id.
2215
-	 */
2216
-	public function set_customer_id( $value ) {
2217
-		$this->set_author( $value );
2251
+     * Alias of self::set_first_name().
2252
+     *
2253
+     * @since 1.0.19
2254
+     * @param  string $value first name.
2255
+     */
2256
+    public function set_user_first_name( $value ) {
2257
+        $this->set_first_name( $value );
2218 2258
     }
2219 2259
 
2220 2260
     /**
2221
-	 * Set the customer's ip.
2222
-	 *
2223
-	 * @since 1.0.19
2224
-	 * @param  string $value ip address.
2225
-	 */
2226
-	public function set_ip( $value ) {
2227
-		$this->set_prop( 'ip', $value );
2261
+     * Alias of self::set_first_name().
2262
+     *
2263
+     * @since 1.0.19
2264
+     * @param  string $value first name.
2265
+     */
2266
+    public function set_customer_first_name( $value ) {
2267
+        $this->set_first_name( $value );
2228 2268
     }
2229 2269
 
2230 2270
     /**
2231
-	 * Alias of self::set_ip().
2232
-	 *
2233
-	 * @since 1.0.19
2234
-	 * @param  string $value ip address.
2235
-	 */
2236
-	public function set_user_ip( $value ) {
2237
-		$this->set_ip( $value );
2271
+     * Set the customer's last name.
2272
+     *
2273
+     * @since 1.0.19
2274
+     * @param  string $value last name.
2275
+     */
2276
+    public function set_last_name( $value ) {
2277
+        $this->set_prop( 'last_name', $value );
2238 2278
     }
2239 2279
 
2240 2280
     /**
2241
-	 * Set the customer's first name.
2242
-	 *
2243
-	 * @since 1.0.19
2244
-	 * @param  string $value first name.
2245
-	 */
2246
-	public function set_first_name( $value ) {
2247
-		$this->set_prop( 'first_name', $value );
2281
+     * Alias of self::set_last_name().
2282
+     *
2283
+     * @since 1.0.19
2284
+     * @param  string $value last name.
2285
+     */
2286
+    public function set_user_last_name( $value ) {
2287
+        $this->set_last_name( $value );
2248 2288
     }
2249 2289
 
2250 2290
     /**
2251
-	 * Alias of self::set_first_name().
2252
-	 *
2253
-	 * @since 1.0.19
2254
-	 * @param  string $value first name.
2255
-	 */
2256
-	public function set_user_first_name( $value ) {
2257
-		$this->set_first_name( $value );
2291
+     * Alias of self::set_last_name().
2292
+     *
2293
+     * @since 1.0.19
2294
+     * @param  string $value last name.
2295
+     */
2296
+    public function set_customer_last_name( $value ) {
2297
+        $this->set_last_name( $value );
2258 2298
     }
2259 2299
 
2260 2300
     /**
2261
-	 * Alias of self::set_first_name().
2262
-	 *
2263
-	 * @since 1.0.19
2264
-	 * @param  string $value first name.
2265
-	 */
2266
-	public function set_customer_first_name( $value ) {
2267
-		$this->set_first_name( $value );
2301
+     * Set the customer's phone number.
2302
+     *
2303
+     * @since 1.0.19
2304
+     * @param  string $value phone.
2305
+     */
2306
+    public function set_phone( $value ) {
2307
+        $this->set_prop( 'phone', $value );
2268 2308
     }
2269 2309
 
2270 2310
     /**
2271
-	 * Set the customer's last name.
2272
-	 *
2273
-	 * @since 1.0.19
2274
-	 * @param  string $value last name.
2275
-	 */
2276
-	public function set_last_name( $value ) {
2277
-		$this->set_prop( 'last_name', $value );
2311
+     * Alias of self::set_phone().
2312
+     *
2313
+     * @since 1.0.19
2314
+     * @param  string $value phone.
2315
+     */
2316
+    public function set_user_phone( $value ) {
2317
+        $this->set_phone( $value );
2278 2318
     }
2279 2319
 
2280 2320
     /**
2281
-	 * Alias of self::set_last_name().
2282
-	 *
2283
-	 * @since 1.0.19
2284
-	 * @param  string $value last name.
2285
-	 */
2286
-	public function set_user_last_name( $value ) {
2287
-		$this->set_last_name( $value );
2321
+     * Alias of self::set_phone().
2322
+     *
2323
+     * @since 1.0.19
2324
+     * @param  string $value phone.
2325
+     */
2326
+    public function set_customer_phone( $value ) {
2327
+        $this->set_phone( $value );
2288 2328
     }
2289 2329
 
2290 2330
     /**
2291
-	 * Alias of self::set_last_name().
2292
-	 *
2293
-	 * @since 1.0.19
2294
-	 * @param  string $value last name.
2295
-	 */
2296
-	public function set_customer_last_name( $value ) {
2297
-		$this->set_last_name( $value );
2331
+     * Alias of self::set_phone().
2332
+     *
2333
+     * @since 1.0.19
2334
+     * @param  string $value phone.
2335
+     */
2336
+    public function set_phone_number( $value ) {
2337
+        $this->set_phone( $value );
2298 2338
     }
2299 2339
 
2300 2340
     /**
2301
-	 * Set the customer's phone number.
2302
-	 *
2303
-	 * @since 1.0.19
2304
-	 * @param  string $value phone.
2305
-	 */
2306
-	public function set_phone( $value ) {
2307
-		$this->set_prop( 'phone', $value );
2341
+     * Set the customer's email address.
2342
+     *
2343
+     * @since 1.0.19
2344
+     * @param  string $value email address.
2345
+     */
2346
+    public function set_email( $value ) {
2347
+        $this->set_prop( 'email', $value );
2308 2348
     }
2309 2349
 
2310 2350
     /**
2311
-	 * Alias of self::set_phone().
2312
-	 *
2313
-	 * @since 1.0.19
2314
-	 * @param  string $value phone.
2315
-	 */
2316
-	public function set_user_phone( $value ) {
2317
-		$this->set_phone( $value );
2351
+     * Alias of self::set_email().
2352
+     *
2353
+     * @since 1.0.19
2354
+     * @param  string $value email address.
2355
+     */
2356
+    public function set_user_email( $value ) {
2357
+        $this->set_email( $value );
2318 2358
     }
2319 2359
 
2320 2360
     /**
2321
-	 * Alias of self::set_phone().
2322
-	 *
2323
-	 * @since 1.0.19
2324
-	 * @param  string $value phone.
2325
-	 */
2326
-	public function set_customer_phone( $value ) {
2327
-		$this->set_phone( $value );
2361
+     * Alias of self::set_email().
2362
+     *
2363
+     * @since 1.0.19
2364
+     * @param  string $value email address.
2365
+     */
2366
+    public function set_email_address( $value ) {
2367
+        $this->set_email( $value );
2328 2368
     }
2329 2369
 
2330 2370
     /**
2331
-	 * Alias of self::set_phone().
2332
-	 *
2333
-	 * @since 1.0.19
2334
-	 * @param  string $value phone.
2335
-	 */
2336
-	public function set_phone_number( $value ) {
2337
-		$this->set_phone( $value );
2371
+     * Alias of self::set_email().
2372
+     *
2373
+     * @since 1.0.19
2374
+     * @param  string $value email address.
2375
+     */
2376
+    public function set_customer_email( $value ) {
2377
+        $this->set_email( $value );
2338 2378
     }
2339 2379
 
2340 2380
     /**
2341
-	 * Set the customer's email address.
2342
-	 *
2343
-	 * @since 1.0.19
2344
-	 * @param  string $value email address.
2345
-	 */
2346
-	public function set_email( $value ) {
2347
-		$this->set_prop( 'email', $value );
2381
+     * Set the customer's country.
2382
+     *
2383
+     * @since 1.0.19
2384
+     * @param  string $value country.
2385
+     */
2386
+    public function set_country( $value ) {
2387
+        $this->set_prop( 'country', $value );
2348 2388
     }
2349 2389
 
2350 2390
     /**
2351
-	 * Alias of self::set_email().
2352
-	 *
2353
-	 * @since 1.0.19
2354
-	 * @param  string $value email address.
2355
-	 */
2356
-	public function set_user_email( $value ) {
2357
-		$this->set_email( $value );
2391
+     * Alias of self::set_country().
2392
+     *
2393
+     * @since 1.0.19
2394
+     * @param  string $value country.
2395
+     */
2396
+    public function set_user_country( $value ) {
2397
+        $this->set_country( $value );
2358 2398
     }
2359 2399
 
2360 2400
     /**
2361
-	 * Alias of self::set_email().
2362
-	 *
2363
-	 * @since 1.0.19
2364
-	 * @param  string $value email address.
2365
-	 */
2366
-	public function set_email_address( $value ) {
2367
-		$this->set_email( $value );
2401
+     * Alias of self::set_country().
2402
+     *
2403
+     * @since 1.0.19
2404
+     * @param  string $value country.
2405
+     */
2406
+    public function set_customer_country( $value ) {
2407
+        $this->set_country( $value );
2368 2408
     }
2369 2409
 
2370 2410
     /**
2371
-	 * Alias of self::set_email().
2372
-	 *
2373
-	 * @since 1.0.19
2374
-	 * @param  string $value email address.
2375
-	 */
2376
-	public function set_customer_email( $value ) {
2377
-		$this->set_email( $value );
2411
+     * Set the customer's state.
2412
+     *
2413
+     * @since 1.0.19
2414
+     * @param  string $value state.
2415
+     */
2416
+    public function set_state( $value ) {
2417
+        $this->set_prop( 'state', $value );
2378 2418
     }
2379 2419
 
2380 2420
     /**
2381
-	 * Set the customer's country.
2382
-	 *
2383
-	 * @since 1.0.19
2384
-	 * @param  string $value country.
2385
-	 */
2386
-	public function set_country( $value ) {
2387
-		$this->set_prop( 'country', $value );
2421
+     * Alias of self::set_state().
2422
+     *
2423
+     * @since 1.0.19
2424
+     * @param  string $value state.
2425
+     */
2426
+    public function set_user_state( $value ) {
2427
+        $this->set_state( $value );
2388 2428
     }
2389 2429
 
2390 2430
     /**
2391
-	 * Alias of self::set_country().
2392
-	 *
2393
-	 * @since 1.0.19
2394
-	 * @param  string $value country.
2395
-	 */
2396
-	public function set_user_country( $value ) {
2397
-		$this->set_country( $value );
2431
+     * Alias of self::set_state().
2432
+     *
2433
+     * @since 1.0.19
2434
+     * @param  string $value state.
2435
+     */
2436
+    public function set_customer_state( $value ) {
2437
+        $this->set_state( $value );
2398 2438
     }
2399 2439
 
2400 2440
     /**
2401
-	 * Alias of self::set_country().
2402
-	 *
2403
-	 * @since 1.0.19
2404
-	 * @param  string $value country.
2405
-	 */
2406
-	public function set_customer_country( $value ) {
2407
-		$this->set_country( $value );
2441
+     * Set the customer's city.
2442
+     *
2443
+     * @since 1.0.19
2444
+     * @param  string $value city.
2445
+     */
2446
+    public function set_city( $value ) {
2447
+        $this->set_prop( 'city', $value );
2408 2448
     }
2409 2449
 
2410 2450
     /**
2411
-	 * Set the customer's state.
2412
-	 *
2413
-	 * @since 1.0.19
2414
-	 * @param  string $value state.
2415
-	 */
2416
-	public function set_state( $value ) {
2417
-		$this->set_prop( 'state', $value );
2451
+     * Alias of self::set_city().
2452
+     *
2453
+     * @since 1.0.19
2454
+     * @param  string $value city.
2455
+     */
2456
+    public function set_user_city( $value ) {
2457
+        $this->set_city( $value );
2418 2458
     }
2419 2459
 
2420 2460
     /**
2421
-	 * Alias of self::set_state().
2422
-	 *
2423
-	 * @since 1.0.19
2424
-	 * @param  string $value state.
2425
-	 */
2426
-	public function set_user_state( $value ) {
2427
-		$this->set_state( $value );
2461
+     * Alias of self::set_city().
2462
+     *
2463
+     * @since 1.0.19
2464
+     * @param  string $value city.
2465
+     */
2466
+    public function set_customer_city( $value ) {
2467
+        $this->set_city( $value );
2428 2468
     }
2429 2469
 
2430 2470
     /**
2431
-	 * Alias of self::set_state().
2432
-	 *
2433
-	 * @since 1.0.19
2434
-	 * @param  string $value state.
2435
-	 */
2436
-	public function set_customer_state( $value ) {
2437
-		$this->set_state( $value );
2471
+     * Set the customer's zip code.
2472
+     *
2473
+     * @since 1.0.19
2474
+     * @param  string $value zip.
2475
+     */
2476
+    public function set_zip( $value ) {
2477
+        $this->set_prop( 'zip', $value );
2438 2478
     }
2439 2479
 
2440 2480
     /**
2441
-	 * Set the customer's city.
2442
-	 *
2443
-	 * @since 1.0.19
2444
-	 * @param  string $value city.
2445
-	 */
2446
-	public function set_city( $value ) {
2447
-		$this->set_prop( 'city', $value );
2481
+     * Alias of self::set_zip().
2482
+     *
2483
+     * @since 1.0.19
2484
+     * @param  string $value zip.
2485
+     */
2486
+    public function set_user_zip( $value ) {
2487
+        $this->set_zip( $value );
2448 2488
     }
2449 2489
 
2450 2490
     /**
2451
-	 * Alias of self::set_city().
2452
-	 *
2453
-	 * @since 1.0.19
2454
-	 * @param  string $value city.
2455
-	 */
2456
-	public function set_user_city( $value ) {
2457
-		$this->set_city( $value );
2491
+     * Alias of self::set_zip().
2492
+     *
2493
+     * @since 1.0.19
2494
+     * @param  string $value zip.
2495
+     */
2496
+    public function set_customer_zip( $value ) {
2497
+        $this->set_zip( $value );
2458 2498
     }
2459 2499
 
2460 2500
     /**
2461
-	 * Alias of self::set_city().
2462
-	 *
2463
-	 * @since 1.0.19
2464
-	 * @param  string $value city.
2465
-	 */
2466
-	public function set_customer_city( $value ) {
2467
-		$this->set_city( $value );
2501
+     * Set the customer's company.
2502
+     *
2503
+     * @since 1.0.19
2504
+     * @param  string $value company.
2505
+     */
2506
+    public function set_company( $value ) {
2507
+        $this->set_prop( 'company', $value );
2468 2508
     }
2469 2509
 
2470 2510
     /**
2471
-	 * Set the customer's zip code.
2472
-	 *
2473
-	 * @since 1.0.19
2474
-	 * @param  string $value zip.
2475
-	 */
2476
-	public function set_zip( $value ) {
2477
-		$this->set_prop( 'zip', $value );
2511
+     * Alias of self::set_company().
2512
+     *
2513
+     * @since 1.0.19
2514
+     * @param  string $value company.
2515
+     */
2516
+    public function set_user_company( $value ) {
2517
+        $this->set_company( $value );
2478 2518
     }
2479 2519
 
2480 2520
     /**
2481
-	 * Alias of self::set_zip().
2482
-	 *
2483
-	 * @since 1.0.19
2484
-	 * @param  string $value zip.
2485
-	 */
2486
-	public function set_user_zip( $value ) {
2487
-		$this->set_zip( $value );
2521
+     * Alias of self::set_company().
2522
+     *
2523
+     * @since 1.0.19
2524
+     * @param  string $value company.
2525
+     */
2526
+    public function set_customer_company( $value ) {
2527
+        $this->set_company( $value );
2488 2528
     }
2489 2529
 
2490 2530
     /**
2491
-	 * Alias of self::set_zip().
2492
-	 *
2493
-	 * @since 1.0.19
2494
-	 * @param  string $value zip.
2495
-	 */
2496
-	public function set_customer_zip( $value ) {
2497
-		$this->set_zip( $value );
2531
+     * Set the customer's var number.
2532
+     *
2533
+     * @since 1.0.19
2534
+     * @param  string $value var number.
2535
+     */
2536
+    public function set_vat_number( $value ) {
2537
+        $this->set_prop( 'vat_number', $value );
2498 2538
     }
2499 2539
 
2500 2540
     /**
2501
-	 * Set the customer's company.
2502
-	 *
2503
-	 * @since 1.0.19
2504
-	 * @param  string $value company.
2505
-	 */
2506
-	public function set_company( $value ) {
2507
-		$this->set_prop( 'company', $value );
2541
+     * Alias of self::set_vat_number().
2542
+     *
2543
+     * @since 1.0.19
2544
+     * @param  string $value var number.
2545
+     */
2546
+    public function set_user_vat_number( $value ) {
2547
+        $this->set_vat_number( $value );
2508 2548
     }
2509 2549
 
2510 2550
     /**
2511
-	 * Alias of self::set_company().
2512
-	 *
2513
-	 * @since 1.0.19
2514
-	 * @param  string $value company.
2515
-	 */
2516
-	public function set_user_company( $value ) {
2517
-		$this->set_company( $value );
2551
+     * Alias of self::set_vat_number().
2552
+     *
2553
+     * @since 1.0.19
2554
+     * @param  string $value var number.
2555
+     */
2556
+    public function set_customer_vat_number( $value ) {
2557
+        $this->set_vat_number( $value );
2518 2558
     }
2519 2559
 
2520 2560
     /**
2521
-	 * Alias of self::set_company().
2522
-	 *
2523
-	 * @since 1.0.19
2524
-	 * @param  string $value company.
2525
-	 */
2526
-	public function set_customer_company( $value ) {
2527
-		$this->set_company( $value );
2561
+     * Set the customer's vat rate.
2562
+     *
2563
+     * @since 1.0.19
2564
+     * @param  string $value var rate.
2565
+     */
2566
+    public function set_vat_rate( $value ) {
2567
+        $this->set_prop( 'vat_rate', $value );
2528 2568
     }
2529 2569
 
2530 2570
     /**
2531
-	 * Set the customer's var number.
2532
-	 *
2533
-	 * @since 1.0.19
2534
-	 * @param  string $value var number.
2535
-	 */
2536
-	public function set_vat_number( $value ) {
2537
-		$this->set_prop( 'vat_number', $value );
2571
+     * Alias of self::set_vat_rate().
2572
+     *
2573
+     * @since 1.0.19
2574
+     * @param  string $value var number.
2575
+     */
2576
+    public function set_user_vat_rate( $value ) {
2577
+        $this->set_vat_rate( $value );
2538 2578
     }
2539 2579
 
2540 2580
     /**
2541
-	 * Alias of self::set_vat_number().
2542
-	 *
2543
-	 * @since 1.0.19
2544
-	 * @param  string $value var number.
2545
-	 */
2546
-	public function set_user_vat_number( $value ) {
2547
-		$this->set_vat_number( $value );
2581
+     * Alias of self::set_vat_rate().
2582
+     *
2583
+     * @since 1.0.19
2584
+     * @param  string $value var number.
2585
+     */
2586
+    public function set_customer_vat_rate( $value ) {
2587
+        $this->set_vat_rate( $value );
2548 2588
     }
2549 2589
 
2550 2590
     /**
2551
-	 * Alias of self::set_vat_number().
2552
-	 *
2553
-	 * @since 1.0.19
2554
-	 * @param  string $value var number.
2555
-	 */
2556
-	public function set_customer_vat_number( $value ) {
2557
-		$this->set_vat_number( $value );
2591
+     * Set the customer's address.
2592
+     *
2593
+     * @since 1.0.19
2594
+     * @param  string $value address.
2595
+     */
2596
+    public function set_address( $value ) {
2597
+        $this->set_prop( 'address', $value );
2558 2598
     }
2559 2599
 
2560 2600
     /**
2561
-	 * Set the customer's vat rate.
2562
-	 *
2563
-	 * @since 1.0.19
2564
-	 * @param  string $value var rate.
2565
-	 */
2566
-	public function set_vat_rate( $value ) {
2567
-		$this->set_prop( 'vat_rate', $value );
2601
+     * Alias of self::set_address().
2602
+     *
2603
+     * @since 1.0.19
2604
+     * @param  string $value address.
2605
+     */
2606
+    public function set_user_address( $value ) {
2607
+        $this->set_address( $value );
2568 2608
     }
2569 2609
 
2570 2610
     /**
2571
-	 * Alias of self::set_vat_rate().
2572
-	 *
2573
-	 * @since 1.0.19
2574
-	 * @param  string $value var number.
2575
-	 */
2576
-	public function set_user_vat_rate( $value ) {
2577
-		$this->set_vat_rate( $value );
2611
+     * Alias of self::set_address().
2612
+     *
2613
+     * @since 1.0.19
2614
+     * @param  string $value address.
2615
+     */
2616
+    public function set_customer_address( $value ) {
2617
+        $this->set_address( $value );
2578 2618
     }
2579 2619
 
2580 2620
     /**
2581
-	 * Alias of self::set_vat_rate().
2582
-	 *
2583
-	 * @since 1.0.19
2584
-	 * @param  string $value var number.
2585
-	 */
2586
-	public function set_customer_vat_rate( $value ) {
2587
-		$this->set_vat_rate( $value );
2621
+     * Set whether the customer has viewed the invoice or not.
2622
+     *
2623
+     * @since 1.0.19
2624
+     * @param  int|bool $value confirmed.
2625
+     */
2626
+    public function set_is_viewed( $value ) {
2627
+        $this->set_prop( 'is_viewed', $value );
2588 2628
     }
2589 2629
 
2590 2630
     /**
2591
-	 * Set the customer's address.
2592
-	 *
2593
-	 * @since 1.0.19
2594
-	 * @param  string $value address.
2595
-	 */
2596
-	public function set_address( $value ) {
2597
-		$this->set_prop( 'address', $value );
2631
+     * Set extra email recipients.
2632
+     *
2633
+     * @since 1.0.19
2634
+     * @param  string $value email recipients.
2635
+     */
2636
+    public function set_email_cc( $value ) {
2637
+        $this->set_prop( 'email_cc', $value );
2598 2638
     }
2599 2639
 
2600 2640
     /**
2601
-	 * Alias of self::set_address().
2602
-	 *
2603
-	 * @since 1.0.19
2604
-	 * @param  string $value address.
2605
-	 */
2606
-	public function set_user_address( $value ) {
2607
-		$this->set_address( $value );
2641
+     * Set the invoice template.
2642
+     *
2643
+     * @since 1.0.19
2644
+     * @param  string $value template.
2645
+     */
2646
+    public function set_template( $value ) {
2647
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2648
+            $this->set_prop( 'template', $value );
2649
+        }
2608 2650
     }
2609 2651
 
2610 2652
     /**
2611
-	 * Alias of self::set_address().
2612
-	 *
2613
-	 * @since 1.0.19
2614
-	 * @param  string $value address.
2615
-	 */
2616
-	public function set_customer_address( $value ) {
2617
-		$this->set_address( $value );
2653
+     * Set the invoice source.
2654
+     *
2655
+     * @since 1.0.19
2656
+     * @param  string $value email recipients.
2657
+     */
2658
+    public function created_via( $value ) {
2659
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2618 2660
     }
2619 2661
 
2620 2662
     /**
2621
-	 * Set whether the customer has viewed the invoice or not.
2622
-	 *
2623
-	 * @since 1.0.19
2624
-	 * @param  int|bool $value confirmed.
2625
-	 */
2626
-	public function set_is_viewed( $value ) {
2627
-		$this->set_prop( 'is_viewed', $value );
2628
-	}
2629
-
2630
-	/**
2631
-	 * Set extra email recipients.
2632
-	 *
2633
-	 * @since 1.0.19
2634
-	 * @param  string $value email recipients.
2635
-	 */
2636
-	public function set_email_cc( $value ) {
2637
-		$this->set_prop( 'email_cc', $value );
2638
-	}
2639
-
2640
-	/**
2641
-	 * Set the invoice template.
2642
-	 *
2643
-	 * @since 1.0.19
2644
-	 * @param  string $value template.
2645
-	 */
2646
-	public function set_template( $value ) {
2647
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2648
-			$this->set_prop( 'template', $value );
2649
-		}
2650
-	}
2651
-
2652
-	/**
2653
-	 * Set the invoice source.
2654
-	 *
2655
-	 * @since 1.0.19
2656
-	 * @param  string $value email recipients.
2657
-	 */
2658
-	public function created_via( $value ) {
2659
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2660
-	}
2661
-
2662
-	/**
2663
-	 * Set the customer's address confirmed status.
2664
-	 *
2665
-	 * @since 1.0.19
2666
-	 * @param  int|bool $value confirmed.
2667
-	 */
2668
-	public function set_address_confirmed( $value ) {
2669
-		$this->set_prop( 'address_confirmed', $value );
2663
+     * Set the customer's address confirmed status.
2664
+     *
2665
+     * @since 1.0.19
2666
+     * @param  int|bool $value confirmed.
2667
+     */
2668
+    public function set_address_confirmed( $value ) {
2669
+        $this->set_prop( 'address_confirmed', $value );
2670 2670
     }
2671 2671
 
2672 2672
     /**
2673
-	 * Alias of self::set_address_confirmed().
2674
-	 *
2675
-	 * @since 1.0.19
2676
-	 * @param  int|bool $value confirmed.
2677
-	 */
2678
-	public function set_user_address_confirmed( $value ) {
2679
-		$this->set_address_confirmed( $value );
2673
+     * Alias of self::set_address_confirmed().
2674
+     *
2675
+     * @since 1.0.19
2676
+     * @param  int|bool $value confirmed.
2677
+     */
2678
+    public function set_user_address_confirmed( $value ) {
2679
+        $this->set_address_confirmed( $value );
2680 2680
     }
2681 2681
 
2682 2682
     /**
2683
-	 * Alias of self::set_address_confirmed().
2684
-	 *
2685
-	 * @since 1.0.19
2686
-	 * @param  int|bool $value confirmed.
2687
-	 */
2688
-	public function set_customer_address_confirmed( $value ) {
2689
-		$this->set_address_confirmed( $value );
2683
+     * Alias of self::set_address_confirmed().
2684
+     *
2685
+     * @since 1.0.19
2686
+     * @param  int|bool $value confirmed.
2687
+     */
2688
+    public function set_customer_address_confirmed( $value ) {
2689
+        $this->set_address_confirmed( $value );
2690 2690
     }
2691 2691
 
2692 2692
     /**
2693
-	 * Set the invoice sub total.
2694
-	 *
2695
-	 * @since 1.0.19
2696
-	 * @param  float $value sub total.
2697
-	 */
2698
-	public function set_subtotal( $value ) {
2699
-		$this->set_prop( 'subtotal', $value );
2693
+     * Set the invoice sub total.
2694
+     *
2695
+     * @since 1.0.19
2696
+     * @param  float $value sub total.
2697
+     */
2698
+    public function set_subtotal( $value ) {
2699
+        $this->set_prop( 'subtotal', $value );
2700 2700
     }
2701 2701
 
2702 2702
     /**
2703
-	 * Set the invoice discount amount.
2704
-	 *
2705
-	 * @since 1.0.19
2706
-	 * @param  float $value discount total.
2707
-	 */
2708
-	public function set_total_discount( $value ) {
2709
-		$this->set_prop( 'total_discount', $value );
2703
+     * Set the invoice discount amount.
2704
+     *
2705
+     * @since 1.0.19
2706
+     * @param  float $value discount total.
2707
+     */
2708
+    public function set_total_discount( $value ) {
2709
+        $this->set_prop( 'total_discount', $value );
2710 2710
     }
2711 2711
 
2712 2712
     /**
2713
-	 * Alias of self::set_total_discount().
2714
-	 *
2715
-	 * @since 1.0.19
2716
-	 * @param  float $value discount total.
2717
-	 */
2718
-	public function set_discount( $value ) {
2719
-		$this->set_total_discount( $value );
2713
+     * Alias of self::set_total_discount().
2714
+     *
2715
+     * @since 1.0.19
2716
+     * @param  float $value discount total.
2717
+     */
2718
+    public function set_discount( $value ) {
2719
+        $this->set_total_discount( $value );
2720 2720
     }
2721 2721
 
2722 2722
     /**
2723
-	 * Set the invoice tax amount.
2724
-	 *
2725
-	 * @since 1.0.19
2726
-	 * @param  float $value tax total.
2727
-	 */
2728
-	public function set_total_tax( $value ) {
2729
-		$this->set_prop( 'total_tax', $value );
2723
+     * Set the invoice tax amount.
2724
+     *
2725
+     * @since 1.0.19
2726
+     * @param  float $value tax total.
2727
+     */
2728
+    public function set_total_tax( $value ) {
2729
+        $this->set_prop( 'total_tax', $value );
2730 2730
     }
2731 2731
 
2732 2732
     /**
2733
-	 * Alias of self::set_total_tax().
2734
-	 *
2735
-	 * @since 1.0.19
2736
-	 * @param  float $value tax total.
2737
-	 */
2738
-	public function set_tax_total( $value ) {
2739
-		$this->set_total_tax( $value );
2733
+     * Alias of self::set_total_tax().
2734
+     *
2735
+     * @since 1.0.19
2736
+     * @param  float $value tax total.
2737
+     */
2738
+    public function set_tax_total( $value ) {
2739
+        $this->set_total_tax( $value );
2740 2740
     }
2741 2741
 
2742 2742
     /**
2743
-	 * Set the invoice fees amount.
2744
-	 *
2745
-	 * @since 1.0.19
2746
-	 * @param  float $value fees total.
2747
-	 */
2748
-	public function set_total_fees( $value ) {
2749
-		$this->set_prop( 'total_fees', $value );
2743
+     * Set the invoice fees amount.
2744
+     *
2745
+     * @since 1.0.19
2746
+     * @param  float $value fees total.
2747
+     */
2748
+    public function set_total_fees( $value ) {
2749
+        $this->set_prop( 'total_fees', $value );
2750 2750
     }
2751 2751
 
2752 2752
     /**
2753
-	 * Alias of self::set_total_fees().
2754
-	 *
2755
-	 * @since 1.0.19
2756
-	 * @param  float $value fees total.
2757
-	 */
2758
-	public function set_fees_total( $value ) {
2759
-		$this->set_total_fees( $value );
2753
+     * Alias of self::set_total_fees().
2754
+     *
2755
+     * @since 1.0.19
2756
+     * @param  float $value fees total.
2757
+     */
2758
+    public function set_fees_total( $value ) {
2759
+        $this->set_total_fees( $value );
2760 2760
     }
2761 2761
 
2762 2762
     /**
2763
-	 * Set the invoice fees.
2764
-	 *
2765
-	 * @since 1.0.19
2766
-	 * @param  array $value fees.
2767
-	 */
2768
-	public function set_fees( $value ) {
2763
+     * Set the invoice fees.
2764
+     *
2765
+     * @since 1.0.19
2766
+     * @param  array $value fees.
2767
+     */
2768
+    public function set_fees( $value ) {
2769 2769
 
2770
-		if ( ! is_array( $value ) ) {
2771
-			$value = array();
2772
-		}
2770
+        if ( ! is_array( $value ) ) {
2771
+            $value = array();
2772
+        }
2773 2773
 
2774
-		$this->set_prop( 'fees', $value );
2774
+        $this->set_prop( 'fees', $value );
2775 2775
 
2776 2776
     }
2777 2777
 
2778 2778
     /**
2779
-	 * Set the invoice taxes.
2780
-	 *
2781
-	 * @since 1.0.19
2782
-	 * @param  array $value taxes.
2783
-	 */
2784
-	public function set_taxes( $value ) {
2779
+     * Set the invoice taxes.
2780
+     *
2781
+     * @since 1.0.19
2782
+     * @param  array $value taxes.
2783
+     */
2784
+    public function set_taxes( $value ) {
2785 2785
 
2786
-		if ( ! is_array( $value ) ) {
2787
-			$value = array();
2788
-		}
2786
+        if ( ! is_array( $value ) ) {
2787
+            $value = array();
2788
+        }
2789 2789
 
2790
-		$this->set_prop( 'taxes', $value );
2790
+        $this->set_prop( 'taxes', $value );
2791 2791
 
2792 2792
     }
2793 2793
 
2794 2794
     /**
2795
-	 * Set the invoice discounts.
2796
-	 *
2797
-	 * @since 1.0.19
2798
-	 * @param  array $value discounts.
2799
-	 */
2800
-	public function set_discounts( $value ) {
2795
+     * Set the invoice discounts.
2796
+     *
2797
+     * @since 1.0.19
2798
+     * @param  array $value discounts.
2799
+     */
2800
+    public function set_discounts( $value ) {
2801 2801
 
2802
-		if ( ! is_array( $value ) ) {
2803
-			$value = array();
2804
-		}
2802
+        if ( ! is_array( $value ) ) {
2803
+            $value = array();
2804
+        }
2805 2805
 
2806
-		$this->set_prop( 'discounts', $value );
2806
+        $this->set_prop( 'discounts', $value );
2807 2807
     }
2808 2808
 
2809 2809
     /**
2810
-	 * Set the invoice items.
2811
-	 *
2812
-	 * @since 1.0.19
2813
-	 * @param  GetPaid_Form_Item[] $value items.
2814
-	 */
2815
-	public function set_items( $value ) {
2810
+     * Set the invoice items.
2811
+     *
2812
+     * @since 1.0.19
2813
+     * @param  GetPaid_Form_Item[] $value items.
2814
+     */
2815
+    public function set_items( $value ) {
2816 2816
 
2817 2817
         // Remove existing items.
2818 2818
         $this->set_prop( 'items', array() );
@@ -2829,95 +2829,95 @@  discard block
 block discarded – undo
2829 2829
     }
2830 2830
 
2831 2831
     /**
2832
-	 * Set the payment form.
2833
-	 *
2834
-	 * @since 1.0.19
2835
-	 * @param  int $value payment form.
2836
-	 */
2837
-	public function set_payment_form( $value ) {
2838
-		$this->set_prop( 'payment_form', $value );
2832
+     * Set the payment form.
2833
+     *
2834
+     * @since 1.0.19
2835
+     * @param  int $value payment form.
2836
+     */
2837
+    public function set_payment_form( $value ) {
2838
+        $this->set_prop( 'payment_form', $value );
2839 2839
     }
2840 2840
 
2841 2841
     /**
2842
-	 * Set the submission id.
2843
-	 *
2844
-	 * @since 1.0.19
2845
-	 * @param  string $value submission id.
2846
-	 */
2847
-	public function set_submission_id( $value ) {
2848
-		$this->set_prop( 'submission_id', $value );
2842
+     * Set the submission id.
2843
+     *
2844
+     * @since 1.0.19
2845
+     * @param  string $value submission id.
2846
+     */
2847
+    public function set_submission_id( $value ) {
2848
+        $this->set_prop( 'submission_id', $value );
2849 2849
     }
2850 2850
 
2851 2851
     /**
2852
-	 * Set the discount code.
2853
-	 *
2854
-	 * @since 1.0.19
2855
-	 * @param  string $value discount code.
2856
-	 */
2857
-	public function set_discount_code( $value ) {
2858
-		$this->set_prop( 'discount_code', $value );
2852
+     * Set the discount code.
2853
+     *
2854
+     * @since 1.0.19
2855
+     * @param  string $value discount code.
2856
+     */
2857
+    public function set_discount_code( $value ) {
2858
+        $this->set_prop( 'discount_code', $value );
2859 2859
     }
2860 2860
 
2861 2861
     /**
2862
-	 * Set the gateway.
2863
-	 *
2864
-	 * @since 1.0.19
2865
-	 * @param  string $value gateway.
2866
-	 */
2867
-	public function set_gateway( $value ) {
2868
-		$this->set_prop( 'gateway', $value );
2862
+     * Set the gateway.
2863
+     *
2864
+     * @since 1.0.19
2865
+     * @param  string $value gateway.
2866
+     */
2867
+    public function set_gateway( $value ) {
2868
+        $this->set_prop( 'gateway', $value );
2869 2869
     }
2870 2870
 
2871 2871
     /**
2872
-	 * Set the transaction id.
2873
-	 *
2874
-	 * @since 1.0.19
2875
-	 * @param  string $value transaction id.
2876
-	 */
2877
-	public function set_transaction_id( $value ) {
2878
-		if ( ! empty( $value ) ) {
2879
-			$this->set_prop( 'transaction_id', $value );
2880
-		}
2872
+     * Set the transaction id.
2873
+     *
2874
+     * @since 1.0.19
2875
+     * @param  string $value transaction id.
2876
+     */
2877
+    public function set_transaction_id( $value ) {
2878
+        if ( ! empty( $value ) ) {
2879
+            $this->set_prop( 'transaction_id', $value );
2880
+        }
2881 2881
     }
2882 2882
 
2883 2883
     /**
2884
-	 * Set the currency id.
2885
-	 *
2886
-	 * @since 1.0.19
2887
-	 * @param  string $value currency id.
2888
-	 */
2889
-	public function set_currency( $value ) {
2890
-		$this->set_prop( 'currency', $value );
2884
+     * Set the currency id.
2885
+     *
2886
+     * @since 1.0.19
2887
+     * @param  string $value currency id.
2888
+     */
2889
+    public function set_currency( $value ) {
2890
+        $this->set_prop( 'currency', $value );
2891 2891
     }
2892 2892
 
2893
-	/**
2894
-	 * Set whether to disable taxes.
2895
-	 *
2896
-	 * @since 1.0.19
2897
-	 * @param  bool $value value.
2898
-	 */
2899
-	public function set_disable_taxes( $value ) {
2900
-		$this->set_prop( 'disable_taxes', (bool) $value );
2901
-	}
2893
+    /**
2894
+     * Set whether to disable taxes.
2895
+     *
2896
+     * @since 1.0.19
2897
+     * @param  bool $value value.
2898
+     */
2899
+    public function set_disable_taxes( $value ) {
2900
+        $this->set_prop( 'disable_taxes', (bool) $value );
2901
+    }
2902 2902
 
2903 2903
     /**
2904
-	 * Set the subscription id.
2905
-	 *
2906
-	 * @since 1.0.19
2907
-	 * @param  string $value subscription id.
2908
-	 */
2909
-	public function set_subscription_id( $value ) {
2910
-		$this->set_prop( 'subscription_id', $value );
2911
-	}
2904
+     * Set the subscription id.
2905
+     *
2906
+     * @since 1.0.19
2907
+     * @param  string $value subscription id.
2908
+     */
2909
+    public function set_subscription_id( $value ) {
2910
+        $this->set_prop( 'subscription_id', $value );
2911
+    }
2912 2912
 	
2913
-	/**
2914
-	 * Set the remote subscription id.
2915
-	 *
2916
-	 * @since 1.0.19
2917
-	 * @param  string $value subscription id.
2918
-	 */
2919
-	public function set_remote_subscription_id( $value ) {
2920
-		$this->set_prop( 'remote_subscription_id', $value );
2913
+    /**
2914
+     * Set the remote subscription id.
2915
+     *
2916
+     * @since 1.0.19
2917
+     * @param  string $value subscription id.
2918
+     */
2919
+    public function set_remote_subscription_id( $value ) {
2920
+        $this->set_prop( 'remote_subscription_id', $value );
2921 2921
     }
2922 2922
 
2923 2923
     /*
@@ -2956,24 +2956,24 @@  discard block
 block discarded – undo
2956 2956
      */
2957 2957
     public function is_taxable() {
2958 2958
         return ! $this->get_disable_taxes();
2959
-	}
2959
+    }
2960 2960
 
2961
-	/**
2962
-	 * @deprecated
2963
-	 */
2964
-	public function has_vat() {
2961
+    /**
2962
+     * @deprecated
2963
+     */
2964
+    public function has_vat() {
2965 2965
         return $this->is_taxable();
2966
-	}
2966
+    }
2967 2967
 
2968
-	/**
2969
-	 * Checks to see if the invoice requires payment.
2970
-	 */
2971
-	public function is_free() {
2968
+    /**
2969
+     * Checks to see if the invoice requires payment.
2970
+     */
2971
+    public function is_free() {
2972 2972
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2973 2973
 
2974
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2975
-			$is_free = false;
2976
-		}
2974
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2975
+            $is_free = false;
2976
+        }
2977 2977
 
2978 2978
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2979 2979
     }
@@ -2984,46 +2984,46 @@  discard block
 block discarded – undo
2984 2984
     public function is_paid() {
2985 2985
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2986 2986
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2987
-	}
2987
+    }
2988 2988
 
2989
-	/**
2989
+    /**
2990 2990
      * Checks if the invoice needs payment.
2991 2991
      */
2992
-	public function needs_payment() {
2993
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2992
+    public function needs_payment() {
2993
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2994 2994
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2995 2995
     }
2996 2996
   
2997
-	/**
2997
+    /**
2998 2998
      * Checks if the invoice is refunded.
2999 2999
      */
3000
-	public function is_refunded() {
3000
+    public function is_refunded() {
3001 3001
         $is_refunded = $this->has_status( 'wpi-refunded' );
3002 3002
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3003
-	}
3003
+    }
3004 3004
 
3005
-	/**
3005
+    /**
3006 3006
      * Checks if the invoice is held.
3007 3007
      */
3008
-	public function is_held() {
3008
+    public function is_held() {
3009 3009
         $is_held = $this->has_status( 'wpi-onhold' );
3010 3010
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3011
-	}
3011
+    }
3012 3012
 
3013
-	/**
3013
+    /**
3014 3014
      * Checks if the invoice is due.
3015 3015
      */
3016
-	public function is_due() {
3017
-		$due_date = $this->get_due_date();
3018
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3019
-	}
3016
+    public function is_due() {
3017
+        $due_date = $this->get_due_date();
3018
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3019
+    }
3020 3020
 
3021
-	/**
3021
+    /**
3022 3022
      * Checks if the invoice is draft.
3023 3023
      */
3024
-	public function is_draft() {
3024
+    public function is_draft() {
3025 3025
         return $this->has_status( 'draft, auto-draft' );
3026
-	}
3026
+    }
3027 3027
 
3028 3028
     /**
3029 3029
      * Checks if the invoice has a given status.
@@ -3031,9 +3031,9 @@  discard block
 block discarded – undo
3031 3031
     public function has_status( $status ) {
3032 3032
         $status = wpinv_parse_list( $status );
3033 3033
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3034
-	}
3034
+    }
3035 3035
 
3036
-	/**
3036
+    /**
3037 3037
      * Checks if the invoice is of a given type.
3038 3038
      */
3039 3039
     public function is_type( $type ) {
@@ -3056,25 +3056,25 @@  discard block
 block discarded – undo
3056 3056
      */
3057 3057
     public function has_free_trial() {
3058 3058
         return $this->is_recurring() && 0 == $this->get_initial_total();
3059
-	}
3059
+    }
3060 3060
 
3061
-	/**
3061
+    /**
3062 3062
      * @deprecated
3063 3063
      */
3064 3064
     public function is_free_trial() {
3065 3065
         $this->has_free_trial();
3066 3066
     }
3067 3067
 
3068
-	/**
3068
+    /**
3069 3069
      * Check if the initial payment if 0.
3070 3070
      *
3071 3071
      */
3072
-	public function is_initial_free() {
3072
+    public function is_initial_free() {
3073 3073
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3074 3074
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3075 3075
     }
3076 3076
 	
3077
-	/**
3077
+    /**
3078 3078
      * Check if the recurring item has a free trial.
3079 3079
      *
3080 3080
      */
@@ -3087,21 +3087,21 @@  discard block
 block discarded – undo
3087 3087
 
3088 3088
         $item = $this->get_recurring( true );
3089 3089
         return $item->has_free_trial();
3090
-	}
3090
+    }
3091 3091
 
3092
-	/**
3092
+    /**
3093 3093
      * Check if the free trial is a result of a discount.
3094 3094
      */
3095 3095
     public function is_free_trial_from_discount() {
3096
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3097
-	}
3096
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3097
+    }
3098 3098
 	
3099
-	/**
3099
+    /**
3100 3100
      * @deprecated
3101 3101
      */
3102 3102
     public function discount_first_payment_only() {
3103 3103
 
3104
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3104
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3105 3105
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3106 3106
             return true;
3107 3107
         }
@@ -3126,28 +3126,28 @@  discard block
 block discarded – undo
3126 3126
      */
3127 3127
     public function add_item( $item ) {
3128 3128
 
3129
-		if ( is_array( $item ) ) {
3130
-			$item = $this->process_array_item( $item );
3131
-		}
3129
+        if ( is_array( $item ) ) {
3130
+            $item = $this->process_array_item( $item );
3131
+        }
3132 3132
 
3133
-		if ( is_numeric( $item ) ) {
3134
-			$item = new GetPaid_Form_Item( $item );
3135
-		}
3133
+        if ( is_numeric( $item ) ) {
3134
+            $item = new GetPaid_Form_Item( $item );
3135
+        }
3136 3136
 
3137 3137
         // Make sure that it is available for purchase.
3138
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3139
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3138
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3139
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3140 3140
         }
3141 3141
 
3142 3142
         // Do we have a recurring item?
3143
-		if ( $item->is_recurring() ) {
3143
+        if ( $item->is_recurring() ) {
3144 3144
 
3145
-			// An invoice can only contain one recurring item.
3146
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3147
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3148
-			}
3145
+            // An invoice can only contain one recurring item.
3146
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3147
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3148
+            }
3149 3149
 
3150
-			$this->recurring_item = $item->get_id();
3150
+            $this->recurring_item = $item->get_id();
3151 3151
         }
3152 3152
 
3153 3153
         // Invoice id.
@@ -3158,60 +3158,60 @@  discard block
 block discarded – undo
3158 3158
         $items[ (int) $item->get_id() ] = $item;
3159 3159
 
3160 3160
         $this->set_prop( 'items', $items );
3161
-		return true;
3162
-	}
3161
+        return true;
3162
+    }
3163 3163
 
3164
-	/**
3165
-	 * Converts an array to an item.
3166
-	 *
3167
-	 * @since 1.0.19
3168
-	 * @return GetPaid_Form_Item
3169
-	 */
3170
-	protected function process_array_item( $array ) {
3164
+    /**
3165
+     * Converts an array to an item.
3166
+     *
3167
+     * @since 1.0.19
3168
+     * @return GetPaid_Form_Item
3169
+     */
3170
+    protected function process_array_item( $array ) {
3171 3171
 
3172
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3173
-		$item    = new GetPaid_Form_Item( $item_id );
3172
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3173
+        $item    = new GetPaid_Form_Item( $item_id );
3174 3174
 
3175
-		// Set item data.
3176
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3177
-			if ( isset( $array[ "item_$key" ] ) ) {
3178
-				$method = "set_$key";
3179
-				$item->$method( $array[ "item_$key" ] );
3180
-			}
3181
-		}
3175
+        // Set item data.
3176
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3177
+            if ( isset( $array[ "item_$key" ] ) ) {
3178
+                $method = "set_$key";
3179
+                $item->$method( $array[ "item_$key" ] );
3180
+            }
3181
+        }
3182 3182
 
3183
-		if ( isset( $array['quantity'] ) ) {
3184
-			$item->set_quantity( $array['quantity'] );
3185
-		}
3183
+        if ( isset( $array['quantity'] ) ) {
3184
+            $item->set_quantity( $array['quantity'] );
3185
+        }
3186 3186
 
3187
-		// Set item meta.
3188
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3189
-			$item->set_item_meta( $array['meta'] );
3190
-		}
3187
+        // Set item meta.
3188
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3189
+            $item->set_item_meta( $array['meta'] );
3190
+        }
3191 3191
 
3192
-		return $item;
3192
+        return $item;
3193 3193
 
3194
-	}
3194
+    }
3195 3195
 
3196 3196
     /**
3197
-	 * Retrieves a specific item.
3198
-	 *
3199
-	 * @since 1.0.19
3200
-	 */
3201
-	public function get_item( $item_id ) {
3202
-		$items   = $this->get_items();
3203
-		$item_id = (int) $item_id;
3204
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3197
+     * Retrieves a specific item.
3198
+     *
3199
+     * @since 1.0.19
3200
+     */
3201
+    public function get_item( $item_id ) {
3202
+        $items   = $this->get_items();
3203
+        $item_id = (int) $item_id;
3204
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3205 3205
     }
3206 3206
 
3207 3207
     /**
3208
-	 * Removes a specific item.
3209
-	 *
3210
-	 * @since 1.0.19
3211
-	 */
3212
-	public function remove_item( $item_id ) {
3213
-		$items   = $this->get_items();
3214
-		$item_id = (int) $item_id;
3208
+     * Removes a specific item.
3209
+     *
3210
+     * @since 1.0.19
3211
+     */
3212
+    public function remove_item( $item_id ) {
3213
+        $items   = $this->get_items();
3214
+        $item_id = (int) $item_id;
3215 3215
 
3216 3216
         if ( $item_id == $this->recurring_item ) {
3217 3217
             $this->recurring_item = null;
@@ -3224,35 +3224,35 @@  discard block
 block discarded – undo
3224 3224
     }
3225 3225
 
3226 3226
     /**
3227
-	 * Adds a fee to the invoice.
3228
-	 *
3229
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3230
-	 * @since 1.0.19
3231
-	 */
3227
+     * Adds a fee to the invoice.
3228
+     *
3229
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3230
+     * @since 1.0.19
3231
+     */
3232 3232
     public function add_fee( $fee ) {
3233 3233
 
3234
-		$fees                 = $this->get_fees();
3235
-		$fees[ $fee['name'] ] = $fee;
3236
-		$this->set_prop( 'fees', $fees );
3234
+        $fees                 = $this->get_fees();
3235
+        $fees[ $fee['name'] ] = $fee;
3236
+        $this->set_prop( 'fees', $fees );
3237 3237
 
3238 3238
     }
3239 3239
 
3240 3240
     /**
3241
-	 * Retrieves a specific fee.
3242
-	 *
3243
-	 * @since 1.0.19
3244
-	 */
3245
-	public function get_fee( $fee ) {
3241
+     * Retrieves a specific fee.
3242
+     *
3243
+     * @since 1.0.19
3244
+     */
3245
+    public function get_fee( $fee ) {
3246 3246
         $fees = $this->get_fees();
3247
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3247
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3248 3248
     }
3249 3249
 
3250 3250
     /**
3251
-	 * Removes a specific fee.
3252
-	 *
3253
-	 * @since 1.0.19
3254
-	 */
3255
-	public function remove_fee( $fee ) {
3251
+     * Removes a specific fee.
3252
+     *
3253
+     * @since 1.0.19
3254
+     */
3255
+    public function remove_fee( $fee ) {
3256 3256
         $fees = $this->get_fees();
3257 3257
         if ( isset( $fees[ $fee ] ) ) {
3258 3258
             unset( $fees[ $fee ] );
@@ -3260,43 +3260,43 @@  discard block
 block discarded – undo
3260 3260
         }
3261 3261
     }
3262 3262
 
3263
-	/**
3264
-	 * Adds a discount to the invoice.
3265
-	 *
3266
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3267
-	 * @since 1.0.19
3268
-	 */
3269
-	public function add_discount( $discount ) {
3263
+    /**
3264
+     * Adds a discount to the invoice.
3265
+     *
3266
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3267
+     * @since 1.0.19
3268
+     */
3269
+    public function add_discount( $discount ) {
3270 3270
 
3271
-		$discounts = $this->get_discounts();
3272
-		$discounts[ $discount['name'] ] = $discount;
3273
-		$this->set_prop( 'discounts', $discounts );
3271
+        $discounts = $this->get_discounts();
3272
+        $discounts[ $discount['name'] ] = $discount;
3273
+        $this->set_prop( 'discounts', $discounts );
3274 3274
 
3275
-	}
3275
+    }
3276 3276
 
3277 3277
     /**
3278
-	 * Retrieves a specific discount.
3279
-	 *
3280
-	 * @since 1.0.19
3281
-	 * @return float
3282
-	 */
3283
-	public function get_discount( $discount = false ) {
3278
+     * Retrieves a specific discount.
3279
+     *
3280
+     * @since 1.0.19
3281
+     * @return float
3282
+     */
3283
+    public function get_discount( $discount = false ) {
3284 3284
 
3285
-		// Backwards compatibilty.
3286
-		if ( empty( $discount ) ) {
3287
-			return $this->get_total_discount();
3288
-		}
3285
+        // Backwards compatibilty.
3286
+        if ( empty( $discount ) ) {
3287
+            return $this->get_total_discount();
3288
+        }
3289 3289
 
3290 3290
         $discounts = $this->get_discounts();
3291
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3291
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3292 3292
     }
3293 3293
 
3294 3294
     /**
3295
-	 * Removes a specific discount.
3296
-	 *
3297
-	 * @since 1.0.19
3298
-	 */
3299
-	public function remove_discount( $discount ) {
3295
+     * Removes a specific discount.
3296
+     *
3297
+     * @since 1.0.19
3298
+     */
3299
+    public function remove_discount( $discount ) {
3300 3300
         $discounts = $this->get_discounts();
3301 3301
         if ( isset( $discounts[ $discount ] ) ) {
3302 3302
             unset( $discounts[ $discount ] );
@@ -3313,34 +3313,34 @@  discard block
 block discarded – undo
3313 3313
         if ( $this->is_taxable() ) {
3314 3314
 
3315 3315
             $taxes                 = $this->get_taxes();
3316
-			$taxes[ $tax['name'] ] = $tax;
3317
-			$this->set_prop( 'taxes', $tax );
3316
+            $taxes[ $tax['name'] ] = $tax;
3317
+            $this->set_prop( 'taxes', $tax );
3318 3318
 
3319 3319
         }
3320 3320
     }
3321 3321
 
3322 3322
     /**
3323
-	 * Retrieves a specific tax.
3324
-	 *
3325
-	 * @since 1.0.19
3326
-	 */
3327
-	public function get_tax( $tax = null ) {
3323
+     * Retrieves a specific tax.
3324
+     *
3325
+     * @since 1.0.19
3326
+     */
3327
+    public function get_tax( $tax = null ) {
3328 3328
 
3329
-		// Backwards compatility.
3330
-		if ( empty( $tax ) ) {
3331
-			return $this->get_total_tax();
3332
-		}
3329
+        // Backwards compatility.
3330
+        if ( empty( $tax ) ) {
3331
+            return $this->get_total_tax();
3332
+        }
3333 3333
 
3334 3334
         $taxes = $this->get_taxes();
3335
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3335
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3336 3336
     }
3337 3337
 
3338 3338
     /**
3339
-	 * Removes a specific tax.
3340
-	 *
3341
-	 * @since 1.0.19
3342
-	 */
3343
-	public function remove_tax( $tax ) {
3339
+     * Removes a specific tax.
3340
+     *
3341
+     * @since 1.0.19
3342
+     */
3343
+    public function remove_tax( $tax ) {
3344 3344
         $taxes = $this->get_taxes();
3345 3345
         if ( isset( $taxes[ $tax ] ) ) {
3346 3346
             unset( $taxes[ $tax ] );
@@ -3349,134 +3349,134 @@  discard block
 block discarded – undo
3349 3349
     }
3350 3350
 
3351 3351
     /**
3352
-	 * Recalculates the invoice subtotal.
3353
-	 *
3354
-	 * @since 1.0.19
3355
-	 * @return float The recalculated subtotal
3356
-	 */
3357
-	public function recalculate_subtotal() {
3352
+     * Recalculates the invoice subtotal.
3353
+     *
3354
+     * @since 1.0.19
3355
+     * @return float The recalculated subtotal
3356
+     */
3357
+    public function recalculate_subtotal() {
3358 3358
         $items     = $this->get_items();
3359
-		$subtotal  = 0;
3360
-		$recurring = 0;
3359
+        $subtotal  = 0;
3360
+        $recurring = 0;
3361 3361
 
3362 3362
         foreach ( $items as $item ) {
3363
-			$subtotal  += $item->get_sub_total();
3364
-			$recurring += $item->get_recurring_sub_total();
3363
+            $subtotal  += $item->get_sub_total();
3364
+            $recurring += $item->get_recurring_sub_total();
3365 3365
         }
3366 3366
 
3367
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3368
-		$this->set_subtotal( $current );
3367
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3368
+        $this->set_subtotal( $current );
3369 3369
 
3370
-		$this->totals['subtotal'] = array(
3371
-			'initial'   => $subtotal,
3372
-			'recurring' => $recurring,
3373
-		);
3370
+        $this->totals['subtotal'] = array(
3371
+            'initial'   => $subtotal,
3372
+            'recurring' => $recurring,
3373
+        );
3374 3374
 
3375 3375
         return $current;
3376 3376
     }
3377 3377
 
3378 3378
     /**
3379
-	 * Recalculates the invoice discount total.
3380
-	 *
3381
-	 * @since 1.0.19
3382
-	 * @return float The recalculated discount
3383
-	 */
3384
-	public function recalculate_total_discount() {
3379
+     * Recalculates the invoice discount total.
3380
+     *
3381
+     * @since 1.0.19
3382
+     * @return float The recalculated discount
3383
+     */
3384
+    public function recalculate_total_discount() {
3385 3385
         $discounts = $this->get_discounts();
3386
-		$discount  = 0;
3387
-		$recurring = 0;
3386
+        $discount  = 0;
3387
+        $recurring = 0;
3388 3388
 
3389 3389
         foreach ( $discounts as $data ) {
3390
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3391
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3392
-		}
3390
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3391
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3392
+        }
3393 3393
 
3394
-		$current = $this->is_renewal() ? $recurring : $discount;
3394
+        $current = $this->is_renewal() ? $recurring : $discount;
3395 3395
 
3396
-		$this->set_total_discount( $current );
3396
+        $this->set_total_discount( $current );
3397 3397
 
3398
-		$this->totals['discount'] = array(
3399
-			'initial'   => $discount,
3400
-			'recurring' => $recurring,
3401
-		);
3398
+        $this->totals['discount'] = array(
3399
+            'initial'   => $discount,
3400
+            'recurring' => $recurring,
3401
+        );
3402 3402
 
3403
-		return $current;
3403
+        return $current;
3404 3404
 
3405 3405
     }
3406 3406
 
3407 3407
     /**
3408
-	 * Recalculates the invoice tax total.
3409
-	 *
3410
-	 * @since 1.0.19
3411
-	 * @return float The recalculated tax
3412
-	 */
3413
-	public function recalculate_total_tax() {
3408
+     * Recalculates the invoice tax total.
3409
+     *
3410
+     * @since 1.0.19
3411
+     * @return float The recalculated tax
3412
+     */
3413
+    public function recalculate_total_tax() {
3414 3414
         $taxes     = $this->get_taxes();
3415
-		$tax       = 0;
3416
-		$recurring = 0;
3415
+        $tax       = 0;
3416
+        $recurring = 0;
3417 3417
 
3418 3418
         foreach ( $taxes as $data ) {
3419
-			$tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3420
-			$recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3421
-		}
3419
+            $tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3420
+            $recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3421
+        }
3422 3422
 
3423
-		$current = $this->is_renewal() ? $recurring : $tax;
3424
-		$this->set_total_tax( $current );
3423
+        $current = $this->is_renewal() ? $recurring : $tax;
3424
+        $this->set_total_tax( $current );
3425 3425
 
3426
-		$this->totals['tax'] = array(
3427
-			'initial'   => $tax,
3428
-			'recurring' => $recurring,
3429
-		);
3426
+        $this->totals['tax'] = array(
3427
+            'initial'   => $tax,
3428
+            'recurring' => $recurring,
3429
+        );
3430 3430
 
3431
-		return $current;
3431
+        return $current;
3432 3432
 
3433 3433
     }
3434 3434
 
3435 3435
     /**
3436
-	 * Recalculates the invoice fees total.
3437
-	 *
3438
-	 * @since 1.0.19
3439
-	 * @return float The recalculated fee
3440
-	 */
3441
-	public function recalculate_total_fees() {
3442
-		$fees      = $this->get_fees();
3443
-		$fee       = 0;
3444
-		$recurring = 0;
3436
+     * Recalculates the invoice fees total.
3437
+     *
3438
+     * @since 1.0.19
3439
+     * @return float The recalculated fee
3440
+     */
3441
+    public function recalculate_total_fees() {
3442
+        $fees      = $this->get_fees();
3443
+        $fee       = 0;
3444
+        $recurring = 0;
3445 3445
 
3446 3446
         foreach ( $fees as $data ) {
3447
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3448
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3449
-		}
3447
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3448
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3449
+        }
3450 3450
 
3451
-		$current = $this->is_renewal() ? $recurring : $fee;
3452
-		$this->set_total_fees( $current );
3451
+        $current = $this->is_renewal() ? $recurring : $fee;
3452
+        $this->set_total_fees( $current );
3453 3453
 
3454
-		$this->totals['fee'] = array(
3455
-			'initial'   => $fee,
3456
-			'recurring' => $recurring,
3457
-		);
3454
+        $this->totals['fee'] = array(
3455
+            'initial'   => $fee,
3456
+            'recurring' => $recurring,
3457
+        );
3458 3458
 
3459 3459
         $this->set_total_fees( $fee );
3460 3460
         return $current;
3461 3461
     }
3462 3462
 
3463 3463
     /**
3464
-	 * Recalculates the invoice total.
3465
-	 *
3466
-	 * @since 1.0.19
3464
+     * Recalculates the invoice total.
3465
+     *
3466
+     * @since 1.0.19
3467 3467
      * @return float The invoice total
3468
-	 */
3469
-	public function recalculate_total() {
3468
+     */
3469
+    public function recalculate_total() {
3470 3470
         $this->recalculate_subtotal();
3471 3471
         $this->recalculate_total_fees();
3472 3472
         $this->recalculate_total_discount();
3473 3473
         $this->recalculate_total_tax();
3474
-		return $this->get_total();
3475
-	}
3474
+        return $this->get_total();
3475
+    }
3476 3476
 
3477
-	/**
3478
-	 * @deprecated
3479
-	 */
3477
+    /**
3478
+     * @deprecated
3479
+     */
3480 3480
     public function recalculate_totals( $temp = false ) {
3481 3481
         $this->update_items( $temp );
3482 3482
         $this->save( true );
@@ -3494,7 +3494,7 @@  discard block
 block discarded – undo
3494 3494
      * Adds a note to an invoice.
3495 3495
      *
3496 3496
      * @param string $note The note being added.
3497
-	 * @return int|false The new note's ID on success, false on failure.
3497
+     * @return int|false The new note's ID on success, false on failure.
3498 3498
      *
3499 3499
      */
3500 3500
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3504,21 +3504,21 @@  discard block
 block discarded – undo
3504 3504
             return false;
3505 3505
         }
3506 3506
 
3507
-		$author       = 'System';
3508
-		$author_email = '[email protected]';
3507
+        $author       = 'System';
3508
+        $author_email = '[email protected]';
3509 3509
 
3510
-		// If this is an admin comment or it has been added by the user.
3511
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3512
-			$user         = get_user_by( 'id', get_current_user_id() );
3510
+        // If this is an admin comment or it has been added by the user.
3511
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3512
+            $user         = get_user_by( 'id', get_current_user_id() );
3513 3513
             $author       = $user->display_name;
3514 3514
             $author_email = $user->user_email;
3515
-		}
3515
+        }
3516 3516
 
3517
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3517
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3518 3518
 
3519
-	}
3519
+    }
3520 3520
 
3521
-	/**
3521
+    /**
3522 3522
      * Generates a unique key for the invoice.
3523 3523
      */
3524 3524
     public function generate_key( $string = '' ) {
@@ -3538,113 +3538,113 @@  discard block
 block discarded – undo
3538 3538
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3539 3539
         }
3540 3540
 
3541
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3542
-
3543
-	}
3544
-
3545
-	/**
3546
-	 * Handle the status transition.
3547
-	 */
3548
-	protected function status_transition() {
3549
-		$status_transition = $this->status_transition;
3550
-
3551
-		// Reset status transition variable.
3552
-		$this->status_transition = false;
3553
-
3554
-		if ( $status_transition ) {
3555
-			try {
3541
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3556 3542
 
3557
-				// Fire a hook for the status change.
3558
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3559
-
3560
-				// @deprecated this is deprecated and will be removed in the future.
3561
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3562
-
3563
-				if ( ! empty( $status_transition['from'] ) ) {
3564
-
3565
-					/* translators: 1: old invoice status 2: new invoice status */
3566
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3567
-
3568
-					// Fire another hook.
3569
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3570
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3571
-
3572
-					// @deprecated this is deprecated and will be removed in the future.
3573
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3574
-
3575
-					// Note the transition occurred.
3576
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3577
-
3578
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3579
-					if (
3580
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3581
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3582
-					) {
3583
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3584
-					}
3585
-
3586
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3587
-					if (
3588
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3589
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3590
-					) {
3591
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3592
-					}
3593
-				} else {
3594
-					/* translators: %s: new invoice status */
3595
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3596
-
3597
-					// Note the transition occurred.
3598
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3543
+    }
3599 3544
 
3600
-				}
3601
-			} catch ( Exception $e ) {
3602
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3603
-			}
3604
-		}
3605
-	}
3545
+    /**
3546
+     * Handle the status transition.
3547
+     */
3548
+    protected function status_transition() {
3549
+        $status_transition = $this->status_transition;
3550
+
3551
+        // Reset status transition variable.
3552
+        $this->status_transition = false;
3553
+
3554
+        if ( $status_transition ) {
3555
+            try {
3556
+
3557
+                // Fire a hook for the status change.
3558
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3559
+
3560
+                // @deprecated this is deprecated and will be removed in the future.
3561
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3562
+
3563
+                if ( ! empty( $status_transition['from'] ) ) {
3564
+
3565
+                    /* translators: 1: old invoice status 2: new invoice status */
3566
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3567
+
3568
+                    // Fire another hook.
3569
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3570
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3571
+
3572
+                    // @deprecated this is deprecated and will be removed in the future.
3573
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3574
+
3575
+                    // Note the transition occurred.
3576
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3577
+
3578
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3579
+                    if (
3580
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3581
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3582
+                    ) {
3583
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3584
+                    }
3585
+
3586
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3587
+                    if (
3588
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3589
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3590
+                    ) {
3591
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3592
+                    }
3593
+                } else {
3594
+                    /* translators: %s: new invoice status */
3595
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3596
+
3597
+                    // Note the transition occurred.
3598
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3599
+
3600
+                }
3601
+            } catch ( Exception $e ) {
3602
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3603
+            }
3604
+        }
3605
+    }
3606 3606
 
3607
-	/**
3608
-	 * Updates an invoice status.
3609
-	 */
3610
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3607
+    /**
3608
+     * Updates an invoice status.
3609
+     */
3610
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3611 3611
 
3612
-		// Fires before updating a status.
3613
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3612
+        // Fires before updating a status.
3613
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3614 3614
 
3615
-		// Update the status.
3616
-		$this->set_status( $new_status, $note, $manual );
3615
+        // Update the status.
3616
+        $this->set_status( $new_status, $note, $manual );
3617 3617
 
3618
-		// Save the order.
3619
-		return $this->save();
3618
+        // Save the order.
3619
+        return $this->save();
3620 3620
 
3621
-	}
3621
+    }
3622 3622
 
3623
-	/**
3624
-	 * @deprecated
3625
-	 */
3626
-	public function refresh_item_ids() {
3623
+    /**
3624
+     * @deprecated
3625
+     */
3626
+    public function refresh_item_ids() {
3627 3627
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3628 3628
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3629
-	}
3629
+    }
3630 3630
 
3631
-	/**
3632
-	 * @deprecated
3633
-	 */
3634
-	public function update_items( $temp = false ) {
3631
+    /**
3632
+     * @deprecated
3633
+     */
3634
+    public function update_items( $temp = false ) {
3635 3635
 
3636
-		$this->set_items( $this->get_items() );
3636
+        $this->set_items( $this->get_items() );
3637 3637
 
3638
-		if ( ! $temp ) {
3639
-			$this->save();
3640
-		}
3638
+        if ( ! $temp ) {
3639
+            $this->save();
3640
+        }
3641 3641
 
3642 3642
         return $this;
3643
-	}
3643
+    }
3644 3644
 
3645
-	/**
3646
-	 * @deprecated
3647
-	 */
3645
+    /**
3646
+     * @deprecated
3647
+     */
3648 3648
     public function validate_discount() {
3649 3649
 
3650 3650
         $discount_code = $this->get_discount_code();
@@ -3660,97 +3660,97 @@  discard block
 block discarded – undo
3660 3660
 
3661 3661
     }
3662 3662
 
3663
-	/**
3664
-	 * Refunds an invoice.
3665
-	 */
3663
+    /**
3664
+     * Refunds an invoice.
3665
+     */
3666 3666
     public function refund() {
3667
-		$this->set_status( 'wpi-refunded' );
3667
+        $this->set_status( 'wpi-refunded' );
3668 3668
         $this->save();
3669
-	}
3669
+    }
3670 3670
 
3671
-	/**
3672
-	 * Marks an invoice as paid.
3673
-	 * 
3674
-	 * @param string $transaction_id
3675
-	 */
3671
+    /**
3672
+     * Marks an invoice as paid.
3673
+     * 
3674
+     * @param string $transaction_id
3675
+     */
3676 3676
     public function mark_paid( $transaction_id = null, $note = '' ) {
3677 3677
 
3678
-		// Set the transaction id.
3679
-		if ( empty( $transaction_id ) ) {
3680
-			$transaction_id = $this->generate_key('trans_');
3681
-		}
3678
+        // Set the transaction id.
3679
+        if ( empty( $transaction_id ) ) {
3680
+            $transaction_id = $this->generate_key('trans_');
3681
+        }
3682 3682
 
3683
-		if ( ! $this->get_transaction_id() ) {
3684
-			$this->set_transaction_id( $transaction_id );
3685
-		}
3683
+        if ( ! $this->get_transaction_id() ) {
3684
+            $this->set_transaction_id( $transaction_id );
3685
+        }
3686 3686
 
3687
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3688
-			return $this->save();
3689
-		}
3687
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3688
+            return $this->save();
3689
+        }
3690 3690
 
3691
-		// Set the completed date.
3692
-		$this->set_date_completed( current_time( 'mysql' ) );
3691
+        // Set the completed date.
3692
+        $this->set_date_completed( current_time( 'mysql' ) );
3693 3693
 
3694
-		// Set the new status.
3695
-		if ( $this->is_renewal() ) {
3694
+        // Set the new status.
3695
+        if ( $this->is_renewal() ) {
3696 3696
 
3697
-			$_note = sprintf(
3698
-				__( 'Renewed via %s', 'invoicing' ),
3699
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3700
-			);
3697
+            $_note = sprintf(
3698
+                __( 'Renewed via %s', 'invoicing' ),
3699
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3700
+            );
3701 3701
 
3702
-			if ( 'none' == $this->get_gateway() ) {
3703
-				$_note = $note;
3704
-			}
3702
+            if ( 'none' == $this->get_gateway() ) {
3703
+                $_note = $note;
3704
+            }
3705 3705
 
3706
-			$this->set_status( 'wpi-renewal', $_note );
3706
+            $this->set_status( 'wpi-renewal', $_note );
3707 3707
 
3708
-		} else {
3708
+        } else {
3709 3709
 
3710
-			$_note = sprintf(
3711
-				__( 'Paid via %s', 'invoicing' ),
3712
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3713
-			);
3710
+            $_note = sprintf(
3711
+                __( 'Paid via %s', 'invoicing' ),
3712
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3713
+            );
3714 3714
 
3715
-			if ( 'none' == $this->get_gateway() ) {
3716
-				$_note = $note;
3717
-			}
3715
+            if ( 'none' == $this->get_gateway() ) {
3716
+                $_note = $note;
3717
+            }
3718 3718
 
3719
-			$this->set_status( 'publish',$_note );
3719
+            $this->set_status( 'publish',$_note );
3720 3720
 
3721
-		}
3721
+        }
3722 3722
 
3723
-		// Set checkout mode.
3724
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3725
-		$this->set_mode( $mode );
3723
+        // Set checkout mode.
3724
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3725
+        $this->set_mode( $mode );
3726 3726
 
3727
-		// Save the invoice.
3727
+        // Save the invoice.
3728 3728
         $this->save();
3729
-	}
3730
-
3731
-
3732
-	/**
3733
-	 * Save data to the database.
3734
-	 *
3735
-	 * @since 1.0.19
3736
-	 * @return int invoice ID
3737
-	 */
3738
-	public function save() {
3739
-		$this->maybe_set_date_paid();
3740
-		$this->maybe_set_key();
3741
-		parent::save();
3742
-		$this->clear_cache();
3743
-		$this->status_transition();
3744
-		return $this->get_id();
3745
-	}
3746
-
3747
-	/**
3729
+    }
3730
+
3731
+
3732
+    /**
3733
+     * Save data to the database.
3734
+     *
3735
+     * @since 1.0.19
3736
+     * @return int invoice ID
3737
+     */
3738
+    public function save() {
3739
+        $this->maybe_set_date_paid();
3740
+        $this->maybe_set_key();
3741
+        parent::save();
3742
+        $this->clear_cache();
3743
+        $this->status_transition();
3744
+        return $this->get_id();
3745
+    }
3746
+
3747
+    /**
3748 3748
      * Clears the subscription's cache.
3749 3749
      */
3750 3750
     public function clear_cache() {
3751
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3752
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3753
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3754
-	}
3751
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3752
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3753
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3754
+    }
3755 3755
 
3756 3756
 }
Please login to merge, or discard this patch.
Spacing   +740 added lines, -740 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.
@@ -135,40 +135,40 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137 137
 	 */
138
-    public function __construct( $invoice = 0 ) {
138
+    public function __construct($invoice = 0) {
139 139
 
140
-        parent::__construct( $invoice );
140
+        parent::__construct($invoice);
141 141
 
142
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
143
-			$this->set_id( (int) $invoice );
144
-		} elseif ( $invoice instanceof self ) {
145
-			$this->set_id( $invoice->get_id() );
146
-		} elseif ( ! empty( $invoice->ID ) ) {
147
-			$this->set_id( $invoice->ID );
148
-		} elseif ( is_array( $invoice ) ) {
149
-			$this->set_props( $invoice );
142
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
143
+			$this->set_id((int) $invoice);
144
+		} elseif ($invoice instanceof self) {
145
+			$this->set_id($invoice->get_id());
146
+		} elseif (!empty($invoice->ID)) {
147
+			$this->set_id($invoice->ID);
148
+		} elseif (is_array($invoice)) {
149
+			$this->set_props($invoice);
150 150
 
151
-			if ( isset( $invoice['ID'] ) ) {
152
-				$this->set_id( $invoice['ID'] );
151
+			if (isset($invoice['ID'])) {
152
+				$this->set_id($invoice['ID']);
153 153
 			}
154 154
 
155
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
-			$this->set_id( $invoice_id );
161
-		}else {
162
-			$this->set_object_read( true );
155
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
156
+			$this->set_id($invoice_id);
157
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
158
+			$this->set_id($invoice_id);
159
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
160
+			$this->set_id($invoice_id);
161
+		} else {
162
+			$this->set_object_read(true);
163 163
 		}
164 164
 
165 165
         // Load the datastore.
166
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
167 167
 
168
-		if ( $this->get_id() > 0 ) {
169
-            $this->post = get_post( $this->get_id() );
168
+		if ($this->get_id() > 0) {
169
+            $this->post = get_post($this->get_id());
170 170
             $this->ID   = $this->get_id();
171
-			$this->data_store->read( $this );
171
+			$this->data_store->read($this);
172 172
         }
173 173
 
174 174
     }
@@ -183,38 +183,38 @@  discard block
 block discarded – undo
183 183
 	 * @since 1.0.15
184 184
 	 * @return int
185 185
 	 */
186
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186
+	public static function get_invoice_id_by_field($value, $field = 'key') {
187 187
         global $wpdb;
188 188
 
189 189
 		// Trim the value.
190
-		$value = trim( $value );
190
+		$value = trim($value);
191 191
 
192
-		if ( empty( $value ) ) {
192
+		if (empty($value)) {
193 193
 			return 0;
194 194
 		}
195 195
 
196 196
         // Valid fields.
197
-        $fields = array( 'key', 'number', 'transaction_id' );
197
+        $fields = array('key', 'number', 'transaction_id');
198 198
 
199 199
 		// Ensure a field has been passed.
200
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
+		if (empty($field) || !in_array($field, $fields)) {
201 201
 			return 0;
202 202
 		}
203 203
 
204 204
 		// Maybe retrieve from the cache.
205
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
-		if ( false !== $invoice_id ) {
205
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
206
+		if (false !== $invoice_id) {
207 207
 			return $invoice_id;
208 208
 		}
209 209
 
210 210
         // Fetch from the db.
211 211
         $table       = $wpdb->prefix . 'getpaid_invoices';
212 212
         $invoice_id  = (int) $wpdb->get_var(
213
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
213
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
214 214
         );
215 215
 
216 216
 		// Update the cache with our data
217
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
217
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
218 218
 
219 219
 		return $invoice_id;
220 220
     }
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
     /**
223 223
      * Checks if an invoice key is set.
224 224
      */
225
-    public function _isset( $key ) {
226
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
225
+    public function _isset($key) {
226
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
227 227
     }
228 228
 
229 229
     /*
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return int
250 250
 	 */
251
-	public function get_parent_id( $context = 'view' ) {
252
-		return (int) $this->get_prop( 'parent_id', $context );
251
+	public function get_parent_id($context = 'view') {
252
+		return (int) $this->get_prop('parent_id', $context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * @return WPInv_Invoice
260 260
 	 */
261 261
     public function get_parent_payment() {
262
-        return new WPInv_Invoice( $this->get_parent_id() );
262
+        return new WPInv_Invoice($this->get_parent_id());
263 263
     }
264 264
 
265 265
     /**
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param  string $context View or edit context.
280 280
 	 * @return string
281 281
 	 */
282
-	public function get_status( $context = 'view' ) {
283
-		return $this->get_prop( 'status', $context );
282
+	public function get_status($context = 'view') {
283
+		return $this->get_prop('status', $context);
284 284
 	}
285 285
 	
286 286
 	/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @return array
291 291
 	 */
292 292
 	public function get_all_statuses() {
293
-		return wpinv_get_invoice_statuses( true, true, $this );
293
+		return wpinv_get_invoice_statuses(true, true, $this);
294 294
     }
295 295
 
296 296
     /**
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
     public function get_status_nicename() {
303 303
 		$statuses = $this->get_all_statuses();
304 304
 
305
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
305
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
306 306
 
307
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
307
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
308 308
     }
309 309
 
310 310
 	/**
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function get_status_label_html() {
317 317
 
318
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
319
-		$status       = sanitize_html_class( $this->get_status() );
318
+		$status_label = sanitize_text_field($this->get_status_nicename());
319
+		$status       = sanitize_html_class($this->get_status());
320 320
 
321 321
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
322 322
 	}
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
 	 * @param  string $context View or edit context.
329 329
 	 * @return string
330 330
 	 */
331
-	public function get_version( $context = 'view' ) {
332
-		return $this->get_prop( 'version', $context );
331
+	public function get_version($context = 'view') {
332
+		return $this->get_prop('version', $context);
333 333
 	}
334 334
 
335 335
 	/**
336 336
 	 * @deprecated
337 337
 	 */
338
-	public function get_invoice_date( $format = true ) {
339
-		$date      = getpaid_format_date( $this->get_date_completed() );
340
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
341
-		$formatted = getpaid_format_date( $date );
338
+	public function get_invoice_date($format = true) {
339
+		$date      = getpaid_format_date($this->get_date_completed());
340
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
341
+		$formatted = getpaid_format_date($date);
342 342
 
343
-		if ( $format ) {
343
+		if ($format) {
344 344
 			return $formatted;
345 345
 		}
346 346
 
347
-		return empty( $formatted ) ? '' : $date;
347
+		return empty($formatted) ? '' : $date;
348 348
 
349 349
     }
350 350
 
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	 * @param  string $context View or edit context.
356 356
 	 * @return string
357 357
 	 */
358
-	public function get_date_created( $context = 'view' ) {
359
-		return $this->get_prop( 'date_created', $context );
358
+	public function get_date_created($context = 'view') {
359
+		return $this->get_prop('date_created', $context);
360 360
 	}
361 361
 	
362 362
 	/**
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 * @param  string $context View or edit context.
367 367
 	 * @return string
368 368
 	 */
369
-	public function get_created_date( $context = 'view' ) {
370
-		return $this->get_date_created( $context );
369
+	public function get_created_date($context = 'view') {
370
+		return $this->get_date_created($context);
371 371
     }
372 372
 
373 373
     /**
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
 	 * @param  string $context View or edit context.
378 378
 	 * @return string
379 379
 	 */
380
-	public function get_date_created_gmt( $context = 'view' ) {
381
-        $date = $this->get_date_created( $context );
380
+	public function get_date_created_gmt($context = 'view') {
381
+        $date = $this->get_date_created($context);
382 382
 
383
-        if ( $date ) {
384
-            $date = get_gmt_from_date( $date );
383
+        if ($date) {
384
+            $date = get_gmt_from_date($date);
385 385
         }
386 386
 		return $date;
387 387
     }
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @param  string $context View or edit context.
394 394
 	 * @return string
395 395
 	 */
396
-	public function get_date_modified( $context = 'view' ) {
397
-		return $this->get_prop( 'date_modified', $context );
396
+	public function get_date_modified($context = 'view') {
397
+		return $this->get_prop('date_modified', $context);
398 398
 	}
399 399
 
400 400
 	/**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context View or edit context.
405 405
 	 * @return string
406 406
 	 */
407
-	public function get_modified_date( $context = 'view' ) {
408
-		return $this->get_date_modified( $context );
407
+	public function get_modified_date($context = 'view') {
408
+		return $this->get_date_modified($context);
409 409
     }
410 410
 
411 411
     /**
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $context View or edit context.
416 416
 	 * @return string
417 417
 	 */
418
-	public function get_date_modified_gmt( $context = 'view' ) {
419
-        $date = $this->get_date_modified( $context );
418
+	public function get_date_modified_gmt($context = 'view') {
419
+        $date = $this->get_date_modified($context);
420 420
 
421
-        if ( $date ) {
422
-            $date = get_gmt_from_date( $date );
421
+        if ($date) {
422
+            $date = get_gmt_from_date($date);
423 423
         }
424 424
 		return $date;
425 425
     }
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return string
433 433
 	 */
434
-	public function get_due_date( $context = 'view' ) {
435
-		return $this->get_prop( 'due_date', $context );
434
+	public function get_due_date($context = 'view') {
435
+		return $this->get_prop('due_date', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return string
444 444
 	 */
445
-	public function get_date_due( $context = 'view' ) {
446
-		return $this->get_due_date( $context );
445
+	public function get_date_due($context = 'view') {
446
+		return $this->get_due_date($context);
447 447
     }
448 448
 
449 449
     /**
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return string
455 455
 	 */
456
-	public function get_due_date_gmt( $context = 'view' ) {
457
-        $date = $this->get_due_date( $context );
456
+	public function get_due_date_gmt($context = 'view') {
457
+        $date = $this->get_due_date($context);
458 458
 
459
-        if ( $date ) {
460
-            $date = get_gmt_from_date( $date );
459
+        if ($date) {
460
+            $date = get_gmt_from_date($date);
461 461
         }
462 462
 		return $date;
463 463
     }
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 	 * @param  string $context View or edit context.
470 470
 	 * @return string
471 471
 	 */
472
-	public function get_gmt_date_due( $context = 'view' ) {
473
-		return $this->get_due_date_gmt( $context );
472
+	public function get_gmt_date_due($context = 'view') {
473
+		return $this->get_due_date_gmt($context);
474 474
     }
475 475
 
476 476
     /**
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 * @param  string $context View or edit context.
481 481
 	 * @return string
482 482
 	 */
483
-	public function get_completed_date( $context = 'view' ) {
484
-		return $this->get_prop( 'completed_date', $context );
483
+	public function get_completed_date($context = 'view') {
484
+		return $this->get_prop('completed_date', $context);
485 485
     }
486 486
 
487 487
     /**
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 	 * @param  string $context View or edit context.
492 492
 	 * @return string
493 493
 	 */
494
-	public function get_date_completed( $context = 'view' ) {
495
-		return $this->get_completed_date( $context );
494
+	public function get_date_completed($context = 'view') {
495
+		return $this->get_completed_date($context);
496 496
     }
497 497
 
498 498
     /**
@@ -502,11 +502,11 @@  discard block
 block discarded – undo
502 502
 	 * @param  string $context View or edit context.
503 503
 	 * @return string
504 504
 	 */
505
-	public function get_completed_date_gmt( $context = 'view' ) {
506
-        $date = $this->get_completed_date( $context );
505
+	public function get_completed_date_gmt($context = 'view') {
506
+        $date = $this->get_completed_date($context);
507 507
 
508
-        if ( $date ) {
509
-            $date = get_gmt_from_date( $date );
508
+        if ($date) {
509
+            $date = get_gmt_from_date($date);
510 510
         }
511 511
 		return $date;
512 512
     }
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
 	 * @param  string $context View or edit context.
519 519
 	 * @return string
520 520
 	 */
521
-	public function get_gmt_completed_date( $context = 'view' ) {
522
-		return $this->get_completed_date_gmt( $context );
521
+	public function get_gmt_completed_date($context = 'view') {
522
+		return $this->get_completed_date_gmt($context);
523 523
     }
524 524
 
525 525
     /**
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
 	 * @param  string $context View or edit context.
530 530
 	 * @return string
531 531
 	 */
532
-	public function get_number( $context = 'view' ) {
533
-		$number = $this->get_prop( 'number', $context );
532
+	public function get_number($context = 'view') {
533
+		$number = $this->get_prop('number', $context);
534 534
 
535
-		if ( empty( $number ) ) {
535
+		if (empty($number)) {
536 536
 			$number = $this->generate_number();
537
-			$this->set_number( $this->generate_number() );
537
+			$this->set_number($this->generate_number());
538 538
 		}
539 539
 
540 540
 		return $number;
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 	public function maybe_set_number() {
549 549
         $number = $this->get_number();
550 550
 
551
-        if ( empty( $number ) || $this->get_id() == $number ) {
552
-			$this->set_number( $this->generate_number() );
551
+        if (empty($number) || $this->get_id() == $number) {
552
+			$this->set_number($this->generate_number());
553 553
         }
554 554
 
555 555
 	}
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return string
563 563
 	 */
564
-	public function get_key( $context = 'view' ) {
565
-        return $this->get_prop( 'key', $context );
564
+	public function get_key($context = 'view') {
565
+        return $this->get_prop('key', $context);
566 566
 	}
567 567
 
568 568
 	/**
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
 	public function maybe_set_key() {
574 574
         $key = $this->get_key();
575 575
 
576
-        if ( empty( $key ) ) {
577
-            $key = $this->generate_key( $this->get_type() . '_' );
578
-            $this->set_key( $key );
576
+        if (empty($key)) {
577
+            $key = $this->generate_key($this->get_type() . '_');
578
+            $this->set_key($key);
579 579
         }
580 580
 
581 581
     }
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
 	 * @param  string $context View or edit context.
588 588
 	 * @return string
589 589
 	 */
590
-	public function get_type( $context = 'view' ) {
591
-        return $this->get_prop( 'type', $context );
590
+	public function get_type($context = 'view') {
591
+        return $this->get_prop('type', $context);
592 592
 	}
593 593
 
594 594
 	/**
595 595
 	 * @deprecated
596 596
 	 */
597 597
 	public function get_invoice_quote_type() {
598
-        ucfirst( $this->get_type() );
598
+        ucfirst($this->get_type());
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_post_type( $context = 'view' ) {
609
-        return $this->get_prop( 'post_type', $context );
608
+	public function get_post_type($context = 'view') {
609
+        return $this->get_prop('post_type', $context);
610 610
     }
611 611
 
612 612
     /**
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
 	 * @param  string $context View or edit context.
617 617
 	 * @return string
618 618
 	 */
619
-	public function get_mode( $context = 'view' ) {
620
-        return $this->get_prop( 'mode', $context );
619
+	public function get_mode($context = 'view') {
620
+        return $this->get_prop('mode', $context);
621 621
     }
622 622
 
623 623
     /**
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
 	 * @param  string $context View or edit context.
628 628
 	 * @return string
629 629
 	 */
630
-	public function get_path( $context = 'view' ) {
631
-        $path   = $this->get_prop( 'path', $context );
630
+	public function get_path($context = 'view') {
631
+        $path = $this->get_prop('path', $context);
632 632
 		$prefix = $this->get_type();
633 633
 
634
-		if ( 0 !== strpos( $path, $prefix ) ) {
635
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
636
-			$this->set_path( $path );
634
+		if (0 !== strpos($path, $prefix)) {
635
+			$path = sanitize_title($prefix . '-' . $this->get_id());
636
+			$this->set_path($path);
637 637
 		}
638 638
 
639 639
 		return $path;
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 	 * @param  string $context View or edit context.
647 647
 	 * @return string
648 648
 	 */
649
-	public function get_name( $context = 'view' ) {
650
-        return $this->get_prop( 'title', $context );
649
+	public function get_name($context = 'view') {
650
+        return $this->get_prop('title', $context);
651 651
     }
652 652
 
653 653
     /**
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
 	 * @param  string $context View or edit context.
658 658
 	 * @return string
659 659
 	 */
660
-	public function get_title( $context = 'view' ) {
661
-		return $this->get_name( $context );
660
+	public function get_title($context = 'view') {
661
+		return $this->get_name($context);
662 662
     }
663 663
 
664 664
     /**
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 	 * @param  string $context View or edit context.
669 669
 	 * @return string
670 670
 	 */
671
-	public function get_description( $context = 'view' ) {
672
-		return $this->get_prop( 'description', $context );
671
+	public function get_description($context = 'view') {
672
+		return $this->get_prop('description', $context);
673 673
     }
674 674
 
675 675
     /**
@@ -679,8 +679,8 @@  discard block
 block discarded – undo
679 679
 	 * @param  string $context View or edit context.
680 680
 	 * @return string
681 681
 	 */
682
-	public function get_excerpt( $context = 'view' ) {
683
-		return $this->get_description( $context );
682
+	public function get_excerpt($context = 'view') {
683
+		return $this->get_description($context);
684 684
     }
685 685
 
686 686
     /**
@@ -690,8 +690,8 @@  discard block
 block discarded – undo
690 690
 	 * @param  string $context View or edit context.
691 691
 	 * @return string
692 692
 	 */
693
-	public function get_summary( $context = 'view' ) {
694
-		return $this->get_description( $context );
693
+	public function get_summary($context = 'view') {
694
+		return $this->get_description($context);
695 695
     }
696 696
 
697 697
     /**
@@ -701,25 +701,25 @@  discard block
 block discarded – undo
701 701
      * @param  string $context View or edit context.
702 702
 	 * @return array
703 703
 	 */
704
-    public function get_user_info( $context = 'view' ) {
704
+    public function get_user_info($context = 'view') {
705 705
 
706 706
         $user_info = array(
707
-            'user_id'    => $this->get_user_id( $context ),
708
-            'email'      => $this->get_email( $context ),
709
-            'first_name' => $this->get_first_name( $context ),
710
-            'last_name'  => $this->get_last_name( $context ),
711
-            'address'    => $this->get_address( $context ),
712
-            'phone'      => $this->get_phone( $context ),
713
-            'city'       => $this->get_city( $context ),
714
-            'country'    => $this->get_country( $context ),
715
-            'state'      => $this->get_state( $context ),
716
-            'zip'        => $this->get_zip( $context ),
717
-            'company'    => $this->get_company( $context ),
718
-            'vat_number' => $this->get_vat_number( $context ),
719
-            'discount'   => $this->get_discount_code( $context ),
707
+            'user_id'    => $this->get_user_id($context),
708
+            'email'      => $this->get_email($context),
709
+            'first_name' => $this->get_first_name($context),
710
+            'last_name'  => $this->get_last_name($context),
711
+            'address'    => $this->get_address($context),
712
+            'phone'      => $this->get_phone($context),
713
+            'city'       => $this->get_city($context),
714
+            'country'    => $this->get_country($context),
715
+            'state'      => $this->get_state($context),
716
+            'zip'        => $this->get_zip($context),
717
+            'company'    => $this->get_company($context),
718
+            'vat_number' => $this->get_vat_number($context),
719
+            'discount'   => $this->get_discount_code($context),
720 720
 		);
721 721
 
722
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
722
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
723 723
 
724 724
     }
725 725
 
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 	 * @param  string $context View or edit context.
731 731
 	 * @return int
732 732
 	 */
733
-	public function get_author( $context = 'view' ) {
734
-		return (int) $this->get_prop( 'author', $context );
733
+	public function get_author($context = 'view') {
734
+		return (int) $this->get_prop('author', $context);
735 735
     }
736 736
 
737 737
     /**
@@ -741,8 +741,8 @@  discard block
 block discarded – undo
741 741
 	 * @param  string $context View or edit context.
742 742
 	 * @return int
743 743
 	 */
744
-	public function get_user_id( $context = 'view' ) {
745
-		return $this->get_author( $context );
744
+	public function get_user_id($context = 'view') {
745
+		return $this->get_author($context);
746 746
     }
747 747
 
748 748
      /**
@@ -752,8 +752,8 @@  discard block
 block discarded – undo
752 752
 	 * @param  string $context View or edit context.
753 753
 	 * @return int
754 754
 	 */
755
-	public function get_customer_id( $context = 'view' ) {
756
-		return $this->get_author( $context );
755
+	public function get_customer_id($context = 'view') {
756
+		return $this->get_author($context);
757 757
     }
758 758
 
759 759
     /**
@@ -763,8 +763,8 @@  discard block
 block discarded – undo
763 763
 	 * @param  string $context View or edit context.
764 764
 	 * @return string
765 765
 	 */
766
-	public function get_ip( $context = 'view' ) {
767
-		return $this->get_prop( 'user_ip', $context );
766
+	public function get_ip($context = 'view') {
767
+		return $this->get_prop('user_ip', $context);
768 768
     }
769 769
 
770 770
     /**
@@ -774,8 +774,8 @@  discard block
 block discarded – undo
774 774
 	 * @param  string $context View or edit context.
775 775
 	 * @return string
776 776
 	 */
777
-	public function get_user_ip( $context = 'view' ) {
778
-		return $this->get_ip( $context );
777
+	public function get_user_ip($context = 'view') {
778
+		return $this->get_ip($context);
779 779
     }
780 780
 
781 781
      /**
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 	 * @param  string $context View or edit context.
786 786
 	 * @return string
787 787
 	 */
788
-	public function get_customer_ip( $context = 'view' ) {
789
-		return $this->get_ip( $context );
788
+	public function get_customer_ip($context = 'view') {
789
+		return $this->get_ip($context);
790 790
     }
791 791
 
792 792
     /**
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
 	 * @param  string $context View or edit context.
797 797
 	 * @return string
798 798
 	 */
799
-	public function get_first_name( $context = 'view' ) {
800
-		return $this->get_prop( 'first_name', $context );
799
+	public function get_first_name($context = 'view') {
800
+		return $this->get_prop('first_name', $context);
801 801
     }
802 802
 
803 803
     /**
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 	 * @param  string $context View or edit context.
808 808
 	 * @return string
809 809
 	 */
810
-	public function get_user_first_name( $context = 'view' ) {
811
-		return $this->get_first_name( $context );
810
+	public function get_user_first_name($context = 'view') {
811
+		return $this->get_first_name($context);
812 812
     }
813 813
 
814 814
      /**
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
 	 * @param  string $context View or edit context.
819 819
 	 * @return string
820 820
 	 */
821
-	public function get_customer_first_name( $context = 'view' ) {
822
-		return $this->get_first_name( $context );
821
+	public function get_customer_first_name($context = 'view') {
822
+		return $this->get_first_name($context);
823 823
     }
824 824
 
825 825
     /**
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 	 * @param  string $context View or edit context.
830 830
 	 * @return string
831 831
 	 */
832
-	public function get_last_name( $context = 'view' ) {
833
-		return $this->get_prop( 'last_name', $context );
832
+	public function get_last_name($context = 'view') {
833
+		return $this->get_prop('last_name', $context);
834 834
     }
835 835
 
836 836
     /**
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 	 * @param  string $context View or edit context.
841 841
 	 * @return string
842 842
 	 */
843
-	public function get_user_last_name( $context = 'view' ) {
844
-		return $this->get_last_name( $context );
843
+	public function get_user_last_name($context = 'view') {
844
+		return $this->get_last_name($context);
845 845
     }
846 846
 
847 847
     /**
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
 	 * @param  string $context View or edit context.
852 852
 	 * @return string
853 853
 	 */
854
-	public function get_customer_last_name( $context = 'view' ) {
855
-		return $this->get_last_name( $context );
854
+	public function get_customer_last_name($context = 'view') {
855
+		return $this->get_last_name($context);
856 856
     }
857 857
 
858 858
     /**
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 	 * @param  string $context View or edit context.
863 863
 	 * @return string
864 864
 	 */
865
-	public function get_full_name( $context = 'view' ) {
866
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
865
+	public function get_full_name($context = 'view') {
866
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
867 867
     }
868 868
 
869 869
     /**
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @param  string $context View or edit context.
874 874
 	 * @return string
875 875
 	 */
876
-	public function get_user_full_name( $context = 'view' ) {
877
-		return $this->get_full_name( $context );
876
+	public function get_user_full_name($context = 'view') {
877
+		return $this->get_full_name($context);
878 878
     }
879 879
 
880 880
     /**
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 	 * @param  string $context View or edit context.
885 885
 	 * @return string
886 886
 	 */
887
-	public function get_customer_full_name( $context = 'view' ) {
888
-		return $this->get_full_name( $context );
887
+	public function get_customer_full_name($context = 'view') {
888
+		return $this->get_full_name($context);
889 889
     }
890 890
 
891 891
     /**
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 	 * @param  string $context View or edit context.
896 896
 	 * @return string
897 897
 	 */
898
-	public function get_phone( $context = 'view' ) {
899
-		return $this->get_prop( 'phone', $context );
898
+	public function get_phone($context = 'view') {
899
+		return $this->get_prop('phone', $context);
900 900
     }
901 901
 
902 902
     /**
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 	 * @param  string $context View or edit context.
907 907
 	 * @return string
908 908
 	 */
909
-	public function get_phone_number( $context = 'view' ) {
910
-		return $this->get_phone( $context );
909
+	public function get_phone_number($context = 'view') {
910
+		return $this->get_phone($context);
911 911
     }
912 912
 
913 913
     /**
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
 	 * @param  string $context View or edit context.
918 918
 	 * @return string
919 919
 	 */
920
-	public function get_user_phone( $context = 'view' ) {
921
-		return $this->get_phone( $context );
920
+	public function get_user_phone($context = 'view') {
921
+		return $this->get_phone($context);
922 922
     }
923 923
 
924 924
     /**
@@ -928,8 +928,8 @@  discard block
 block discarded – undo
928 928
 	 * @param  string $context View or edit context.
929 929
 	 * @return string
930 930
 	 */
931
-	public function get_customer_phone( $context = 'view' ) {
932
-		return $this->get_phone( $context );
931
+	public function get_customer_phone($context = 'view') {
932
+		return $this->get_phone($context);
933 933
     }
934 934
 
935 935
     /**
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 	 * @param  string $context View or edit context.
940 940
 	 * @return string
941 941
 	 */
942
-	public function get_email( $context = 'view' ) {
943
-		return $this->get_prop( 'email', $context );
942
+	public function get_email($context = 'view') {
943
+		return $this->get_prop('email', $context);
944 944
     }
945 945
 
946 946
     /**
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
 	 * @param  string $context View or edit context.
951 951
 	 * @return string
952 952
 	 */
953
-	public function get_email_address( $context = 'view' ) {
954
-		return $this->get_email( $context );
953
+	public function get_email_address($context = 'view') {
954
+		return $this->get_email($context);
955 955
     }
956 956
 
957 957
     /**
@@ -961,8 +961,8 @@  discard block
 block discarded – undo
961 961
 	 * @param  string $context View or edit context.
962 962
 	 * @return string
963 963
 	 */
964
-	public function get_user_email( $context = 'view' ) {
965
-		return $this->get_email( $context );
964
+	public function get_user_email($context = 'view') {
965
+		return $this->get_email($context);
966 966
     }
967 967
 
968 968
     /**
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
 	 * @param  string $context View or edit context.
973 973
 	 * @return string
974 974
 	 */
975
-	public function get_customer_email( $context = 'view' ) {
976
-		return $this->get_email( $context );
975
+	public function get_customer_email($context = 'view') {
976
+		return $this->get_email($context);
977 977
     }
978 978
 
979 979
     /**
@@ -983,9 +983,9 @@  discard block
 block discarded – undo
983 983
 	 * @param  string $context View or edit context.
984 984
 	 * @return string
985 985
 	 */
986
-	public function get_country( $context = 'view' ) {
987
-		$country = $this->get_prop( 'country', $context );
988
-		return empty( $country ) ? wpinv_get_default_country() : $country;
986
+	public function get_country($context = 'view') {
987
+		$country = $this->get_prop('country', $context);
988
+		return empty($country) ? wpinv_get_default_country() : $country;
989 989
     }
990 990
 
991 991
     /**
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 	 * @param  string $context View or edit context.
996 996
 	 * @return string
997 997
 	 */
998
-	public function get_user_country( $context = 'view' ) {
999
-		return $this->get_country( $context );
998
+	public function get_user_country($context = 'view') {
999
+		return $this->get_country($context);
1000 1000
     }
1001 1001
 
1002 1002
     /**
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 	 * @param  string $context View or edit context.
1007 1007
 	 * @return string
1008 1008
 	 */
1009
-	public function get_customer_country( $context = 'view' ) {
1010
-		return $this->get_country( $context );
1009
+	public function get_customer_country($context = 'view') {
1010
+		return $this->get_country($context);
1011 1011
     }
1012 1012
 
1013 1013
     /**
@@ -1017,9 +1017,9 @@  discard block
 block discarded – undo
1017 1017
 	 * @param  string $context View or edit context.
1018 1018
 	 * @return string
1019 1019
 	 */
1020
-	public function get_state( $context = 'view' ) {
1021
-		$state = $this->get_prop( 'state', $context );
1022
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1020
+	public function get_state($context = 'view') {
1021
+		$state = $this->get_prop('state', $context);
1022
+		return empty($state) ? wpinv_get_default_state() : $state;
1023 1023
     }
1024 1024
 
1025 1025
     /**
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * @param  string $context View or edit context.
1030 1030
 	 * @return string
1031 1031
 	 */
1032
-	public function get_user_state( $context = 'view' ) {
1033
-		return $this->get_state( $context );
1032
+	public function get_user_state($context = 'view') {
1033
+		return $this->get_state($context);
1034 1034
     }
1035 1035
 
1036 1036
     /**
@@ -1040,8 +1040,8 @@  discard block
 block discarded – undo
1040 1040
 	 * @param  string $context View or edit context.
1041 1041
 	 * @return string
1042 1042
 	 */
1043
-	public function get_customer_state( $context = 'view' ) {
1044
-		return $this->get_state( $context );
1043
+	public function get_customer_state($context = 'view') {
1044
+		return $this->get_state($context);
1045 1045
     }
1046 1046
 
1047 1047
     /**
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 	 * @param  string $context View or edit context.
1052 1052
 	 * @return string
1053 1053
 	 */
1054
-	public function get_city( $context = 'view' ) {
1055
-		return $this->get_prop( 'city', $context );
1054
+	public function get_city($context = 'view') {
1055
+		return $this->get_prop('city', $context);
1056 1056
     }
1057 1057
 
1058 1058
     /**
@@ -1062,8 +1062,8 @@  discard block
 block discarded – undo
1062 1062
 	 * @param  string $context View or edit context.
1063 1063
 	 * @return string
1064 1064
 	 */
1065
-	public function get_user_city( $context = 'view' ) {
1066
-		return $this->get_city( $context );
1065
+	public function get_user_city($context = 'view') {
1066
+		return $this->get_city($context);
1067 1067
     }
1068 1068
 
1069 1069
     /**
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 	 * @param  string $context View or edit context.
1074 1074
 	 * @return string
1075 1075
 	 */
1076
-	public function get_customer_city( $context = 'view' ) {
1077
-		return $this->get_city( $context );
1076
+	public function get_customer_city($context = 'view') {
1077
+		return $this->get_city($context);
1078 1078
     }
1079 1079
 
1080 1080
     /**
@@ -1084,8 +1084,8 @@  discard block
 block discarded – undo
1084 1084
 	 * @param  string $context View or edit context.
1085 1085
 	 * @return string
1086 1086
 	 */
1087
-	public function get_zip( $context = 'view' ) {
1088
-		return $this->get_prop( 'zip', $context );
1087
+	public function get_zip($context = 'view') {
1088
+		return $this->get_prop('zip', $context);
1089 1089
     }
1090 1090
 
1091 1091
     /**
@@ -1095,8 +1095,8 @@  discard block
 block discarded – undo
1095 1095
 	 * @param  string $context View or edit context.
1096 1096
 	 * @return string
1097 1097
 	 */
1098
-	public function get_user_zip( $context = 'view' ) {
1099
-		return $this->get_zip( $context );
1098
+	public function get_user_zip($context = 'view') {
1099
+		return $this->get_zip($context);
1100 1100
     }
1101 1101
 
1102 1102
     /**
@@ -1106,8 +1106,8 @@  discard block
 block discarded – undo
1106 1106
 	 * @param  string $context View or edit context.
1107 1107
 	 * @return string
1108 1108
 	 */
1109
-	public function get_customer_zip( $context = 'view' ) {
1110
-		return $this->get_zip( $context );
1109
+	public function get_customer_zip($context = 'view') {
1110
+		return $this->get_zip($context);
1111 1111
     }
1112 1112
 
1113 1113
     /**
@@ -1117,8 +1117,8 @@  discard block
 block discarded – undo
1117 1117
 	 * @param  string $context View or edit context.
1118 1118
 	 * @return string
1119 1119
 	 */
1120
-	public function get_company( $context = 'view' ) {
1121
-		return $this->get_prop( 'company', $context );
1120
+	public function get_company($context = 'view') {
1121
+		return $this->get_prop('company', $context);
1122 1122
     }
1123 1123
 
1124 1124
     /**
@@ -1128,8 +1128,8 @@  discard block
 block discarded – undo
1128 1128
 	 * @param  string $context View or edit context.
1129 1129
 	 * @return string
1130 1130
 	 */
1131
-	public function get_user_company( $context = 'view' ) {
1132
-		return $this->get_company( $context );
1131
+	public function get_user_company($context = 'view') {
1132
+		return $this->get_company($context);
1133 1133
     }
1134 1134
 
1135 1135
     /**
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 	 * @param  string $context View or edit context.
1140 1140
 	 * @return string
1141 1141
 	 */
1142
-	public function get_customer_company( $context = 'view' ) {
1143
-		return $this->get_company( $context );
1142
+	public function get_customer_company($context = 'view') {
1143
+		return $this->get_company($context);
1144 1144
     }
1145 1145
 
1146 1146
     /**
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
 	 * @param  string $context View or edit context.
1151 1151
 	 * @return string
1152 1152
 	 */
1153
-	public function get_vat_number( $context = 'view' ) {
1154
-		return $this->get_prop( 'vat_number', $context );
1153
+	public function get_vat_number($context = 'view') {
1154
+		return $this->get_prop('vat_number', $context);
1155 1155
     }
1156 1156
 
1157 1157
     /**
@@ -1161,8 +1161,8 @@  discard block
 block discarded – undo
1161 1161
 	 * @param  string $context View or edit context.
1162 1162
 	 * @return string
1163 1163
 	 */
1164
-	public function get_user_vat_number( $context = 'view' ) {
1165
-		return $this->get_vat_number( $context );
1164
+	public function get_user_vat_number($context = 'view') {
1165
+		return $this->get_vat_number($context);
1166 1166
     }
1167 1167
 
1168 1168
     /**
@@ -1172,8 +1172,8 @@  discard block
 block discarded – undo
1172 1172
 	 * @param  string $context View or edit context.
1173 1173
 	 * @return string
1174 1174
 	 */
1175
-	public function get_customer_vat_number( $context = 'view' ) {
1176
-		return $this->get_vat_number( $context );
1175
+	public function get_customer_vat_number($context = 'view') {
1176
+		return $this->get_vat_number($context);
1177 1177
     }
1178 1178
 
1179 1179
     /**
@@ -1183,8 +1183,8 @@  discard block
 block discarded – undo
1183 1183
 	 * @param  string $context View or edit context.
1184 1184
 	 * @return string
1185 1185
 	 */
1186
-	public function get_vat_rate( $context = 'view' ) {
1187
-		return $this->get_prop( 'vat_rate', $context );
1186
+	public function get_vat_rate($context = 'view') {
1187
+		return $this->get_prop('vat_rate', $context);
1188 1188
     }
1189 1189
 
1190 1190
     /**
@@ -1194,8 +1194,8 @@  discard block
 block discarded – undo
1194 1194
 	 * @param  string $context View or edit context.
1195 1195
 	 * @return string
1196 1196
 	 */
1197
-	public function get_user_vat_rate( $context = 'view' ) {
1198
-		return $this->get_vat_rate( $context );
1197
+	public function get_user_vat_rate($context = 'view') {
1198
+		return $this->get_vat_rate($context);
1199 1199
     }
1200 1200
 
1201 1201
     /**
@@ -1205,8 +1205,8 @@  discard block
 block discarded – undo
1205 1205
 	 * @param  string $context View or edit context.
1206 1206
 	 * @return string
1207 1207
 	 */
1208
-	public function get_customer_vat_rate( $context = 'view' ) {
1209
-		return $this->get_vat_rate( $context );
1208
+	public function get_customer_vat_rate($context = 'view') {
1209
+		return $this->get_vat_rate($context);
1210 1210
     }
1211 1211
 
1212 1212
     /**
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
 	 * @param  string $context View or edit context.
1217 1217
 	 * @return string
1218 1218
 	 */
1219
-	public function get_address( $context = 'view' ) {
1220
-		return $this->get_prop( 'address', $context );
1219
+	public function get_address($context = 'view') {
1220
+		return $this->get_prop('address', $context);
1221 1221
     }
1222 1222
 
1223 1223
     /**
@@ -1227,8 +1227,8 @@  discard block
 block discarded – undo
1227 1227
 	 * @param  string $context View or edit context.
1228 1228
 	 * @return string
1229 1229
 	 */
1230
-	public function get_user_address( $context = 'view' ) {
1231
-		return $this->get_address( $context );
1230
+	public function get_user_address($context = 'view') {
1231
+		return $this->get_address($context);
1232 1232
     }
1233 1233
 
1234 1234
     /**
@@ -1238,8 +1238,8 @@  discard block
 block discarded – undo
1238 1238
 	 * @param  string $context View or edit context.
1239 1239
 	 * @return string
1240 1240
 	 */
1241
-	public function get_customer_address( $context = 'view' ) {
1242
-		return $this->get_address( $context );
1241
+	public function get_customer_address($context = 'view') {
1242
+		return $this->get_address($context);
1243 1243
     }
1244 1244
 
1245 1245
     /**
@@ -1249,8 +1249,8 @@  discard block
 block discarded – undo
1249 1249
 	 * @param  string $context View or edit context.
1250 1250
 	 * @return bool
1251 1251
 	 */
1252
-	public function get_is_viewed( $context = 'view' ) {
1253
-		return (bool) $this->get_prop( 'is_viewed', $context );
1252
+	public function get_is_viewed($context = 'view') {
1253
+		return (bool) $this->get_prop('is_viewed', $context);
1254 1254
 	}
1255 1255
 
1256 1256
 	/**
@@ -1260,8 +1260,8 @@  discard block
 block discarded – undo
1260 1260
 	 * @param  string $context View or edit context.
1261 1261
 	 * @return bool
1262 1262
 	 */
1263
-	public function get_email_cc( $context = 'view' ) {
1264
-		return $this->get_prop( 'email_cc', $context );
1263
+	public function get_email_cc($context = 'view') {
1264
+		return $this->get_prop('email_cc', $context);
1265 1265
 	}
1266 1266
 
1267 1267
 	/**
@@ -1271,8 +1271,8 @@  discard block
 block discarded – undo
1271 1271
 	 * @param  string $context View or edit context.
1272 1272
 	 * @return bool
1273 1273
 	 */
1274
-	public function get_template( $context = 'view' ) {
1275
-		return $this->get_prop( 'template', $context );
1274
+	public function get_template($context = 'view') {
1275
+		return $this->get_prop('template', $context);
1276 1276
 	}
1277 1277
 
1278 1278
 	/**
@@ -1282,8 +1282,8 @@  discard block
 block discarded – undo
1282 1282
 	 * @param  string $context View or edit context.
1283 1283
 	 * @return bool
1284 1284
 	 */
1285
-	public function get_created_via( $context = 'view' ) {
1286
-		return $this->get_prop( 'created_via', $context );
1285
+	public function get_created_via($context = 'view') {
1286
+		return $this->get_prop('created_via', $context);
1287 1287
 	}
1288 1288
 
1289 1289
 	/**
@@ -1293,8 +1293,8 @@  discard block
 block discarded – undo
1293 1293
 	 * @param  string $context View or edit context.
1294 1294
 	 * @return bool
1295 1295
 	 */
1296
-	public function get_address_confirmed( $context = 'view' ) {
1297
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1296
+	public function get_address_confirmed($context = 'view') {
1297
+		return (bool) $this->get_prop('address_confirmed', $context);
1298 1298
     }
1299 1299
 
1300 1300
     /**
@@ -1304,8 +1304,8 @@  discard block
 block discarded – undo
1304 1304
 	 * @param  string $context View or edit context.
1305 1305
 	 * @return bool
1306 1306
 	 */
1307
-	public function get_user_address_confirmed( $context = 'view' ) {
1308
-		return $this->get_address_confirmed( $context );
1307
+	public function get_user_address_confirmed($context = 'view') {
1308
+		return $this->get_address_confirmed($context);
1309 1309
     }
1310 1310
 
1311 1311
     /**
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 	 * @param  string $context View or edit context.
1316 1316
 	 * @return bool
1317 1317
 	 */
1318
-	public function get_customer_address_confirmed( $context = 'view' ) {
1319
-		return $this->get_address_confirmed( $context );
1318
+	public function get_customer_address_confirmed($context = 'view') {
1319
+		return $this->get_address_confirmed($context);
1320 1320
     }
1321 1321
 
1322 1322
     /**
@@ -1326,12 +1326,12 @@  discard block
 block discarded – undo
1326 1326
 	 * @param  string $context View or edit context.
1327 1327
 	 * @return float
1328 1328
 	 */
1329
-	public function get_subtotal( $context = 'view' ) {
1330
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1329
+	public function get_subtotal($context = 'view') {
1330
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1331 1331
 
1332 1332
         // Backwards compatibility.
1333
-        if ( is_bool( $context ) && $context ) {
1334
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1333
+        if (is_bool($context) && $context) {
1334
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1335 1335
         }
1336 1336
 
1337 1337
         return $subtotal;
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 	 * @param  string $context View or edit context.
1345 1345
 	 * @return float
1346 1346
 	 */
1347
-	public function get_total_discount( $context = 'view' ) {
1348
-		return (float) $this->get_prop( 'total_discount', $context );
1347
+	public function get_total_discount($context = 'view') {
1348
+		return (float) $this->get_prop('total_discount', $context);
1349 1349
     }
1350 1350
 
1351 1351
     /**
@@ -1355,18 +1355,18 @@  discard block
 block discarded – undo
1355 1355
 	 * @param  string $context View or edit context.
1356 1356
 	 * @return float
1357 1357
 	 */
1358
-	public function get_total_tax( $context = 'view' ) {
1359
-		return (float) $this->get_prop( 'total_tax', $context );
1358
+	public function get_total_tax($context = 'view') {
1359
+		return (float) $this->get_prop('total_tax', $context);
1360 1360
 	}
1361 1361
 
1362 1362
 	/**
1363 1363
 	 * @deprecated
1364 1364
 	 */
1365
-	public function get_final_tax( $currency = false ) {
1365
+	public function get_final_tax($currency = false) {
1366 1366
 		$tax = $this->get_total_tax();
1367 1367
 
1368
-        if ( $currency ) {
1369
-			return wpinv_price( $tax, $this->get_currency() );
1368
+        if ($currency) {
1369
+			return wpinv_price($tax, $this->get_currency());
1370 1370
         }
1371 1371
 
1372 1372
         return $tax;
@@ -1379,8 +1379,8 @@  discard block
 block discarded – undo
1379 1379
 	 * @param  string $context View or edit context.
1380 1380
 	 * @return float
1381 1381
 	 */
1382
-	public function get_total_fees( $context = 'view' ) {
1383
-		return (float) $this->get_prop( 'total_fees', $context );
1382
+	public function get_total_fees($context = 'view') {
1383
+		return (float) $this->get_prop('total_fees', $context);
1384 1384
     }
1385 1385
 
1386 1386
     /**
@@ -1390,8 +1390,8 @@  discard block
 block discarded – undo
1390 1390
 	 * @param  string $context View or edit context.
1391 1391
 	 * @return float
1392 1392
 	 */
1393
-	public function get_fees_total( $context = 'view' ) {
1394
-		return $this->get_total_fees( $context );
1393
+	public function get_fees_total($context = 'view') {
1394
+		return $this->get_total_fees($context);
1395 1395
     }
1396 1396
 
1397 1397
     /**
@@ -1402,7 +1402,7 @@  discard block
 block discarded – undo
1402 1402
 	 */
1403 1403
 	public function get_total() {
1404 1404
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1405
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1405
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1406 1406
 	}
1407 1407
 	
1408 1408
 	/**
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
 	 */
1425 1425
     public function get_initial_total() {
1426 1426
 
1427
-		if ( empty( $this->totals ) ) {
1427
+		if (empty($this->totals)) {
1428 1428
 			$this->recalculate_total();
1429 1429
 		}
1430 1430
 
@@ -1434,11 +1434,11 @@  discard block
 block discarded – undo
1434 1434
 		$subtotal = $this->totals['subtotal']['initial'];
1435 1435
 		$total    = $tax + $fee - $discount + $subtotal;
1436 1436
 
1437
-		if ( 0 > $total ) {
1437
+		if (0 > $total) {
1438 1438
 			$total = 0;
1439 1439
 		}
1440 1440
 
1441
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1441
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1442 1442
 	}
1443 1443
 
1444 1444
 	/**
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
 	 */
1451 1451
     public function get_recurring_total() {
1452 1452
 
1453
-		if ( empty( $this->totals ) ) {
1453
+		if (empty($this->totals)) {
1454 1454
 			$this->recalculate_total();
1455 1455
 		}
1456 1456
 
@@ -1460,11 +1460,11 @@  discard block
 block discarded – undo
1460 1460
 		$subtotal = $this->totals['subtotal']['recurring'];
1461 1461
 		$total    = $tax + $fee - $discount + $subtotal;
1462 1462
 
1463
-		if ( 0 > $total ) {
1463
+		if (0 > $total) {
1464 1464
 			$total = 0;
1465 1465
 		}
1466 1466
 
1467
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1467
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1468 1468
 	}
1469 1469
 
1470 1470
 	/**
@@ -1475,10 +1475,10 @@  discard block
 block discarded – undo
1475 1475
 	 * @param string $currency Whether to include the currency.
1476 1476
      * @return float|string
1477 1477
 	 */
1478
-    public function get_recurring_details( $field = '', $currency = false ) {
1478
+    public function get_recurring_details($field = '', $currency = false) {
1479 1479
 
1480 1480
 		// Maybe recalculate totals.
1481
-		if ( empty( $this->totals ) ) {
1481
+		if (empty($this->totals)) {
1482 1482
 			$this->recalculate_total();
1483 1483
 		}
1484 1484
 
@@ -1498,8 +1498,8 @@  discard block
 block discarded – undo
1498 1498
 			$currency
1499 1499
 		);
1500 1500
 
1501
-        if ( isset( $data[$field] ) ) {
1502
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1501
+        if (isset($data[$field])) {
1502
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1503 1503
         }
1504 1504
 
1505 1505
         return $data;
@@ -1512,8 +1512,8 @@  discard block
 block discarded – undo
1512 1512
 	 * @param  string $context View or edit context.
1513 1513
 	 * @return array
1514 1514
 	 */
1515
-	public function get_fees( $context = 'view' ) {
1516
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1515
+	public function get_fees($context = 'view') {
1516
+		return wpinv_parse_list($this->get_prop('fees', $context));
1517 1517
     }
1518 1518
 
1519 1519
     /**
@@ -1523,8 +1523,8 @@  discard block
 block discarded – undo
1523 1523
 	 * @param  string $context View or edit context.
1524 1524
 	 * @return array
1525 1525
 	 */
1526
-	public function get_discounts( $context = 'view' ) {
1527
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1526
+	public function get_discounts($context = 'view') {
1527
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1528 1528
     }
1529 1529
 
1530 1530
     /**
@@ -1534,8 +1534,8 @@  discard block
 block discarded – undo
1534 1534
 	 * @param  string $context View or edit context.
1535 1535
 	 * @return array
1536 1536
 	 */
1537
-	public function get_taxes( $context = 'view' ) {
1538
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1537
+	public function get_taxes($context = 'view') {
1538
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1539 1539
     }
1540 1540
 
1541 1541
     /**
@@ -1545,8 +1545,8 @@  discard block
 block discarded – undo
1545 1545
 	 * @param  string $context View or edit context.
1546 1546
 	 * @return GetPaid_Form_Item[]
1547 1547
 	 */
1548
-	public function get_items( $context = 'view' ) {
1549
-        return $this->get_prop( 'items', $context );
1548
+	public function get_items($context = 'view') {
1549
+        return $this->get_prop('items', $context);
1550 1550
     }
1551 1551
 
1552 1552
     /**
@@ -1556,8 +1556,8 @@  discard block
 block discarded – undo
1556 1556
 	 * @param  string $context View or edit context.
1557 1557
 	 * @return int
1558 1558
 	 */
1559
-	public function get_payment_form( $context = 'view' ) {
1560
-		return intval( $this->get_prop( 'payment_form', $context ) );
1559
+	public function get_payment_form($context = 'view') {
1560
+		return intval($this->get_prop('payment_form', $context));
1561 1561
     }
1562 1562
 
1563 1563
     /**
@@ -1567,8 +1567,8 @@  discard block
 block discarded – undo
1567 1567
 	 * @param  string $context View or edit context.
1568 1568
 	 * @return string
1569 1569
 	 */
1570
-	public function get_submission_id( $context = 'view' ) {
1571
-		return $this->get_prop( 'submission_id', $context );
1570
+	public function get_submission_id($context = 'view') {
1571
+		return $this->get_prop('submission_id', $context);
1572 1572
     }
1573 1573
 
1574 1574
     /**
@@ -1578,8 +1578,8 @@  discard block
 block discarded – undo
1578 1578
 	 * @param  string $context View or edit context.
1579 1579
 	 * @return string
1580 1580
 	 */
1581
-	public function get_discount_code( $context = 'view' ) {
1582
-		return $this->get_prop( 'discount_code', $context );
1581
+	public function get_discount_code($context = 'view') {
1582
+		return $this->get_prop('discount_code', $context);
1583 1583
     }
1584 1584
 
1585 1585
     /**
@@ -1589,8 +1589,8 @@  discard block
 block discarded – undo
1589 1589
 	 * @param  string $context View or edit context.
1590 1590
 	 * @return string
1591 1591
 	 */
1592
-	public function get_gateway( $context = 'view' ) {
1593
-		return $this->get_prop( 'gateway', $context );
1592
+	public function get_gateway($context = 'view') {
1593
+		return $this->get_prop('gateway', $context);
1594 1594
     }
1595 1595
 
1596 1596
     /**
@@ -1600,8 +1600,8 @@  discard block
 block discarded – undo
1600 1600
 	 * @return string
1601 1601
 	 */
1602 1602
     public function get_gateway_title() {
1603
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1604
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1603
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1604
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1605 1605
     }
1606 1606
 
1607 1607
     /**
@@ -1611,8 +1611,8 @@  discard block
 block discarded – undo
1611 1611
 	 * @param  string $context View or edit context.
1612 1612
 	 * @return string
1613 1613
 	 */
1614
-	public function get_transaction_id( $context = 'view' ) {
1615
-		return $this->get_prop( 'transaction_id', $context );
1614
+	public function get_transaction_id($context = 'view') {
1615
+		return $this->get_prop('transaction_id', $context);
1616 1616
     }
1617 1617
 
1618 1618
     /**
@@ -1622,9 +1622,9 @@  discard block
 block discarded – undo
1622 1622
 	 * @param  string $context View or edit context.
1623 1623
 	 * @return string
1624 1624
 	 */
1625
-	public function get_currency( $context = 'view' ) {
1626
-        $currency = $this->get_prop( 'currency', $context );
1627
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1625
+	public function get_currency($context = 'view') {
1626
+        $currency = $this->get_prop('currency', $context);
1627
+        return empty($currency) ? wpinv_get_currency() : $currency;
1628 1628
     }
1629 1629
 
1630 1630
     /**
@@ -1634,8 +1634,8 @@  discard block
 block discarded – undo
1634 1634
 	 * @param  string $context View or edit context.
1635 1635
 	 * @return bool
1636 1636
 	 */
1637
-	public function get_disable_taxes( $context = 'view' ) {
1638
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1637
+	public function get_disable_taxes($context = 'view') {
1638
+        return (bool) $this->get_prop('disable_taxes', $context);
1639 1639
     }
1640 1640
 
1641 1641
     /**
@@ -1645,8 +1645,8 @@  discard block
 block discarded – undo
1645 1645
 	 * @param  string $context View or edit context.
1646 1646
 	 * @return int
1647 1647
 	 */
1648
-    public function get_subscription_id( $context = 'view' ) {
1649
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1648
+    public function get_subscription_id($context = 'view') {
1649
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1650 1650
 	}
1651 1651
 
1652 1652
 	/**
@@ -1656,12 +1656,12 @@  discard block
 block discarded – undo
1656 1656
 	 * @param  string $context View or edit context.
1657 1657
 	 * @return int
1658 1658
 	 */
1659
-    public function get_remote_subscription_id( $context = 'view' ) {
1660
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1659
+    public function get_remote_subscription_id($context = 'view') {
1660
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1661 1661
 
1662
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1662
+        if (empty($subscription_id) && $this->is_renewal()) {
1663 1663
             $parent = $this->get_parent();
1664
-            return $parent->get_subscription_id( $context );
1664
+            return $parent->get_subscription_id($context);
1665 1665
         }
1666 1666
 
1667 1667
         return $subscription_id;
@@ -1674,20 +1674,20 @@  discard block
 block discarded – undo
1674 1674
 	 * @param  string $context View or edit context.
1675 1675
 	 * @return array
1676 1676
 	 */
1677
-    public function get_payment_meta( $context = 'view' ) {
1677
+    public function get_payment_meta($context = 'view') {
1678 1678
 
1679 1679
         return array(
1680
-            'price'        => $this->get_total( $context ),
1681
-            'date'         => $this->get_date_created( $context ),
1682
-            'user_email'   => $this->get_email( $context ),
1683
-            'invoice_key'  => $this->get_key( $context ),
1684
-            'currency'     => $this->get_currency( $context ),
1685
-            'items'        => $this->get_items( $context ),
1686
-            'user_info'    => $this->get_user_info( $context ),
1680
+            'price'        => $this->get_total($context),
1681
+            'date'         => $this->get_date_created($context),
1682
+            'user_email'   => $this->get_email($context),
1683
+            'invoice_key'  => $this->get_key($context),
1684
+            'currency'     => $this->get_currency($context),
1685
+            'items'        => $this->get_items($context),
1686
+            'user_info'    => $this->get_user_info($context),
1687 1687
             'cart_details' => $this->get_cart_details(),
1688
-            'status'       => $this->get_status( $context ),
1689
-            'fees'         => $this->get_fees( $context ),
1690
-            'taxes'        => $this->get_taxes( $context ),
1688
+            'status'       => $this->get_status($context),
1689
+            'fees'         => $this->get_fees($context),
1690
+            'taxes'        => $this->get_taxes($context),
1691 1691
         );
1692 1692
 
1693 1693
     }
@@ -1702,9 +1702,9 @@  discard block
 block discarded – undo
1702 1702
         $items        = $this->get_items();
1703 1703
         $cart_details = array();
1704 1704
 
1705
-        foreach ( $items as $item_id => $item ) {
1705
+        foreach ($items as $item_id => $item) {
1706 1706
 			$item->invoice_id = $this->get_id();
1707
-            $cart_details[]   = $item->prepare_data_for_saving();
1707
+            $cart_details[] = $item->prepare_data_for_saving();
1708 1708
         }
1709 1709
 
1710 1710
         return $cart_details;
@@ -1715,11 +1715,11 @@  discard block
 block discarded – undo
1715 1715
 	 *
1716 1716
 	 * @return null|GetPaid_Form_Item|int
1717 1717
 	 */
1718
-	public function get_recurring( $object = false ) {
1718
+	public function get_recurring($object = false) {
1719 1719
 
1720 1720
 		// Are we returning an object?
1721
-        if ( $object ) {
1722
-            return $this->get_item( $this->recurring_item );
1721
+        if ($object) {
1722
+            return $this->get_item($this->recurring_item);
1723 1723
         }
1724 1724
 
1725 1725
         return $this->recurring_item;
@@ -1734,15 +1734,15 @@  discard block
 block discarded – undo
1734 1734
 	public function get_subscription_name() {
1735 1735
 
1736 1736
 		// Retrieve the recurring name
1737
-        $item = $this->get_recurring( true );
1737
+        $item = $this->get_recurring(true);
1738 1738
 
1739 1739
 		// Abort if it does not exist.
1740
-        if ( empty( $item ) ) {
1740
+        if (empty($item)) {
1741 1741
             return '';
1742 1742
         }
1743 1743
 
1744 1744
 		// Return the item name.
1745
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1745
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1746 1746
 	}
1747 1747
 
1748 1748
 	/**
@@ -1752,9 +1752,9 @@  discard block
 block discarded – undo
1752 1752
 	 * @return string
1753 1753
 	 */
1754 1754
 	public function get_view_url() {
1755
-        $invoice_url = get_permalink( $this->get_id() );
1756
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1757
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1755
+        $invoice_url = get_permalink($this->get_id());
1756
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1757
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1758 1758
 	}
1759 1759
 
1760 1760
 	/**
@@ -1763,25 +1763,25 @@  discard block
 block discarded – undo
1763 1763
 	 * @since 1.0.19
1764 1764
 	 * @return string
1765 1765
 	 */
1766
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1766
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1767 1767
 
1768 1768
 		// Retrieve the checkout url.
1769 1769
         $pay_url = wpinv_get_checkout_uri();
1770 1770
 
1771 1771
 		// Maybe force ssl.
1772
-        if ( is_ssl() ) {
1773
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1772
+        if (is_ssl()) {
1773
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1774 1774
         }
1775 1775
 
1776 1776
 		// Add the invoice key.
1777
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1777
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1778 1778
 
1779 1779
 		// (Maybe?) add a secret
1780
-        if ( $secret ) {
1781
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1780
+        if ($secret) {
1781
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1782 1782
         }
1783 1783
 
1784
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1784
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1785 1785
 	}
1786 1786
 	
1787 1787
 	/**
@@ -1796,14 +1796,14 @@  discard block
 block discarded – undo
1796 1796
         $receipt_url = wpinv_get_success_page_uri();
1797 1797
 
1798 1798
 		// Maybe force ssl.
1799
-        if ( is_ssl() ) {
1800
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1799
+        if (is_ssl()) {
1800
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1801 1801
         }
1802 1802
 
1803 1803
 		// Add the invoice key.
1804
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1804
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1805 1805
 
1806
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1806
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1807 1807
 	}
1808 1808
 	
1809 1809
 	/**
@@ -1816,7 +1816,7 @@  discard block
 block discarded – undo
1816 1816
 
1817 1817
 		$type   = $this->get_type();
1818 1818
 		$status = "wpi-$type-pending";
1819
-		return str_replace( '-invoice', '', $status );
1819
+		return str_replace('-invoice', '', $status);
1820 1820
 
1821 1821
 	}
1822 1822
 
@@ -1830,8 +1830,8 @@  discard block
 block discarded – undo
1830 1830
 	 * @param  string $context View or edit context.
1831 1831
 	 * @return mixed Value of the given invoice property (if set).
1832 1832
 	 */
1833
-	public function get( $key, $context = 'view' ) {
1834
-        return $this->get_prop( $key, $context );
1833
+	public function get($key, $context = 'view') {
1834
+        return $this->get_prop($key, $context);
1835 1835
 	}
1836 1836
 
1837 1837
     /*
@@ -1854,11 +1854,11 @@  discard block
 block discarded – undo
1854 1854
 	 * @param  mixed $value new value.
1855 1855
 	 * @return mixed Value of the given invoice property (if set).
1856 1856
 	 */
1857
-	public function set( $key, $value ) {
1857
+	public function set($key, $value) {
1858 1858
 
1859 1859
         $setter = "set_$key";
1860
-        if ( is_callable( array( $this, $setter ) ) ) {
1861
-            $this->{$setter}( $value );
1860
+        if (is_callable(array($this, $setter))) {
1861
+            $this->{$setter}($value);
1862 1862
         }
1863 1863
 
1864 1864
 	}
@@ -1872,47 +1872,47 @@  discard block
 block discarded – undo
1872 1872
 	 * @param bool   $manual_update Is this a manual status change?.
1873 1873
 	 * @return array details of change.
1874 1874
 	 */
1875
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1875
+	public function set_status($new_status, $note = '', $manual_update = false) {
1876 1876
 		$old_status = $this->get_status();
1877 1877
 
1878 1878
 		$statuses = $this->get_all_statuses();
1879 1879
 
1880
-		if ( isset( $statuses[ 'draft' ] ) ) {
1881
-			unset( $statuses[ 'draft' ] );
1880
+		if (isset($statuses['draft'])) {
1881
+			unset($statuses['draft']);
1882 1882
 		}
1883 1883
 
1884
-		$this->set_prop( 'status', $new_status );
1884
+		$this->set_prop('status', $new_status);
1885 1885
 
1886 1886
 		// If setting the status, ensure it's set to a valid status.
1887
-		if ( true === $this->object_read ) {
1887
+		if (true === $this->object_read) {
1888 1888
 
1889 1889
 			// Only allow valid new status.
1890
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1890
+			if (!array_key_exists($new_status, $statuses)) {
1891 1891
 				$new_status = $this->get_default_status();
1892 1892
 			}
1893 1893
 
1894 1894
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1895
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1895
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1896 1896
 				$old_status = $this->get_default_status();
1897 1897
 			}
1898 1898
 
1899 1899
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1900
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1900
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1901 1901
 				$old_status = 'wpi-pending';
1902 1902
 			}
1903 1903
 
1904 1904
 		}
1905 1905
 
1906
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1906
+		if (true === $this->object_read && $old_status !== $new_status) {
1907 1907
 			$this->status_transition = array(
1908
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1908
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1909 1909
 				'to'     => $new_status,
1910 1910
 				'note'   => $note,
1911 1911
 				'manual' => (bool) $manual_update,
1912 1912
 			);
1913 1913
 
1914
-			if ( $manual_update ) {
1915
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1914
+			if ($manual_update) {
1915
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1916 1916
 			}
1917 1917
 
1918 1918
 			$this->maybe_set_date_paid();
@@ -1935,8 +1935,8 @@  discard block
 block discarded – undo
1935 1935
 	 */
1936 1936
 	public function maybe_set_date_paid() {
1937 1937
 
1938
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1939
-			$this->set_date_completed( current_time( 'mysql' ) );
1938
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1939
+			$this->set_date_completed(current_time('mysql'));
1940 1940
 		}
1941 1941
 	}
1942 1942
 
@@ -1945,11 +1945,11 @@  discard block
 block discarded – undo
1945 1945
 	 *
1946 1946
 	 * @since 1.0.19
1947 1947
 	 */
1948
-	public function set_parent_id( $value ) {
1949
-		if ( $value && ( $value === $this->get_id() ) ) {
1948
+	public function set_parent_id($value) {
1949
+		if ($value && ($value === $this->get_id())) {
1950 1950
 			return;
1951 1951
 		}
1952
-		$this->set_prop( 'parent_id', absint( $value ) );
1952
+		$this->set_prop('parent_id', absint($value));
1953 1953
     }
1954 1954
 
1955 1955
     /**
@@ -1957,8 +1957,8 @@  discard block
 block discarded – undo
1957 1957
 	 *
1958 1958
 	 * @since 1.0.19
1959 1959
 	 */
1960
-	public function set_version( $value ) {
1961
-		$this->set_prop( 'version', $value );
1960
+	public function set_version($value) {
1961
+		$this->set_prop('version', $value);
1962 1962
     }
1963 1963
 
1964 1964
     /**
@@ -1968,15 +1968,15 @@  discard block
 block discarded – undo
1968 1968
 	 * @param string $value Value to set.
1969 1969
      * @return bool Whether or not the date was set.
1970 1970
 	 */
1971
-	public function set_date_created( $value ) {
1972
-        $date = strtotime( $value );
1971
+	public function set_date_created($value) {
1972
+        $date = strtotime($value);
1973 1973
 
1974
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1975
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1974
+        if ($date && $value !== '0000-00-00 00:00:00') {
1975
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1976 1976
             return true;
1977 1977
         }
1978 1978
 
1979
-		$this->set_prop( 'date_created', '' );
1979
+		$this->set_prop('date_created', '');
1980 1980
 		return false;
1981 1981
 
1982 1982
     }
@@ -1988,15 +1988,15 @@  discard block
 block discarded – undo
1988 1988
 	 * @param string $value Value to set.
1989 1989
      * @return bool Whether or not the date was set.
1990 1990
 	 */
1991
-	public function set_due_date( $value ) {
1992
-        $date = strtotime( $value );
1991
+	public function set_due_date($value) {
1992
+        $date = strtotime($value);
1993 1993
 
1994
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1995
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1994
+        if ($date && $value !== '0000-00-00 00:00:00') {
1995
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1996 1996
             return true;
1997 1997
         }
1998 1998
 
1999
-		$this->set_prop( 'due_date', '' );
1999
+		$this->set_prop('due_date', '');
2000 2000
         return false;
2001 2001
 
2002 2002
     }
@@ -2007,8 +2007,8 @@  discard block
 block discarded – undo
2007 2007
 	 * @since 1.0.19
2008 2008
 	 * @param  string $value New name.
2009 2009
 	 */
2010
-	public function set_date_due( $value ) {
2011
-		$this->set_due_date( $value );
2010
+	public function set_date_due($value) {
2011
+		$this->set_due_date($value);
2012 2012
     }
2013 2013
 
2014 2014
     /**
@@ -2018,15 +2018,15 @@  discard block
 block discarded – undo
2018 2018
 	 * @param string $value Value to set.
2019 2019
      * @return bool Whether or not the date was set.
2020 2020
 	 */
2021
-	public function set_completed_date( $value ) {
2022
-        $date = strtotime( $value );
2021
+	public function set_completed_date($value) {
2022
+        $date = strtotime($value);
2023 2023
 
2024
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2025
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2024
+        if ($date && $value !== '0000-00-00 00:00:00') {
2025
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2026 2026
             return true;
2027 2027
         }
2028 2028
 
2029
-		$this->set_prop( 'completed_date', '' );
2029
+		$this->set_prop('completed_date', '');
2030 2030
         return false;
2031 2031
 
2032 2032
     }
@@ -2037,8 +2037,8 @@  discard block
 block discarded – undo
2037 2037
 	 * @since 1.0.19
2038 2038
 	 * @param  string $value New name.
2039 2039
 	 */
2040
-	public function set_date_completed( $value ) {
2041
-		$this->set_completed_date( $value );
2040
+	public function set_date_completed($value) {
2041
+		$this->set_completed_date($value);
2042 2042
     }
2043 2043
 
2044 2044
     /**
@@ -2048,15 +2048,15 @@  discard block
 block discarded – undo
2048 2048
 	 * @param string $value Value to set.
2049 2049
      * @return bool Whether or not the date was set.
2050 2050
 	 */
2051
-	public function set_date_modified( $value ) {
2052
-        $date = strtotime( $value );
2051
+	public function set_date_modified($value) {
2052
+        $date = strtotime($value);
2053 2053
 
2054
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2055
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2054
+        if ($date && $value !== '0000-00-00 00:00:00') {
2055
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2056 2056
             return true;
2057 2057
         }
2058 2058
 
2059
-		$this->set_prop( 'date_modified', '' );
2059
+		$this->set_prop('date_modified', '');
2060 2060
         return false;
2061 2061
 
2062 2062
     }
@@ -2067,9 +2067,9 @@  discard block
 block discarded – undo
2067 2067
 	 * @since 1.0.19
2068 2068
 	 * @param  string $value New number.
2069 2069
 	 */
2070
-	public function set_number( $value ) {
2071
-        $number = sanitize_text_field( $value );
2072
-		$this->set_prop( 'number', $number );
2070
+	public function set_number($value) {
2071
+        $number = sanitize_text_field($value);
2072
+		$this->set_prop('number', $number);
2073 2073
     }
2074 2074
 
2075 2075
     /**
@@ -2078,9 +2078,9 @@  discard block
 block discarded – undo
2078 2078
 	 * @since 1.0.19
2079 2079
 	 * @param  string $value Type.
2080 2080
 	 */
2081
-	public function set_type( $value ) {
2082
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2083
-		$this->set_prop( 'type', $type );
2081
+	public function set_type($value) {
2082
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2083
+		$this->set_prop('type', $type);
2084 2084
 	}
2085 2085
 
2086 2086
     /**
@@ -2089,10 +2089,10 @@  discard block
 block discarded – undo
2089 2089
 	 * @since 1.0.19
2090 2090
 	 * @param  string $value Post type.
2091 2091
 	 */
2092
-	public function set_post_type( $value ) {
2093
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2094
-			$this->set_type( $value );
2095
-            $this->set_prop( 'post_type', $value );
2092
+	public function set_post_type($value) {
2093
+        if (getpaid_is_invoice_post_type($value)) {
2094
+			$this->set_type($value);
2095
+            $this->set_prop('post_type', $value);
2096 2096
         }
2097 2097
     }
2098 2098
 
@@ -2102,9 +2102,9 @@  discard block
 block discarded – undo
2102 2102
 	 * @since 1.0.19
2103 2103
 	 * @param  string $value New key.
2104 2104
 	 */
2105
-	public function set_key( $value ) {
2106
-        $key = sanitize_text_field( $value );
2107
-		$this->set_prop( 'key', $key );
2105
+	public function set_key($value) {
2106
+        $key = sanitize_text_field($value);
2107
+		$this->set_prop('key', $key);
2108 2108
     }
2109 2109
 
2110 2110
     /**
@@ -2113,9 +2113,9 @@  discard block
 block discarded – undo
2113 2113
 	 * @since 1.0.19
2114 2114
 	 * @param  string $value mode.
2115 2115
 	 */
2116
-	public function set_mode( $value ) {
2117
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2118
-            $this->set_prop( 'value', $value );
2116
+	public function set_mode($value) {
2117
+        if (!in_array($value, array('live', 'test'))) {
2118
+            $this->set_prop('value', $value);
2119 2119
         }
2120 2120
     }
2121 2121
 
@@ -2125,8 +2125,8 @@  discard block
 block discarded – undo
2125 2125
 	 * @since 1.0.19
2126 2126
 	 * @param  string $value path.
2127 2127
 	 */
2128
-	public function set_path( $value ) {
2129
-        $this->set_prop( 'path', $value );
2128
+	public function set_path($value) {
2129
+        $this->set_prop('path', $value);
2130 2130
     }
2131 2131
 
2132 2132
     /**
@@ -2135,9 +2135,9 @@  discard block
 block discarded – undo
2135 2135
 	 * @since 1.0.19
2136 2136
 	 * @param  string $value New name.
2137 2137
 	 */
2138
-	public function set_name( $value ) {
2139
-        $name = sanitize_text_field( $value );
2140
-		$this->set_prop( 'name', $name );
2138
+	public function set_name($value) {
2139
+        $name = sanitize_text_field($value);
2140
+		$this->set_prop('name', $name);
2141 2141
     }
2142 2142
 
2143 2143
     /**
@@ -2146,8 +2146,8 @@  discard block
 block discarded – undo
2146 2146
 	 * @since 1.0.19
2147 2147
 	 * @param  string $value New name.
2148 2148
 	 */
2149
-	public function set_title( $value ) {
2150
-		$this->set_name( $value );
2149
+	public function set_title($value) {
2150
+		$this->set_name($value);
2151 2151
     }
2152 2152
 
2153 2153
     /**
@@ -2156,9 +2156,9 @@  discard block
 block discarded – undo
2156 2156
 	 * @since 1.0.19
2157 2157
 	 * @param  string $value New description.
2158 2158
 	 */
2159
-	public function set_description( $value ) {
2160
-        $description = wp_kses_post( $value );
2161
-		$this->set_prop( 'description', $description );
2159
+	public function set_description($value) {
2160
+        $description = wp_kses_post($value);
2161
+		$this->set_prop('description', $description);
2162 2162
     }
2163 2163
 
2164 2164
     /**
@@ -2167,8 +2167,8 @@  discard block
 block discarded – undo
2167 2167
 	 * @since 1.0.19
2168 2168
 	 * @param  string $value New description.
2169 2169
 	 */
2170
-	public function set_excerpt( $value ) {
2171
-		$this->set_description( $value );
2170
+	public function set_excerpt($value) {
2171
+		$this->set_description($value);
2172 2172
     }
2173 2173
 
2174 2174
     /**
@@ -2177,8 +2177,8 @@  discard block
 block discarded – undo
2177 2177
 	 * @since 1.0.19
2178 2178
 	 * @param  string $value New description.
2179 2179
 	 */
2180
-	public function set_summary( $value ) {
2181
-		$this->set_description( $value );
2180
+	public function set_summary($value) {
2181
+		$this->set_description($value);
2182 2182
     }
2183 2183
 
2184 2184
     /**
@@ -2187,12 +2187,12 @@  discard block
 block discarded – undo
2187 2187
 	 * @since 1.0.19
2188 2188
 	 * @param  int $value New author.
2189 2189
 	 */
2190
-	public function set_author( $value ) {
2191
-		$user = get_user_by( 'id', (int) $value );
2190
+	public function set_author($value) {
2191
+		$user = get_user_by('id', (int) $value);
2192 2192
 
2193
-		if ( $user && $user->ID ) {
2194
-			$this->set_prop( 'author', $user->ID );
2195
-			$this->set_prop( 'email', $user->user_email );
2193
+		if ($user && $user->ID) {
2194
+			$this->set_prop('author', $user->ID);
2195
+			$this->set_prop('email', $user->user_email);
2196 2196
 		}
2197 2197
 
2198 2198
     }
@@ -2203,8 +2203,8 @@  discard block
 block discarded – undo
2203 2203
 	 * @since 1.0.19
2204 2204
 	 * @param  int $value New user id.
2205 2205
 	 */
2206
-	public function set_user_id( $value ) {
2207
-		$this->set_author( $value );
2206
+	public function set_user_id($value) {
2207
+		$this->set_author($value);
2208 2208
     }
2209 2209
 
2210 2210
     /**
@@ -2213,8 +2213,8 @@  discard block
 block discarded – undo
2213 2213
 	 * @since 1.0.19
2214 2214
 	 * @param  int $value New user id.
2215 2215
 	 */
2216
-	public function set_customer_id( $value ) {
2217
-		$this->set_author( $value );
2216
+	public function set_customer_id($value) {
2217
+		$this->set_author($value);
2218 2218
     }
2219 2219
 
2220 2220
     /**
@@ -2223,8 +2223,8 @@  discard block
 block discarded – undo
2223 2223
 	 * @since 1.0.19
2224 2224
 	 * @param  string $value ip address.
2225 2225
 	 */
2226
-	public function set_ip( $value ) {
2227
-		$this->set_prop( 'ip', $value );
2226
+	public function set_ip($value) {
2227
+		$this->set_prop('ip', $value);
2228 2228
     }
2229 2229
 
2230 2230
     /**
@@ -2233,8 +2233,8 @@  discard block
 block discarded – undo
2233 2233
 	 * @since 1.0.19
2234 2234
 	 * @param  string $value ip address.
2235 2235
 	 */
2236
-	public function set_user_ip( $value ) {
2237
-		$this->set_ip( $value );
2236
+	public function set_user_ip($value) {
2237
+		$this->set_ip($value);
2238 2238
     }
2239 2239
 
2240 2240
     /**
@@ -2243,8 +2243,8 @@  discard block
 block discarded – undo
2243 2243
 	 * @since 1.0.19
2244 2244
 	 * @param  string $value first name.
2245 2245
 	 */
2246
-	public function set_first_name( $value ) {
2247
-		$this->set_prop( 'first_name', $value );
2246
+	public function set_first_name($value) {
2247
+		$this->set_prop('first_name', $value);
2248 2248
     }
2249 2249
 
2250 2250
     /**
@@ -2253,8 +2253,8 @@  discard block
 block discarded – undo
2253 2253
 	 * @since 1.0.19
2254 2254
 	 * @param  string $value first name.
2255 2255
 	 */
2256
-	public function set_user_first_name( $value ) {
2257
-		$this->set_first_name( $value );
2256
+	public function set_user_first_name($value) {
2257
+		$this->set_first_name($value);
2258 2258
     }
2259 2259
 
2260 2260
     /**
@@ -2263,8 +2263,8 @@  discard block
 block discarded – undo
2263 2263
 	 * @since 1.0.19
2264 2264
 	 * @param  string $value first name.
2265 2265
 	 */
2266
-	public function set_customer_first_name( $value ) {
2267
-		$this->set_first_name( $value );
2266
+	public function set_customer_first_name($value) {
2267
+		$this->set_first_name($value);
2268 2268
     }
2269 2269
 
2270 2270
     /**
@@ -2273,8 +2273,8 @@  discard block
 block discarded – undo
2273 2273
 	 * @since 1.0.19
2274 2274
 	 * @param  string $value last name.
2275 2275
 	 */
2276
-	public function set_last_name( $value ) {
2277
-		$this->set_prop( 'last_name', $value );
2276
+	public function set_last_name($value) {
2277
+		$this->set_prop('last_name', $value);
2278 2278
     }
2279 2279
 
2280 2280
     /**
@@ -2283,8 +2283,8 @@  discard block
 block discarded – undo
2283 2283
 	 * @since 1.0.19
2284 2284
 	 * @param  string $value last name.
2285 2285
 	 */
2286
-	public function set_user_last_name( $value ) {
2287
-		$this->set_last_name( $value );
2286
+	public function set_user_last_name($value) {
2287
+		$this->set_last_name($value);
2288 2288
     }
2289 2289
 
2290 2290
     /**
@@ -2293,8 +2293,8 @@  discard block
 block discarded – undo
2293 2293
 	 * @since 1.0.19
2294 2294
 	 * @param  string $value last name.
2295 2295
 	 */
2296
-	public function set_customer_last_name( $value ) {
2297
-		$this->set_last_name( $value );
2296
+	public function set_customer_last_name($value) {
2297
+		$this->set_last_name($value);
2298 2298
     }
2299 2299
 
2300 2300
     /**
@@ -2303,8 +2303,8 @@  discard block
 block discarded – undo
2303 2303
 	 * @since 1.0.19
2304 2304
 	 * @param  string $value phone.
2305 2305
 	 */
2306
-	public function set_phone( $value ) {
2307
-		$this->set_prop( 'phone', $value );
2306
+	public function set_phone($value) {
2307
+		$this->set_prop('phone', $value);
2308 2308
     }
2309 2309
 
2310 2310
     /**
@@ -2313,8 +2313,8 @@  discard block
 block discarded – undo
2313 2313
 	 * @since 1.0.19
2314 2314
 	 * @param  string $value phone.
2315 2315
 	 */
2316
-	public function set_user_phone( $value ) {
2317
-		$this->set_phone( $value );
2316
+	public function set_user_phone($value) {
2317
+		$this->set_phone($value);
2318 2318
     }
2319 2319
 
2320 2320
     /**
@@ -2323,8 +2323,8 @@  discard block
 block discarded – undo
2323 2323
 	 * @since 1.0.19
2324 2324
 	 * @param  string $value phone.
2325 2325
 	 */
2326
-	public function set_customer_phone( $value ) {
2327
-		$this->set_phone( $value );
2326
+	public function set_customer_phone($value) {
2327
+		$this->set_phone($value);
2328 2328
     }
2329 2329
 
2330 2330
     /**
@@ -2333,8 +2333,8 @@  discard block
 block discarded – undo
2333 2333
 	 * @since 1.0.19
2334 2334
 	 * @param  string $value phone.
2335 2335
 	 */
2336
-	public function set_phone_number( $value ) {
2337
-		$this->set_phone( $value );
2336
+	public function set_phone_number($value) {
2337
+		$this->set_phone($value);
2338 2338
     }
2339 2339
 
2340 2340
     /**
@@ -2343,8 +2343,8 @@  discard block
 block discarded – undo
2343 2343
 	 * @since 1.0.19
2344 2344
 	 * @param  string $value email address.
2345 2345
 	 */
2346
-	public function set_email( $value ) {
2347
-		$this->set_prop( 'email', $value );
2346
+	public function set_email($value) {
2347
+		$this->set_prop('email', $value);
2348 2348
     }
2349 2349
 
2350 2350
     /**
@@ -2353,8 +2353,8 @@  discard block
 block discarded – undo
2353 2353
 	 * @since 1.0.19
2354 2354
 	 * @param  string $value email address.
2355 2355
 	 */
2356
-	public function set_user_email( $value ) {
2357
-		$this->set_email( $value );
2356
+	public function set_user_email($value) {
2357
+		$this->set_email($value);
2358 2358
     }
2359 2359
 
2360 2360
     /**
@@ -2363,8 +2363,8 @@  discard block
 block discarded – undo
2363 2363
 	 * @since 1.0.19
2364 2364
 	 * @param  string $value email address.
2365 2365
 	 */
2366
-	public function set_email_address( $value ) {
2367
-		$this->set_email( $value );
2366
+	public function set_email_address($value) {
2367
+		$this->set_email($value);
2368 2368
     }
2369 2369
 
2370 2370
     /**
@@ -2373,8 +2373,8 @@  discard block
 block discarded – undo
2373 2373
 	 * @since 1.0.19
2374 2374
 	 * @param  string $value email address.
2375 2375
 	 */
2376
-	public function set_customer_email( $value ) {
2377
-		$this->set_email( $value );
2376
+	public function set_customer_email($value) {
2377
+		$this->set_email($value);
2378 2378
     }
2379 2379
 
2380 2380
     /**
@@ -2383,8 +2383,8 @@  discard block
 block discarded – undo
2383 2383
 	 * @since 1.0.19
2384 2384
 	 * @param  string $value country.
2385 2385
 	 */
2386
-	public function set_country( $value ) {
2387
-		$this->set_prop( 'country', $value );
2386
+	public function set_country($value) {
2387
+		$this->set_prop('country', $value);
2388 2388
     }
2389 2389
 
2390 2390
     /**
@@ -2393,8 +2393,8 @@  discard block
 block discarded – undo
2393 2393
 	 * @since 1.0.19
2394 2394
 	 * @param  string $value country.
2395 2395
 	 */
2396
-	public function set_user_country( $value ) {
2397
-		$this->set_country( $value );
2396
+	public function set_user_country($value) {
2397
+		$this->set_country($value);
2398 2398
     }
2399 2399
 
2400 2400
     /**
@@ -2403,8 +2403,8 @@  discard block
 block discarded – undo
2403 2403
 	 * @since 1.0.19
2404 2404
 	 * @param  string $value country.
2405 2405
 	 */
2406
-	public function set_customer_country( $value ) {
2407
-		$this->set_country( $value );
2406
+	public function set_customer_country($value) {
2407
+		$this->set_country($value);
2408 2408
     }
2409 2409
 
2410 2410
     /**
@@ -2413,8 +2413,8 @@  discard block
 block discarded – undo
2413 2413
 	 * @since 1.0.19
2414 2414
 	 * @param  string $value state.
2415 2415
 	 */
2416
-	public function set_state( $value ) {
2417
-		$this->set_prop( 'state', $value );
2416
+	public function set_state($value) {
2417
+		$this->set_prop('state', $value);
2418 2418
     }
2419 2419
 
2420 2420
     /**
@@ -2423,8 +2423,8 @@  discard block
 block discarded – undo
2423 2423
 	 * @since 1.0.19
2424 2424
 	 * @param  string $value state.
2425 2425
 	 */
2426
-	public function set_user_state( $value ) {
2427
-		$this->set_state( $value );
2426
+	public function set_user_state($value) {
2427
+		$this->set_state($value);
2428 2428
     }
2429 2429
 
2430 2430
     /**
@@ -2433,8 +2433,8 @@  discard block
 block discarded – undo
2433 2433
 	 * @since 1.0.19
2434 2434
 	 * @param  string $value state.
2435 2435
 	 */
2436
-	public function set_customer_state( $value ) {
2437
-		$this->set_state( $value );
2436
+	public function set_customer_state($value) {
2437
+		$this->set_state($value);
2438 2438
     }
2439 2439
 
2440 2440
     /**
@@ -2443,8 +2443,8 @@  discard block
 block discarded – undo
2443 2443
 	 * @since 1.0.19
2444 2444
 	 * @param  string $value city.
2445 2445
 	 */
2446
-	public function set_city( $value ) {
2447
-		$this->set_prop( 'city', $value );
2446
+	public function set_city($value) {
2447
+		$this->set_prop('city', $value);
2448 2448
     }
2449 2449
 
2450 2450
     /**
@@ -2453,8 +2453,8 @@  discard block
 block discarded – undo
2453 2453
 	 * @since 1.0.19
2454 2454
 	 * @param  string $value city.
2455 2455
 	 */
2456
-	public function set_user_city( $value ) {
2457
-		$this->set_city( $value );
2456
+	public function set_user_city($value) {
2457
+		$this->set_city($value);
2458 2458
     }
2459 2459
 
2460 2460
     /**
@@ -2463,8 +2463,8 @@  discard block
 block discarded – undo
2463 2463
 	 * @since 1.0.19
2464 2464
 	 * @param  string $value city.
2465 2465
 	 */
2466
-	public function set_customer_city( $value ) {
2467
-		$this->set_city( $value );
2466
+	public function set_customer_city($value) {
2467
+		$this->set_city($value);
2468 2468
     }
2469 2469
 
2470 2470
     /**
@@ -2473,8 +2473,8 @@  discard block
 block discarded – undo
2473 2473
 	 * @since 1.0.19
2474 2474
 	 * @param  string $value zip.
2475 2475
 	 */
2476
-	public function set_zip( $value ) {
2477
-		$this->set_prop( 'zip', $value );
2476
+	public function set_zip($value) {
2477
+		$this->set_prop('zip', $value);
2478 2478
     }
2479 2479
 
2480 2480
     /**
@@ -2483,8 +2483,8 @@  discard block
 block discarded – undo
2483 2483
 	 * @since 1.0.19
2484 2484
 	 * @param  string $value zip.
2485 2485
 	 */
2486
-	public function set_user_zip( $value ) {
2487
-		$this->set_zip( $value );
2486
+	public function set_user_zip($value) {
2487
+		$this->set_zip($value);
2488 2488
     }
2489 2489
 
2490 2490
     /**
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	 * @since 1.0.19
2494 2494
 	 * @param  string $value zip.
2495 2495
 	 */
2496
-	public function set_customer_zip( $value ) {
2497
-		$this->set_zip( $value );
2496
+	public function set_customer_zip($value) {
2497
+		$this->set_zip($value);
2498 2498
     }
2499 2499
 
2500 2500
     /**
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
 	 * @since 1.0.19
2504 2504
 	 * @param  string $value company.
2505 2505
 	 */
2506
-	public function set_company( $value ) {
2507
-		$this->set_prop( 'company', $value );
2506
+	public function set_company($value) {
2507
+		$this->set_prop('company', $value);
2508 2508
     }
2509 2509
 
2510 2510
     /**
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 	 * @since 1.0.19
2514 2514
 	 * @param  string $value company.
2515 2515
 	 */
2516
-	public function set_user_company( $value ) {
2517
-		$this->set_company( $value );
2516
+	public function set_user_company($value) {
2517
+		$this->set_company($value);
2518 2518
     }
2519 2519
 
2520 2520
     /**
@@ -2523,8 +2523,8 @@  discard block
 block discarded – undo
2523 2523
 	 * @since 1.0.19
2524 2524
 	 * @param  string $value company.
2525 2525
 	 */
2526
-	public function set_customer_company( $value ) {
2527
-		$this->set_company( $value );
2526
+	public function set_customer_company($value) {
2527
+		$this->set_company($value);
2528 2528
     }
2529 2529
 
2530 2530
     /**
@@ -2533,8 +2533,8 @@  discard block
 block discarded – undo
2533 2533
 	 * @since 1.0.19
2534 2534
 	 * @param  string $value var number.
2535 2535
 	 */
2536
-	public function set_vat_number( $value ) {
2537
-		$this->set_prop( 'vat_number', $value );
2536
+	public function set_vat_number($value) {
2537
+		$this->set_prop('vat_number', $value);
2538 2538
     }
2539 2539
 
2540 2540
     /**
@@ -2543,8 +2543,8 @@  discard block
 block discarded – undo
2543 2543
 	 * @since 1.0.19
2544 2544
 	 * @param  string $value var number.
2545 2545
 	 */
2546
-	public function set_user_vat_number( $value ) {
2547
-		$this->set_vat_number( $value );
2546
+	public function set_user_vat_number($value) {
2547
+		$this->set_vat_number($value);
2548 2548
     }
2549 2549
 
2550 2550
     /**
@@ -2553,8 +2553,8 @@  discard block
 block discarded – undo
2553 2553
 	 * @since 1.0.19
2554 2554
 	 * @param  string $value var number.
2555 2555
 	 */
2556
-	public function set_customer_vat_number( $value ) {
2557
-		$this->set_vat_number( $value );
2556
+	public function set_customer_vat_number($value) {
2557
+		$this->set_vat_number($value);
2558 2558
     }
2559 2559
 
2560 2560
     /**
@@ -2563,8 +2563,8 @@  discard block
 block discarded – undo
2563 2563
 	 * @since 1.0.19
2564 2564
 	 * @param  string $value var rate.
2565 2565
 	 */
2566
-	public function set_vat_rate( $value ) {
2567
-		$this->set_prop( 'vat_rate', $value );
2566
+	public function set_vat_rate($value) {
2567
+		$this->set_prop('vat_rate', $value);
2568 2568
     }
2569 2569
 
2570 2570
     /**
@@ -2573,8 +2573,8 @@  discard block
 block discarded – undo
2573 2573
 	 * @since 1.0.19
2574 2574
 	 * @param  string $value var number.
2575 2575
 	 */
2576
-	public function set_user_vat_rate( $value ) {
2577
-		$this->set_vat_rate( $value );
2576
+	public function set_user_vat_rate($value) {
2577
+		$this->set_vat_rate($value);
2578 2578
     }
2579 2579
 
2580 2580
     /**
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
 	 * @since 1.0.19
2584 2584
 	 * @param  string $value var number.
2585 2585
 	 */
2586
-	public function set_customer_vat_rate( $value ) {
2587
-		$this->set_vat_rate( $value );
2586
+	public function set_customer_vat_rate($value) {
2587
+		$this->set_vat_rate($value);
2588 2588
     }
2589 2589
 
2590 2590
     /**
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
 	 * @since 1.0.19
2594 2594
 	 * @param  string $value address.
2595 2595
 	 */
2596
-	public function set_address( $value ) {
2597
-		$this->set_prop( 'address', $value );
2596
+	public function set_address($value) {
2597
+		$this->set_prop('address', $value);
2598 2598
     }
2599 2599
 
2600 2600
     /**
@@ -2603,8 +2603,8 @@  discard block
 block discarded – undo
2603 2603
 	 * @since 1.0.19
2604 2604
 	 * @param  string $value address.
2605 2605
 	 */
2606
-	public function set_user_address( $value ) {
2607
-		$this->set_address( $value );
2606
+	public function set_user_address($value) {
2607
+		$this->set_address($value);
2608 2608
     }
2609 2609
 
2610 2610
     /**
@@ -2613,8 +2613,8 @@  discard block
 block discarded – undo
2613 2613
 	 * @since 1.0.19
2614 2614
 	 * @param  string $value address.
2615 2615
 	 */
2616
-	public function set_customer_address( $value ) {
2617
-		$this->set_address( $value );
2616
+	public function set_customer_address($value) {
2617
+		$this->set_address($value);
2618 2618
     }
2619 2619
 
2620 2620
     /**
@@ -2623,8 +2623,8 @@  discard block
 block discarded – undo
2623 2623
 	 * @since 1.0.19
2624 2624
 	 * @param  int|bool $value confirmed.
2625 2625
 	 */
2626
-	public function set_is_viewed( $value ) {
2627
-		$this->set_prop( 'is_viewed', $value );
2626
+	public function set_is_viewed($value) {
2627
+		$this->set_prop('is_viewed', $value);
2628 2628
 	}
2629 2629
 
2630 2630
 	/**
@@ -2633,8 +2633,8 @@  discard block
 block discarded – undo
2633 2633
 	 * @since 1.0.19
2634 2634
 	 * @param  string $value email recipients.
2635 2635
 	 */
2636
-	public function set_email_cc( $value ) {
2637
-		$this->set_prop( 'email_cc', $value );
2636
+	public function set_email_cc($value) {
2637
+		$this->set_prop('email_cc', $value);
2638 2638
 	}
2639 2639
 
2640 2640
 	/**
@@ -2643,9 +2643,9 @@  discard block
 block discarded – undo
2643 2643
 	 * @since 1.0.19
2644 2644
 	 * @param  string $value template.
2645 2645
 	 */
2646
-	public function set_template( $value ) {
2647
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2648
-			$this->set_prop( 'template', $value );
2646
+	public function set_template($value) {
2647
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2648
+			$this->set_prop('template', $value);
2649 2649
 		}
2650 2650
 	}
2651 2651
 
@@ -2655,8 +2655,8 @@  discard block
 block discarded – undo
2655 2655
 	 * @since 1.0.19
2656 2656
 	 * @param  string $value email recipients.
2657 2657
 	 */
2658
-	public function created_via( $value ) {
2659
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2658
+	public function created_via($value) {
2659
+		$this->set_prop('created_via', sanitize_text_field($value));
2660 2660
 	}
2661 2661
 
2662 2662
 	/**
@@ -2665,8 +2665,8 @@  discard block
 block discarded – undo
2665 2665
 	 * @since 1.0.19
2666 2666
 	 * @param  int|bool $value confirmed.
2667 2667
 	 */
2668
-	public function set_address_confirmed( $value ) {
2669
-		$this->set_prop( 'address_confirmed', $value );
2668
+	public function set_address_confirmed($value) {
2669
+		$this->set_prop('address_confirmed', $value);
2670 2670
     }
2671 2671
 
2672 2672
     /**
@@ -2675,8 +2675,8 @@  discard block
 block discarded – undo
2675 2675
 	 * @since 1.0.19
2676 2676
 	 * @param  int|bool $value confirmed.
2677 2677
 	 */
2678
-	public function set_user_address_confirmed( $value ) {
2679
-		$this->set_address_confirmed( $value );
2678
+	public function set_user_address_confirmed($value) {
2679
+		$this->set_address_confirmed($value);
2680 2680
     }
2681 2681
 
2682 2682
     /**
@@ -2685,8 +2685,8 @@  discard block
 block discarded – undo
2685 2685
 	 * @since 1.0.19
2686 2686
 	 * @param  int|bool $value confirmed.
2687 2687
 	 */
2688
-	public function set_customer_address_confirmed( $value ) {
2689
-		$this->set_address_confirmed( $value );
2688
+	public function set_customer_address_confirmed($value) {
2689
+		$this->set_address_confirmed($value);
2690 2690
     }
2691 2691
 
2692 2692
     /**
@@ -2695,8 +2695,8 @@  discard block
 block discarded – undo
2695 2695
 	 * @since 1.0.19
2696 2696
 	 * @param  float $value sub total.
2697 2697
 	 */
2698
-	public function set_subtotal( $value ) {
2699
-		$this->set_prop( 'subtotal', $value );
2698
+	public function set_subtotal($value) {
2699
+		$this->set_prop('subtotal', $value);
2700 2700
     }
2701 2701
 
2702 2702
     /**
@@ -2705,8 +2705,8 @@  discard block
 block discarded – undo
2705 2705
 	 * @since 1.0.19
2706 2706
 	 * @param  float $value discount total.
2707 2707
 	 */
2708
-	public function set_total_discount( $value ) {
2709
-		$this->set_prop( 'total_discount', $value );
2708
+	public function set_total_discount($value) {
2709
+		$this->set_prop('total_discount', $value);
2710 2710
     }
2711 2711
 
2712 2712
     /**
@@ -2715,8 +2715,8 @@  discard block
 block discarded – undo
2715 2715
 	 * @since 1.0.19
2716 2716
 	 * @param  float $value discount total.
2717 2717
 	 */
2718
-	public function set_discount( $value ) {
2719
-		$this->set_total_discount( $value );
2718
+	public function set_discount($value) {
2719
+		$this->set_total_discount($value);
2720 2720
     }
2721 2721
 
2722 2722
     /**
@@ -2725,8 +2725,8 @@  discard block
 block discarded – undo
2725 2725
 	 * @since 1.0.19
2726 2726
 	 * @param  float $value tax total.
2727 2727
 	 */
2728
-	public function set_total_tax( $value ) {
2729
-		$this->set_prop( 'total_tax', $value );
2728
+	public function set_total_tax($value) {
2729
+		$this->set_prop('total_tax', $value);
2730 2730
     }
2731 2731
 
2732 2732
     /**
@@ -2735,8 +2735,8 @@  discard block
 block discarded – undo
2735 2735
 	 * @since 1.0.19
2736 2736
 	 * @param  float $value tax total.
2737 2737
 	 */
2738
-	public function set_tax_total( $value ) {
2739
-		$this->set_total_tax( $value );
2738
+	public function set_tax_total($value) {
2739
+		$this->set_total_tax($value);
2740 2740
     }
2741 2741
 
2742 2742
     /**
@@ -2745,8 +2745,8 @@  discard block
 block discarded – undo
2745 2745
 	 * @since 1.0.19
2746 2746
 	 * @param  float $value fees total.
2747 2747
 	 */
2748
-	public function set_total_fees( $value ) {
2749
-		$this->set_prop( 'total_fees', $value );
2748
+	public function set_total_fees($value) {
2749
+		$this->set_prop('total_fees', $value);
2750 2750
     }
2751 2751
 
2752 2752
     /**
@@ -2755,8 +2755,8 @@  discard block
 block discarded – undo
2755 2755
 	 * @since 1.0.19
2756 2756
 	 * @param  float $value fees total.
2757 2757
 	 */
2758
-	public function set_fees_total( $value ) {
2759
-		$this->set_total_fees( $value );
2758
+	public function set_fees_total($value) {
2759
+		$this->set_total_fees($value);
2760 2760
     }
2761 2761
 
2762 2762
     /**
@@ -2765,13 +2765,13 @@  discard block
 block discarded – undo
2765 2765
 	 * @since 1.0.19
2766 2766
 	 * @param  array $value fees.
2767 2767
 	 */
2768
-	public function set_fees( $value ) {
2768
+	public function set_fees($value) {
2769 2769
 
2770
-		if ( ! is_array( $value ) ) {
2770
+		if (!is_array($value)) {
2771 2771
 			$value = array();
2772 2772
 		}
2773 2773
 
2774
-		$this->set_prop( 'fees', $value );
2774
+		$this->set_prop('fees', $value);
2775 2775
 
2776 2776
     }
2777 2777
 
@@ -2781,13 +2781,13 @@  discard block
 block discarded – undo
2781 2781
 	 * @since 1.0.19
2782 2782
 	 * @param  array $value taxes.
2783 2783
 	 */
2784
-	public function set_taxes( $value ) {
2784
+	public function set_taxes($value) {
2785 2785
 
2786
-		if ( ! is_array( $value ) ) {
2786
+		if (!is_array($value)) {
2787 2787
 			$value = array();
2788 2788
 		}
2789 2789
 
2790
-		$this->set_prop( 'taxes', $value );
2790
+		$this->set_prop('taxes', $value);
2791 2791
 
2792 2792
     }
2793 2793
 
@@ -2797,13 +2797,13 @@  discard block
 block discarded – undo
2797 2797
 	 * @since 1.0.19
2798 2798
 	 * @param  array $value discounts.
2799 2799
 	 */
2800
-	public function set_discounts( $value ) {
2800
+	public function set_discounts($value) {
2801 2801
 
2802
-		if ( ! is_array( $value ) ) {
2802
+		if (!is_array($value)) {
2803 2803
 			$value = array();
2804 2804
 		}
2805 2805
 
2806
-		$this->set_prop( 'discounts', $value );
2806
+		$this->set_prop('discounts', $value);
2807 2807
     }
2808 2808
 
2809 2809
     /**
@@ -2812,18 +2812,18 @@  discard block
 block discarded – undo
2812 2812
 	 * @since 1.0.19
2813 2813
 	 * @param  GetPaid_Form_Item[] $value items.
2814 2814
 	 */
2815
-	public function set_items( $value ) {
2815
+	public function set_items($value) {
2816 2816
 
2817 2817
         // Remove existing items.
2818
-        $this->set_prop( 'items', array() );
2818
+        $this->set_prop('items', array());
2819 2819
 
2820 2820
         // Ensure that we have an array.
2821
-        if ( ! is_array( $value ) ) {
2821
+        if (!is_array($value)) {
2822 2822
             return;
2823 2823
         }
2824 2824
 
2825
-        foreach ( $value as $item ) {
2826
-            $this->add_item( $item );
2825
+        foreach ($value as $item) {
2826
+            $this->add_item($item);
2827 2827
         }
2828 2828
 
2829 2829
     }
@@ -2834,8 +2834,8 @@  discard block
 block discarded – undo
2834 2834
 	 * @since 1.0.19
2835 2835
 	 * @param  int $value payment form.
2836 2836
 	 */
2837
-	public function set_payment_form( $value ) {
2838
-		$this->set_prop( 'payment_form', $value );
2837
+	public function set_payment_form($value) {
2838
+		$this->set_prop('payment_form', $value);
2839 2839
     }
2840 2840
 
2841 2841
     /**
@@ -2844,8 +2844,8 @@  discard block
 block discarded – undo
2844 2844
 	 * @since 1.0.19
2845 2845
 	 * @param  string $value submission id.
2846 2846
 	 */
2847
-	public function set_submission_id( $value ) {
2848
-		$this->set_prop( 'submission_id', $value );
2847
+	public function set_submission_id($value) {
2848
+		$this->set_prop('submission_id', $value);
2849 2849
     }
2850 2850
 
2851 2851
     /**
@@ -2854,8 +2854,8 @@  discard block
 block discarded – undo
2854 2854
 	 * @since 1.0.19
2855 2855
 	 * @param  string $value discount code.
2856 2856
 	 */
2857
-	public function set_discount_code( $value ) {
2858
-		$this->set_prop( 'discount_code', $value );
2857
+	public function set_discount_code($value) {
2858
+		$this->set_prop('discount_code', $value);
2859 2859
     }
2860 2860
 
2861 2861
     /**
@@ -2864,8 +2864,8 @@  discard block
 block discarded – undo
2864 2864
 	 * @since 1.0.19
2865 2865
 	 * @param  string $value gateway.
2866 2866
 	 */
2867
-	public function set_gateway( $value ) {
2868
-		$this->set_prop( 'gateway', $value );
2867
+	public function set_gateway($value) {
2868
+		$this->set_prop('gateway', $value);
2869 2869
     }
2870 2870
 
2871 2871
     /**
@@ -2874,9 +2874,9 @@  discard block
 block discarded – undo
2874 2874
 	 * @since 1.0.19
2875 2875
 	 * @param  string $value transaction id.
2876 2876
 	 */
2877
-	public function set_transaction_id( $value ) {
2878
-		if ( ! empty( $value ) ) {
2879
-			$this->set_prop( 'transaction_id', $value );
2877
+	public function set_transaction_id($value) {
2878
+		if (!empty($value)) {
2879
+			$this->set_prop('transaction_id', $value);
2880 2880
 		}
2881 2881
     }
2882 2882
 
@@ -2886,8 +2886,8 @@  discard block
 block discarded – undo
2886 2886
 	 * @since 1.0.19
2887 2887
 	 * @param  string $value currency id.
2888 2888
 	 */
2889
-	public function set_currency( $value ) {
2890
-		$this->set_prop( 'currency', $value );
2889
+	public function set_currency($value) {
2890
+		$this->set_prop('currency', $value);
2891 2891
     }
2892 2892
 
2893 2893
 	/**
@@ -2896,8 +2896,8 @@  discard block
 block discarded – undo
2896 2896
 	 * @since 1.0.19
2897 2897
 	 * @param  bool $value value.
2898 2898
 	 */
2899
-	public function set_disable_taxes( $value ) {
2900
-		$this->set_prop( 'disable_taxes', (bool) $value );
2899
+	public function set_disable_taxes($value) {
2900
+		$this->set_prop('disable_taxes', (bool) $value);
2901 2901
 	}
2902 2902
 
2903 2903
     /**
@@ -2906,8 +2906,8 @@  discard block
 block discarded – undo
2906 2906
 	 * @since 1.0.19
2907 2907
 	 * @param  string $value subscription id.
2908 2908
 	 */
2909
-	public function set_subscription_id( $value ) {
2910
-		$this->set_prop( 'subscription_id', $value );
2909
+	public function set_subscription_id($value) {
2910
+		$this->set_prop('subscription_id', $value);
2911 2911
 	}
2912 2912
 	
2913 2913
 	/**
@@ -2916,8 +2916,8 @@  discard block
 block discarded – undo
2916 2916
 	 * @since 1.0.19
2917 2917
 	 * @param  string $value subscription id.
2918 2918
 	 */
2919
-	public function set_remote_subscription_id( $value ) {
2920
-		$this->set_prop( 'remote_subscription_id', $value );
2919
+	public function set_remote_subscription_id($value) {
2920
+		$this->set_prop('remote_subscription_id', $value);
2921 2921
     }
2922 2922
 
2923 2923
     /*
@@ -2934,28 +2934,28 @@  discard block
 block discarded – undo
2934 2934
      */
2935 2935
     public function is_parent() {
2936 2936
         $parent = $this->get_parent_id();
2937
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2937
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2938 2938
     }
2939 2939
 
2940 2940
     /**
2941 2941
      * Checks if this is a renewal invoice.
2942 2942
      */
2943 2943
     public function is_renewal() {
2944
-        return ! $this->is_parent();
2944
+        return !$this->is_parent();
2945 2945
     }
2946 2946
 
2947 2947
     /**
2948 2948
      * Checks if this is a recurring invoice.
2949 2949
      */
2950 2950
     public function is_recurring() {
2951
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2951
+        return $this->is_renewal() || !empty($this->recurring_item);
2952 2952
     }
2953 2953
 
2954 2954
     /**
2955 2955
      * Checks if this is a taxable invoice.
2956 2956
      */
2957 2957
     public function is_taxable() {
2958
-        return ! $this->get_disable_taxes();
2958
+        return !$this->get_disable_taxes();
2959 2959
 	}
2960 2960
 
2961 2961
 	/**
@@ -2969,45 +2969,45 @@  discard block
 block discarded – undo
2969 2969
 	 * Checks to see if the invoice requires payment.
2970 2970
 	 */
2971 2971
 	public function is_free() {
2972
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2972
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2973 2973
 
2974
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2974
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2975 2975
 			$is_free = false;
2976 2976
 		}
2977 2977
 
2978
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2978
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2979 2979
     }
2980 2980
 
2981 2981
     /**
2982 2982
      * Checks if the invoice is paid.
2983 2983
      */
2984 2984
     public function is_paid() {
2985
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2986
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2985
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2986
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2987 2987
 	}
2988 2988
 
2989 2989
 	/**
2990 2990
      * Checks if the invoice needs payment.
2991 2991
      */
2992 2992
 	public function needs_payment() {
2993
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2994
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2993
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2994
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2995 2995
     }
2996 2996
   
2997 2997
 	/**
2998 2998
      * Checks if the invoice is refunded.
2999 2999
      */
3000 3000
 	public function is_refunded() {
3001
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3002
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3001
+        $is_refunded = $this->has_status('wpi-refunded');
3002
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3003 3003
 	}
3004 3004
 
3005 3005
 	/**
3006 3006
      * Checks if the invoice is held.
3007 3007
      */
3008 3008
 	public function is_held() {
3009
-        $is_held = $this->has_status( 'wpi-onhold' );
3010
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3009
+        $is_held = $this->has_status('wpi-onhold');
3010
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3011 3011
 	}
3012 3012
 
3013 3013
 	/**
@@ -3015,30 +3015,30 @@  discard block
 block discarded – undo
3015 3015
      */
3016 3016
 	public function is_due() {
3017 3017
 		$due_date = $this->get_due_date();
3018
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3018
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3019 3019
 	}
3020 3020
 
3021 3021
 	/**
3022 3022
      * Checks if the invoice is draft.
3023 3023
      */
3024 3024
 	public function is_draft() {
3025
-        return $this->has_status( 'draft, auto-draft' );
3025
+        return $this->has_status('draft, auto-draft');
3026 3026
 	}
3027 3027
 
3028 3028
     /**
3029 3029
      * Checks if the invoice has a given status.
3030 3030
      */
3031
-    public function has_status( $status ) {
3032
-        $status = wpinv_parse_list( $status );
3033
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3031
+    public function has_status($status) {
3032
+        $status = wpinv_parse_list($status);
3033
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3034 3034
 	}
3035 3035
 
3036 3036
 	/**
3037 3037
      * Checks if the invoice is of a given type.
3038 3038
      */
3039
-    public function is_type( $type ) {
3040
-        $type = wpinv_parse_list( $type );
3041
-        return in_array( $this->get_type(), $type );
3039
+    public function is_type($type) {
3040
+        $type = wpinv_parse_list($type);
3041
+        return in_array($this->get_type(), $type);
3042 3042
     }
3043 3043
 
3044 3044
     /**
@@ -3070,8 +3070,8 @@  discard block
 block discarded – undo
3070 3070
      *
3071 3071
      */
3072 3072
 	public function is_initial_free() {
3073
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3074
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3073
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3074
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3075 3075
     }
3076 3076
 	
3077 3077
 	/**
@@ -3081,11 +3081,11 @@  discard block
 block discarded – undo
3081 3081
     public function item_has_free_trial() {
3082 3082
 
3083 3083
         // Ensure we have a recurring item.
3084
-        if ( ! $this->is_recurring() ) {
3084
+        if (!$this->is_recurring()) {
3085 3085
             return false;
3086 3086
         }
3087 3087
 
3088
-        $item = $this->get_recurring( true );
3088
+        $item = $this->get_recurring(true);
3089 3089
         return $item->has_free_trial();
3090 3090
 	}
3091 3091
 
@@ -3093,7 +3093,7 @@  discard block
 block discarded – undo
3093 3093
      * Check if the free trial is a result of a discount.
3094 3094
      */
3095 3095
     public function is_free_trial_from_discount() {
3096
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3096
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3097 3097
 	}
3098 3098
 	
3099 3099
 	/**
@@ -3101,12 +3101,12 @@  discard block
 block discarded – undo
3101 3101
      */
3102 3102
     public function discount_first_payment_only() {
3103 3103
 
3104
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3105
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3104
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3105
+        if (!$discount->exists() || !$this->is_recurring()) {
3106 3106
             return true;
3107 3107
         }
3108 3108
 
3109
-        return ! $discount->get_is_recurring();
3109
+        return !$discount->get_is_recurring();
3110 3110
     }
3111 3111
 
3112 3112
     /*
@@ -3124,27 +3124,27 @@  discard block
 block discarded – undo
3124 3124
      * @param GetPaid_Form_Item|array $item
3125 3125
      * @return WP_Error|Bool
3126 3126
      */
3127
-    public function add_item( $item ) {
3127
+    public function add_item($item) {
3128 3128
 
3129
-		if ( is_array( $item ) ) {
3130
-			$item = $this->process_array_item( $item );
3129
+		if (is_array($item)) {
3130
+			$item = $this->process_array_item($item);
3131 3131
 		}
3132 3132
 
3133
-		if ( is_numeric( $item ) ) {
3134
-			$item = new GetPaid_Form_Item( $item );
3133
+		if (is_numeric($item)) {
3134
+			$item = new GetPaid_Form_Item($item);
3135 3135
 		}
3136 3136
 
3137 3137
         // Make sure that it is available for purchase.
3138
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3139
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3138
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3139
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3140 3140
         }
3141 3141
 
3142 3142
         // Do we have a recurring item?
3143
-		if ( $item->is_recurring() ) {
3143
+		if ($item->is_recurring()) {
3144 3144
 
3145 3145
 			// An invoice can only contain one recurring item.
3146
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3147
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3146
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3147
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3148 3148
 			}
3149 3149
 
3150 3150
 			$this->recurring_item = $item->get_id();
@@ -3155,9 +3155,9 @@  discard block
 block discarded – undo
3155 3155
 
3156 3156
         // Retrieve all items.
3157 3157
         $items = $this->get_items();
3158
-        $items[ (int) $item->get_id() ] = $item;
3158
+        $items[(int) $item->get_id()] = $item;
3159 3159
 
3160
-        $this->set_prop( 'items', $items );
3160
+        $this->set_prop('items', $items);
3161 3161
 		return true;
3162 3162
 	}
3163 3163
 
@@ -3167,26 +3167,26 @@  discard block
 block discarded – undo
3167 3167
 	 * @since 1.0.19
3168 3168
 	 * @return GetPaid_Form_Item
3169 3169
 	 */
3170
-	protected function process_array_item( $array ) {
3170
+	protected function process_array_item($array) {
3171 3171
 
3172
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3173
-		$item    = new GetPaid_Form_Item( $item_id );
3172
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3173
+		$item    = new GetPaid_Form_Item($item_id);
3174 3174
 
3175 3175
 		// Set item data.
3176
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3177
-			if ( isset( $array[ "item_$key" ] ) ) {
3176
+		foreach (array('name', 'price', 'description') as $key) {
3177
+			if (isset($array["item_$key"])) {
3178 3178
 				$method = "set_$key";
3179
-				$item->$method( $array[ "item_$key" ] );
3179
+				$item->$method($array["item_$key"]);
3180 3180
 			}
3181 3181
 		}
3182 3182
 
3183
-		if ( isset( $array['quantity'] ) ) {
3184
-			$item->set_quantity( $array['quantity'] );
3183
+		if (isset($array['quantity'])) {
3184
+			$item->set_quantity($array['quantity']);
3185 3185
 		}
3186 3186
 
3187 3187
 		// Set item meta.
3188
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3189
-			$item->set_item_meta( $array['meta'] );
3188
+		if (isset($array['meta']) && is_array($array['meta'])) {
3189
+			$item->set_item_meta($array['meta']);
3190 3190
 		}
3191 3191
 
3192 3192
 		return $item;
@@ -3198,10 +3198,10 @@  discard block
 block discarded – undo
3198 3198
 	 *
3199 3199
 	 * @since 1.0.19
3200 3200
 	 */
3201
-	public function get_item( $item_id ) {
3201
+	public function get_item($item_id) {
3202 3202
 		$items   = $this->get_items();
3203 3203
 		$item_id = (int) $item_id;
3204
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3204
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3205 3205
     }
3206 3206
 
3207 3207
     /**
@@ -3209,17 +3209,17 @@  discard block
 block discarded – undo
3209 3209
 	 *
3210 3210
 	 * @since 1.0.19
3211 3211
 	 */
3212
-	public function remove_item( $item_id ) {
3212
+	public function remove_item($item_id) {
3213 3213
 		$items   = $this->get_items();
3214 3214
 		$item_id = (int) $item_id;
3215 3215
 
3216
-        if ( $item_id == $this->recurring_item ) {
3216
+        if ($item_id == $this->recurring_item) {
3217 3217
             $this->recurring_item = null;
3218 3218
         }
3219 3219
 
3220
-        if ( isset( $items[ $item_id ] ) ) {
3221
-            unset( $items[ $item_id ] );
3222
-            $this->set_prop( 'items', $items );
3220
+        if (isset($items[$item_id])) {
3221
+            unset($items[$item_id]);
3222
+            $this->set_prop('items', $items);
3223 3223
         }
3224 3224
     }
3225 3225
 
@@ -3229,11 +3229,11 @@  discard block
 block discarded – undo
3229 3229
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3230 3230
 	 * @since 1.0.19
3231 3231
 	 */
3232
-    public function add_fee( $fee ) {
3232
+    public function add_fee($fee) {
3233 3233
 
3234 3234
 		$fees                 = $this->get_fees();
3235
-		$fees[ $fee['name'] ] = $fee;
3236
-		$this->set_prop( 'fees', $fees );
3235
+		$fees[$fee['name']] = $fee;
3236
+		$this->set_prop('fees', $fees);
3237 3237
 
3238 3238
     }
3239 3239
 
@@ -3242,9 +3242,9 @@  discard block
 block discarded – undo
3242 3242
 	 *
3243 3243
 	 * @since 1.0.19
3244 3244
 	 */
3245
-	public function get_fee( $fee ) {
3245
+	public function get_fee($fee) {
3246 3246
         $fees = $this->get_fees();
3247
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3247
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3248 3248
     }
3249 3249
 
3250 3250
     /**
@@ -3252,11 +3252,11 @@  discard block
 block discarded – undo
3252 3252
 	 *
3253 3253
 	 * @since 1.0.19
3254 3254
 	 */
3255
-	public function remove_fee( $fee ) {
3255
+	public function remove_fee($fee) {
3256 3256
         $fees = $this->get_fees();
3257
-        if ( isset( $fees[ $fee ] ) ) {
3258
-            unset( $fees[ $fee ] );
3259
-            $this->set_prop( 'fees', $fees );
3257
+        if (isset($fees[$fee])) {
3258
+            unset($fees[$fee]);
3259
+            $this->set_prop('fees', $fees);
3260 3260
         }
3261 3261
     }
3262 3262
 
@@ -3266,11 +3266,11 @@  discard block
 block discarded – undo
3266 3266
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3267 3267
 	 * @since 1.0.19
3268 3268
 	 */
3269
-	public function add_discount( $discount ) {
3269
+	public function add_discount($discount) {
3270 3270
 
3271 3271
 		$discounts = $this->get_discounts();
3272
-		$discounts[ $discount['name'] ] = $discount;
3273
-		$this->set_prop( 'discounts', $discounts );
3272
+		$discounts[$discount['name']] = $discount;
3273
+		$this->set_prop('discounts', $discounts);
3274 3274
 
3275 3275
 	}
3276 3276
 
@@ -3280,15 +3280,15 @@  discard block
 block discarded – undo
3280 3280
 	 * @since 1.0.19
3281 3281
 	 * @return float
3282 3282
 	 */
3283
-	public function get_discount( $discount = false ) {
3283
+	public function get_discount($discount = false) {
3284 3284
 
3285 3285
 		// Backwards compatibilty.
3286
-		if ( empty( $discount ) ) {
3286
+		if (empty($discount)) {
3287 3287
 			return $this->get_total_discount();
3288 3288
 		}
3289 3289
 
3290 3290
         $discounts = $this->get_discounts();
3291
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3291
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3292 3292
     }
3293 3293
 
3294 3294
     /**
@@ -3296,11 +3296,11 @@  discard block
 block discarded – undo
3296 3296
 	 *
3297 3297
 	 * @since 1.0.19
3298 3298
 	 */
3299
-	public function remove_discount( $discount ) {
3299
+	public function remove_discount($discount) {
3300 3300
         $discounts = $this->get_discounts();
3301
-        if ( isset( $discounts[ $discount ] ) ) {
3302
-            unset( $discounts[ $discount ] );
3303
-            $this->set_prop( 'discounts', $discounts );
3301
+        if (isset($discounts[$discount])) {
3302
+            unset($discounts[$discount]);
3303
+            $this->set_prop('discounts', $discounts);
3304 3304
         }
3305 3305
     }
3306 3306
 
@@ -3309,12 +3309,12 @@  discard block
 block discarded – undo
3309 3309
      *
3310 3310
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3311 3311
      */
3312
-    public function add_tax( $tax ) {
3313
-        if ( $this->is_taxable() ) {
3312
+    public function add_tax($tax) {
3313
+        if ($this->is_taxable()) {
3314 3314
 
3315
-            $taxes                 = $this->get_taxes();
3316
-			$taxes[ $tax['name'] ] = $tax;
3317
-			$this->set_prop( 'taxes', $tax );
3315
+            $taxes = $this->get_taxes();
3316
+			$taxes[$tax['name']] = $tax;
3317
+			$this->set_prop('taxes', $tax);
3318 3318
 
3319 3319
         }
3320 3320
     }
@@ -3324,15 +3324,15 @@  discard block
 block discarded – undo
3324 3324
 	 *
3325 3325
 	 * @since 1.0.19
3326 3326
 	 */
3327
-	public function get_tax( $tax = null ) {
3327
+	public function get_tax($tax = null) {
3328 3328
 
3329 3329
 		// Backwards compatility.
3330
-		if ( empty( $tax ) ) {
3330
+		if (empty($tax)) {
3331 3331
 			return $this->get_total_tax();
3332 3332
 		}
3333 3333
 
3334 3334
         $taxes = $this->get_taxes();
3335
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3335
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3336 3336
     }
3337 3337
 
3338 3338
     /**
@@ -3340,11 +3340,11 @@  discard block
 block discarded – undo
3340 3340
 	 *
3341 3341
 	 * @since 1.0.19
3342 3342
 	 */
3343
-	public function remove_tax( $tax ) {
3343
+	public function remove_tax($tax) {
3344 3344
         $taxes = $this->get_taxes();
3345
-        if ( isset( $taxes[ $tax ] ) ) {
3346
-            unset( $taxes[ $tax ] );
3347
-            $this->set_prop( 'taxes', $taxes );
3345
+        if (isset($taxes[$tax])) {
3346
+            unset($taxes[$tax]);
3347
+            $this->set_prop('taxes', $taxes);
3348 3348
         }
3349 3349
     }
3350 3350
 
@@ -3355,17 +3355,17 @@  discard block
 block discarded – undo
3355 3355
 	 * @return float The recalculated subtotal
3356 3356
 	 */
3357 3357
 	public function recalculate_subtotal() {
3358
-        $items     = $this->get_items();
3358
+        $items = $this->get_items();
3359 3359
 		$subtotal  = 0;
3360 3360
 		$recurring = 0;
3361 3361
 
3362
-        foreach ( $items as $item ) {
3362
+        foreach ($items as $item) {
3363 3363
 			$subtotal  += $item->get_sub_total();
3364 3364
 			$recurring += $item->get_recurring_sub_total();
3365 3365
         }
3366 3366
 
3367 3367
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3368
-		$this->set_subtotal( $current );
3368
+		$this->set_subtotal($current);
3369 3369
 
3370 3370
 		$this->totals['subtotal'] = array(
3371 3371
 			'initial'   => $subtotal,
@@ -3386,14 +3386,14 @@  discard block
 block discarded – undo
3386 3386
 		$discount  = 0;
3387 3387
 		$recurring = 0;
3388 3388
 
3389
-        foreach ( $discounts as $data ) {
3390
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3391
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3389
+        foreach ($discounts as $data) {
3390
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3391
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3392 3392
 		}
3393 3393
 
3394 3394
 		$current = $this->is_renewal() ? $recurring : $discount;
3395 3395
 
3396
-		$this->set_total_discount( $current );
3396
+		$this->set_total_discount($current);
3397 3397
 
3398 3398
 		$this->totals['discount'] = array(
3399 3399
 			'initial'   => $discount,
@@ -3411,17 +3411,17 @@  discard block
 block discarded – undo
3411 3411
 	 * @return float The recalculated tax
3412 3412
 	 */
3413 3413
 	public function recalculate_total_tax() {
3414
-        $taxes     = $this->get_taxes();
3414
+        $taxes = $this->get_taxes();
3415 3415
 		$tax       = 0;
3416 3416
 		$recurring = 0;
3417 3417
 
3418
-        foreach ( $taxes as $data ) {
3419
-			$tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3420
-			$recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3418
+        foreach ($taxes as $data) {
3419
+			$tax       += wpinv_sanitize_amount($data['initial_tax']);
3420
+			$recurring += wpinv_sanitize_amount($data['recurring_tax']);
3421 3421
 		}
3422 3422
 
3423 3423
 		$current = $this->is_renewal() ? $recurring : $tax;
3424
-		$this->set_total_tax( $current );
3424
+		$this->set_total_tax($current);
3425 3425
 
3426 3426
 		$this->totals['tax'] = array(
3427 3427
 			'initial'   => $tax,
@@ -3443,20 +3443,20 @@  discard block
 block discarded – undo
3443 3443
 		$fee       = 0;
3444 3444
 		$recurring = 0;
3445 3445
 
3446
-        foreach ( $fees as $data ) {
3447
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3448
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3446
+        foreach ($fees as $data) {
3447
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3448
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3449 3449
 		}
3450 3450
 
3451 3451
 		$current = $this->is_renewal() ? $recurring : $fee;
3452
-		$this->set_total_fees( $current );
3452
+		$this->set_total_fees($current);
3453 3453
 
3454 3454
 		$this->totals['fee'] = array(
3455 3455
 			'initial'   => $fee,
3456 3456
 			'recurring' => $recurring,
3457 3457
 		);
3458 3458
 
3459
-        $this->set_total_fees( $fee );
3459
+        $this->set_total_fees($fee);
3460 3460
         return $current;
3461 3461
     }
3462 3462
 
@@ -3477,9 +3477,9 @@  discard block
 block discarded – undo
3477 3477
 	/**
3478 3478
 	 * @deprecated
3479 3479
 	 */
3480
-    public function recalculate_totals( $temp = false ) {
3481
-        $this->update_items( $temp );
3482
-        $this->save( true );
3480
+    public function recalculate_totals($temp = false) {
3481
+        $this->update_items($temp);
3482
+        $this->save(true);
3483 3483
         return $this;
3484 3484
     }
3485 3485
 
@@ -3497,10 +3497,10 @@  discard block
 block discarded – undo
3497 3497
 	 * @return int|false The new note's ID on success, false on failure.
3498 3498
      *
3499 3499
      */
3500
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3500
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3501 3501
 
3502 3502
         // Bail if no note specified or this invoice is not yet saved.
3503
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3503
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3504 3504
             return false;
3505 3505
         }
3506 3506
 
@@ -3508,23 +3508,23 @@  discard block
 block discarded – undo
3508 3508
 		$author_email = '[email protected]';
3509 3509
 
3510 3510
 		// If this is an admin comment or it has been added by the user.
3511
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3512
-			$user         = get_user_by( 'id', get_current_user_id() );
3511
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3512
+			$user = get_user_by('id', get_current_user_id());
3513 3513
             $author       = $user->display_name;
3514 3514
             $author_email = $user->user_email;
3515 3515
 		}
3516 3516
 
3517
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3517
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3518 3518
 
3519 3519
 	}
3520 3520
 
3521 3521
 	/**
3522 3522
      * Generates a unique key for the invoice.
3523 3523
      */
3524
-    public function generate_key( $string = '' ) {
3525
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3524
+    public function generate_key($string = '') {
3525
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3526 3526
         return strtolower(
3527
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3527
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3528 3528
         );
3529 3529
     }
3530 3530
 
@@ -3534,11 +3534,11 @@  discard block
 block discarded – undo
3534 3534
     public function generate_number() {
3535 3535
         $number = $this->get_id();
3536 3536
 
3537
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3538
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3537
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3538
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3539 3539
         }
3540 3540
 
3541
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3541
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3542 3542
 
3543 3543
 	}
3544 3544
 
@@ -3551,55 +3551,55 @@  discard block
 block discarded – undo
3551 3551
 		// Reset status transition variable.
3552 3552
 		$this->status_transition = false;
3553 3553
 
3554
-		if ( $status_transition ) {
3554
+		if ($status_transition) {
3555 3555
 			try {
3556 3556
 
3557 3557
 				// Fire a hook for the status change.
3558
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3558
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3559 3559
 
3560 3560
 				// @deprecated this is deprecated and will be removed in the future.
3561
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3561
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3562 3562
 
3563
-				if ( ! empty( $status_transition['from'] ) ) {
3563
+				if (!empty($status_transition['from'])) {
3564 3564
 
3565 3565
 					/* translators: 1: old invoice status 2: new invoice status */
3566
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3566
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this));
3567 3567
 
3568 3568
 					// Fire another hook.
3569
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3570
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3569
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3570
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3571 3571
 
3572 3572
 					// @deprecated this is deprecated and will be removed in the future.
3573
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3573
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3574 3574
 
3575 3575
 					// Note the transition occurred.
3576
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3576
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3577 3577
 
3578 3578
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3579 3579
 					if (
3580
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3581
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3580
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3581
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3582 3582
 					) {
3583
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3583
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3584 3584
 					}
3585 3585
 
3586 3586
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3587 3587
 					if (
3588
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3589
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3588
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3589
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3590 3590
 					) {
3591
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3591
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3592 3592
 					}
3593 3593
 				} else {
3594 3594
 					/* translators: %s: new invoice status */
3595
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3595
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3596 3596
 
3597 3597
 					// Note the transition occurred.
3598
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3598
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3599 3599
 
3600 3600
 				}
3601
-			} catch ( Exception $e ) {
3602
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3601
+			} catch (Exception $e) {
3602
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3603 3603
 			}
3604 3604
 		}
3605 3605
 	}
@@ -3607,13 +3607,13 @@  discard block
 block discarded – undo
3607 3607
 	/**
3608 3608
 	 * Updates an invoice status.
3609 3609
 	 */
3610
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3610
+	public function update_status($new_status = false, $note = '', $manual = false) {
3611 3611
 
3612 3612
 		// Fires before updating a status.
3613
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3613
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3614 3614
 
3615 3615
 		// Update the status.
3616
-		$this->set_status( $new_status, $note, $manual );
3616
+		$this->set_status($new_status, $note, $manual);
3617 3617
 
3618 3618
 		// Save the order.
3619 3619
 		return $this->save();
@@ -3624,18 +3624,18 @@  discard block
 block discarded – undo
3624 3624
 	 * @deprecated
3625 3625
 	 */
3626 3626
 	public function refresh_item_ids() {
3627
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3628
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3627
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3628
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3629 3629
 	}
3630 3630
 
3631 3631
 	/**
3632 3632
 	 * @deprecated
3633 3633
 	 */
3634
-	public function update_items( $temp = false ) {
3634
+	public function update_items($temp = false) {
3635 3635
 
3636
-		$this->set_items( $this->get_items() );
3636
+		$this->set_items($this->get_items());
3637 3637
 
3638
-		if ( ! $temp ) {
3638
+		if (!$temp) {
3639 3639
 			$this->save();
3640 3640
 		}
3641 3641
 
@@ -3649,11 +3649,11 @@  discard block
 block discarded – undo
3649 3649
 
3650 3650
         $discount_code = $this->get_discount_code();
3651 3651
 
3652
-        if ( empty( $discount_code ) ) {
3652
+        if (empty($discount_code)) {
3653 3653
             return false;
3654 3654
         }
3655 3655
 
3656
-        $discount = wpinv_get_discount_obj( $discount_code );
3656
+        $discount = wpinv_get_discount_obj($discount_code);
3657 3657
 
3658 3658
         // Ensure it is active.
3659 3659
         return $discount->exists();
@@ -3664,7 +3664,7 @@  discard block
 block discarded – undo
3664 3664
 	 * Refunds an invoice.
3665 3665
 	 */
3666 3666
     public function refund() {
3667
-		$this->set_status( 'wpi-refunded' );
3667
+		$this->set_status('wpi-refunded');
3668 3668
         $this->save();
3669 3669
 	}
3670 3670
 
@@ -3673,56 +3673,56 @@  discard block
 block discarded – undo
3673 3673
 	 * 
3674 3674
 	 * @param string $transaction_id
3675 3675
 	 */
3676
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3676
+    public function mark_paid($transaction_id = null, $note = '') {
3677 3677
 
3678 3678
 		// Set the transaction id.
3679
-		if ( empty( $transaction_id ) ) {
3679
+		if (empty($transaction_id)) {
3680 3680
 			$transaction_id = $this->generate_key('trans_');
3681 3681
 		}
3682 3682
 
3683
-		if ( ! $this->get_transaction_id() ) {
3684
-			$this->set_transaction_id( $transaction_id );
3683
+		if (!$this->get_transaction_id()) {
3684
+			$this->set_transaction_id($transaction_id);
3685 3685
 		}
3686 3686
 
3687
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3687
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3688 3688
 			return $this->save();
3689 3689
 		}
3690 3690
 
3691 3691
 		// Set the completed date.
3692
-		$this->set_date_completed( current_time( 'mysql' ) );
3692
+		$this->set_date_completed(current_time('mysql'));
3693 3693
 
3694 3694
 		// Set the new status.
3695
-		if ( $this->is_renewal() ) {
3695
+		if ($this->is_renewal()) {
3696 3696
 
3697 3697
 			$_note = sprintf(
3698
-				__( 'Renewed via %s', 'invoicing' ),
3699
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3698
+				__('Renewed via %s', 'invoicing'),
3699
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3700 3700
 			);
3701 3701
 
3702
-			if ( 'none' == $this->get_gateway() ) {
3702
+			if ('none' == $this->get_gateway()) {
3703 3703
 				$_note = $note;
3704 3704
 			}
3705 3705
 
3706
-			$this->set_status( 'wpi-renewal', $_note );
3706
+			$this->set_status('wpi-renewal', $_note);
3707 3707
 
3708 3708
 		} else {
3709 3709
 
3710 3710
 			$_note = sprintf(
3711
-				__( 'Paid via %s', 'invoicing' ),
3712
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3711
+				__('Paid via %s', 'invoicing'),
3712
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3713 3713
 			);
3714 3714
 
3715
-			if ( 'none' == $this->get_gateway() ) {
3715
+			if ('none' == $this->get_gateway()) {
3716 3716
 				$_note = $note;
3717 3717
 			}
3718 3718
 
3719
-			$this->set_status( 'publish',$_note );
3719
+			$this->set_status('publish', $_note);
3720 3720
 
3721 3721
 		}
3722 3722
 
3723 3723
 		// Set checkout mode.
3724
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3725
-		$this->set_mode( $mode );
3724
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3725
+		$this->set_mode($mode);
3726 3726
 
3727 3727
 		// Save the invoice.
3728 3728
         $this->save();
@@ -3748,9 +3748,9 @@  discard block
 block discarded – undo
3748 3748
      * Clears the subscription's cache.
3749 3749
      */
3750 3750
     public function clear_cache() {
3751
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3752
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3753
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3751
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3752
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3753
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3754 3754
 	}
3755 3755
 
3756 3756
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@
 block discarded – undo
158 158
 			$this->set_id( $invoice_id );
159 159
 		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160 160
 			$this->set_id( $invoice_id );
161
-		}else {
161
+		} else {
162 162
 			$this->set_object_read( true );
163 163
 		}
164 164
 
Please login to merge, or discard this patch.
includes/wpinv-discount-functions.php 1 patch
Spacing   +33 added lines, -33 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
  * Returns an array of discount type.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
     return apply_filters(
18 18
         'wpinv_discount_types',
19 19
         array(
20
-            'percent'   => __( 'Percentage', 'invoicing' ),
21
-            'flat'     => __( 'Flat Amount', 'invoicing' ),
20
+            'percent'   => __('Percentage', 'invoicing'),
21
+            'flat'     => __('Flat Amount', 'invoicing'),
22 22
         )
23 23
     );
24 24
 }
@@ -28,46 +28,46 @@  discard block
 block discarded – undo
28 28
  * 
29 29
  * @return string
30 30
  */
31
-function wpinv_get_discount_type_name( $type = '' ) {
31
+function wpinv_get_discount_type_name($type = '') {
32 32
     $types = wpinv_get_discount_types();
33
-    return isset( $types[ $type ] ) ? $types[ $type ] : $type;
33
+    return isset($types[$type]) ? $types[$type] : $type;
34 34
 }
35 35
 
36 36
 /**
37 37
  * Deletes a discount via the admin page.
38 38
  * 
39 39
  */
40
-function wpinv_delete_discount( $data ) {
40
+function wpinv_delete_discount($data) {
41 41
 
42
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
43
-    $discount->delete( true );
42
+    $discount = new WPInv_Discount(absint($data['discount']));
43
+    $discount->delete(true);
44 44
 
45 45
 }
46
-add_action( 'getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount' );
46
+add_action('getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount');
47 47
 
48 48
 /**
49 49
  * Deactivates a discount via the admin page.
50 50
  */
51
-function wpinv_activate_discount( $data ) {
51
+function wpinv_activate_discount($data) {
52 52
 
53
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
54
-    $discount->set_status( 'publish' );
53
+    $discount = new WPInv_Discount(absint($data['discount']));
54
+    $discount->set_status('publish');
55 55
     $discount->save();
56 56
 
57 57
 }
58
-add_action( 'getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount' );
58
+add_action('getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount');
59 59
 
60 60
 /**
61 61
  * Activates a discount via the admin page.
62 62
  */
63
-function wpinv_deactivate_discount( $data ) {
63
+function wpinv_deactivate_discount($data) {
64 64
 
65
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
66
-    $discount->set_status( 'pending' );
65
+    $discount = new WPInv_Discount(absint($data['discount']));
66
+    $discount->set_status('pending');
67 67
     $discount->save();
68 68
 
69 69
 }
70
-add_action( 'getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount' );
70
+add_action('getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount');
71 71
 
72 72
 /**
73 73
  * Fetches a discount object.
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
  * @since 1.0.15
77 77
  * @return WPInv_Discount
78 78
  */
79
-function wpinv_get_discount( $discount ) {
80
-    return new WPInv_Discount( $discount );
79
+function wpinv_get_discount($discount) {
80
+    return new WPInv_Discount($discount);
81 81
 }
82 82
 
83 83
 /**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
  * @since 1.0.15
88 88
  * @return WPInv_Discount
89 89
  */
90
-function wpinv_get_discount_obj( $discount = 0 ) {
91
-    return new WPInv_Discount( $discount );
90
+function wpinv_get_discount_obj($discount = 0) {
91
+    return new WPInv_Discount($discount);
92 92
 }
93 93
 
94 94
 /**
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
  * @param string|int $value The field value
99 99
  * @return bool|WPInv_Discount
100 100
  */
101
-function wpinv_get_discount_by( $deprecated = null, $value = '' ) {
102
-    $discount = new WPInv_Discount( $value );
101
+function wpinv_get_discount_by($deprecated = null, $value = '') {
102
+    $discount = new WPInv_Discount($value);
103 103
 
104
-    if ( $discount->get_id() != 0 ) {
104
+    if ($discount->get_id() != 0) {
105 105
         return $discount;
106 106
     }
107 107
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 function wpinv_get_discount_statuses() {
117 117
 
118 118
     return array(
119
-        'expired'  => __( 'Expired', 'invoicing' ),
120
-        'publish'  => __( 'Active', 'invoicing' ),
121
-        'inactive' => __( 'Inactive', 'invoicing' ),
119
+        'expired'  => __('Expired', 'invoicing'),
120
+        'publish'  => __('Active', 'invoicing'),
121
+        'inactive' => __('Inactive', 'invoicing'),
122 122
     );
123 123
 
124 124
 }
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 /**
127 127
  * Retrieves an invoice status label.
128 128
  */
129
-function wpinv_discount_status( $status ) {
129
+function wpinv_discount_status($status) {
130 130
     $statuses = wpinv_get_discount_statuses();
131
-    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : __( 'Inactive', 'invoicing' );
131
+    return isset($statuses[$status]) ? $statuses[$status] : __('Inactive', 'invoicing');
132 132
 }
133 133
 
134 134
 /**
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
  * @param int|array|string|WPInv_Discount $code discount data, object, ID or code.
139 139
  * @return bool
140 140
  */
141
-function wpinv_discount_is_recurring( $discount = 0, $code = 0 ) {
141
+function wpinv_discount_is_recurring($discount = 0, $code = 0) {
142 142
 
143
-    if( ! empty( $discount ) ) {
144
-        $discount    = wpinv_get_discount_obj( $discount );
143
+    if (!empty($discount)) {
144
+        $discount    = wpinv_get_discount_obj($discount);
145 145
     } else {
146
-        $discount    = wpinv_get_discount_obj( $code );
146
+        $discount    = wpinv_get_discount_obj($code);
147 147
     }
148 148
 
149 149
     return $discount->get_is_recurring();
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +616 added lines, -616 removed lines patch added patch discarded remove patch
@@ -13,617 +13,617 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-
29
-		// Invoice table columns.
30
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
32
-
33
-		// Items table columns.
34
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
35
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
36
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
37
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
38
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
39
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
40
-
41
-		// Payment forms columns.
42
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
43
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
44
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
45
-
46
-		// Discount table columns.
47
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
48
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
49
-
50
-		// Deleting posts.
51
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
52
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
53
-	}
54
-
55
-	/**
56
-	 * Post updated messages.
57
-	 */
58
-	public static function post_updated_messages( $messages ) {
59
-		global $post;
60
-
61
-		$messages['wpi_discount'] = array(
62
-			0   => '',
63
-			1   => __( 'Discount updated.', 'invoicing' ),
64
-			2   => __( 'Custom field updated.', 'invoicing' ),
65
-			3   => __( 'Custom field deleted.', 'invoicing' ),
66
-			4   => __( 'Discount updated.', 'invoicing' ),
67
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
68
-			6   => __( 'Discount updated.', 'invoicing' ),
69
-			7   => __( 'Discount saved.', 'invoicing' ),
70
-			8   => __( 'Discount submitted.', 'invoicing' ),
71
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
72
-			10  => __( 'Discount draft updated.', 'invoicing' ),
73
-		);
74
-
75
-		$messages['wpi_payment_form'] = array(
76
-			0   => '',
77
-			1   => __( 'Payment Form updated.', 'invoicing' ),
78
-			2   => __( 'Custom field updated.', 'invoicing' ),
79
-			3   => __( 'Custom field deleted.', 'invoicing' ),
80
-			4   => __( 'Payment Form updated.', 'invoicing' ),
81
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
82
-			6   => __( 'Payment Form updated.', 'invoicing' ),
83
-			7   => __( 'Payment Form saved.', 'invoicing' ),
84
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
85
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
86
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
87
-		);
88
-
89
-		return $messages;
90
-
91
-	}
92
-
93
-	/**
94
-	 * Post row actions.
95
-	 */
96
-	public static function post_row_actions( $actions, $post ) {
97
-
98
-		$post = get_post( $post );
99
-
100
-		// We do not want to edit the default payment form.
101
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
102
-			unset( $actions['trash'] );
103
-			unset( $actions['inline hide-if-no-js'] );
104
-		}
105
-
106
-		return $actions;
107
-	}
108
-
109
-	/**
110
-	 * Returns an array of invoice table columns.
111
-	 */
112
-	public static function invoice_columns( $columns ) {
113
-
114
-		$columns = array(
115
-			'cb'                => $columns['cb'],
116
-			'number'            => __( 'Invoice', 'invoicing' ),
117
-			'customer'          => __( 'Customer', 'invoicing' ),
118
-			'invoice_date'      => __( 'Date', 'invoicing' ),
119
-			'amount'            => __( 'Amount', 'invoicing' ),
120
-			'recurring'         => __( 'Recurring', 'invoicing' ),
121
-			'status'            => __( 'Status', 'invoicing' ),
122
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
123
-		);
124
-
125
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
126
-	}
127
-
128
-	/**
129
-	 * Displays invoice table columns.
130
-	 */
131
-	public static function display_invoice_columns( $column_name, $post_id ) {
132
-
133
-		$invoice = new WPInv_Invoice( $post_id );
134
-
135
-		switch ( $column_name ) {
136
-
137
-			case 'invoice_date' :
138
-				$date_time = esc_attr( $invoice->get_created_date() );
139
-				$date      = getpaid_format_date_value( $date_time );
140
-				echo "<span title='$date_time'>$date</span>";
141
-				break;
142
-
143
-			case 'amount' :
144
-
145
-				$amount = $invoice->get_total();
146
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
147
-
148
-				if ( $invoice->is_refunded() ) {
149
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
150
-					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
151
-				} else {
152
-
153
-					$discount = $invoice->get_total_discount();
154
-
155
-					if ( ! empty( $discount ) ) {
156
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
157
-						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
158
-					} else {
159
-						echo $formated_amount;
160
-					}
161
-
162
-				}
163
-
164
-				break;
165
-
166
-			case 'status' :
167
-				$status       = sanitize_text_field( $invoice->get_status() );
168
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
169
-
170
-				// If it is paid, show the gateway title.
171
-				if ( $invoice->is_paid() ) {
172
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
173
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
174 19
 
175
-					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
176
-				} else {
177
-					echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
178
-				}
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
179 22
 
180
-				// If it is not paid, display the overdue and view status.
181
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
182 25
 
183
-					// Invoice view status.
184
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
185
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
186
-					} else {
187
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
188
-					}
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
189 28
 
190
-					// Display the overview status.
191
-					if ( wpinv_get_option( 'overdue_active' ) ) {
192
-						$due_date = $invoice->get_due_date();
193
-						$fomatted = getpaid_format_date( $due_date );
29
+        // Invoice table columns.
30
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
194 32
 
195
-						if ( ! empty( $fomatted ) ) {
196
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
197
-							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
198
-						}
199
-					}
33
+        // Items table columns.
34
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
35
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
36
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
37
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
38
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
39
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
200 40
 
201
-				}
41
+        // Payment forms columns.
42
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
43
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
44
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
202 45
 
203
-				break;
46
+        // Discount table columns.
47
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
48
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
204 49
 
205
-			case 'recurring':
50
+        // Deleting posts.
51
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
52
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
53
+    }
206 54
 
207
-				if ( $invoice->is_recurring() ) {
208
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
209
-				} else {
210
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
211
-				}
212
-				break;
55
+    /**
56
+     * Post updated messages.
57
+     */
58
+    public static function post_updated_messages( $messages ) {
59
+        global $post;
60
+
61
+        $messages['wpi_discount'] = array(
62
+            0   => '',
63
+            1   => __( 'Discount updated.', 'invoicing' ),
64
+            2   => __( 'Custom field updated.', 'invoicing' ),
65
+            3   => __( 'Custom field deleted.', 'invoicing' ),
66
+            4   => __( 'Discount updated.', 'invoicing' ),
67
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
68
+            6   => __( 'Discount updated.', 'invoicing' ),
69
+            7   => __( 'Discount saved.', 'invoicing' ),
70
+            8   => __( 'Discount submitted.', 'invoicing' ),
71
+            9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
72
+            10  => __( 'Discount draft updated.', 'invoicing' ),
73
+        );
74
+
75
+        $messages['wpi_payment_form'] = array(
76
+            0   => '',
77
+            1   => __( 'Payment Form updated.', 'invoicing' ),
78
+            2   => __( 'Custom field updated.', 'invoicing' ),
79
+            3   => __( 'Custom field deleted.', 'invoicing' ),
80
+            4   => __( 'Payment Form updated.', 'invoicing' ),
81
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
82
+            6   => __( 'Payment Form updated.', 'invoicing' ),
83
+            7   => __( 'Payment Form saved.', 'invoicing' ),
84
+            8   => __( 'Payment Form submitted.', 'invoicing' ),
85
+            9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
86
+            10  => __( 'Payment Form draft updated.', 'invoicing' ),
87
+        );
88
+
89
+        return $messages;
90
+
91
+    }
92
+
93
+    /**
94
+     * Post row actions.
95
+     */
96
+    public static function post_row_actions( $actions, $post ) {
97
+
98
+        $post = get_post( $post );
99
+
100
+        // We do not want to edit the default payment form.
101
+        if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
102
+            unset( $actions['trash'] );
103
+            unset( $actions['inline hide-if-no-js'] );
104
+        }
105
+
106
+        return $actions;
107
+    }
108
+
109
+    /**
110
+     * Returns an array of invoice table columns.
111
+     */
112
+    public static function invoice_columns( $columns ) {
113
+
114
+        $columns = array(
115
+            'cb'                => $columns['cb'],
116
+            'number'            => __( 'Invoice', 'invoicing' ),
117
+            'customer'          => __( 'Customer', 'invoicing' ),
118
+            'invoice_date'      => __( 'Date', 'invoicing' ),
119
+            'amount'            => __( 'Amount', 'invoicing' ),
120
+            'recurring'         => __( 'Recurring', 'invoicing' ),
121
+            'status'            => __( 'Status', 'invoicing' ),
122
+            'wpi_actions'       => __( 'Actions', 'invoicing' ),
123
+        );
124
+
125
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
126
+    }
127
+
128
+    /**
129
+     * Displays invoice table columns.
130
+     */
131
+    public static function display_invoice_columns( $column_name, $post_id ) {
132
+
133
+        $invoice = new WPInv_Invoice( $post_id );
134
+
135
+        switch ( $column_name ) {
136
+
137
+            case 'invoice_date' :
138
+                $date_time = esc_attr( $invoice->get_created_date() );
139
+                $date      = getpaid_format_date_value( $date_time );
140
+                echo "<span title='$date_time'>$date</span>";
141
+                break;
142
+
143
+            case 'amount' :
144
+
145
+                $amount = $invoice->get_total();
146
+                $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
147
+
148
+                if ( $invoice->is_refunded() ) {
149
+                    $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
150
+                    echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
151
+                } else {
152
+
153
+                    $discount = $invoice->get_total_discount();
154
+
155
+                    if ( ! empty( $discount ) ) {
156
+                        $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
157
+                        echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
158
+                    } else {
159
+                        echo $formated_amount;
160
+                    }
161
+
162
+                }
163
+
164
+                break;
165
+
166
+            case 'status' :
167
+                $status       = sanitize_text_field( $invoice->get_status() );
168
+                $status_label = sanitize_text_field( $invoice->get_status_nicename() );
169
+
170
+                // If it is paid, show the gateway title.
171
+                if ( $invoice->is_paid() ) {
172
+                    $gateway = sanitize_text_field( $invoice->get_gateway_title() );
173
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
213 174
 
214
-			case 'number' :
175
+                    echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
176
+                } else {
177
+                    echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
178
+                }
215 179
 
216
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
217
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
218
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
180
+                // If it is not paid, display the overdue and view status.
181
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
219 182
 
220
-				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
183
+                    // Invoice view status.
184
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
185
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
186
+                    } else {
187
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
188
+                    }
221 189
 
222
-				break;
190
+                    // Display the overview status.
191
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
192
+                        $due_date = $invoice->get_due_date();
193
+                        $fomatted = getpaid_format_date( $due_date );
223 194
 
224
-			case 'customer' :
195
+                        if ( ! empty( $fomatted ) ) {
196
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
197
+                            echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
198
+                        }
199
+                    }
200
+
201
+                }
202
+
203
+                break;
204
+
205
+            case 'recurring':
206
+
207
+                if ( $invoice->is_recurring() ) {
208
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
209
+                } else {
210
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
211
+                }
212
+                break;
213
+
214
+            case 'number' :
215
+
216
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
217
+                $invoice_number  = sanitize_text_field( $invoice->get_number() );
218
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
219
+
220
+                echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
221
+
222
+                break;
223
+
224
+            case 'customer' :
225 225
 	
226
-				$customer_name = $invoice->get_user_full_name();
226
+                $customer_name = $invoice->get_user_full_name();
227 227
 	
228
-				if ( empty( $customer_name ) ) {
229
-					$customer_name = $invoice->get_email();
230
-				}
228
+                if ( empty( $customer_name ) ) {
229
+                    $customer_name = $invoice->get_email();
230
+                }
231 231
 	
232
-				if ( ! empty( $customer_name ) ) {
233
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
234
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
235
-					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
236
-				} else {
237
-					echo '<div>&mdash;</div>';
238
-				}
232
+                if ( ! empty( $customer_name ) ) {
233
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
234
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
235
+                    echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
236
+                } else {
237
+                    echo '<div>&mdash;</div>';
238
+                }
239
+
240
+                break;
241
+
242
+            case 'wpi_actions' :
243
+
244
+                if ( $invoice->is_draft() ) {
245
+                    return;
246
+                }
247
+
248
+                $url    = esc_url( $invoice->get_view_url() );
249
+                $print  = esc_attr__( 'Print invoice', 'invoicing' );
250
+                echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
251
+
252
+                $url    = esc_url(
253
+                    wp_nonce_url(
254
+                        add_query_arg(
255
+                            array(
256
+                                'getpaid-admin-action' => 'send_invoice',
257
+                                'invoice_id'           => $invoice->get_id()
258
+                            )
259
+                        ),
260
+                        'getpaid-nonce',
261
+                        'getpaid-nonce'
262
+                    )
263
+                );
264
+
265
+                $send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
266
+                echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
267
+
268
+                break;
269
+        }
239 270
 
240
-				break;
271
+    }
241 272
 
242
-			case 'wpi_actions' :
243
-
244
-				if ( $invoice->is_draft() ) {
245
-					return;
246
-				}
247
-
248
-				$url    = esc_url( $invoice->get_view_url() );
249
-				$print  = esc_attr__( 'Print invoice', 'invoicing' );
250
-				echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
273
+    /**
274
+     * Returns an array of payment forms table columns.
275
+     */
276
+    public static function payment_form_columns( $columns ) {
251 277
 
252
-				$url    = esc_url(
253
-					wp_nonce_url(
254
-						add_query_arg(
255
-							array(
256
-								'getpaid-admin-action' => 'send_invoice',
257
-								'invoice_id'           => $invoice->get_id()
258
-							)
259
-						),
260
-						'getpaid-nonce',
261
-						'getpaid-nonce'
262
-					)
263
-				);
278
+        $columns = array(
279
+            'cb'                => $columns['cb'],
280
+            'title'             => __( 'Name', 'invoicing' ),
281
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
282
+            'earnings'          => __( 'Revenue', 'invoicing' ),
283
+            'refunds'           => __( 'Refunded', 'invoicing' ),
284
+            'items'             => __( 'Items', 'invoicing' ),
285
+            'date'              => __( 'Date', 'invoicing' ),
286
+        );
264 287
 
265
-				$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
266
-				echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
288
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
267 289
 
268
-				break;
269
-		}
290
+    }
270 291
 
271
-	}
292
+    /**
293
+     * Displays payment form table columns.
294
+     */
295
+    public static function display_payment_form_columns( $column_name, $post_id ) {
272 296
 
273
-	/**
274
-	 * Returns an array of payment forms table columns.
275
-	 */
276
-	public static function payment_form_columns( $columns ) {
297
+        // Retrieve the payment form.
298
+        $form = new GetPaid_Payment_Form( $post_id );
277 299
 
278
-		$columns = array(
279
-			'cb'                => $columns['cb'],
280
-			'title'             => __( 'Name', 'invoicing' ),
281
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
282
-			'earnings'          => __( 'Revenue', 'invoicing' ),
283
-			'refunds'           => __( 'Refunded', 'invoicing' ),
284
-			'items'             => __( 'Items', 'invoicing' ),
285
-			'date'              => __( 'Date', 'invoicing' ),
286
-		);
300
+        switch ( $column_name ) {
287 301
 
288
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
302
+            case 'earnings' :
303
+                echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
304
+                break;
289 305
 
290
-	}
306
+            case 'refunds' :
307
+                echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
308
+                break;
291 309
 
292
-	/**
293
-	 * Displays payment form table columns.
294
-	 */
295
-	public static function display_payment_form_columns( $column_name, $post_id ) {
310
+            case 'refunds' :
311
+                echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
312
+                break;
296 313
 
297
-		// Retrieve the payment form.
298
-		$form = new GetPaid_Payment_Form( $post_id );
314
+            case 'shortcode' :
299 315
 
300
-		switch ( $column_name ) {
316
+                if ( $form->is_default() ) {
317
+                    echo '&mdash;';
318
+                } else {
319
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
320
+                }
301 321
 
302
-			case 'earnings' :
303
-				echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
304
-				break;
322
+                break;
305 323
 
306
-			case 'refunds' :
307
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
308
-				break;
324
+            case 'items' :
309 325
 
310
-			case 'refunds' :
311
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
312
-				break;
326
+                $items = $form->get_items();
313 327
 
314
-			case 'shortcode' :
328
+                if ( $form->is_default() || empty( $items ) ) {
329
+                    echo '&mdash;';
330
+                    return;
331
+                }
315 332
 
316
-				if ( $form->is_default() ) {
317
-					echo '&mdash;';
318
-				} else {
319
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
320
-				}
333
+                $_items = array();
321 334
 
322
-				break;
335
+                foreach ( $items as $item ) {
336
+                    $url = $item->get_edit_url();
323 337
 
324
-			case 'items' :
338
+                    if ( empty( $url ) ) {
339
+                        $_items[] = sanitize_text_field( $item->get_name() );
340
+                    } else {
341
+                        $_items[] = sprintf(
342
+                            '<a href="%s">%s</a>',
343
+                            esc_url( $url ),
344
+                            sanitize_text_field( $item->get_name() )
345
+                        );
346
+                    }
325 347
 
326
-				$items = $form->get_items();
348
+                }
327 349
 
328
-				if ( $form->is_default() || empty( $items ) ) {
329
-					echo '&mdash;';
330
-					return;
331
-				}
350
+                echo implode( '<br>', $_items );
332 351
 
333
-				$_items = array();
352
+                break;
334 353
 
335
-				foreach ( $items as $item ) {
336
-					$url = $item->get_edit_url();
354
+        }
337 355
 
338
-					if ( empty( $url ) ) {
339
-						$_items[] = sanitize_text_field( $item->get_name() );
340
-					} else {
341
-						$_items[] = sprintf(
342
-							'<a href="%s">%s</a>',
343
-							esc_url( $url ),
344
-							sanitize_text_field( $item->get_name() )
345
-						);
346
-					}
356
+    }
347 357
 
348
-				}
358
+    /**
359
+     * Filters post states.
360
+     */
361
+    public static function filter_payment_form_state( $post_states, $post ) {
349 362
 
350
-				echo implode( '<br>', $_items );
363
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
364
+            $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
365
+        }
366
+	
367
+        return $post_states;
351 368
 
352
-				break;
369
+    }
353 370
 
354
-		}
371
+    /**
372
+     * Returns an array of coupon table columns.
373
+     */
374
+    public static function discount_columns( $columns ) {
375
+
376
+        $columns = array(
377
+            'cb'                => $columns['cb'],
378
+            'title'             => __( 'Name', 'invoicing' ),
379
+            'code'              => __( 'Code', 'invoicing' ),
380
+            'amount'            => __( 'Amount', 'invoicing' ),
381
+            'usage'             => __( 'Usage / Limit', 'invoicing' ),
382
+            'start_date'        => __( 'Start Date', 'invoicing' ),
383
+            'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
384
+        );
385
+
386
+        return apply_filters( 'wpi_discount_table_columns', $columns );
387
+    }
355 388
 
356
-	}
389
+    /**
390
+     * Filters post states.
391
+     */
392
+    public static function filter_discount_state( $post_states, $post ) {
357 393
 
358
-	/**
359
-	 * Filters post states.
360
-	 */
361
-	public static function filter_payment_form_state( $post_states, $post ) {
394
+        if ( 'wpi_discount' == $post->post_type ) {
362 395
 
363
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
364
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
365
-		}
366
-	
367
-		return $post_states;
396
+            $discount = new WPInv_Discount( $post );
368 397
 
369
-	}
398
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
370 399
 
371
-	/**
372
-	 * Returns an array of coupon table columns.
373
-	 */
374
-	public static function discount_columns( $columns ) {
400
+            if ( $status != 'publish' ) {
401
+                return array(
402
+                    'discount_status' => wpinv_discount_status( $status ),
403
+                );
404
+            }
375 405
 
376
-		$columns = array(
377
-			'cb'                => $columns['cb'],
378
-			'title'             => __( 'Name', 'invoicing' ),
379
-			'code'              => __( 'Code', 'invoicing' ),
380
-			'amount'            => __( 'Amount', 'invoicing' ),
381
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
382
-			'start_date'        => __( 'Start Date', 'invoicing' ),
383
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
384
-		);
406
+            return array();
385 407
 
386
-		return apply_filters( 'wpi_discount_table_columns', $columns );
387
-	}
408
+        }
388 409
 
389
-	/**
390
-	 * Filters post states.
391
-	 */
392
-	public static function filter_discount_state( $post_states, $post ) {
410
+        return $post_states;
393 411
 
394
-		if ( 'wpi_discount' == $post->post_type ) {
412
+    }
395 413
 
396
-			$discount = new WPInv_Discount( $post );
414
+    /**
415
+     * Returns an array of items table columns.
416
+     */
417
+    public static function item_columns( $columns ) {
418
+        global $wpinv_euvat;
419
+
420
+        $columns = array(
421
+            'cb'                => $columns['cb'],
422
+            'title'             => __( 'Name', 'invoicing' ),
423
+            'price'             => __( 'Price', 'invoicing' ),
424
+            'vat_rule'          => __( 'VAT rule', 'invoicing' ),
425
+            'vat_class'         => __( 'VAT class', 'invoicing' ),
426
+            'type'              => __( 'Type', 'invoicing' ),
427
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
428
+        );
429
+
430
+        if ( ! $wpinv_euvat->allow_vat_rules() ) {
431
+            unset( $columns['vat_rule'] );
432
+        }
397 433
 
398
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
434
+        if ( ! $wpinv_euvat->allow_vat_classes() ) {
435
+            unset( $columns['vat_class'] );
436
+        }
399 437
 
400
-			if ( $status != 'publish' ) {
401
-				return array(
402
-					'discount_status' => wpinv_discount_status( $status ),
403
-				);
404
-			}
438
+        return apply_filters( 'wpi_item_table_columns', $columns );
439
+    }
405 440
 
406
-			return array();
441
+    /**
442
+     * Returns an array of sortable items table columns.
443
+     */
444
+    public static function sortable_item_columns( $columns ) {
445
+
446
+        return array_merge(
447
+            $columns,
448
+            array(
449
+                'price'     => 'price',
450
+                'vat_rule'  => 'vat_rule',
451
+                'vat_class' => 'vat_class',
452
+                'type'      => 'type',
453
+            )
454
+        );
455
+
456
+    }
407 457
 
408
-		}
458
+    /**
459
+     * Displays items table columns.
460
+     */
461
+    public static function display_item_columns( $column_name, $post_id ) {
462
+        global $wpinv_euvat;
409 463
 
410
-		return $post_states;
464
+        $item = new WPInv_Item( $post_id );
411 465
 
412
-	}
466
+        switch ( $column_name ) {
413 467
 
414
-	/**
415
-	 * Returns an array of items table columns.
416
-	 */
417
-	public static function item_columns( $columns ) {
418
-		global $wpinv_euvat;
468
+            case 'price' :
419 469
 
420
-		$columns = array(
421
-			'cb'                => $columns['cb'],
422
-			'title'             => __( 'Name', 'invoicing' ),
423
-			'price'             => __( 'Price', 'invoicing' ),
424
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
425
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
426
-			'type'              => __( 'Type', 'invoicing' ),
427
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
428
-		);
470
+                if ( ! $item->is_recurring() ) {
471
+                    echo $item->get_the_price();
472
+                    break;
473
+                }
429 474
 
430
-		if ( ! $wpinv_euvat->allow_vat_rules() ) {
431
-			unset( $columns['vat_rule'] );
432
-		}
475
+                $price = wp_sprintf(
476
+                    __( '%s / %s', 'invoicing' ),
477
+                    $item->get_the_price(),
478
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
479
+                );
433 480
 
434
-		if ( ! $wpinv_euvat->allow_vat_classes() ) {
435
-			unset( $columns['vat_class'] );
436
-		}
481
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
482
+                    echo $price;
483
+                    break;
484
+                }
437 485
 
438
-		return apply_filters( 'wpi_item_table_columns', $columns );
439
-	}
486
+                echo $item->get_the_initial_price();
440 487
 
441
-	/**
442
-	 * Returns an array of sortable items table columns.
443
-	 */
444
-	public static function sortable_item_columns( $columns ) {
488
+                echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
489
+                break;
445 490
 
446
-		return array_merge(
447
-			$columns,
448
-			array(
449
-				'price'     => 'price',
450
-				'vat_rule'  => 'vat_rule',
451
-				'vat_class' => 'vat_class',
452
-				'type'      => 'type',
453
-			)
454
-		);
491
+            case 'vat_rule' :
492
+                echo $wpinv_euvat->item_rule_label( $item->get_id() );
493
+                break;
455 494
 
456
-	}
495
+            case 'vat_class' :
496
+                echo $wpinv_euvat->item_class_label( $item->get_id() );
497
+                break;
457 498
 
458
-	/**
459
-	 * Displays items table columns.
460
-	 */
461
-	public static function display_item_columns( $column_name, $post_id ) {
462
-		global $wpinv_euvat;
499
+            case 'shortcode' :
500
+                echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
501
+                break;
463 502
 
464
-		$item = new WPInv_Item( $post_id );
503
+            case 'type' :
504
+                echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
505
+                break;
465 506
 
466
-		switch ( $column_name ) {
507
+        }
467 508
 
468
-			case 'price' :
509
+    }
469 510
 
470
-				if ( ! $item->is_recurring() ) {
471
-					echo $item->get_the_price();
472
-					break;
473
-				}
511
+    /**
512
+     * Lets users filter items using taxes.
513
+     */
514
+    public static function add_item_filters( $post_type ) {
515
+        $wpinv_euvat = getpaid_tax();
516
+
517
+        // Abort if we're not dealing with items.
518
+        if ( $post_type != 'wpi_item' ) {
519
+            return;
520
+        }
521
+
522
+        // Filter by vat rules.
523
+        if ( $wpinv_euvat->allow_vat_rules() ) {
524
+	
525
+            // Sanitize selected vat rule.
526
+            $vat_rule   = '';
527
+            $vat_rules  = $wpinv_euvat->get_rules();
528
+            if ( isset( $_GET['vat_rule'] ) ) {
529
+                $vat_rule   =  $_GET['vat_rule'];
530
+            }
531
+
532
+            // Filter by VAT rule.
533
+            echo wpinv_html_select(
534
+                array(
535
+                    'options'          => array_merge(
536
+                        array(
537
+                            '' => __( 'All VAT rules', 'invoicing' )
538
+                        ),
539
+                        $vat_rules
540
+                    ),
541
+                    'name'             => 'vat_rule',
542
+                    'id'               => 'vat_rule',
543
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
544
+                    'show_option_all'  => false,
545
+                    'show_option_none' => false,
546
+                    'class'            => 'gdmbx2-text-medium',
547
+                )
548
+            );
549
+
550
+            // Filter by VAT class.
551
+        }
474 552
 
475
-				$price = wp_sprintf(
476
-					__( '%s / %s', 'invoicing' ),
477
-					$item->get_the_price(),
478
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
479
-				);
553
+        // Filter by vat class.
554
+        if ( $wpinv_euvat->allow_vat_classes() ) {
555
+	
556
+            // Sanitize selected vat rule.
557
+            $vat_class   = '';
558
+            $vat_classes = $wpinv_euvat->get_all_classes();
559
+            if ( isset( $_GET['vat_class'] ) ) {
560
+                $vat_class   =  $_GET['vat_class'];
561
+            }
562
+
563
+            echo wpinv_html_select(
564
+                array(
565
+                    'options'          => array_merge(
566
+                        array(
567
+                            '' => __( 'All VAT classes', 'invoicing' )
568
+                        ),
569
+                        $vat_classes
570
+                    ),
571
+                    'name'             => 'vat_class',
572
+                    'id'               => 'vat_class',
573
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
574
+                    'show_option_all'  => false,
575
+                    'show_option_none' => false,
576
+                    'class'            => 'gdmbx2-text-medium',
577
+                )
578
+            );
480 579
 
481
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
482
-					echo $price;
483
-					break;
484
-				}
580
+        }
485 581
 
486
-				echo $item->get_the_initial_price();
582
+        // Filter by item type.
583
+        $type   = '';
584
+        if ( isset( $_GET['type'] ) ) {
585
+            $type   =  $_GET['type'];
586
+        }
487 587
 
488
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
489
-				break;
588
+        echo wpinv_html_select(
589
+            array(
590
+                'options'          => array_merge(
591
+                    array(
592
+                        '' => __( 'All item types', 'invoicing' )
593
+                    ),
594
+                    wpinv_get_item_types()
595
+                ),
596
+                'name'             => 'type',
597
+                'id'               => 'type',
598
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
599
+                'show_option_all'  => false,
600
+                'show_option_none' => false,
601
+                'class'            => 'gdmbx2-text-medium',
602
+            )
603
+        );
604
+
605
+    }
490 606
 
491
-			case 'vat_rule' :
492
-				echo $wpinv_euvat->item_rule_label( $item->get_id() );
493
-				break;
607
+    /**
608
+     * Filters the item query.
609
+     */
610
+    public static function filter_item_query( $query ) {
494 611
 
495
-			case 'vat_class' :
496
-				echo $wpinv_euvat->item_class_label( $item->get_id() );
497
-				break;
612
+        // modify the query only if it admin and main query.
613
+        if ( ! ( is_admin() && $query->is_main_query() ) ){ 
614
+            return $query;
615
+        }
498 616
 
499
-			case 'shortcode' :
500
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
501
-				break;
617
+        // we want to modify the query for our items.
618
+        if ( 'wpi_item' != $query->query['post_type'] ){
619
+            return $query;
620
+        }
502 621
 
503
-			case 'type' :
504
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
505
-				break;
622
+        if ( empty( $query->query_vars['meta_query'] ) ) {
623
+            $query->query_vars['meta_query'] = array();
624
+        }
506 625
 
507
-		}
508
-
509
-	}
510
-
511
-	/**
512
-	 * Lets users filter items using taxes.
513
-	 */
514
-	public static function add_item_filters( $post_type ) {
515
-		$wpinv_euvat = getpaid_tax();
516
-
517
-		// Abort if we're not dealing with items.
518
-		if ( $post_type != 'wpi_item' ) {
519
-			return;
520
-		}
521
-
522
-		// Filter by vat rules.
523
-		if ( $wpinv_euvat->allow_vat_rules() ) {
524
-	
525
-			// Sanitize selected vat rule.
526
-			$vat_rule   = '';
527
-			$vat_rules  = $wpinv_euvat->get_rules();
528
-			if ( isset( $_GET['vat_rule'] ) ) {
529
-				$vat_rule   =  $_GET['vat_rule'];
530
-			}
531
-
532
-			// Filter by VAT rule.
533
-			echo wpinv_html_select(
534
-				array(
535
-					'options'          => array_merge(
536
-						array(
537
-							'' => __( 'All VAT rules', 'invoicing' )
538
-						),
539
-						$vat_rules
540
-					),
541
-					'name'             => 'vat_rule',
542
-					'id'               => 'vat_rule',
543
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
544
-					'show_option_all'  => false,
545
-					'show_option_none' => false,
546
-					'class'            => 'gdmbx2-text-medium',
547
-				)
548
-			);
549
-
550
-			// Filter by VAT class.
551
-		}
552
-
553
-		// Filter by vat class.
554
-		if ( $wpinv_euvat->allow_vat_classes() ) {
555
-	
556
-			// Sanitize selected vat rule.
557
-			$vat_class   = '';
558
-			$vat_classes = $wpinv_euvat->get_all_classes();
559
-			if ( isset( $_GET['vat_class'] ) ) {
560
-				$vat_class   =  $_GET['vat_class'];
561
-			}
562
-
563
-			echo wpinv_html_select(
564
-				array(
565
-					'options'          => array_merge(
566
-						array(
567
-							'' => __( 'All VAT classes', 'invoicing' )
568
-						),
569
-						$vat_classes
570
-					),
571
-					'name'             => 'vat_class',
572
-					'id'               => 'vat_class',
573
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
574
-					'show_option_all'  => false,
575
-					'show_option_none' => false,
576
-					'class'            => 'gdmbx2-text-medium',
577
-				)
578
-			);
579
-
580
-		}
581
-
582
-		// Filter by item type.
583
-		$type   = '';
584
-		if ( isset( $_GET['type'] ) ) {
585
-			$type   =  $_GET['type'];
586
-		}
587
-
588
-		echo wpinv_html_select(
589
-			array(
590
-				'options'          => array_merge(
591
-					array(
592
-						'' => __( 'All item types', 'invoicing' )
593
-					),
594
-					wpinv_get_item_types()
595
-				),
596
-				'name'             => 'type',
597
-				'id'               => 'type',
598
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
599
-				'show_option_all'  => false,
600
-				'show_option_none' => false,
601
-				'class'            => 'gdmbx2-text-medium',
602
-			)
603
-		);
604
-
605
-	}
606
-
607
-	/**
608
-	 * Filters the item query.
609
-	 */
610
-	public static function filter_item_query( $query ) {
611
-
612
-		// modify the query only if it admin and main query.
613
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
614
-			return $query;
615
-		}
616
-
617
-		// we want to modify the query for our items.
618
-		if ( 'wpi_item' != $query->query['post_type'] ){
619
-			return $query;
620
-		}
621
-
622
-		if ( empty( $query->query_vars['meta_query'] ) ) {
623
-			$query->query_vars['meta_query'] = array();
624
-		}
625
-
626
-		// Filter vat rule type
626
+        // Filter vat rule type
627 627
         if ( ! empty( $_GET['vat_rule'] ) ) {
628 628
             $query->query_vars['meta_query'][] = array(
629 629
                 'key'     => '_wpinv_vat_rule',
@@ -648,94 +648,94 @@  discard block
 block discarded – undo
648 648
                 'value'   => sanitize_text_field( $_GET['type'] ),
649 649
                 'compare' => '='
650 650
             );
651
-		}
652
-
653
-	}
654
-
655
-	/**
656
-	 * Reorders items.
657
-	 */
658
-	public static function reorder_items( $vars ) {
659
-		global $typenow;
660
-
661
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
662
-			return $vars;
663
-		}
664
-
665
-		// By item type.
666
-		if ( 'type' == $vars['orderby'] ) {
667
-			return array_merge(
668
-				$vars,
669
-				array(
670
-					'meta_key' => '_wpinv_type',
671
-					'orderby'  => 'meta_value'
672
-				)
673
-			);
674
-		}
675
-
676
-		// By vat class.
677
-		if ( 'vat_class' == $vars['orderby'] ) {
678
-			return array_merge(
679
-				$vars,
680
-				array(
681
-					'meta_key' => '_wpinv_vat_class',
682
-					'orderby'  => 'meta_value'
683
-				)
684
-			);
685
-		}
686
-
687
-		// By vat rule.
688
-		if ( 'vat_rule' == $vars['orderby'] ) {
689
-			return array_merge(
690
-				$vars,
691
-				array(
692
-					'meta_key' => '_wpinv_vat_rule',
693
-					'orderby'  => 'meta_value'
694
-				)
695
-			);
696
-		}
697
-
698
-		// By price.
699
-		if ( 'price' == $vars['orderby'] ) {
700
-			return array_merge(
701
-				$vars,
702
-				array(
703
-					'meta_key' => '_wpinv_price',
704
-					'orderby'  => 'meta_value_num'
705
-				)
706
-			);
707
-		}
708
-
709
-		return $vars;
710
-
711
-	}
712
-
713
-	/**
714
-	 * Fired when deleting a post.
715
-	 */
716
-	public static function delete_post( $post_id ) {
717
-
718
-		switch ( get_post_type( $post_id ) ) {
719
-
720
-			case 'wpi_item' :
721
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
722
-				break;
723
-
724
-			case 'wpi_payment_form' :
725
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
726
-				break;
727
-
728
-			case 'wpi_discount' :
729
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
730
-				break;
731
-
732
-			case 'wpi_invoice' :
733
-				$invoice = new WPInv_Invoice( $post_id );
734
-				do_action( "getpaid_before_delete_invoice", $invoice );
735
-				$invoice->get_data_store()->delete_items( $invoice );
736
-				$invoice->get_data_store()->delete_special_fields( $invoice );
737
-				break;
738
-		}
739
-	}
651
+        }
652
+
653
+    }
654
+
655
+    /**
656
+     * Reorders items.
657
+     */
658
+    public static function reorder_items( $vars ) {
659
+        global $typenow;
660
+
661
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
662
+            return $vars;
663
+        }
664
+
665
+        // By item type.
666
+        if ( 'type' == $vars['orderby'] ) {
667
+            return array_merge(
668
+                $vars,
669
+                array(
670
+                    'meta_key' => '_wpinv_type',
671
+                    'orderby'  => 'meta_value'
672
+                )
673
+            );
674
+        }
675
+
676
+        // By vat class.
677
+        if ( 'vat_class' == $vars['orderby'] ) {
678
+            return array_merge(
679
+                $vars,
680
+                array(
681
+                    'meta_key' => '_wpinv_vat_class',
682
+                    'orderby'  => 'meta_value'
683
+                )
684
+            );
685
+        }
686
+
687
+        // By vat rule.
688
+        if ( 'vat_rule' == $vars['orderby'] ) {
689
+            return array_merge(
690
+                $vars,
691
+                array(
692
+                    'meta_key' => '_wpinv_vat_rule',
693
+                    'orderby'  => 'meta_value'
694
+                )
695
+            );
696
+        }
697
+
698
+        // By price.
699
+        if ( 'price' == $vars['orderby'] ) {
700
+            return array_merge(
701
+                $vars,
702
+                array(
703
+                    'meta_key' => '_wpinv_price',
704
+                    'orderby'  => 'meta_value_num'
705
+                )
706
+            );
707
+        }
708
+
709
+        return $vars;
710
+
711
+    }
712
+
713
+    /**
714
+     * Fired when deleting a post.
715
+     */
716
+    public static function delete_post( $post_id ) {
717
+
718
+        switch ( get_post_type( $post_id ) ) {
719
+
720
+            case 'wpi_item' :
721
+                do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
722
+                break;
723
+
724
+            case 'wpi_payment_form' :
725
+                do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
726
+                break;
727
+
728
+            case 'wpi_discount' :
729
+                do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
730
+                break;
731
+
732
+            case 'wpi_invoice' :
733
+                $invoice = new WPInv_Invoice( $post_id );
734
+                do_action( "getpaid_before_delete_invoice", $invoice );
735
+                $invoice->get_data_store()->delete_items( $invoice );
736
+                $invoice->get_data_store()->delete_special_fields( $invoice );
737
+                break;
738
+        }
739
+    }
740 740
 
741 741
 }
Please login to merge, or discard this patch.
Spacing   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Post types Admin Class
@@ -21,69 +21,69 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28 28
 
29 29
 		// Invoice table columns.
30
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
30
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
31
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
32 32
 
33 33
 		// Items table columns.
34
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
35
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
36
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
37
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
38
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
39
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
34
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
35
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
36
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
37
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
38
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
39
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
40 40
 
41 41
 		// Payment forms columns.
42
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
43
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
44
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
42
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
43
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
44
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
45 45
 
46 46
 		// Discount table columns.
47
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
48
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
47
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
48
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
49 49
 
50 50
 		// Deleting posts.
51
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
52
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
51
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
52
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * Post updated messages.
57 57
 	 */
58
-	public static function post_updated_messages( $messages ) {
58
+	public static function post_updated_messages($messages) {
59 59
 		global $post;
60 60
 
61 61
 		$messages['wpi_discount'] = array(
62 62
 			0   => '',
63
-			1   => __( 'Discount updated.', 'invoicing' ),
64
-			2   => __( 'Custom field updated.', 'invoicing' ),
65
-			3   => __( 'Custom field deleted.', 'invoicing' ),
66
-			4   => __( 'Discount updated.', 'invoicing' ),
67
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
68
-			6   => __( 'Discount updated.', 'invoicing' ),
69
-			7   => __( 'Discount saved.', 'invoicing' ),
70
-			8   => __( 'Discount submitted.', 'invoicing' ),
71
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
72
-			10  => __( 'Discount draft updated.', 'invoicing' ),
63
+			1   => __('Discount updated.', 'invoicing'),
64
+			2   => __('Custom field updated.', 'invoicing'),
65
+			3   => __('Custom field deleted.', 'invoicing'),
66
+			4   => __('Discount updated.', 'invoicing'),
67
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
68
+			6   => __('Discount updated.', 'invoicing'),
69
+			7   => __('Discount saved.', 'invoicing'),
70
+			8   => __('Discount submitted.', 'invoicing'),
71
+			9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
72
+			10  => __('Discount draft updated.', 'invoicing'),
73 73
 		);
74 74
 
75 75
 		$messages['wpi_payment_form'] = array(
76 76
 			0   => '',
77
-			1   => __( 'Payment Form updated.', 'invoicing' ),
78
-			2   => __( 'Custom field updated.', 'invoicing' ),
79
-			3   => __( 'Custom field deleted.', 'invoicing' ),
80
-			4   => __( 'Payment Form updated.', 'invoicing' ),
81
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
82
-			6   => __( 'Payment Form updated.', 'invoicing' ),
83
-			7   => __( 'Payment Form saved.', 'invoicing' ),
84
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
85
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
86
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
77
+			1   => __('Payment Form updated.', 'invoicing'),
78
+			2   => __('Custom field updated.', 'invoicing'),
79
+			3   => __('Custom field deleted.', 'invoicing'),
80
+			4   => __('Payment Form updated.', 'invoicing'),
81
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
82
+			6   => __('Payment Form updated.', 'invoicing'),
83
+			7   => __('Payment Form saved.', 'invoicing'),
84
+			8   => __('Payment Form submitted.', 'invoicing'),
85
+			9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
86
+			10  => __('Payment Form draft updated.', 'invoicing'),
87 87
 		);
88 88
 
89 89
 		return $messages;
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * Post row actions.
95 95
 	 */
96
-	public static function post_row_actions( $actions, $post ) {
96
+	public static function post_row_actions($actions, $post) {
97 97
 
98
-		$post = get_post( $post );
98
+		$post = get_post($post);
99 99
 
100 100
 		// We do not want to edit the default payment form.
101
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
102
-			unset( $actions['trash'] );
103
-			unset( $actions['inline hide-if-no-js'] );
101
+		if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
102
+			unset($actions['trash']);
103
+			unset($actions['inline hide-if-no-js']);
104 104
 		}
105 105
 
106 106
 		return $actions;
@@ -109,51 +109,51 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * Returns an array of invoice table columns.
111 111
 	 */
112
-	public static function invoice_columns( $columns ) {
112
+	public static function invoice_columns($columns) {
113 113
 
114 114
 		$columns = array(
115 115
 			'cb'                => $columns['cb'],
116
-			'number'            => __( 'Invoice', 'invoicing' ),
117
-			'customer'          => __( 'Customer', 'invoicing' ),
118
-			'invoice_date'      => __( 'Date', 'invoicing' ),
119
-			'amount'            => __( 'Amount', 'invoicing' ),
120
-			'recurring'         => __( 'Recurring', 'invoicing' ),
121
-			'status'            => __( 'Status', 'invoicing' ),
122
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
116
+			'number'            => __('Invoice', 'invoicing'),
117
+			'customer'          => __('Customer', 'invoicing'),
118
+			'invoice_date'      => __('Date', 'invoicing'),
119
+			'amount'            => __('Amount', 'invoicing'),
120
+			'recurring'         => __('Recurring', 'invoicing'),
121
+			'status'            => __('Status', 'invoicing'),
122
+			'wpi_actions'       => __('Actions', 'invoicing'),
123 123
 		);
124 124
 
125
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
125
+		return apply_filters('wpi_invoice_table_columns', $columns);
126 126
 	}
127 127
 
128 128
 	/**
129 129
 	 * Displays invoice table columns.
130 130
 	 */
131
-	public static function display_invoice_columns( $column_name, $post_id ) {
131
+	public static function display_invoice_columns($column_name, $post_id) {
132 132
 
133
-		$invoice = new WPInv_Invoice( $post_id );
133
+		$invoice = new WPInv_Invoice($post_id);
134 134
 
135
-		switch ( $column_name ) {
135
+		switch ($column_name) {
136 136
 
137 137
 			case 'invoice_date' :
138
-				$date_time = esc_attr( $invoice->get_created_date() );
139
-				$date      = getpaid_format_date_value( $date_time );
138
+				$date_time = esc_attr($invoice->get_created_date());
139
+				$date      = getpaid_format_date_value($date_time);
140 140
 				echo "<span title='$date_time'>$date</span>";
141 141
 				break;
142 142
 
143 143
 			case 'amount' :
144 144
 
145 145
 				$amount = $invoice->get_total();
146
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
146
+				$formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency());
147 147
 
148
-				if ( $invoice->is_refunded() ) {
149
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
148
+				if ($invoice->is_refunded()) {
149
+					$refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency());
150 150
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
151 151
 				} else {
152 152
 
153 153
 					$discount = $invoice->get_total_discount();
154 154
 
155
-					if ( ! empty( $discount ) ) {
156
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
155
+					if (!empty($discount)) {
156
+						$new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency());
157 157
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
158 158
 					} else {
159 159
 						echo $formated_amount;
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 				break;
165 165
 
166 166
 			case 'status' :
167
-				$status       = sanitize_text_field( $invoice->get_status() );
168
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
167
+				$status       = sanitize_text_field($invoice->get_status());
168
+				$status_label = sanitize_text_field($invoice->get_status_nicename());
169 169
 
170 170
 				// If it is paid, show the gateway title.
171
-				if ( $invoice->is_paid() ) {
172
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
173
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
171
+				if ($invoice->is_paid()) {
172
+					$gateway = sanitize_text_field($invoice->get_gateway_title());
173
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
174 174
 
175 175
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
176 176
 				} else {
@@ -178,22 +178,22 @@  discard block
 block discarded – undo
178 178
 				}
179 179
 
180 180
 				// If it is not paid, display the overdue and view status.
181
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
181
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
182 182
 
183 183
 					// Invoice view status.
184
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
185
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
184
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
185
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
186 186
 					} else {
187
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
187
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
188 188
 					}
189 189
 
190 190
 					// Display the overview status.
191
-					if ( wpinv_get_option( 'overdue_active' ) ) {
191
+					if (wpinv_get_option('overdue_active')) {
192 192
 						$due_date = $invoice->get_due_date();
193
-						$fomatted = getpaid_format_date( $due_date );
193
+						$fomatted = getpaid_format_date($due_date);
194 194
 
195
-						if ( ! empty( $fomatted ) ) {
196
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
195
+						if (!empty($fomatted)) {
196
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
197 197
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
198 198
 						}
199 199
 					}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 			case 'recurring':
206 206
 
207
-				if ( $invoice->is_recurring() ) {
207
+				if ($invoice->is_recurring()) {
208 208
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
209 209
 				} else {
210 210
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 
214 214
 			case 'number' :
215 215
 
216
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
217
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
218
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
216
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
217
+				$invoice_number  = sanitize_text_field($invoice->get_number());
218
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
219 219
 
220 220
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
221 221
 
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 	
226 226
 				$customer_name = $invoice->get_user_full_name();
227 227
 	
228
-				if ( empty( $customer_name ) ) {
228
+				if (empty($customer_name)) {
229 229
 					$customer_name = $invoice->get_email();
230 230
 				}
231 231
 	
232
-				if ( ! empty( $customer_name ) ) {
233
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
234
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
232
+				if (!empty($customer_name)) {
233
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
234
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
235 235
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
236 236
 				} else {
237 237
 					echo '<div>&mdash;</div>';
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 
242 242
 			case 'wpi_actions' :
243 243
 
244
-				if ( $invoice->is_draft() ) {
244
+				if ($invoice->is_draft()) {
245 245
 					return;
246 246
 				}
247 247
 
248
-				$url    = esc_url( $invoice->get_view_url() );
249
-				$print  = esc_attr__( 'Print invoice', 'invoicing' );
248
+				$url    = esc_url($invoice->get_view_url());
249
+				$print  = esc_attr__('Print invoice', 'invoicing');
250 250
 				echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
251 251
 
252 252
 				$url    = esc_url(
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 					)
263 263
 				);
264 264
 
265
-				$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
265
+				$send = esc_attr__('Send invoice to customer', 'invoicing');
266 266
 				echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
267 267
 
268 268
 				break;
@@ -273,50 +273,50 @@  discard block
 block discarded – undo
273 273
 	/**
274 274
 	 * Returns an array of payment forms table columns.
275 275
 	 */
276
-	public static function payment_form_columns( $columns ) {
276
+	public static function payment_form_columns($columns) {
277 277
 
278 278
 		$columns = array(
279 279
 			'cb'                => $columns['cb'],
280
-			'title'             => __( 'Name', 'invoicing' ),
281
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
282
-			'earnings'          => __( 'Revenue', 'invoicing' ),
283
-			'refunds'           => __( 'Refunded', 'invoicing' ),
284
-			'items'             => __( 'Items', 'invoicing' ),
285
-			'date'              => __( 'Date', 'invoicing' ),
280
+			'title'             => __('Name', 'invoicing'),
281
+			'shortcode'         => __('Shortcode', 'invoicing'),
282
+			'earnings'          => __('Revenue', 'invoicing'),
283
+			'refunds'           => __('Refunded', 'invoicing'),
284
+			'items'             => __('Items', 'invoicing'),
285
+			'date'              => __('Date', 'invoicing'),
286 286
 		);
287 287
 
288
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
288
+		return apply_filters('wpi_payment_form_table_columns', $columns);
289 289
 
290 290
 	}
291 291
 
292 292
 	/**
293 293
 	 * Displays payment form table columns.
294 294
 	 */
295
-	public static function display_payment_form_columns( $column_name, $post_id ) {
295
+	public static function display_payment_form_columns($column_name, $post_id) {
296 296
 
297 297
 		// Retrieve the payment form.
298
-		$form = new GetPaid_Payment_Form( $post_id );
298
+		$form = new GetPaid_Payment_Form($post_id);
299 299
 
300
-		switch ( $column_name ) {
300
+		switch ($column_name) {
301 301
 
302 302
 			case 'earnings' :
303
-				echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
303
+				echo wpinv_price(wpinv_format_amount($form->get_earned()));
304 304
 				break;
305 305
 
306 306
 			case 'refunds' :
307
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
307
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
308 308
 				break;
309 309
 
310 310
 			case 'refunds' :
311
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
311
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
312 312
 				break;
313 313
 
314 314
 			case 'shortcode' :
315 315
 
316
-				if ( $form->is_default() ) {
316
+				if ($form->is_default()) {
317 317
 					echo '&mdash;';
318 318
 				} else {
319
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
319
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
320 320
 				}
321 321
 
322 322
 				break;
@@ -325,29 +325,29 @@  discard block
 block discarded – undo
325 325
 
326 326
 				$items = $form->get_items();
327 327
 
328
-				if ( $form->is_default() || empty( $items ) ) {
328
+				if ($form->is_default() || empty($items)) {
329 329
 					echo '&mdash;';
330 330
 					return;
331 331
 				}
332 332
 
333 333
 				$_items = array();
334 334
 
335
-				foreach ( $items as $item ) {
335
+				foreach ($items as $item) {
336 336
 					$url = $item->get_edit_url();
337 337
 
338
-					if ( empty( $url ) ) {
339
-						$_items[] = sanitize_text_field( $item->get_name() );
338
+					if (empty($url)) {
339
+						$_items[] = sanitize_text_field($item->get_name());
340 340
 					} else {
341 341
 						$_items[] = sprintf(
342 342
 							'<a href="%s">%s</a>',
343
-							esc_url( $url ),
344
-							sanitize_text_field( $item->get_name() )
343
+							esc_url($url),
344
+							sanitize_text_field($item->get_name())
345 345
 						);
346 346
 					}
347 347
 
348 348
 				}
349 349
 
350
-				echo implode( '<br>', $_items );
350
+				echo implode('<br>', $_items);
351 351
 
352 352
 				break;
353 353
 
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
 	/**
359 359
 	 * Filters post states.
360 360
 	 */
361
-	public static function filter_payment_form_state( $post_states, $post ) {
361
+	public static function filter_payment_form_state($post_states, $post) {
362 362
 
363
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
364
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
363
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
364
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
365 365
 		}
366 366
 	
367 367
 		return $post_states;
@@ -371,35 +371,35 @@  discard block
 block discarded – undo
371 371
 	/**
372 372
 	 * Returns an array of coupon table columns.
373 373
 	 */
374
-	public static function discount_columns( $columns ) {
374
+	public static function discount_columns($columns) {
375 375
 
376 376
 		$columns = array(
377 377
 			'cb'                => $columns['cb'],
378
-			'title'             => __( 'Name', 'invoicing' ),
379
-			'code'              => __( 'Code', 'invoicing' ),
380
-			'amount'            => __( 'Amount', 'invoicing' ),
381
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
382
-			'start_date'        => __( 'Start Date', 'invoicing' ),
383
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
378
+			'title'             => __('Name', 'invoicing'),
379
+			'code'              => __('Code', 'invoicing'),
380
+			'amount'            => __('Amount', 'invoicing'),
381
+			'usage'             => __('Usage / Limit', 'invoicing'),
382
+			'start_date'        => __('Start Date', 'invoicing'),
383
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
384 384
 		);
385 385
 
386
-		return apply_filters( 'wpi_discount_table_columns', $columns );
386
+		return apply_filters('wpi_discount_table_columns', $columns);
387 387
 	}
388 388
 
389 389
 	/**
390 390
 	 * Filters post states.
391 391
 	 */
392
-	public static function filter_discount_state( $post_states, $post ) {
392
+	public static function filter_discount_state($post_states, $post) {
393 393
 
394
-		if ( 'wpi_discount' == $post->post_type ) {
394
+		if ('wpi_discount' == $post->post_type) {
395 395
 
396
-			$discount = new WPInv_Discount( $post );
396
+			$discount = new WPInv_Discount($post);
397 397
 
398 398
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
399 399
 
400
-			if ( $status != 'publish' ) {
400
+			if ($status != 'publish') {
401 401
 				return array(
402
-					'discount_status' => wpinv_discount_status( $status ),
402
+					'discount_status' => wpinv_discount_status($status),
403 403
 				);
404 404
 			}
405 405
 
@@ -414,34 +414,34 @@  discard block
 block discarded – undo
414 414
 	/**
415 415
 	 * Returns an array of items table columns.
416 416
 	 */
417
-	public static function item_columns( $columns ) {
417
+	public static function item_columns($columns) {
418 418
 		global $wpinv_euvat;
419 419
 
420 420
 		$columns = array(
421 421
 			'cb'                => $columns['cb'],
422
-			'title'             => __( 'Name', 'invoicing' ),
423
-			'price'             => __( 'Price', 'invoicing' ),
424
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
425
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
426
-			'type'              => __( 'Type', 'invoicing' ),
427
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
422
+			'title'             => __('Name', 'invoicing'),
423
+			'price'             => __('Price', 'invoicing'),
424
+			'vat_rule'          => __('VAT rule', 'invoicing'),
425
+			'vat_class'         => __('VAT class', 'invoicing'),
426
+			'type'              => __('Type', 'invoicing'),
427
+			'shortcode'         => __('Shortcode', 'invoicing'),
428 428
 		);
429 429
 
430
-		if ( ! $wpinv_euvat->allow_vat_rules() ) {
431
-			unset( $columns['vat_rule'] );
430
+		if (!$wpinv_euvat->allow_vat_rules()) {
431
+			unset($columns['vat_rule']);
432 432
 		}
433 433
 
434
-		if ( ! $wpinv_euvat->allow_vat_classes() ) {
435
-			unset( $columns['vat_class'] );
434
+		if (!$wpinv_euvat->allow_vat_classes()) {
435
+			unset($columns['vat_class']);
436 436
 		}
437 437
 
438
-		return apply_filters( 'wpi_item_table_columns', $columns );
438
+		return apply_filters('wpi_item_table_columns', $columns);
439 439
 	}
440 440
 
441 441
 	/**
442 442
 	 * Returns an array of sortable items table columns.
443 443
 	 */
444
-	public static function sortable_item_columns( $columns ) {
444
+	public static function sortable_item_columns($columns) {
445 445
 
446 446
 		return array_merge(
447 447
 			$columns,
@@ -458,50 +458,50 @@  discard block
 block discarded – undo
458 458
 	/**
459 459
 	 * Displays items table columns.
460 460
 	 */
461
-	public static function display_item_columns( $column_name, $post_id ) {
461
+	public static function display_item_columns($column_name, $post_id) {
462 462
 		global $wpinv_euvat;
463 463
 
464
-		$item = new WPInv_Item( $post_id );
464
+		$item = new WPInv_Item($post_id);
465 465
 
466
-		switch ( $column_name ) {
466
+		switch ($column_name) {
467 467
 
468 468
 			case 'price' :
469 469
 
470
-				if ( ! $item->is_recurring() ) {
470
+				if (!$item->is_recurring()) {
471 471
 					echo $item->get_the_price();
472 472
 					break;
473 473
 				}
474 474
 
475 475
 				$price = wp_sprintf(
476
-					__( '%s / %s', 'invoicing' ),
476
+					__('%s / %s', 'invoicing'),
477 477
 					$item->get_the_price(),
478
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
478
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
479 479
 				);
480 480
 
481
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
481
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
482 482
 					echo $price;
483 483
 					break;
484 484
 				}
485 485
 
486 486
 				echo $item->get_the_initial_price();
487 487
 
488
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
488
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
489 489
 				break;
490 490
 
491 491
 			case 'vat_rule' :
492
-				echo $wpinv_euvat->item_rule_label( $item->get_id() );
492
+				echo $wpinv_euvat->item_rule_label($item->get_id());
493 493
 				break;
494 494
 
495 495
 			case 'vat_class' :
496
-				echo $wpinv_euvat->item_class_label( $item->get_id() );
496
+				echo $wpinv_euvat->item_class_label($item->get_id());
497 497
 				break;
498 498
 
499 499
 			case 'shortcode' :
500
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
500
+				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
501 501
 				break;
502 502
 
503 503
 			case 'type' :
504
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
504
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
505 505
 				break;
506 506
 
507 507
 		}
@@ -511,22 +511,22 @@  discard block
 block discarded – undo
511 511
 	/**
512 512
 	 * Lets users filter items using taxes.
513 513
 	 */
514
-	public static function add_item_filters( $post_type ) {
514
+	public static function add_item_filters($post_type) {
515 515
 		$wpinv_euvat = getpaid_tax();
516 516
 
517 517
 		// Abort if we're not dealing with items.
518
-		if ( $post_type != 'wpi_item' ) {
518
+		if ($post_type != 'wpi_item') {
519 519
 			return;
520 520
 		}
521 521
 
522 522
 		// Filter by vat rules.
523
-		if ( $wpinv_euvat->allow_vat_rules() ) {
523
+		if ($wpinv_euvat->allow_vat_rules()) {
524 524
 	
525 525
 			// Sanitize selected vat rule.
526 526
 			$vat_rule   = '';
527 527
 			$vat_rules  = $wpinv_euvat->get_rules();
528
-			if ( isset( $_GET['vat_rule'] ) ) {
529
-				$vat_rule   =  $_GET['vat_rule'];
528
+			if (isset($_GET['vat_rule'])) {
529
+				$vat_rule = $_GET['vat_rule'];
530 530
 			}
531 531
 
532 532
 			// Filter by VAT rule.
@@ -534,13 +534,13 @@  discard block
 block discarded – undo
534 534
 				array(
535 535
 					'options'          => array_merge(
536 536
 						array(
537
-							'' => __( 'All VAT rules', 'invoicing' )
537
+							'' => __('All VAT rules', 'invoicing')
538 538
 						),
539 539
 						$vat_rules
540 540
 					),
541 541
 					'name'             => 'vat_rule',
542 542
 					'id'               => 'vat_rule',
543
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
543
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
544 544
 					'show_option_all'  => false,
545 545
 					'show_option_none' => false,
546 546
 					'class'            => 'gdmbx2-text-medium',
@@ -551,26 +551,26 @@  discard block
 block discarded – undo
551 551
 		}
552 552
 
553 553
 		// Filter by vat class.
554
-		if ( $wpinv_euvat->allow_vat_classes() ) {
554
+		if ($wpinv_euvat->allow_vat_classes()) {
555 555
 	
556 556
 			// Sanitize selected vat rule.
557 557
 			$vat_class   = '';
558 558
 			$vat_classes = $wpinv_euvat->get_all_classes();
559
-			if ( isset( $_GET['vat_class'] ) ) {
560
-				$vat_class   =  $_GET['vat_class'];
559
+			if (isset($_GET['vat_class'])) {
560
+				$vat_class = $_GET['vat_class'];
561 561
 			}
562 562
 
563 563
 			echo wpinv_html_select(
564 564
 				array(
565 565
 					'options'          => array_merge(
566 566
 						array(
567
-							'' => __( 'All VAT classes', 'invoicing' )
567
+							'' => __('All VAT classes', 'invoicing')
568 568
 						),
569 569
 						$vat_classes
570 570
 					),
571 571
 					'name'             => 'vat_class',
572 572
 					'id'               => 'vat_class',
573
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
573
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
574 574
 					'show_option_all'  => false,
575 575
 					'show_option_none' => false,
576 576
 					'class'            => 'gdmbx2-text-medium',
@@ -580,22 +580,22 @@  discard block
 block discarded – undo
580 580
 		}
581 581
 
582 582
 		// Filter by item type.
583
-		$type   = '';
584
-		if ( isset( $_GET['type'] ) ) {
585
-			$type   =  $_GET['type'];
583
+		$type = '';
584
+		if (isset($_GET['type'])) {
585
+			$type = $_GET['type'];
586 586
 		}
587 587
 
588 588
 		echo wpinv_html_select(
589 589
 			array(
590 590
 				'options'          => array_merge(
591 591
 					array(
592
-						'' => __( 'All item types', 'invoicing' )
592
+						'' => __('All item types', 'invoicing')
593 593
 					),
594 594
 					wpinv_get_item_types()
595 595
 				),
596 596
 				'name'             => 'type',
597 597
 				'id'               => 'type',
598
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
598
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
599 599
 				'show_option_all'  => false,
600 600
 				'show_option_none' => false,
601 601
 				'class'            => 'gdmbx2-text-medium',
@@ -607,45 +607,45 @@  discard block
 block discarded – undo
607 607
 	/**
608 608
 	 * Filters the item query.
609 609
 	 */
610
-	public static function filter_item_query( $query ) {
610
+	public static function filter_item_query($query) {
611 611
 
612 612
 		// modify the query only if it admin and main query.
613
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
613
+		if (!(is_admin() && $query->is_main_query())) { 
614 614
 			return $query;
615 615
 		}
616 616
 
617 617
 		// we want to modify the query for our items.
618
-		if ( 'wpi_item' != $query->query['post_type'] ){
618
+		if ('wpi_item' != $query->query['post_type']) {
619 619
 			return $query;
620 620
 		}
621 621
 
622
-		if ( empty( $query->query_vars['meta_query'] ) ) {
622
+		if (empty($query->query_vars['meta_query'])) {
623 623
 			$query->query_vars['meta_query'] = array();
624 624
 		}
625 625
 
626 626
 		// Filter vat rule type
627
-        if ( ! empty( $_GET['vat_rule'] ) ) {
627
+        if (!empty($_GET['vat_rule'])) {
628 628
             $query->query_vars['meta_query'][] = array(
629 629
                 'key'     => '_wpinv_vat_rule',
630
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
630
+                'value'   => sanitize_text_field($_GET['vat_rule']),
631 631
                 'compare' => '='
632 632
             );
633 633
         }
634 634
 
635 635
         // Filter vat class
636
-        if ( ! empty( $_GET['vat_class'] ) ) {
636
+        if (!empty($_GET['vat_class'])) {
637 637
             $query->query_vars['meta_query'][] = array(
638 638
                 'key'     => '_wpinv_vat_class',
639
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
639
+                'value'   => sanitize_text_field($_GET['vat_class']),
640 640
                 'compare' => '='
641 641
             );
642 642
         }
643 643
 
644 644
         // Filter item type
645
-        if ( ! empty( $_GET['type'] ) ) {
645
+        if (!empty($_GET['type'])) {
646 646
             $query->query_vars['meta_query'][] = array(
647 647
                 'key'     => '_wpinv_type',
648
-                'value'   => sanitize_text_field( $_GET['type'] ),
648
+                'value'   => sanitize_text_field($_GET['type']),
649 649
                 'compare' => '='
650 650
             );
651 651
 		}
@@ -655,15 +655,15 @@  discard block
 block discarded – undo
655 655
 	/**
656 656
 	 * Reorders items.
657 657
 	 */
658
-	public static function reorder_items( $vars ) {
658
+	public static function reorder_items($vars) {
659 659
 		global $typenow;
660 660
 
661
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
661
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
662 662
 			return $vars;
663 663
 		}
664 664
 
665 665
 		// By item type.
666
-		if ( 'type' == $vars['orderby'] ) {
666
+		if ('type' == $vars['orderby']) {
667 667
 			return array_merge(
668 668
 				$vars,
669 669
 				array(
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		}
675 675
 
676 676
 		// By vat class.
677
-		if ( 'vat_class' == $vars['orderby'] ) {
677
+		if ('vat_class' == $vars['orderby']) {
678 678
 			return array_merge(
679 679
 				$vars,
680 680
 				array(
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 		}
686 686
 
687 687
 		// By vat rule.
688
-		if ( 'vat_rule' == $vars['orderby'] ) {
688
+		if ('vat_rule' == $vars['orderby']) {
689 689
 			return array_merge(
690 690
 				$vars,
691 691
 				array(
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		}
697 697
 
698 698
 		// By price.
699
-		if ( 'price' == $vars['orderby'] ) {
699
+		if ('price' == $vars['orderby']) {
700 700
 			return array_merge(
701 701
 				$vars,
702 702
 				array(
@@ -713,27 +713,27 @@  discard block
 block discarded – undo
713 713
 	/**
714 714
 	 * Fired when deleting a post.
715 715
 	 */
716
-	public static function delete_post( $post_id ) {
716
+	public static function delete_post($post_id) {
717 717
 
718
-		switch ( get_post_type( $post_id ) ) {
718
+		switch (get_post_type($post_id)) {
719 719
 
720 720
 			case 'wpi_item' :
721
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
721
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
722 722
 				break;
723 723
 
724 724
 			case 'wpi_payment_form' :
725
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
725
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
726 726
 				break;
727 727
 
728 728
 			case 'wpi_discount' :
729
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
729
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
730 730
 				break;
731 731
 
732 732
 			case 'wpi_invoice' :
733
-				$invoice = new WPInv_Invoice( $post_id );
734
-				do_action( "getpaid_before_delete_invoice", $invoice );
735
-				$invoice->get_data_store()->delete_items( $invoice );
736
-				$invoice->get_data_store()->delete_special_fields( $invoice );
733
+				$invoice = new WPInv_Invoice($post_id);
734
+				do_action("getpaid_before_delete_invoice", $invoice);
735
+				$invoice->get_data_store()->delete_items($invoice);
736
+				$invoice->get_data_store()->delete_special_fields($invoice);
737 737
 				break;
738 738
 		}
739 739
 	}
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 }
57 57
 
58 58
 function wpinv_admin_messages() {
59
-	settings_errors( 'wpinv-notices' );
59
+    settings_errors( 'wpinv-notices' );
60 60
 }
61 61
 add_action( 'admin_notices', 'wpinv_admin_messages' );
62 62
 
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -7,65 +7,65 @@  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
-function wpinv_bulk_actions( $actions ) {
15
-    if ( isset( $actions['edit'] ) ) {
16
-        unset( $actions['edit'] );
14
+function wpinv_bulk_actions($actions) {
15
+    if (isset($actions['edit'])) {
16
+        unset($actions['edit']);
17 17
     }
18 18
 
19 19
     return $actions;
20 20
 }
21
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
22
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
21
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
22
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
23 23
 
24
-function wpinv_admin_post_id( $id = 0 ) {
24
+function wpinv_admin_post_id($id = 0) {
25 25
     global $post;
26 26
 
27
-    if ( isset( $id ) && ! empty( $id ) ) {
28
-        return (int)$id;
29
-    } else if ( get_the_ID() ) {
27
+    if (isset($id) && !empty($id)) {
28
+        return (int) $id;
29
+    } else if (get_the_ID()) {
30 30
         return (int) get_the_ID();
31
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
31
+    } else if (isset($post->ID) && !empty($post->ID)) {
32 32
         return (int) $post->ID;
33
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
33
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
34 34
         return (int) $_GET['post'];
35
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
35
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
36 36
         return (int) $_GET['id'];
37
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
37
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
38 38
         return (int) $_POST['id'];
39 39
     } 
40 40
 
41 41
     return null;
42 42
 }
43 43
     
44
-function wpinv_admin_post_type( $id = 0 ) {
45
-    if ( !$id ) {
44
+function wpinv_admin_post_type($id = 0) {
45
+    if (!$id) {
46 46
         $id = wpinv_admin_post_id();
47 47
     }
48 48
     
49
-    $type = get_post_type( $id );
49
+    $type = get_post_type($id);
50 50
     
51
-    if ( !$type ) {
52
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
51
+    if (!$type) {
52
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
53 53
     }
54 54
     
55
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
55
+    return apply_filters('wpinv_admin_post_type', $type, $id);
56 56
 }
57 57
 
58 58
 function wpinv_admin_messages() {
59
-	settings_errors( 'wpinv-notices' );
59
+	settings_errors('wpinv-notices');
60 60
 }
61
-add_action( 'admin_notices', 'wpinv_admin_messages' );
61
+add_action('admin_notices', 'wpinv_admin_messages');
62 62
 
63
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
64
-function wpinv_show_test_payment_gateway_notice(){
65
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
63
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
64
+function wpinv_show_test_payment_gateway_notice() {
65
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
66 66
 }
67 67
 
68
-function wpinv_test_payment_gateway_messages(){
68
+function wpinv_test_payment_gateway_messages() {
69 69
     $gateways = wpinv_get_enabled_payment_gateways();
70 70
     $name = array(); $test_gateways = '';
71 71
     if ($gateways) {
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
         }
77 77
         $test_gateways = implode(', ', $name);
78 78
     }
79
-    if(isset($test_gateways) && !empty($test_gateways)){
79
+    if (isset($test_gateways) && !empty($test_gateways)) {
80 80
         $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
81
-        $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link );
81
+        $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link);
82 82
         ?>
83 83
         <div class="notice notice-warning is-dismissible">
84 84
             <p><?php echo $notice; ?></p>
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
     }
88 88
 }
89 89
 
90
-function wpinv_send_invoice_after_save( $invoice ) {
91
-    if ( empty( $_POST['wpi_save_send'] ) ) {
90
+function wpinv_send_invoice_after_save($invoice) {
91
+    if (empty($_POST['wpi_save_send'])) {
92 92
         return;
93 93
     }
94 94
     
95
-    if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) {
96
-        wpinv_user_invoice_notification( $invoice->ID );
95
+    if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) {
96
+        wpinv_user_invoice_notification($invoice->ID);
97 97
     }
98 98
 }
99
-add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 );
99
+add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1);
100 100
 
101 101
 
102 102
 add_action('admin_init', 'admin_init_example_type');
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 function admin_init_example_type() {
108 108
     global $typenow;
109 109
 
110
-    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
110
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
111 111
         add_filter('posts_search', 'posts_search_example_type', 10, 2);
112 112
     }
113 113
 }
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
     global $wpdb;
123 123
 
124 124
     if ($query->is_main_query() && !empty($query->query['s'])) {
125
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
126
-        if ( ! empty( $search ) ) {
127
-            $search = preg_replace( '/^ AND /', '', $search );
125
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
126
+        if (!empty($search)) {
127
+            $search = preg_replace('/^ AND /', '', $search);
128 128
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
129 129
         } else {
130 130
             $search = " AND ( {$conditions_str} )";
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
     return $search;
135 135
 }
136 136
 
137
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
138
-function wpinv_reset_invoice_count(){
139
-    if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
137
+add_action('admin_init', 'wpinv_reset_invoice_count');
138
+function wpinv_reset_invoice_count() {
139
+    if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
140 140
         wpinv_update_option('invoice_sequence_start', 1);
141 141
         delete_option('wpinv_last_invoice_number');
142 142
         $url = add_query_arg(array('reset_invoice_done' => 1));
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 }
148 148
 
149 149
 add_action('admin_notices', 'wpinv_invoice_count_reset_message');
150
-function wpinv_invoice_count_reset_message(){
151
-    if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
150
+function wpinv_invoice_count_reset_message() {
151
+    if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
152 152
         $notice = __('Invoice number sequence reset successfully.', 'invoicing');
153 153
         ?>
154 154
         <div class="notice notice-success is-dismissible">
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -14,62 +14,62 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28 28
     public $admin_url;
29 29
 
30 30
     /**
31
-	 * Class constructor.
32
-	 */
33
-	public function __construct(){
31
+     * Class constructor.
32
+     */
33
+    public function __construct(){
34 34
 
35 35
         $this->admin_path  = plugin_dir_path( __FILE__ );
36 36
         $this->admin_url   = plugins_url( '/', __FILE__ );
37 37
 
38 38
         if ( is_admin() ) {
39
-			$this->init_admin_hooks();
39
+            $this->init_admin_hooks();
40 40
         }
41 41
 
42 42
     }
43 43
 
44 44
     /**
45
-	 * Init action and filter hooks
46
-	 *
47
-	 */
48
-	private function init_admin_hooks() {
45
+     * Init action and filter hooks
46
+     *
47
+     */
48
+    private function init_admin_hooks() {
49 49
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
50 50
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
51 51
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
52 52
         add_action( 'admin_init', array( $this, 'activation_redirect') );
53 53
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
54
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
-		do_action( 'getpaid_init_admin_hooks', $this );
54
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
+        do_action( 'getpaid_init_admin_hooks', $this );
58 58
 
59 59
     }
60 60
 
61 61
     /**
62
-	 * Register admin scripts
63
-	 *
64
-	 */
65
-	public function enqeue_scripts() {
62
+     * Register admin scripts
63
+     *
64
+     */
65
+    public function enqeue_scripts() {
66 66
         global $current_screen, $pagenow;
67 67
 
68
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
69
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
68
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
69
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
70 70
 
71 71
         if ( ! empty( $current_screen->post_type ) ) {
72
-			$page = $current_screen->post_type;
72
+            $page = $current_screen->post_type;
73 73
         }
74 74
 
75 75
         // General styles.
@@ -93,30 +93,30 @@  discard block
 block discarded – undo
93 93
         }
94 94
 
95 95
         // Payment form scripts.
96
-		if ( 'wpi_payment_form' == $page && $editing ) {
96
+        if ( 'wpi_payment_form' == $page && $editing ) {
97 97
             $this->load_payment_form_scripts();
98 98
         }
99 99
 
100 100
         if ( $page == 'wpinv-subscriptions' ) {
101
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
102
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
103
-		}
101
+            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
102
+            wp_enqueue_script( 'wpinv-sub-admin-script' );
103
+        }
104 104
 
105
-		if ( $page == 'wpinv-reports' ) {
106
-			wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
107
-		}
105
+        if ( $page == 'wpinv-reports' ) {
106
+            wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
107
+        }
108 108
 
109
-		if ( $page == 'wpinv-subscriptions' ) {
110
-			wp_enqueue_script( 'postbox' );
111
-		}
109
+        if ( $page == 'wpinv-subscriptions' ) {
110
+            wp_enqueue_script( 'postbox' );
111
+        }
112 112
 
113 113
     }
114 114
 
115 115
     /**
116
-	 * Returns admin js translations.
117
-	 *
118
-	 */
119
-	protected function get_admin_i18() {
116
+     * Returns admin js translations.
117
+     *
118
+     */
119
+    protected function get_admin_i18() {
120 120
         global $post;
121 121
 
122 122
         $i18n = array(
@@ -152,50 +152,50 @@  discard block
 block discarded – undo
152 152
             'searching'                 => __( 'Searching', 'invoicing' ),
153 153
         );
154 154
 
155
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
155
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
156 156
 
157
-			$invoice              = new WPInv_Invoice( $post );
158
-			$i18n['save_invoice'] = sprintf(
159
-				__( 'Save %s', 'invoicing' ),
160
-				ucfirst( $invoice->get_type() )
161
-			);
157
+            $invoice              = new WPInv_Invoice( $post );
158
+            $i18n['save_invoice'] = sprintf(
159
+                __( 'Save %s', 'invoicing' ),
160
+                ucfirst( $invoice->get_type() )
161
+            );
162 162
 
163
-			$i18n['invoice_description'] = sprintf(
164
-				__( '%s Description', 'invoicing' ),
165
-				ucfirst( $invoice->get_type() )
166
-			);
163
+            $i18n['invoice_description'] = sprintf(
164
+                __( '%s Description', 'invoicing' ),
165
+                ucfirst( $invoice->get_type() )
166
+            );
167 167
 
168
-		}
169
-		return $i18n;
168
+        }
169
+        return $i18n;
170 170
     }
171 171
 
172 172
     /**
173
-	 * Loads payment form js.
174
-	 *
175
-	 */
176
-	protected function load_payment_form_scripts() {
173
+     * Loads payment form js.
174
+     *
175
+     */
176
+    protected function load_payment_form_scripts() {
177 177
         global $post;
178 178
 
179 179
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
180
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
181
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
180
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
181
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
182 182
 
183
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
184
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
183
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
184
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
185 185
 
186
-		wp_localize_script(
186
+        wp_localize_script(
187 187
             'wpinv-admin-payment-form-script',
188 188
             'wpinvPaymentFormAdmin',
189 189
             array(
190
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
191
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
192
-				'currency'      => wpinv_currency_symbol(),
193
-				'position'      => wpinv_currency_position(),
194
-				'decimals'      => (int) wpinv_decimals(),
195
-				'thousands_sep' => wpinv_thousands_separator(),
196
-				'decimals_sep'  => wpinv_decimal_separator(),
197
-				'form_items'    => gepaid_get_form_items( $post->ID ),
198
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
190
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
191
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
192
+                'currency'      => wpinv_currency_symbol(),
193
+                'position'      => wpinv_currency_position(),
194
+                'decimals'      => (int) wpinv_decimals(),
195
+                'thousands_sep' => wpinv_thousands_separator(),
196
+                'decimals_sep'  => wpinv_decimal_separator(),
197
+                'form_items'    => gepaid_get_form_items( $post->ID ),
198
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
199 199
             )
200 200
         );
201 201
 
@@ -204,20 +204,20 @@  discard block
 block discarded – undo
204 204
     }
205 205
 
206 206
     /**
207
-	 * Add our classes to admin pages.
207
+     * Add our classes to admin pages.
208 208
      *
209 209
      * @param string $classes
210 210
      * @return string
211
-	 *
212
-	 */
211
+     *
212
+     */
213 213
     public function admin_body_class( $classes ) {
214
-		global $pagenow, $post, $current_screen;
214
+        global $pagenow, $post, $current_screen;
215 215
 
216 216
 
217 217
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
218 218
 
219 219
         if ( ! empty( $current_screen->post_type ) ) {
220
-			$page = $current_screen->post_type;
220
+            $page = $current_screen->post_type;
221 221
         }
222 222
 
223 223
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -226,29 +226,29 @@  discard block
 block discarded – undo
226 226
 
227 227
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
228 228
             $classes .= ' wpinv-cpt wpinv';
229
-		}
229
+        }
230 230
 		
231
-		if ( getpaid_is_invoice_post_type( $page ) ) {
231
+        if ( getpaid_is_invoice_post_type( $page ) ) {
232 232
             $classes .= ' getpaid-is-invoice-cpt';
233 233
         }
234 234
 
235
-		return $classes;
235
+        return $classes;
236 236
     }
237 237
 
238 238
     /**
239
-	 * Maybe show the AyeCode Connect Notice.
240
-	 */
241
-	public function init_ayecode_connect_helper(){
239
+     * Maybe show the AyeCode Connect Notice.
240
+     */
241
+    public function init_ayecode_connect_helper(){
242 242
 
243 243
         new AyeCode_Connect_Helper(
244 244
             array(
245
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
246
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
247
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
248
-				'connect_button'    => __("Connect Site","invoicing"),
249
-				'connecting_button'    => __("Connecting...","invoicing"),
250
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
251
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
245
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
246
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
247
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
248
+                'connect_button'    => __("Connect Site","invoicing"),
249
+                'connecting_button'    => __("Connecting...","invoicing"),
250
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
251
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
252 252
             ),
253 253
             array( 'wpi-addons' )
254 254
         );
@@ -260,21 +260,21 @@  discard block
 block discarded – undo
260 260
      */
261 261
     public function activation_redirect() {
262 262
 
263
-		// Bail if no activation redirect.
264
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
265
-			return;
266
-		}
263
+        // Bail if no activation redirect.
264
+        if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
265
+            return;
266
+        }
267 267
 
268
-		// Delete the redirect transient.
269
-		delete_transient( '_wpinv_activation_redirect' );
268
+        // Delete the redirect transient.
269
+        delete_transient( '_wpinv_activation_redirect' );
270 270
 
271
-		// Bail if activating from network, or bulk
272
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
273
-			return;
274
-		}
271
+        // Bail if activating from network, or bulk
272
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
273
+            return;
274
+        }
275 275
 
276
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
277
-		exit;
276
+        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
277
+        exit;
278 278
     }
279 279
 
280 280
     /**
@@ -289,150 +289,150 @@  discard block
 block discarded – undo
289 289
 
290 290
     }
291 291
 
292
-	/**
292
+    /**
293 293
      * Sends a payment reminder to a customer.
294
-	 * 
295
-	 * @param array $args
294
+     * 
295
+     * @param array $args
296 296
      */
297 297
     public function send_customer_invoice( $args ) {
298
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
298
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
299 299
 
300
-		if ( $sent ) {
301
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
302
-		} else {
303
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
304
-		}
300
+        if ( $sent ) {
301
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
302
+        } else {
303
+            $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
304
+        }
305 305
 
306
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
307
-		exit;
308
-	}
306
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
307
+        exit;
308
+    }
309 309
 
310
-	/**
310
+    /**
311 311
      * Sends a payment reminder to a customer.
312
-	 * 
313
-	 * @param array $args
312
+     * 
313
+     * @param array $args
314 314
      */
315 315
     public function send_customer_payment_reminder( $args ) {
316
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
316
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
317 317
 
318
-		if ( $sent ) {
319
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
320
-		} else {
321
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
322
-		}
318
+        if ( $sent ) {
319
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
320
+        } else {
321
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
322
+        }
323 323
 
324
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
325
-		exit;
326
-	}
324
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
325
+        exit;
326
+    }
327 327
 
328 328
     /**
329
-	 * Returns an array of admin notices.
330
-	 *
331
-	 * @since       1.0.19
329
+     * Returns an array of admin notices.
330
+     *
331
+     * @since       1.0.19
332 332
      * @return array
333
-	 */
334
-	public function get_notices() {
335
-		$notices = get_option( 'wpinv_admin_notices' );
333
+     */
334
+    public function get_notices() {
335
+        $notices = get_option( 'wpinv_admin_notices' );
336 336
         return is_array( $notices ) ? $notices : array();
337
-	}
338
-
339
-	/**
340
-	 * Clears all admin notices
341
-	 *
342
-	 * @access      public
343
-	 * @since       1.0.19
344
-	 */
345
-	public function clear_notices() {
346
-		delete_option( 'wpinv_admin_notices' );
347
-	}
348
-
349
-	/**
350
-	 * Saves a new admin notice
351
-	 *
352
-	 * @access      public
353
-	 * @since       1.0.19
354
-	 */
355
-	public function save_notice( $type, $message ) {
356
-		$notices = $this->get_notices();
357
-
358
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
359
-			$notices[ $type ] = array();
360
-		}
361
-
362
-		$notices[ $type ][] = $message;
363
-
364
-		update_option( 'wpinv_admin_notices', $notices );
365
-	}
366
-
367
-	/**
368
-	 * Displays a success notice
369
-	 *
370
-	 * @param       string $msg The message to qeue.
371
-	 * @access      public
372
-	 * @since       1.0.19
373
-	 */
374
-	public function show_success( $msg ) {
375
-		$this->save_notice( 'success', $msg );
376
-	}
377
-
378
-	/**
379
-	 * Displays a error notice
380
-	 *
381
-	 * @access      public
382
-	 * @param       string $msg The message to qeue.
383
-	 * @since       1.0.19
384
-	 */
385
-	public function show_error( $msg ) {
386
-		$this->save_notice( 'error', $msg );
387
-	}
388
-
389
-	/**
390
-	 * Displays a warning notice
391
-	 *
392
-	 * @access      public
393
-	 * @param       string $msg The message to qeue.
394
-	 * @since       1.0.19
395
-	 */
396
-	public function show_warning( $msg ) {
397
-		$this->save_notice( 'warning', $msg );
398
-	}
399
-
400
-	/**
401
-	 * Displays a info notice
402
-	 *
403
-	 * @access      public
404
-	 * @param       string $msg The message to qeue.
405
-	 * @since       1.0.19
406
-	 */
407
-	public function show_info( $msg ) {
408
-		$this->save_notice( 'info', $msg );
409
-	}
410
-
411
-	/**
412
-	 * Show notices
413
-	 *
414
-	 * @access      public
415
-	 * @since       1.0.19
416
-	 */
417
-	public function show_notices() {
337
+    }
338
+
339
+    /**
340
+     * Clears all admin notices
341
+     *
342
+     * @access      public
343
+     * @since       1.0.19
344
+     */
345
+    public function clear_notices() {
346
+        delete_option( 'wpinv_admin_notices' );
347
+    }
348
+
349
+    /**
350
+     * Saves a new admin notice
351
+     *
352
+     * @access      public
353
+     * @since       1.0.19
354
+     */
355
+    public function save_notice( $type, $message ) {
356
+        $notices = $this->get_notices();
357
+
358
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
359
+            $notices[ $type ] = array();
360
+        }
361
+
362
+        $notices[ $type ][] = $message;
363
+
364
+        update_option( 'wpinv_admin_notices', $notices );
365
+    }
366
+
367
+    /**
368
+     * Displays a success notice
369
+     *
370
+     * @param       string $msg The message to qeue.
371
+     * @access      public
372
+     * @since       1.0.19
373
+     */
374
+    public function show_success( $msg ) {
375
+        $this->save_notice( 'success', $msg );
376
+    }
377
+
378
+    /**
379
+     * Displays a error notice
380
+     *
381
+     * @access      public
382
+     * @param       string $msg The message to qeue.
383
+     * @since       1.0.19
384
+     */
385
+    public function show_error( $msg ) {
386
+        $this->save_notice( 'error', $msg );
387
+    }
388
+
389
+    /**
390
+     * Displays a warning notice
391
+     *
392
+     * @access      public
393
+     * @param       string $msg The message to qeue.
394
+     * @since       1.0.19
395
+     */
396
+    public function show_warning( $msg ) {
397
+        $this->save_notice( 'warning', $msg );
398
+    }
399
+
400
+    /**
401
+     * Displays a info notice
402
+     *
403
+     * @access      public
404
+     * @param       string $msg The message to qeue.
405
+     * @since       1.0.19
406
+     */
407
+    public function show_info( $msg ) {
408
+        $this->save_notice( 'info', $msg );
409
+    }
410
+
411
+    /**
412
+     * Show notices
413
+     *
414
+     * @access      public
415
+     * @since       1.0.19
416
+     */
417
+    public function show_notices() {
418 418
 
419 419
         $notices = $this->get_notices();
420 420
         $this->clear_notices();
421 421
 
422
-		foreach ( $notices as $type => $messages ) {
422
+        foreach ( $notices as $type => $messages ) {
423 423
 
424
-			if ( ! is_array( $messages ) ) {
425
-				continue;
426
-			}
424
+            if ( ! is_array( $messages ) ) {
425
+                continue;
426
+            }
427 427
 
428 428
             $type  = sanitize_key( $type );
429
-			foreach ( $messages as $message ) {
429
+            foreach ( $messages as $message ) {
430 430
                 $message = wp_kses_post( $message );
431
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
431
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
432 432
             }
433 433
 
434 434
         }
435 435
 
436
-	}
436
+    }
437 437
 
438 438
 }
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
     /**
31 31
 	 * Class constructor.
32 32
 	 */
33
-	public function __construct(){
33
+	public function __construct() {
34 34
 
35
-        $this->admin_path  = plugin_dir_path( __FILE__ );
36
-        $this->admin_url   = plugins_url( '/', __FILE__ );
35
+        $this->admin_path  = plugin_dir_path(__FILE__);
36
+        $this->admin_url   = plugins_url('/', __FILE__);
37 37
 
38
-        if ( is_admin() ) {
38
+        if (is_admin()) {
39 39
 			$this->init_admin_hooks();
40 40
         }
41 41
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 */
48 48
 	private function init_admin_hooks() {
49
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
50
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
51
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
52
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
53
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
54
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
-		do_action( 'getpaid_init_admin_hooks', $this );
49
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
50
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
51
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
52
+        add_action('admin_init', array($this, 'activation_redirect'));
53
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
54
+		add_action('admin_notices', array($this, 'show_notices'));
55
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
56
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
57
+		do_action('getpaid_init_admin_hooks', $this);
58 58
 
59 59
     }
60 60
 
@@ -65,49 +65,49 @@  discard block
 block discarded – undo
65 65
 	public function enqeue_scripts() {
66 66
         global $current_screen, $pagenow;
67 67
 
68
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
68
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
69 69
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
70 70
 
71
-        if ( ! empty( $current_screen->post_type ) ) {
71
+        if (!empty($current_screen->post_type)) {
72 72
 			$page = $current_screen->post_type;
73 73
         }
74 74
 
75 75
         // General styles.
76
-        if ( false !== stripos( $page, 'wpi' ) ) {
76
+        if (false !== stripos($page, 'wpi')) {
77 77
 
78 78
             // Styles.
79
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
80
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
81
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
82
-            wp_enqueue_style( 'wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
83
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
79
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
80
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
81
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
82
+            wp_enqueue_style('wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
83
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
84 84
 
85 85
             // Scripts.
86
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
87
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
86
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
87
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
88 88
 
89
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
90
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
91
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
89
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
90
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
91
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
92 92
 
93 93
         }
94 94
 
95 95
         // Payment form scripts.
96
-		if ( 'wpi_payment_form' == $page && $editing ) {
96
+		if ('wpi_payment_form' == $page && $editing) {
97 97
             $this->load_payment_form_scripts();
98 98
         }
99 99
 
100
-        if ( $page == 'wpinv-subscriptions' ) {
101
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
102
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
100
+        if ($page == 'wpinv-subscriptions') {
101
+			wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
102
+			wp_enqueue_script('wpinv-sub-admin-script');
103 103
 		}
104 104
 
105
-		if ( $page == 'wpinv-reports' ) {
106
-			wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
105
+		if ($page == 'wpinv-reports') {
106
+			wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
107 107
 		}
108 108
 
109
-		if ( $page == 'wpinv-subscriptions' ) {
110
-			wp_enqueue_script( 'postbox' );
109
+		if ($page == 'wpinv-subscriptions') {
110
+			wp_enqueue_script('postbox');
111 111
 		}
112 112
 
113 113
     }
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         global $post;
121 121
 
122 122
         $i18n = array(
123
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
124
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
125
-            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
126
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
127
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
128
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
129
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
123
+            'ajax_url'                  => admin_url('admin-ajax.php'),
124
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
125
+            'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
126
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
127
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
128
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
129
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
130 130
             'tax'                       => wpinv_tax_amount(),
131 131
             'discount'                  => 0,
132 132
             'currency_symbol'           => wpinv_currency_symbol(),
@@ -134,35 +134,35 @@  discard block
 block discarded – undo
134 134
             'thousand_sep'              => wpinv_thousands_separator(),
135 135
             'decimal_sep'               => wpinv_decimal_separator(),
136 136
             'decimals'                  => wpinv_decimals(),
137
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
138
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
139
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
140
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
141
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
142
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
143
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
144
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
145
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
146
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
147
-            'action_edit'               => __( 'Edit', 'invoicing' ),
148
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
149
-            'item_description'          => __( 'Item Description', 'invoicing' ),
150
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
151
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
152
-            'searching'                 => __( 'Searching', 'invoicing' ),
137
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
138
+            'status_publish'            => wpinv_status_nicename('publish'),
139
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
140
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
141
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
142
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
143
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
144
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
145
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
146
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
147
+            'action_edit'               => __('Edit', 'invoicing'),
148
+            'action_cancel'             => __('Cancel', 'invoicing'),
149
+            'item_description'          => __('Item Description', 'invoicing'),
150
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
151
+            'discount_description'      => __('Discount Description', 'invoicing'),
152
+            'searching'                 => __('Searching', 'invoicing'),
153 153
         );
154 154
 
155
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
155
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
156 156
 
157
-			$invoice              = new WPInv_Invoice( $post );
157
+			$invoice              = new WPInv_Invoice($post);
158 158
 			$i18n['save_invoice'] = sprintf(
159
-				__( 'Save %s', 'invoicing' ),
160
-				ucfirst( $invoice->get_type() )
159
+				__('Save %s', 'invoicing'),
160
+				ucfirst($invoice->get_type())
161 161
 			);
162 162
 
163 163
 			$i18n['invoice_description'] = sprintf(
164
-				__( '%s Description', 'invoicing' ),
165
-				ucfirst( $invoice->get_type() )
164
+				__('%s Description', 'invoicing'),
165
+				ucfirst($invoice->get_type())
166 166
 			);
167 167
 
168 168
 		}
@@ -176,30 +176,30 @@  discard block
 block discarded – undo
176 176
 	protected function load_payment_form_scripts() {
177 177
         global $post;
178 178
 
179
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
180
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
181
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
179
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
180
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
181
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
182 182
 
183
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
184
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
183
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
184
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
185 185
 
186 186
 		wp_localize_script(
187 187
             'wpinv-admin-payment-form-script',
188 188
             'wpinvPaymentFormAdmin',
189 189
             array(
190
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
191
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
190
+				'elements'      => wpinv_get_data('payment-form-elements'),
191
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
192 192
 				'currency'      => wpinv_currency_symbol(),
193 193
 				'position'      => wpinv_currency_position(),
194 194
 				'decimals'      => (int) wpinv_decimals(),
195 195
 				'thousands_sep' => wpinv_thousands_separator(),
196 196
 				'decimals_sep'  => wpinv_decimal_separator(),
197
-				'form_items'    => gepaid_get_form_items( $post->ID ),
197
+				'form_items'    => gepaid_get_form_items($post->ID),
198 198
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
199 199
             )
200 200
         );
201 201
 
202
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
202
+        wp_enqueue_script('wpinv-admin-payment-form-script');
203 203
 
204 204
     }
205 205
 
@@ -210,25 +210,25 @@  discard block
 block discarded – undo
210 210
      * @return string
211 211
 	 *
212 212
 	 */
213
-    public function admin_body_class( $classes ) {
213
+    public function admin_body_class($classes) {
214 214
 		global $pagenow, $post, $current_screen;
215 215
 
216 216
 
217
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
217
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
218 218
 
219
-        if ( ! empty( $current_screen->post_type ) ) {
219
+        if (!empty($current_screen->post_type)) {
220 220
 			$page = $current_screen->post_type;
221 221
         }
222 222
 
223
-        if ( false !== stripos( $page, 'wpi' ) ) {
224
-            $classes .= ' wpi-' . sanitize_key( $page );
223
+        if (false !== stripos($page, 'wpi')) {
224
+            $classes .= ' wpi-' . sanitize_key($page);
225 225
         }
226 226
 
227
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
227
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
228 228
             $classes .= ' wpinv-cpt wpinv';
229 229
 		}
230 230
 		
231
-		if ( getpaid_is_invoice_post_type( $page ) ) {
231
+		if (getpaid_is_invoice_post_type($page)) {
232 232
             $classes .= ' getpaid-is-invoice-cpt';
233 233
         }
234 234
 
@@ -238,19 +238,19 @@  discard block
 block discarded – undo
238 238
     /**
239 239
 	 * Maybe show the AyeCode Connect Notice.
240 240
 	 */
241
-	public function init_ayecode_connect_helper(){
241
+	public function init_ayecode_connect_helper() {
242 242
 
243 243
         new AyeCode_Connect_Helper(
244 244
             array(
245
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
246
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
247
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
248
-				'connect_button'    => __("Connect Site","invoicing"),
249
-				'connecting_button'    => __("Connecting...","invoicing"),
250
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
251
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
245
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
246
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
247
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
248
+				'connect_button'    => __("Connect Site", "invoicing"),
249
+				'connecting_button'    => __("Connecting...", "invoicing"),
250
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
251
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
252 252
             ),
253
-            array( 'wpi-addons' )
253
+            array('wpi-addons')
254 254
         );
255 255
 
256 256
     }
@@ -261,19 +261,19 @@  discard block
 block discarded – undo
261 261
     public function activation_redirect() {
262 262
 
263 263
 		// Bail if no activation redirect.
264
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
264
+		if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) {
265 265
 			return;
266 266
 		}
267 267
 
268 268
 		// Delete the redirect transient.
269
-		delete_transient( '_wpinv_activation_redirect' );
269
+		delete_transient('_wpinv_activation_redirect');
270 270
 
271 271
 		// Bail if activating from network, or bulk
272
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
272
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
273 273
 			return;
274 274
 		}
275 275
 
276
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
276
+		wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
277 277
 		exit;
278 278
     }
279 279
 
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
      */
283 283
     public function maybe_do_admin_action() {
284 284
 
285
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
286
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
287
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
285
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
286
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
287
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
288 288
         }
289 289
 
290 290
     }
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
 	 * 
295 295
 	 * @param array $args
296 296
      */
297
-    public function send_customer_invoice( $args ) {
298
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
297
+    public function send_customer_invoice($args) {
298
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
299 299
 
300
-		if ( $sent ) {
301
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
300
+		if ($sent) {
301
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
302 302
 		} else {
303
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
303
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
304 304
 		}
305 305
 
306
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
306
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
307 307
 		exit;
308 308
 	}
309 309
 
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
 	 * 
313 313
 	 * @param array $args
314 314
      */
315
-    public function send_customer_payment_reminder( $args ) {
316
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
315
+    public function send_customer_payment_reminder($args) {
316
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
317 317
 
318
-		if ( $sent ) {
319
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
318
+		if ($sent) {
319
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
320 320
 		} else {
321
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
321
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
322 322
 		}
323 323
 
324
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
324
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
325 325
 		exit;
326 326
 	}
327 327
 
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
      * @return array
333 333
 	 */
334 334
 	public function get_notices() {
335
-		$notices = get_option( 'wpinv_admin_notices' );
336
-        return is_array( $notices ) ? $notices : array();
335
+		$notices = get_option('wpinv_admin_notices');
336
+        return is_array($notices) ? $notices : array();
337 337
 	}
338 338
 
339 339
 	/**
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 * @since       1.0.19
344 344
 	 */
345 345
 	public function clear_notices() {
346
-		delete_option( 'wpinv_admin_notices' );
346
+		delete_option('wpinv_admin_notices');
347 347
 	}
348 348
 
349 349
 	/**
@@ -352,16 +352,16 @@  discard block
 block discarded – undo
352 352
 	 * @access      public
353 353
 	 * @since       1.0.19
354 354
 	 */
355
-	public function save_notice( $type, $message ) {
355
+	public function save_notice($type, $message) {
356 356
 		$notices = $this->get_notices();
357 357
 
358
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
359
-			$notices[ $type ] = array();
358
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
359
+			$notices[$type] = array();
360 360
 		}
361 361
 
362
-		$notices[ $type ][] = $message;
362
+		$notices[$type][] = $message;
363 363
 
364
-		update_option( 'wpinv_admin_notices', $notices );
364
+		update_option('wpinv_admin_notices', $notices);
365 365
 	}
366 366
 
367 367
 	/**
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @access      public
372 372
 	 * @since       1.0.19
373 373
 	 */
374
-	public function show_success( $msg ) {
375
-		$this->save_notice( 'success', $msg );
374
+	public function show_success($msg) {
375
+		$this->save_notice('success', $msg);
376 376
 	}
377 377
 
378 378
 	/**
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param       string $msg The message to qeue.
383 383
 	 * @since       1.0.19
384 384
 	 */
385
-	public function show_error( $msg ) {
386
-		$this->save_notice( 'error', $msg );
385
+	public function show_error($msg) {
386
+		$this->save_notice('error', $msg);
387 387
 	}
388 388
 
389 389
 	/**
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @param       string $msg The message to qeue.
394 394
 	 * @since       1.0.19
395 395
 	 */
396
-	public function show_warning( $msg ) {
397
-		$this->save_notice( 'warning', $msg );
396
+	public function show_warning($msg) {
397
+		$this->save_notice('warning', $msg);
398 398
 	}
399 399
 
400 400
 	/**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @param       string $msg The message to qeue.
405 405
 	 * @since       1.0.19
406 406
 	 */
407
-	public function show_info( $msg ) {
408
-		$this->save_notice( 'info', $msg );
407
+	public function show_info($msg) {
408
+		$this->save_notice('info', $msg);
409 409
 	}
410 410
 
411 411
 	/**
@@ -419,15 +419,15 @@  discard block
 block discarded – undo
419 419
         $notices = $this->get_notices();
420 420
         $this->clear_notices();
421 421
 
422
-		foreach ( $notices as $type => $messages ) {
422
+		foreach ($notices as $type => $messages) {
423 423
 
424
-			if ( ! is_array( $messages ) ) {
424
+			if (!is_array($messages)) {
425 425
 				continue;
426 426
 			}
427 427
 
428
-            $type  = sanitize_key( $type );
429
-			foreach ( $messages as $message ) {
430
-                $message = wp_kses_post( $message );
428
+            $type = sanitize_key($type);
429
+			foreach ($messages as $message) {
430
+                $message = wp_kses_post($message);
431 431
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
432 432
             }
433 433
 
Please login to merge, or discard this patch.
includes/data/item-schema.php 2 patches
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -13,233 +13,233 @@
 block discarded – undo
13 13
 
14 14
 return array(
15 15
 
16
-	'id'              => array(
17
-		'description' => __( 'Unique identifier for the item.', 'invoicing' ),
18
-		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
20
-		'readonly'    => true,
21
-	),
22
-
23
-	'parent_id'       => array(
24
-		'description' => __( 'Parent item ID.', 'invoicing' ),
25
-		'type'        => 'integer',
26
-		'context'     => array( 'view', 'edit', 'embed' ),
27
-		'default'     => 0,
28
-	),
29
-
30
-	'status'          => array(
31
-		'description' => __( 'A named status for the item.', 'invoicing' ),
32
-		'type'        => 'string',
33
-		'enum'        => array( 'draft', 'pending', 'publish' ),
34
-		'context'     => array( 'view', 'edit', 'embed' ),
35
-		'default'     => 'draft',
36
-	),
37
-
38
-	'version'         => array(
39
-		'description' => __( 'Plugin version when the item was created.', 'invoicing' ),
40
-		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit' ),
42
-		'readonly'    => true,
43
-	),
44
-
45
-	'date_created'    => array(
46
-		'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ),
47
-		'type'        => 'string',
48
-		'context'     => array( 'view', 'edit', 'embed' ),
49
-	),
50
-
51
-	'date_created_gmt'    => array(
52
-		'description' => __( 'The GMT date the item was created.', 'invoicing' ),
53
-		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
55
-		'readonly'    => true,
56
-	),
57
-
58
-	'date_modified'   => array(
59
-		'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ),
60
-		'type'        => 'string',
61
-		'context'     => array( 'view', 'edit', 'embed' ),
62
-		'readonly'    => true,
63
-	),
64
-
65
-	'date_modified_gmt'    => array(
66
-		'description' => __( 'The GMT date the item was last modified.', 'invoicing' ),
67
-		'type'        => 'string',
68
-		'context'     => array( 'view', 'edit', 'embed' ),
69
-		'readonly'    => true,
70
-	),
71
-
72
-	'name'			  => array(
73
-		'description' => __( "The item's name.", 'invoicing' ),
74
-		'type'        => 'string',
75
-		'context'     => array( 'view', 'edit', 'embed' ),
76
-		'required'    => true,
77
-	),
78
-
79
-	'description'     => array(
80
-		'description' => __( "The item's description.", 'invoicing' ),
81
-		'type'        => 'string',
82
-		'context'     => array( 'view', 'edit', 'embed' ),
83
-	),
84
-
85
-	'owner'           => array(
86
-		'description' => __( 'The owner of the item (user id).', 'invoicing' ),
87
-		'type'        => 'integer',
88
-		'context'     => array( 'view', 'edit', 'embed' ),
89
-	),
90
-
91
-	'price'           => array(
92
-		'description' => __( 'The price of the item.', 'invoicing' ),
93
-		'type'        => 'number',
94
-		'context'     => array( 'view', 'edit', 'embed' ),
95
-		'required'    => true,
96
-	),
97
-
98
-	'the_price'       => array(
99
-		'description' => __( 'The formatted price of the item.', 'invoicing' ),
100
-		'type'        => 'string',
101
-		'context'     => array( 'view', 'edit', 'embed' ),
102
-		'readonly'    => true,
103
-	),
104
-
105
-	'type'       => array(
106
-		'description' => __( 'The item type.', 'invoicing' ),
107
-		'type'        => 'string',
108
-		'enum'        => wpinv_item_types(),
109
-		'default'     => 'custom',
110
-		'context'     => array( 'view', 'edit', 'embed' ),
111
-	),
112
-
113
-	'vat_rule'       => array(
114
-		'description' => __( 'VAT rule applied to the item.', 'invoicing' ),
115
-		'type'        => 'string',
116
-		'enum'        => array_keys( getpaid_tax()->get_rules() ),
117
-		'context'     => array( 'view', 'edit', 'embed' ),
118
-	),
119
-
120
-	'vat_class'       => array(
121
-		'description' => __( 'VAT class for the item.', 'invoicing' ),
122
-		'type'        => 'string',
123
-		'context'     => array( 'view', 'edit', 'embed' ),
124
-		'enum'        => array_keys( getpaid_tax()->get_vat_groups() ),
125
-	),
126
-
127
-	'custom_id'       => array(
128
-		'description' => __( 'Custom id for the item.', 'invoicing' ),
129
-		'type'        => 'string',
130
-		'context'     => array( 'view', 'edit', 'embed' ),
131
-	),
16
+    'id'              => array(
17
+        'description' => __( 'Unique identifier for the item.', 'invoicing' ),
18
+        'type'        => 'integer',
19
+        'context'     => array( 'view', 'edit', 'embed' ),
20
+        'readonly'    => true,
21
+    ),
22
+
23
+    'parent_id'       => array(
24
+        'description' => __( 'Parent item ID.', 'invoicing' ),
25
+        'type'        => 'integer',
26
+        'context'     => array( 'view', 'edit', 'embed' ),
27
+        'default'     => 0,
28
+    ),
29
+
30
+    'status'          => array(
31
+        'description' => __( 'A named status for the item.', 'invoicing' ),
32
+        'type'        => 'string',
33
+        'enum'        => array( 'draft', 'pending', 'publish' ),
34
+        'context'     => array( 'view', 'edit', 'embed' ),
35
+        'default'     => 'draft',
36
+    ),
37
+
38
+    'version'         => array(
39
+        'description' => __( 'Plugin version when the item was created.', 'invoicing' ),
40
+        'type'        => 'string',
41
+        'context'     => array( 'view', 'edit' ),
42
+        'readonly'    => true,
43
+    ),
44
+
45
+    'date_created'    => array(
46
+        'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ),
47
+        'type'        => 'string',
48
+        'context'     => array( 'view', 'edit', 'embed' ),
49
+    ),
50
+
51
+    'date_created_gmt'    => array(
52
+        'description' => __( 'The GMT date the item was created.', 'invoicing' ),
53
+        'type'        => 'string',
54
+        'context'     => array( 'view', 'edit', 'embed' ),
55
+        'readonly'    => true,
56
+    ),
57
+
58
+    'date_modified'   => array(
59
+        'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ),
60
+        'type'        => 'string',
61
+        'context'     => array( 'view', 'edit', 'embed' ),
62
+        'readonly'    => true,
63
+    ),
64
+
65
+    'date_modified_gmt'    => array(
66
+        'description' => __( 'The GMT date the item was last modified.', 'invoicing' ),
67
+        'type'        => 'string',
68
+        'context'     => array( 'view', 'edit', 'embed' ),
69
+        'readonly'    => true,
70
+    ),
71
+
72
+    'name'			  => array(
73
+        'description' => __( "The item's name.", 'invoicing' ),
74
+        'type'        => 'string',
75
+        'context'     => array( 'view', 'edit', 'embed' ),
76
+        'required'    => true,
77
+    ),
78
+
79
+    'description'     => array(
80
+        'description' => __( "The item's description.", 'invoicing' ),
81
+        'type'        => 'string',
82
+        'context'     => array( 'view', 'edit', 'embed' ),
83
+    ),
84
+
85
+    'owner'           => array(
86
+        'description' => __( 'The owner of the item (user id).', 'invoicing' ),
87
+        'type'        => 'integer',
88
+        'context'     => array( 'view', 'edit', 'embed' ),
89
+    ),
90
+
91
+    'price'           => array(
92
+        'description' => __( 'The price of the item.', 'invoicing' ),
93
+        'type'        => 'number',
94
+        'context'     => array( 'view', 'edit', 'embed' ),
95
+        'required'    => true,
96
+    ),
97
+
98
+    'the_price'       => array(
99
+        'description' => __( 'The formatted price of the item.', 'invoicing' ),
100
+        'type'        => 'string',
101
+        'context'     => array( 'view', 'edit', 'embed' ),
102
+        'readonly'    => true,
103
+    ),
104
+
105
+    'type'       => array(
106
+        'description' => __( 'The item type.', 'invoicing' ),
107
+        'type'        => 'string',
108
+        'enum'        => wpinv_item_types(),
109
+        'default'     => 'custom',
110
+        'context'     => array( 'view', 'edit', 'embed' ),
111
+    ),
112
+
113
+    'vat_rule'       => array(
114
+        'description' => __( 'VAT rule applied to the item.', 'invoicing' ),
115
+        'type'        => 'string',
116
+        'enum'        => array_keys( getpaid_tax()->get_rules() ),
117
+        'context'     => array( 'view', 'edit', 'embed' ),
118
+    ),
119
+
120
+    'vat_class'       => array(
121
+        'description' => __( 'VAT class for the item.', 'invoicing' ),
122
+        'type'        => 'string',
123
+        'context'     => array( 'view', 'edit', 'embed' ),
124
+        'enum'        => array_keys( getpaid_tax()->get_vat_groups() ),
125
+    ),
126
+
127
+    'custom_id'       => array(
128
+        'description' => __( 'Custom id for the item.', 'invoicing' ),
129
+        'type'        => 'string',
130
+        'context'     => array( 'view', 'edit', 'embed' ),
131
+    ),
132 132
 	
133
-	'custom_name'       => array(
134
-		'description' => __( 'Custom name for the item.', 'invoicing' ),
135
-		'type'        => 'string',
136
-		'context'     => array( 'view', 'edit', 'embed' ),
137
-	),
138
-
139
-	'custom_singular_name'       => array(
140
-		'description' => __( 'Custom singular name for the item.', 'invoicing' ),
141
-		'type'        => 'string',
142
-		'context'     => array( 'view', 'edit', 'embed' ),
143
-	),
144
-
145
-	'is_dynamic_pricing'     => array(
146
-		'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ),
147
-		'type'        => 'integer',
148
-		'enum'        => array( 0, 1 ),
149
-		'context'     => array( 'view', 'edit', 'embed' ),
150
-	),
151
-
152
-	'minimum_price'   => array(
153
-		'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ),
154
-		'type'        => 'number',
155
-		'context'     => array( 'view', 'edit', 'embed' ),
156
-	),
157
-
158
-	'is_recurring'        => array(
159
-		'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ),
160
-		'type'        => 'integer',
161
-		'enum'        => array( 0, 1 ),
162
-		'context'     => array( 'view', 'edit', 'embed' ),
163
-	),
164
-
165
-	'initial_price'   => array(
166
-		'description' => __( 'The initial price of the item.', 'invoicing' ),
167
-		'type'        => 'number',
168
-		'context'     => array( 'view', 'edit', 'embed' ),
169
-		'readonly'    => true,
170
-	),
171
-
172
-	'the_initial_price'       => array(
173
-		'description' => __( 'The formatted initial price of the item.', 'invoicing' ),
174
-		'type'        => 'string',
175
-		'context'     => array( 'view', 'edit', 'embed' ),
176
-		'readonly'    => true,
177
-	),
178
-
179
-	'recurring_price' => array(
180
-		'description' => __( 'The recurring price of the item.', 'invoicing' ),
181
-		'type'        => 'number',
182
-		'context'     => array( 'view', 'edit', 'embed' ),
183
-		'readonly'    => true,
184
-	),
185
-
186
-	'the_recurring_price'       => array(
187
-		'description' => __( 'The formatted recurring price of the item.', 'invoicing' ),
188
-		'type'        => 'string',
189
-		'context'     => array( 'view', 'edit', 'embed' ),
190
-		'readonly'    => true,
191
-	),
192
-
193
-	'recurring_period'        => array(
194
-		'description' => __( 'The recurring period for a recurring item.', 'invoicing' ),
195
-		'type'        => 'string',
196
-		'context'     => array( 'view', 'edit', 'embed' ),
197
-		'enum'        => array( 'D', 'W', 'M', 'Y' ),
198
-	),
199
-
200
-	'recurring_interval'        => array(
201
-		'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ),
202
-		'type'        => 'integer',
203
-		'context'     => array( 'view', 'edit', 'embed' ),
204
-	),
205
-
206
-	'recurring_limit' => array(
207
-		'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ),
208
-		'type'        => 'integer',
209
-		'context'     => array( 'view', 'edit', 'embed' ),
210
-	),
211
-
212
-	'is_free_trial'   => array(
213
-		'description' => __( 'Whether the item has a free trial period.', 'invoicing' ),
214
-		'type'        => 'integer',
215
-		'enum'        => array( 0, 1 ),
216
-		'context'     => array( 'view', 'edit', 'embed' ),
217
-	),
218
-
219
-	'trial_period'    => array(
220
-		'description' => __( 'The trial period.', 'invoicing' ),
221
-		'type'        => 'string',
222
-		'context'     => array( 'view', 'edit', 'embed' ),
223
-		'enum'        => array( 'D', 'W', 'M', 'Y' ),
224
-	),
225
-
226
-	'trial_interval'  => array(
227
-		'description' => __( 'The trial interval.', 'invoicing' ),
228
-		'type'        => 'integer',
229
-		'context'     => array( 'view', 'edit', 'embed' ),
230
-	),
231
-
232
-	'first_renewal_date'       => array(
233
-		'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ),
234
-		'type'        => 'string',
235
-		'context'     => array( 'view', 'edit', 'embed' ),
236
-		'readonly'    => true,
237
-	),
238
-
239
-	'edit_url'        => array(
240
-		'description' => __( 'The URL to edit an item.', 'invoicing' ),
241
-		'type'        => 'string',
242
-		'context'     => array( 'view', 'edit', 'embed' ),
243
-		'readonly'    => true,
244
-	),
133
+    'custom_name'       => array(
134
+        'description' => __( 'Custom name for the item.', 'invoicing' ),
135
+        'type'        => 'string',
136
+        'context'     => array( 'view', 'edit', 'embed' ),
137
+    ),
138
+
139
+    'custom_singular_name'       => array(
140
+        'description' => __( 'Custom singular name for the item.', 'invoicing' ),
141
+        'type'        => 'string',
142
+        'context'     => array( 'view', 'edit', 'embed' ),
143
+    ),
144
+
145
+    'is_dynamic_pricing'     => array(
146
+        'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ),
147
+        'type'        => 'integer',
148
+        'enum'        => array( 0, 1 ),
149
+        'context'     => array( 'view', 'edit', 'embed' ),
150
+    ),
151
+
152
+    'minimum_price'   => array(
153
+        'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ),
154
+        'type'        => 'number',
155
+        'context'     => array( 'view', 'edit', 'embed' ),
156
+    ),
157
+
158
+    'is_recurring'        => array(
159
+        'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ),
160
+        'type'        => 'integer',
161
+        'enum'        => array( 0, 1 ),
162
+        'context'     => array( 'view', 'edit', 'embed' ),
163
+    ),
164
+
165
+    'initial_price'   => array(
166
+        'description' => __( 'The initial price of the item.', 'invoicing' ),
167
+        'type'        => 'number',
168
+        'context'     => array( 'view', 'edit', 'embed' ),
169
+        'readonly'    => true,
170
+    ),
171
+
172
+    'the_initial_price'       => array(
173
+        'description' => __( 'The formatted initial price of the item.', 'invoicing' ),
174
+        'type'        => 'string',
175
+        'context'     => array( 'view', 'edit', 'embed' ),
176
+        'readonly'    => true,
177
+    ),
178
+
179
+    'recurring_price' => array(
180
+        'description' => __( 'The recurring price of the item.', 'invoicing' ),
181
+        'type'        => 'number',
182
+        'context'     => array( 'view', 'edit', 'embed' ),
183
+        'readonly'    => true,
184
+    ),
185
+
186
+    'the_recurring_price'       => array(
187
+        'description' => __( 'The formatted recurring price of the item.', 'invoicing' ),
188
+        'type'        => 'string',
189
+        'context'     => array( 'view', 'edit', 'embed' ),
190
+        'readonly'    => true,
191
+    ),
192
+
193
+    'recurring_period'        => array(
194
+        'description' => __( 'The recurring period for a recurring item.', 'invoicing' ),
195
+        'type'        => 'string',
196
+        'context'     => array( 'view', 'edit', 'embed' ),
197
+        'enum'        => array( 'D', 'W', 'M', 'Y' ),
198
+    ),
199
+
200
+    'recurring_interval'        => array(
201
+        'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ),
202
+        'type'        => 'integer',
203
+        'context'     => array( 'view', 'edit', 'embed' ),
204
+    ),
205
+
206
+    'recurring_limit' => array(
207
+        'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ),
208
+        'type'        => 'integer',
209
+        'context'     => array( 'view', 'edit', 'embed' ),
210
+    ),
211
+
212
+    'is_free_trial'   => array(
213
+        'description' => __( 'Whether the item has a free trial period.', 'invoicing' ),
214
+        'type'        => 'integer',
215
+        'enum'        => array( 0, 1 ),
216
+        'context'     => array( 'view', 'edit', 'embed' ),
217
+    ),
218
+
219
+    'trial_period'    => array(
220
+        'description' => __( 'The trial period.', 'invoicing' ),
221
+        'type'        => 'string',
222
+        'context'     => array( 'view', 'edit', 'embed' ),
223
+        'enum'        => array( 'D', 'W', 'M', 'Y' ),
224
+    ),
225
+
226
+    'trial_interval'  => array(
227
+        'description' => __( 'The trial interval.', 'invoicing' ),
228
+        'type'        => 'integer',
229
+        'context'     => array( 'view', 'edit', 'embed' ),
230
+    ),
231
+
232
+    'first_renewal_date'       => array(
233
+        'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ),
234
+        'type'        => 'string',
235
+        'context'     => array( 'view', 'edit', 'embed' ),
236
+        'readonly'    => true,
237
+    ),
238
+
239
+    'edit_url'        => array(
240
+        'description' => __( 'The URL to edit an item.', 'invoicing' ),
241
+        'type'        => 'string',
242
+        'context'     => array( 'view', 'edit', 'embed' ),
243
+        'readonly'    => true,
244
+    ),
245 245
 );
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -9,237 +9,237 @@
 block discarded – undo
9 9
  * @version 1.0.19
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 return array(
15 15
 
16 16
 	'id'              => array(
17
-		'description' => __( 'Unique identifier for the item.', 'invoicing' ),
17
+		'description' => __('Unique identifier for the item.', 'invoicing'),
18 18
 		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
19
+		'context'     => array('view', 'edit', 'embed'),
20 20
 		'readonly'    => true,
21 21
 	),
22 22
 
23 23
 	'parent_id'       => array(
24
-		'description' => __( 'Parent item ID.', 'invoicing' ),
24
+		'description' => __('Parent item ID.', 'invoicing'),
25 25
 		'type'        => 'integer',
26
-		'context'     => array( 'view', 'edit', 'embed' ),
26
+		'context'     => array('view', 'edit', 'embed'),
27 27
 		'default'     => 0,
28 28
 	),
29 29
 
30 30
 	'status'          => array(
31
-		'description' => __( 'A named status for the item.', 'invoicing' ),
31
+		'description' => __('A named status for the item.', 'invoicing'),
32 32
 		'type'        => 'string',
33
-		'enum'        => array( 'draft', 'pending', 'publish' ),
34
-		'context'     => array( 'view', 'edit', 'embed' ),
33
+		'enum'        => array('draft', 'pending', 'publish'),
34
+		'context'     => array('view', 'edit', 'embed'),
35 35
 		'default'     => 'draft',
36 36
 	),
37 37
 
38 38
 	'version'         => array(
39
-		'description' => __( 'Plugin version when the item was created.', 'invoicing' ),
39
+		'description' => __('Plugin version when the item was created.', 'invoicing'),
40 40
 		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit' ),
41
+		'context'     => array('view', 'edit'),
42 42
 		'readonly'    => true,
43 43
 	),
44 44
 
45 45
 	'date_created'    => array(
46
-		'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ),
46
+		'description' => __("The date the item was created, in the site's timezone.", 'invoicing'),
47 47
 		'type'        => 'string',
48
-		'context'     => array( 'view', 'edit', 'embed' ),
48
+		'context'     => array('view', 'edit', 'embed'),
49 49
 	),
50 50
 
51 51
 	'date_created_gmt'    => array(
52
-		'description' => __( 'The GMT date the item was created.', 'invoicing' ),
52
+		'description' => __('The GMT date the item was created.', 'invoicing'),
53 53
 		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
54
+		'context'     => array('view', 'edit', 'embed'),
55 55
 		'readonly'    => true,
56 56
 	),
57 57
 
58 58
 	'date_modified'   => array(
59
-		'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ),
59
+		'description' => __("The date the item was last modified, in the site's timezone.", 'invoicing'),
60 60
 		'type'        => 'string',
61
-		'context'     => array( 'view', 'edit', 'embed' ),
61
+		'context'     => array('view', 'edit', 'embed'),
62 62
 		'readonly'    => true,
63 63
 	),
64 64
 
65 65
 	'date_modified_gmt'    => array(
66
-		'description' => __( 'The GMT date the item was last modified.', 'invoicing' ),
66
+		'description' => __('The GMT date the item was last modified.', 'invoicing'),
67 67
 		'type'        => 'string',
68
-		'context'     => array( 'view', 'edit', 'embed' ),
68
+		'context'     => array('view', 'edit', 'embed'),
69 69
 		'readonly'    => true,
70 70
 	),
71 71
 
72 72
 	'name'			  => array(
73
-		'description' => __( "The item's name.", 'invoicing' ),
73
+		'description' => __("The item's name.", 'invoicing'),
74 74
 		'type'        => 'string',
75
-		'context'     => array( 'view', 'edit', 'embed' ),
75
+		'context'     => array('view', 'edit', 'embed'),
76 76
 		'required'    => true,
77 77
 	),
78 78
 
79 79
 	'description'     => array(
80
-		'description' => __( "The item's description.", 'invoicing' ),
80
+		'description' => __("The item's description.", 'invoicing'),
81 81
 		'type'        => 'string',
82
-		'context'     => array( 'view', 'edit', 'embed' ),
82
+		'context'     => array('view', 'edit', 'embed'),
83 83
 	),
84 84
 
85 85
 	'owner'           => array(
86
-		'description' => __( 'The owner of the item (user id).', 'invoicing' ),
86
+		'description' => __('The owner of the item (user id).', 'invoicing'),
87 87
 		'type'        => 'integer',
88
-		'context'     => array( 'view', 'edit', 'embed' ),
88
+		'context'     => array('view', 'edit', 'embed'),
89 89
 	),
90 90
 
91 91
 	'price'           => array(
92
-		'description' => __( 'The price of the item.', 'invoicing' ),
92
+		'description' => __('The price of the item.', 'invoicing'),
93 93
 		'type'        => 'number',
94
-		'context'     => array( 'view', 'edit', 'embed' ),
94
+		'context'     => array('view', 'edit', 'embed'),
95 95
 		'required'    => true,
96 96
 	),
97 97
 
98 98
 	'the_price'       => array(
99
-		'description' => __( 'The formatted price of the item.', 'invoicing' ),
99
+		'description' => __('The formatted price of the item.', 'invoicing'),
100 100
 		'type'        => 'string',
101
-		'context'     => array( 'view', 'edit', 'embed' ),
101
+		'context'     => array('view', 'edit', 'embed'),
102 102
 		'readonly'    => true,
103 103
 	),
104 104
 
105 105
 	'type'       => array(
106
-		'description' => __( 'The item type.', 'invoicing' ),
106
+		'description' => __('The item type.', 'invoicing'),
107 107
 		'type'        => 'string',
108 108
 		'enum'        => wpinv_item_types(),
109 109
 		'default'     => 'custom',
110
-		'context'     => array( 'view', 'edit', 'embed' ),
110
+		'context'     => array('view', 'edit', 'embed'),
111 111
 	),
112 112
 
113 113
 	'vat_rule'       => array(
114
-		'description' => __( 'VAT rule applied to the item.', 'invoicing' ),
114
+		'description' => __('VAT rule applied to the item.', 'invoicing'),
115 115
 		'type'        => 'string',
116
-		'enum'        => array_keys( getpaid_tax()->get_rules() ),
117
-		'context'     => array( 'view', 'edit', 'embed' ),
116
+		'enum'        => array_keys(getpaid_tax()->get_rules()),
117
+		'context'     => array('view', 'edit', 'embed'),
118 118
 	),
119 119
 
120 120
 	'vat_class'       => array(
121
-		'description' => __( 'VAT class for the item.', 'invoicing' ),
121
+		'description' => __('VAT class for the item.', 'invoicing'),
122 122
 		'type'        => 'string',
123
-		'context'     => array( 'view', 'edit', 'embed' ),
124
-		'enum'        => array_keys( getpaid_tax()->get_vat_groups() ),
123
+		'context'     => array('view', 'edit', 'embed'),
124
+		'enum'        => array_keys(getpaid_tax()->get_vat_groups()),
125 125
 	),
126 126
 
127 127
 	'custom_id'       => array(
128
-		'description' => __( 'Custom id for the item.', 'invoicing' ),
128
+		'description' => __('Custom id for the item.', 'invoicing'),
129 129
 		'type'        => 'string',
130
-		'context'     => array( 'view', 'edit', 'embed' ),
130
+		'context'     => array('view', 'edit', 'embed'),
131 131
 	),
132 132
 	
133 133
 	'custom_name'       => array(
134
-		'description' => __( 'Custom name for the item.', 'invoicing' ),
134
+		'description' => __('Custom name for the item.', 'invoicing'),
135 135
 		'type'        => 'string',
136
-		'context'     => array( 'view', 'edit', 'embed' ),
136
+		'context'     => array('view', 'edit', 'embed'),
137 137
 	),
138 138
 
139 139
 	'custom_singular_name'       => array(
140
-		'description' => __( 'Custom singular name for the item.', 'invoicing' ),
140
+		'description' => __('Custom singular name for the item.', 'invoicing'),
141 141
 		'type'        => 'string',
142
-		'context'     => array( 'view', 'edit', 'embed' ),
142
+		'context'     => array('view', 'edit', 'embed'),
143 143
 	),
144 144
 
145 145
 	'is_dynamic_pricing'     => array(
146
-		'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ),
146
+		'description' => __('Whether or not customers can enter their own prices when checking out.', 'invoicing'),
147 147
 		'type'        => 'integer',
148
-		'enum'        => array( 0, 1 ),
149
-		'context'     => array( 'view', 'edit', 'embed' ),
148
+		'enum'        => array(0, 1),
149
+		'context'     => array('view', 'edit', 'embed'),
150 150
 	),
151 151
 
152 152
 	'minimum_price'   => array(
153
-		'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ),
153
+		'description' => __('For dynamic prices, this is the minimum price that a user can set.', 'invoicing'),
154 154
 		'type'        => 'number',
155
-		'context'     => array( 'view', 'edit', 'embed' ),
155
+		'context'     => array('view', 'edit', 'embed'),
156 156
 	),
157 157
 
158 158
 	'is_recurring'        => array(
159
-		'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ),
159
+		'description' => __('Whether or not this is a subscription item.', 'invoicing'),
160 160
 		'type'        => 'integer',
161
-		'enum'        => array( 0, 1 ),
162
-		'context'     => array( 'view', 'edit', 'embed' ),
161
+		'enum'        => array(0, 1),
162
+		'context'     => array('view', 'edit', 'embed'),
163 163
 	),
164 164
 
165 165
 	'initial_price'   => array(
166
-		'description' => __( 'The initial price of the item.', 'invoicing' ),
166
+		'description' => __('The initial price of the item.', 'invoicing'),
167 167
 		'type'        => 'number',
168
-		'context'     => array( 'view', 'edit', 'embed' ),
168
+		'context'     => array('view', 'edit', 'embed'),
169 169
 		'readonly'    => true,
170 170
 	),
171 171
 
172 172
 	'the_initial_price'       => array(
173
-		'description' => __( 'The formatted initial price of the item.', 'invoicing' ),
173
+		'description' => __('The formatted initial price of the item.', 'invoicing'),
174 174
 		'type'        => 'string',
175
-		'context'     => array( 'view', 'edit', 'embed' ),
175
+		'context'     => array('view', 'edit', 'embed'),
176 176
 		'readonly'    => true,
177 177
 	),
178 178
 
179 179
 	'recurring_price' => array(
180
-		'description' => __( 'The recurring price of the item.', 'invoicing' ),
180
+		'description' => __('The recurring price of the item.', 'invoicing'),
181 181
 		'type'        => 'number',
182
-		'context'     => array( 'view', 'edit', 'embed' ),
182
+		'context'     => array('view', 'edit', 'embed'),
183 183
 		'readonly'    => true,
184 184
 	),
185 185
 
186 186
 	'the_recurring_price'       => array(
187
-		'description' => __( 'The formatted recurring price of the item.', 'invoicing' ),
187
+		'description' => __('The formatted recurring price of the item.', 'invoicing'),
188 188
 		'type'        => 'string',
189
-		'context'     => array( 'view', 'edit', 'embed' ),
189
+		'context'     => array('view', 'edit', 'embed'),
190 190
 		'readonly'    => true,
191 191
 	),
192 192
 
193 193
 	'recurring_period'        => array(
194
-		'description' => __( 'The recurring period for a recurring item.', 'invoicing' ),
194
+		'description' => __('The recurring period for a recurring item.', 'invoicing'),
195 195
 		'type'        => 'string',
196
-		'context'     => array( 'view', 'edit', 'embed' ),
197
-		'enum'        => array( 'D', 'W', 'M', 'Y' ),
196
+		'context'     => array('view', 'edit', 'embed'),
197
+		'enum'        => array('D', 'W', 'M', 'Y'),
198 198
 	),
199 199
 
200 200
 	'recurring_interval'        => array(
201
-		'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ),
201
+		'description' => __('The recurring interval for a subscription item.', 'invoicing'),
202 202
 		'type'        => 'integer',
203
-		'context'     => array( 'view', 'edit', 'embed' ),
203
+		'context'     => array('view', 'edit', 'embed'),
204 204
 	),
205 205
 
206 206
 	'recurring_limit' => array(
207
-		'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ),
207
+		'description' => __('The maximum number of renewals for a subscription item.', 'invoicing'),
208 208
 		'type'        => 'integer',
209
-		'context'     => array( 'view', 'edit', 'embed' ),
209
+		'context'     => array('view', 'edit', 'embed'),
210 210
 	),
211 211
 
212 212
 	'is_free_trial'   => array(
213
-		'description' => __( 'Whether the item has a free trial period.', 'invoicing' ),
213
+		'description' => __('Whether the item has a free trial period.', 'invoicing'),
214 214
 		'type'        => 'integer',
215
-		'enum'        => array( 0, 1 ),
216
-		'context'     => array( 'view', 'edit', 'embed' ),
215
+		'enum'        => array(0, 1),
216
+		'context'     => array('view', 'edit', 'embed'),
217 217
 	),
218 218
 
219 219
 	'trial_period'    => array(
220
-		'description' => __( 'The trial period.', 'invoicing' ),
220
+		'description' => __('The trial period.', 'invoicing'),
221 221
 		'type'        => 'string',
222
-		'context'     => array( 'view', 'edit', 'embed' ),
223
-		'enum'        => array( 'D', 'W', 'M', 'Y' ),
222
+		'context'     => array('view', 'edit', 'embed'),
223
+		'enum'        => array('D', 'W', 'M', 'Y'),
224 224
 	),
225 225
 
226 226
 	'trial_interval'  => array(
227
-		'description' => __( 'The trial interval.', 'invoicing' ),
227
+		'description' => __('The trial interval.', 'invoicing'),
228 228
 		'type'        => 'integer',
229
-		'context'     => array( 'view', 'edit', 'embed' ),
229
+		'context'     => array('view', 'edit', 'embed'),
230 230
 	),
231 231
 
232 232
 	'first_renewal_date'       => array(
233
-		'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ),
233
+		'description' => __('The first renewal date in case the item was to be bought today.', 'invoicing'),
234 234
 		'type'        => 'string',
235
-		'context'     => array( 'view', 'edit', 'embed' ),
235
+		'context'     => array('view', 'edit', 'embed'),
236 236
 		'readonly'    => true,
237 237
 	),
238 238
 
239 239
 	'edit_url'        => array(
240
-		'description' => __( 'The URL to edit an item.', 'invoicing' ),
240
+		'description' => __('The URL to edit an item.', 'invoicing'),
241 241
 		'type'        => 'string',
242
-		'context'     => array( 'view', 'edit', 'embed' ),
242
+		'context'     => array('view', 'edit', 'embed'),
243 243
 		'readonly'    => true,
244 244
 	),
245 245
 );
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,25 +13,25 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
17
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
18
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
19
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
20
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
21
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
22
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
17
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
18
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
19
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
20
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
21
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
22
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
23 23
     }
24 24
 
25 25
     public function admin_menu() {
26 26
 
27
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
27
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
28 28
         add_menu_page(
29
-            __( 'GetPaid', 'invoicing' ),
30
-            __( 'GetPaid', 'invoicing' ),
29
+            __('GetPaid', 'invoicing'),
30
+            __('GetPaid', 'invoicing'),
31 31
             $capability,
32 32
             'wpinv',
33 33
             null,
34
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
34
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
35 35
             '54.123460'
36 36
         );
37 37
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     public function add_customers_menu() {
44 44
         add_submenu_page(
45 45
             'wpinv',
46
-            __( 'Customers', 'invoicing' ),
47
-            __( 'Customers', 'invoicing' ),
46
+            __('Customers', 'invoicing'),
47
+            __('Customers', 'invoicing'),
48 48
             wpinv_get_capability(),
49 49
             'wpinv-customers',
50
-            array( $this, 'customers_page' )
50
+            array($this, 'customers_page')
51 51
         );
52 52
     }
53 53
 
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
     public function add_subscriptions_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Subscriptions', 'invoicing' ),
61
-            __( 'Subscriptions', 'invoicing' ),
60
+            __('Subscriptions', 'invoicing'),
61
+            __('Subscriptions', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-subscriptions',
64 64
             'wpinv_subscriptions_page'
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * Displays the customers page.
70 70
      */
71 71
     public function customers_page() {
72
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
72
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
73 73
         ?>
74 74
         <div class="wrap wpi-customers-wrap">
75 75
             <style>
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     width: 30%;
78 78
                 }
79 79
             </style>
80
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1>
80
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1>
81 81
             <?php
82 82
                 $table = new WPInv_Customers_Table();
83 83
                 $table->prepare_items();
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
     public function add_settings_menu() {
94 94
         add_submenu_page(
95 95
             'wpinv',
96
-            __( 'Invoice Settings', 'invoicing' ),
97
-            __( 'Settings', 'invoicing' ),
98
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
96
+            __('Invoice Settings', 'invoicing'),
97
+            __('Settings', 'invoicing'),
98
+            apply_filters('invoicing_capability', wpinv_get_capability()),
99 99
             'wpinv-settings',
100
-            array( $this, 'options_page' )
100
+            array($this, 'options_page')
101 101
         );
102 102
     }
103 103
 
104
-    public function add_addons_menu(){
105
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
104
+    public function add_addons_menu() {
105
+        if (!apply_filters('wpi_show_addons_page', true)) {
106 106
             return;
107 107
         }
108 108
 
@@ -112,78 +112,78 @@  discard block
 block discarded – undo
112 112
             __('Extensions', 'invoicing'),
113 113
             'manage_options',
114 114
             'wpi-addons',
115
-            array( $this, 'addons_page' )
115
+            array($this, 'addons_page')
116 116
         );
117 117
     }
118 118
 
119
-    public function addons_page(){
119
+    public function addons_page() {
120 120
         $addon_obj = new WPInv_Admin_Addons();
121 121
         $addon_obj->output();
122 122
     }
123 123
 
124 124
     function options_page() {
125
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
125
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
126 126
 
127
-        if ( $page !== 'wpinv-settings' ) {
127
+        if ($page !== 'wpinv-settings') {
128 128
             return;
129 129
         }
130 130
 
131 131
         $settings_tabs = wpinv_get_settings_tabs();
132 132
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
133
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
134
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
133
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
134
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
135 135
         $key           = 'main';
136 136
 
137
-        if ( is_array( $sections ) ) {
138
-            $key = key( $sections );
137
+        if (is_array($sections)) {
138
+            $key = key($sections);
139 139
         }
140 140
 
141
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
142
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
141
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
142
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
143 143
         ob_start();
144 144
         ?>
145 145
         <div class="wrap">
146 146
             <h1 class="nav-tab-wrapper">
147 147
                 <?php
148
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
149
-                    $tab_url = add_query_arg( array(
148
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
149
+                    $tab_url = add_query_arg(array(
150 150
                         'settings-updated' => false,
151 151
                         'tab' => $tab_id,
152
-                    ) );
152
+                    ));
153 153
 
154 154
                     // Remove the section from the tabs so we always end up at the main section
155
-                    $tab_url = remove_query_arg( 'section', $tab_url );
156
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
155
+                    $tab_url = remove_query_arg('section', $tab_url);
156
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
157 157
 
158 158
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
159 159
 
160
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
161
-                    echo esc_html( $tab_name );
160
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
161
+                    echo esc_html($tab_name);
162 162
                     echo '</a>';
163 163
                 }
164 164
                 ?>
165 165
             </h1>
166 166
             <?php
167
-            $number_of_sections = count( $sections );
167
+            $number_of_sections = count($sections);
168 168
             $number = 0;
169
-            if ( $number_of_sections > 1 ) {
169
+            if ($number_of_sections > 1) {
170 170
                 echo '<div><ul class="subsubsub">';
171
-                foreach( $sections as $section_id => $section_name ) {
171
+                foreach ($sections as $section_id => $section_name) {
172 172
                     echo '<li>';
173 173
                     $number++;
174
-                    $tab_url = add_query_arg( array(
174
+                    $tab_url = add_query_arg(array(
175 175
                         'settings-updated' => false,
176 176
                         'tab' => $active_tab,
177 177
                         'section' => $section_id
178
-                    ) );
179
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
178
+                    ));
179
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
180 180
                     $class = '';
181
-                    if ( $section == $section_id ) {
181
+                    if ($section == $section_id) {
182 182
                         $class = 'current';
183 183
                     }
184
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
184
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
185 185
 
186
-                    if ( $number != $number_of_sections ) {
186
+                    if ($number != $number_of_sections) {
187 187
                         echo ' | ';
188 188
                     }
189 189
                     echo '</li>';
@@ -195,20 +195,20 @@  discard block
 block discarded – undo
195 195
                 <form method="post" action="options.php">
196 196
                     <table class="form-table">
197 197
                         <?php
198
-                        settings_fields( 'wpinv_settings' );
198
+                        settings_fields('wpinv_settings');
199 199
 
200
-                        if ( 'main' === $section ) {
201
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
200
+                        if ('main' === $section) {
201
+                            do_action('wpinv_settings_tab_top', $active_tab);
202 202
                         }
203 203
 
204
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
205
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
206
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
207
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
204
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
205
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
206
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
207
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
208 208
 
209 209
                         // For backwards compatibility
210
-                        if ( 'main' === $section ) {
211
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
210
+                        if ('main' === $section) {
211
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
212 212
                         }
213 213
                         ?>
214 214
                     </table>
@@ -222,18 +222,18 @@  discard block
 block discarded – undo
222 222
     }
223 223
 
224 224
     public function remove_admin_submenus() {
225
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
225
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
226 226
     }
227 227
 
228
-    public function add_nav_menu_meta_boxes(){
229
-        add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
228
+    public function add_nav_menu_meta_boxes() {
229
+        add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low');
230 230
     }
231 231
 
232
-    public function nav_menu_links(){
232
+    public function nav_menu_links() {
233 233
         $endpoints = $this->get_menu_items();
234 234
         ?>
235 235
         <div id="invoicing-endpoints" class="posttypediv">
236
-        <?php if(!empty($endpoints['pages'])){ ?>
236
+        <?php if (!empty($endpoints['pages'])) { ?>
237 237
             <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
238 238
                 <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
239 239
                     <?php
@@ -245,29 +245,29 @@  discard block
 block discarded – undo
245 245
         <?php } ?>
246 246
         <p class="button-controls">
247 247
         <span class="list-controls">
248
-            <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a>
248
+            <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a>
249 249
         </span>
250 250
             <span class="add-to-menu">
251
-            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
251
+            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
252 252
             <span class="spinner"></span>
253 253
         </span>
254 254
         </p>
255 255
         <?php
256 256
     }
257 257
 
258
-    public function get_menu_items(){
258
+    public function get_menu_items() {
259 259
         $items = array();
260 260
 
261
-        $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' );
262
-        if($wpinv_history_page_id > 0){
261
+        $wpinv_history_page_id = (int) wpinv_get_option('invoice_history_page');
262
+        if ($wpinv_history_page_id > 0) {
263 263
             $item = new stdClass();
264 264
             $item->object_id = $wpinv_history_page_id;
265 265
             $item->db_id = 0;
266
-            $item->object =  'page';
266
+            $item->object = 'page';
267 267
             $item->menu_item_parent = 0;
268 268
             $item->type = 'post_type';
269
-            $item->title = __('Invoice History Page','invoicing');
270
-            $item->url = get_permalink( $wpinv_history_page_id );
269
+            $item->title = __('Invoice History Page', 'invoicing');
270
+            $item->url = get_permalink($wpinv_history_page_id);
271 271
             $item->target = '';
272 272
             $item->attr_title = '';
273 273
             $item->classes = array('wpinv-menu-item');
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
             $items['pages'][] = $item;
277 277
         }
278 278
 
279
-        $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' );
280
-        if($wpinv_sub_history_page_id > 0){
279
+        $wpinv_sub_history_page_id = (int) wpinv_get_option('invoice_subscription_page');
280
+        if ($wpinv_sub_history_page_id > 0) {
281 281
             $item = new stdClass();
282 282
             $item->object_id = $wpinv_sub_history_page_id;
283 283
             $item->db_id = 0;
284
-            $item->object =  'page';
284
+            $item->object = 'page';
285 285
             $item->menu_item_parent = 0;
286 286
             $item->type = 'post_type';
287
-            $item->title = __('Invoice Subscriptions Page','invoicing');
288
-            $item->url = get_permalink( $wpinv_sub_history_page_id );
287
+            $item->title = __('Invoice Subscriptions Page', 'invoicing');
288
+            $item->url = get_permalink($wpinv_sub_history_page_id);
289 289
             $item->target = '';
290 290
             $item->attr_title = '';
291 291
             $item->classes = array('wpinv-menu-item');
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
             $items['pages'][] = $item;
295 295
         }
296 296
 
297
-        $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' );
298
-        if($wpinv_checkout_page_id > 0){
297
+        $wpinv_checkout_page_id = (int) wpinv_get_option('checkout_page');
298
+        if ($wpinv_checkout_page_id > 0) {
299 299
             $item = new stdClass();
300 300
             $item->object_id = $wpinv_checkout_page_id;
301 301
             $item->db_id = 0;
302
-            $item->object =  'page';
302
+            $item->object = 'page';
303 303
             $item->menu_item_parent = 0;
304 304
             $item->type = 'post_type';
305
-            $item->title = __('Checkout Page','invoicing');
306
-            $item->url = get_permalink( $wpinv_checkout_page_id );
305
+            $item->title = __('Checkout Page', 'invoicing');
306
+            $item->url = get_permalink($wpinv_checkout_page_id);
307 307
             $item->target = '';
308 308
             $item->attr_title = '';
309 309
             $item->classes = array('wpinv-menu-item');
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
             $items['pages'][] = $item;
313 313
         }
314 314
 
315
-        $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' );
316
-        if($wpinv_success_page_id > 0){
315
+        $wpinv_success_page_id = (int) wpinv_get_option('success_page');
316
+        if ($wpinv_success_page_id > 0) {
317 317
             $item = new stdClass();
318 318
             $item->object_id = $wpinv_success_page_id;
319 319
             $item->db_id = 0;
320
-            $item->object =  'page';
320
+            $item->object = 'page';
321 321
             $item->menu_item_parent = 0;
322 322
             $item->type = 'post_type';
323
-            $item->title = __('Success Page','invoicing');
324
-            $item->url = get_permalink( $wpinv_success_page_id );
323
+            $item->title = __('Success Page', 'invoicing');
324
+            $item->url = get_permalink($wpinv_success_page_id);
325 325
             $item->target = '';
326 326
             $item->attr_title = '';
327 327
             $item->classes = array('wpinv-menu-item');
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
             $items['pages'][] = $item;
331 331
         }
332 332
 
333
-        $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' );
334
-        if($wpinv_failure_page_id > 0){
333
+        $wpinv_failure_page_id = (int) wpinv_get_option('failure_page');
334
+        if ($wpinv_failure_page_id > 0) {
335 335
             $item = new stdClass();
336 336
             $item->object_id = $wpinv_failure_page_id;
337 337
             $item->db_id = 0;
338
-            $item->object =  'page';
338
+            $item->object = 'page';
339 339
             $item->menu_item_parent = 0;
340 340
             $item->type = 'post_type';
341
-            $item->title = __('Failed Transaction Page','invoicing');
342
-            $item->url = get_permalink( $wpinv_failure_page_id );
341
+            $item->title = __('Failed Transaction Page', 'invoicing');
342
+            $item->url = get_permalink($wpinv_failure_page_id);
343 343
             $item->target = '';
344 344
             $item->attr_title = '';
345 345
             $item->classes = array('wpinv-menu-item');
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
             $items['pages'][] = $item;
349 349
         }
350 350
 
351
-        return apply_filters( 'wpinv_menu_items', $items );
351
+        return apply_filters('wpinv_menu_items', $items);
352 352
     }
353 353
 
354 354
 }
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-maxmind-geolocation.php 2 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -16,164 +16,164 @@
 block discarded – undo
16 16
  */
17 17
 class GetPaid_MaxMind_Geolocation {
18 18
 
19
-	/**
20
-	 * The service responsible for interacting with the MaxMind database.
21
-	 *
22
-	 * @var GetPaid_MaxMind_Database_Service
23
-	 */
24
-	private $database_service;
25
-
26
-	/**
27
-	 * Initialize the integration.
28
-	 */
29
-	public function __construct() {
30
-
31
-		/**
32
-		 * Supports overriding the database service to be used.
33
-		 *
34
-		 * @since 1.0.19
35
-		 * @return mixed|null The geolocation database service.
36
-		 */
37
-		$this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
-		if ( null === $this->database_service ) {
39
-			$this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
40
-		}
41
-
42
-		// Bind to the scheduled updater action.
43
-		add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
44
-
45
-		// Bind to the geolocation filter for MaxMind database lookups.
46
-		add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
47
-
48
-		// Handle maxmind key updates.
49
-		add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Get database service.
55
-	 *
56
-	 * @return GetPaid_MaxMind_Database_Service|null
57
-	 */
58
-	public function get_database_service() {
59
-		return $this->database_service;
60
-	}
61
-
62
-	/**
63
-	 * Checks to make sure that the license key is valid.
64
-	 *
65
-	 * @param string $license_key The new license key.
66
-	 * @return string
67
-	 */
68
-	public function handle_key_updates( $license_key ) {
69
-
70
-		// Trim whitespaces and strip slashes.
71
-		$license_key = trim( $license_key );
72
-
73
-		// Abort if the license key is empty or unchanged.
74
-		if ( empty( $license_key ) ) {
75
-			return $license_key;
76
-		}
77
-
78
-		// Abort if a database exists and the license key is unchaged.
79
-		if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
80
-			return $license_key;
81
-		}
82
-
83
-		// Check the license key by attempting to download the Geolocation database.
84
-		$tmp_database_path = $this->database_service->download_database( $license_key );
85
-		if ( is_wp_error( $tmp_database_path ) ) {
86
-			getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
87
-			return $license_key;
88
-		}
89
-
90
-		$this->update_database( $tmp_database_path );
91
-
92
-	}
93
-
94
-	/**
95
-	 * Updates the database used for geolocation queries.
96
-	 *
97
-	 * @param string $tmp_database_path Temporary database path.
98
-	 */
99
-	public function update_database( $tmp_database_path = null ) {
100
-
101
-		// Allow us to easily interact with the filesystem.
102
-		require_once ABSPATH . 'wp-admin/includes/file.php';
103
-		WP_Filesystem();
104
-		global $wp_filesystem;
105
-
106
-		// Remove any existing archives to comply with the MaxMind TOS.
107
-		$target_database_path = $this->database_service->get_database_path();
108
-
109
-		// If there's no database path, we can't store the database.
110
-		if ( empty( $target_database_path ) ) {
111
-			return;
112
-		}
113
-
114
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
115
-			$wp_filesystem->delete( $target_database_path );
116
-		}
117
-
118
-		// We can't download a database if there's no license key configured.
119
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
120
-		if ( empty( $license_key ) ) {
121
-			return;
122
-		}
123
-
124
-		if ( empty( $tmp_database_path ) ) {
125
-			$tmp_database_path = $this->database_service->download_database( $license_key );
126
-		}
127
-
128
-		if ( is_wp_error( $tmp_database_path ) ) {
129
-			wpinv_error_log( $tmp_database_path->get_error_message() );
130
-			return;
131
-		}
132
-
133
-		// Move the new database into position.
134
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
135
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
136
-	}
137
-
138
-	/**
139
-	 * Performs a geolocation lookup against the MaxMind database for the given IP address.
140
-	 *
141
-	 * @param array  $data       Geolocation data.
142
-	 * @param string $ip_address The IP address to geolocate.
143
-	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
144
-	 */
145
-	public function get_geolocation( $data, $ip_address ) {
146
-
147
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
148
-			return $data;
149
-		}
150
-
151
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
152
-
153
-		return array(
154
-			'country'  => $country_code,
155
-			'state'    => '',
156
-			'city'     => '',
157
-			'postcode' => '',
158
-		);
159
-
160
-	}
161
-
162
-	/**
163
-	 * Fetches the prefix for the MaxMind database file.
164
-	 *
165
-	 * @return string
166
-	 */
167
-	private function get_database_prefix() {
168
-
169
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
170
-
171
-		if ( empty( $prefix ) ) {
172
-			$prefix = md5( uniqid( 'wpinv' ) );
173
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
174
-		}
175
-
176
-		return $prefix;
177
-	}
19
+    /**
20
+     * The service responsible for interacting with the MaxMind database.
21
+     *
22
+     * @var GetPaid_MaxMind_Database_Service
23
+     */
24
+    private $database_service;
25
+
26
+    /**
27
+     * Initialize the integration.
28
+     */
29
+    public function __construct() {
30
+
31
+        /**
32
+         * Supports overriding the database service to be used.
33
+         *
34
+         * @since 1.0.19
35
+         * @return mixed|null The geolocation database service.
36
+         */
37
+        $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
+        if ( null === $this->database_service ) {
39
+            $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
40
+        }
41
+
42
+        // Bind to the scheduled updater action.
43
+        add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
44
+
45
+        // Bind to the geolocation filter for MaxMind database lookups.
46
+        add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
47
+
48
+        // Handle maxmind key updates.
49
+        add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
50
+
51
+    }
52
+
53
+    /**
54
+     * Get database service.
55
+     *
56
+     * @return GetPaid_MaxMind_Database_Service|null
57
+     */
58
+    public function get_database_service() {
59
+        return $this->database_service;
60
+    }
61
+
62
+    /**
63
+     * Checks to make sure that the license key is valid.
64
+     *
65
+     * @param string $license_key The new license key.
66
+     * @return string
67
+     */
68
+    public function handle_key_updates( $license_key ) {
69
+
70
+        // Trim whitespaces and strip slashes.
71
+        $license_key = trim( $license_key );
72
+
73
+        // Abort if the license key is empty or unchanged.
74
+        if ( empty( $license_key ) ) {
75
+            return $license_key;
76
+        }
77
+
78
+        // Abort if a database exists and the license key is unchaged.
79
+        if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
80
+            return $license_key;
81
+        }
82
+
83
+        // Check the license key by attempting to download the Geolocation database.
84
+        $tmp_database_path = $this->database_service->download_database( $license_key );
85
+        if ( is_wp_error( $tmp_database_path ) ) {
86
+            getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
87
+            return $license_key;
88
+        }
89
+
90
+        $this->update_database( $tmp_database_path );
91
+
92
+    }
93
+
94
+    /**
95
+     * Updates the database used for geolocation queries.
96
+     *
97
+     * @param string $tmp_database_path Temporary database path.
98
+     */
99
+    public function update_database( $tmp_database_path = null ) {
100
+
101
+        // Allow us to easily interact with the filesystem.
102
+        require_once ABSPATH . 'wp-admin/includes/file.php';
103
+        WP_Filesystem();
104
+        global $wp_filesystem;
105
+
106
+        // Remove any existing archives to comply with the MaxMind TOS.
107
+        $target_database_path = $this->database_service->get_database_path();
108
+
109
+        // If there's no database path, we can't store the database.
110
+        if ( empty( $target_database_path ) ) {
111
+            return;
112
+        }
113
+
114
+        if ( $wp_filesystem->exists( $target_database_path ) ) {
115
+            $wp_filesystem->delete( $target_database_path );
116
+        }
117
+
118
+        // We can't download a database if there's no license key configured.
119
+        $license_key = wpinv_get_option( 'maxmind_license_key' );
120
+        if ( empty( $license_key ) ) {
121
+            return;
122
+        }
123
+
124
+        if ( empty( $tmp_database_path ) ) {
125
+            $tmp_database_path = $this->database_service->download_database( $license_key );
126
+        }
127
+
128
+        if ( is_wp_error( $tmp_database_path ) ) {
129
+            wpinv_error_log( $tmp_database_path->get_error_message() );
130
+            return;
131
+        }
132
+
133
+        // Move the new database into position.
134
+        $wp_filesystem->move( $tmp_database_path, $target_database_path, true );
135
+        $wp_filesystem->delete( dirname( $tmp_database_path ) );
136
+    }
137
+
138
+    /**
139
+     * Performs a geolocation lookup against the MaxMind database for the given IP address.
140
+     *
141
+     * @param array  $data       Geolocation data.
142
+     * @param string $ip_address The IP address to geolocate.
143
+     * @return array Geolocation including country code, state, city and postcode based on an IP address.
144
+     */
145
+    public function get_geolocation( $data, $ip_address ) {
146
+
147
+        if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
148
+            return $data;
149
+        }
150
+
151
+        $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
152
+
153
+        return array(
154
+            'country'  => $country_code,
155
+            'state'    => '',
156
+            'city'     => '',
157
+            'postcode' => '',
158
+        );
159
+
160
+    }
161
+
162
+    /**
163
+     * Fetches the prefix for the MaxMind database file.
164
+     *
165
+     * @return string
166
+     */
167
+    private function get_database_prefix() {
168
+
169
+        $prefix = get_option( 'wpinv_maxmind_database_prefix' );
170
+
171
+        if ( empty( $prefix ) ) {
172
+            $prefix = md5( uniqid( 'wpinv' ) );
173
+            update_option( 'wpinv_maxmind_database_prefix', $prefix );
174
+        }
175
+
176
+        return $prefix;
177
+    }
178 178
 
179 179
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 /**
13 13
  * Uses MaxMind for Geolocation
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 		 * @since 1.0.19
35 35
 		 * @return mixed|null The geolocation database service.
36 36
 		 */
37
-		$this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
-		if ( null === $this->database_service ) {
39
-			$this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
37
+		$this->database_service = apply_filters('getpaid_maxmind_geolocation_database_service', null);
38
+		if (null === $this->database_service) {
39
+			$this->database_service = new GetPaid_MaxMind_Database_Service($this->get_database_prefix());
40 40
 		}
41 41
 
42 42
 		// Bind to the scheduled updater action.
43
-		add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
43
+		add_action('getpaid_update_geoip_databases', array($this, 'update_database'));
44 44
 
45 45
 		// Bind to the geolocation filter for MaxMind database lookups.
46
-		add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
46
+		add_filter('getpaid_get_geolocation', array($this, 'get_geolocation'), 10, 2);
47 47
 
48 48
 		// Handle maxmind key updates.
49
-		add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
49
+		add_filter('wpinv_settings_sanitize_maxmind_license_key', array($this, 'handle_key_updates'));
50 50
 
51 51
 	}
52 52
 
@@ -65,29 +65,29 @@  discard block
 block discarded – undo
65 65
 	 * @param string $license_key The new license key.
66 66
 	 * @return string
67 67
 	 */
68
-	public function handle_key_updates( $license_key ) {
68
+	public function handle_key_updates($license_key) {
69 69
 
70 70
 		// Trim whitespaces and strip slashes.
71
-		$license_key = trim( $license_key );
71
+		$license_key = trim($license_key);
72 72
 
73 73
 		// Abort if the license key is empty or unchanged.
74
-		if ( empty( $license_key ) ) {
74
+		if (empty($license_key)) {
75 75
 			return $license_key;
76 76
 		}
77 77
 
78 78
 		// Abort if a database exists and the license key is unchaged.
79
-		if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
79
+		if (file_exists($this->database_service->get_database_path() && $license_key == wpinv_get_option('maxmind_license_key'))) {
80 80
 			return $license_key;
81 81
 		}
82 82
 
83 83
 		// Check the license key by attempting to download the Geolocation database.
84
-		$tmp_database_path = $this->database_service->download_database( $license_key );
85
-		if ( is_wp_error( $tmp_database_path ) ) {
86
-			getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
84
+		$tmp_database_path = $this->database_service->download_database($license_key);
85
+		if (is_wp_error($tmp_database_path)) {
86
+			getpaid_admin()->show_error($tmp_database_path->get_error_message());
87 87
 			return $license_key;
88 88
 		}
89 89
 
90
-		$this->update_database( $tmp_database_path );
90
+		$this->update_database($tmp_database_path);
91 91
 
92 92
 	}
93 93
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @param string $tmp_database_path Temporary database path.
98 98
 	 */
99
-	public function update_database( $tmp_database_path = null ) {
99
+	public function update_database($tmp_database_path = null) {
100 100
 
101 101
 		// Allow us to easily interact with the filesystem.
102 102
 		require_once ABSPATH . 'wp-admin/includes/file.php';
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
 		$target_database_path = $this->database_service->get_database_path();
108 108
 
109 109
 		// If there's no database path, we can't store the database.
110
-		if ( empty( $target_database_path ) ) {
110
+		if (empty($target_database_path)) {
111 111
 			return;
112 112
 		}
113 113
 
114
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
115
-			$wp_filesystem->delete( $target_database_path );
114
+		if ($wp_filesystem->exists($target_database_path)) {
115
+			$wp_filesystem->delete($target_database_path);
116 116
 		}
117 117
 
118 118
 		// We can't download a database if there's no license key configured.
119
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
120
-		if ( empty( $license_key ) ) {
119
+		$license_key = wpinv_get_option('maxmind_license_key');
120
+		if (empty($license_key)) {
121 121
 			return;
122 122
 		}
123 123
 
124
-		if ( empty( $tmp_database_path ) ) {
125
-			$tmp_database_path = $this->database_service->download_database( $license_key );
124
+		if (empty($tmp_database_path)) {
125
+			$tmp_database_path = $this->database_service->download_database($license_key);
126 126
 		}
127 127
 
128
-		if ( is_wp_error( $tmp_database_path ) ) {
129
-			wpinv_error_log( $tmp_database_path->get_error_message() );
128
+		if (is_wp_error($tmp_database_path)) {
129
+			wpinv_error_log($tmp_database_path->get_error_message());
130 130
 			return;
131 131
 		}
132 132
 
133 133
 		// Move the new database into position.
134
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
135
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
134
+		$wp_filesystem->move($tmp_database_path, $target_database_path, true);
135
+		$wp_filesystem->delete(dirname($tmp_database_path));
136 136
 	}
137 137
 
138 138
 	/**
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 	 * @param string $ip_address The IP address to geolocate.
143 143
 	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
144 144
 	 */
145
-	public function get_geolocation( $data, $ip_address ) {
145
+	public function get_geolocation($data, $ip_address) {
146 146
 
147
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
147
+		if (!empty($data['country']) || empty($ip_address)) {
148 148
 			return $data;
149 149
 		}
150 150
 
151
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
151
+		$country_code = $this->database_service->get_iso_country_code_for_ip($ip_address);
152 152
 
153 153
 		return array(
154 154
 			'country'  => $country_code,
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	private function get_database_prefix() {
168 168
 
169
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
169
+		$prefix = get_option('wpinv_maxmind_database_prefix');
170 170
 
171
-		if ( empty( $prefix ) ) {
172
-			$prefix = md5( uniqid( 'wpinv' ) );
173
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
171
+		if (empty($prefix)) {
172
+			$prefix = md5(uniqid('wpinv'));
173
+			update_option('wpinv_maxmind_database_prefix', $prefix);
174 174
 		}
175 175
 
176 176
 		return $prefix;
Please login to merge, or discard this patch.