Passed
Push — master ( b4ab02...d1178c )
by Brian
11:00 queued 04:56
created
includes/admin/class-getpaid-post-types-admin.php 1 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,68 +21,68 @@  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 );
47
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
48 48
 
49 49
 		// Deleting posts.
50
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
51
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
50
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
51
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
52 52
 	}
53 53
 
54 54
 	/**
55 55
 	 * Post updated messages.
56 56
 	 */
57
-	public static function post_updated_messages( $messages ) {
57
+	public static function post_updated_messages($messages) {
58 58
 		global $post;
59 59
 
60 60
 		$messages['wpi_discount'] = array(
61 61
 			0   => '',
62
-			1   => __( 'Discount updated.', 'invoicing' ),
63
-			2   => __( 'Custom field updated.', 'invoicing' ),
64
-			3   => __( 'Custom field deleted.', 'invoicing' ),
65
-			4   => __( 'Discount updated.', 'invoicing' ),
66
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
67
-			6   => __( 'Discount updated.', 'invoicing' ),
68
-			7   => __( 'Discount saved.', 'invoicing' ),
69
-			8   => __( 'Discount submitted.', 'invoicing' ),
70
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
71
-			10  => __( 'Discount draft updated.', 'invoicing' ),
62
+			1   => __('Discount updated.', 'invoicing'),
63
+			2   => __('Custom field updated.', 'invoicing'),
64
+			3   => __('Custom field deleted.', 'invoicing'),
65
+			4   => __('Discount updated.', 'invoicing'),
66
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
67
+			6   => __('Discount updated.', 'invoicing'),
68
+			7   => __('Discount saved.', 'invoicing'),
69
+			8   => __('Discount submitted.', 'invoicing'),
70
+			9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
71
+			10  => __('Discount draft updated.', 'invoicing'),
72 72
 		);
73 73
 
74 74
 		$messages['wpi_payment_form'] = array(
75 75
 			0   => '',
76
-			1   => __( 'Payment Form updated.', 'invoicing' ),
77
-			2   => __( 'Custom field updated.', 'invoicing' ),
78
-			3   => __( 'Custom field deleted.', 'invoicing' ),
79
-			4   => __( 'Payment Form updated.', 'invoicing' ),
80
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
81
-			6   => __( 'Payment Form updated.', 'invoicing' ),
82
-			7   => __( 'Payment Form saved.', 'invoicing' ),
83
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
84
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
85
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
76
+			1   => __('Payment Form updated.', 'invoicing'),
77
+			2   => __('Custom field updated.', 'invoicing'),
78
+			3   => __('Custom field deleted.', 'invoicing'),
79
+			4   => __('Payment Form updated.', 'invoicing'),
80
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
81
+			6   => __('Payment Form updated.', 'invoicing'),
82
+			7   => __('Payment Form saved.', 'invoicing'),
83
+			8   => __('Payment Form submitted.', 'invoicing'),
84
+			9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
85
+			10  => __('Payment Form draft updated.', 'invoicing'),
86 86
 		);
87 87
 
88 88
 		return $messages;
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
 	/**
93 93
 	 * Post row actions.
94 94
 	 */
95
-	public static function post_row_actions( $actions, $post ) {
95
+	public static function post_row_actions($actions, $post) {
96 96
 
97
-		$post = get_post( $post );
97
+		$post = get_post($post);
98 98
 
99 99
 		// We do not want to edit the default payment form.
100
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
101
-			unset( $actions['trash'] );
102
-			unset( $actions['inline hide-if-no-js'] );
100
+		if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
101
+			unset($actions['trash']);
102
+			unset($actions['inline hide-if-no-js']);
103 103
 		}
104 104
 
105 105
 		return $actions;
@@ -108,51 +108,51 @@  discard block
 block discarded – undo
108 108
 	/**
109 109
 	 * Returns an array of invoice table columns.
110 110
 	 */
111
-	public static function invoice_columns( $columns ) {
111
+	public static function invoice_columns($columns) {
112 112
 
113 113
 		$columns = array(
114 114
 			'cb'                => $columns['cb'],
115
-			'number'            => __( 'Invoice', 'invoicing' ),
116
-			'customer'          => __( 'Customer', 'invoicing' ),
117
-			'invoice_date'      => __( 'Date', 'invoicing' ),
118
-			'amount'            => __( 'Amount', 'invoicing' ),
119
-			'recurring'         => __( 'Recurring', 'invoicing' ),
120
-			'status'            => __( 'Status', 'invoicing' ),
121
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
115
+			'number'            => __('Invoice', 'invoicing'),
116
+			'customer'          => __('Customer', 'invoicing'),
117
+			'invoice_date'      => __('Date', 'invoicing'),
118
+			'amount'            => __('Amount', 'invoicing'),
119
+			'recurring'         => __('Recurring', 'invoicing'),
120
+			'status'            => __('Status', 'invoicing'),
121
+			'wpi_actions'       => __('Actions', 'invoicing'),
122 122
 		);
123 123
 
124
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
124
+		return apply_filters('wpi_invoice_table_columns', $columns);
125 125
 	}
126 126
 
127 127
 	/**
128 128
 	 * Displays invoice table columns.
129 129
 	 */
130
-	public static function display_invoice_columns( $column_name, $post_id ) {
130
+	public static function display_invoice_columns($column_name, $post_id) {
131 131
 
132
-		$invoice = new WPInv_Invoice( $post_id );
132
+		$invoice = new WPInv_Invoice($post_id);
133 133
 
134
-		switch ( $column_name ) {
134
+		switch ($column_name) {
135 135
 
136 136
 			case 'invoice_date' :
137
-				$date_time = sanitize_text_field( $invoice->get_created_date() );
138
-				$date      = mysql2date( get_option( 'date_format' ), $date_time );
137
+				$date_time = sanitize_text_field($invoice->get_created_date());
138
+				$date      = mysql2date(get_option('date_format'), $date_time);
139 139
 				echo "<span title='$date_time'>$date</span>";
140 140
 				break;
141 141
 
142 142
 			case 'amount' :
143 143
 
144 144
 				$amount = $invoice->get_total();
145
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
145
+				$formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency());
146 146
 
147
-				if ( $invoice->is_refunded() ) {
148
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
147
+				if ($invoice->is_refunded()) {
148
+					$refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency());
149 149
 					echo "<del>$formated_amount</del><ins>$refunded_amount</ins>";
150 150
 				} else {
151 151
 
152 152
 					$discount = $invoice->get_total_discount();
153 153
 
154
-					if ( ! empty( $discount ) ) {
155
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
154
+					if (!empty($discount)) {
155
+						$new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency());
156 156
 						echo "<del>$new_amount</del><ins>$formated_amount</ins>";
157 157
 					} else {
158 158
 						echo $formated_amount;
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 				break;
164 164
 
165 165
 			case 'status' :
166
-				$status       = sanitize_text_field( $invoice->get_status() );
167
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
166
+				$status       = sanitize_text_field($invoice->get_status());
167
+				$status_label = sanitize_text_field($invoice->get_status_nicename());
168 168
 
169 169
 				// If it is paid, show the gateway title.
170
-				if ( $invoice->is_paid() ) {
171
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
172
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
170
+				if ($invoice->is_paid()) {
171
+					$gateway = sanitize_text_field($invoice->get_gateway_title());
172
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
173 173
 
174 174
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
175 175
 				} else {
@@ -177,22 +177,22 @@  discard block
 block discarded – undo
177 177
 				}
178 178
 
179 179
 				// If it is not paid, display the overdue and view status.
180
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
180
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
181 181
 
182 182
 					// Invoice view status.
183
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
184
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
183
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
184
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
185 185
 					} else {
186
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
186
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
187 187
 					}
188 188
 
189 189
 					// Display the overview status.
190
-					if ( wpinv_get_option( 'overdue_active' ) ) {
190
+					if (wpinv_get_option('overdue_active')) {
191 191
 						$due_date = $invoice->get_due_date();
192 192
 
193
-						if ( ! empty( $due_date ) ) {
194
-							$date = mysql2date( get_option( 'date_format' ), $due_date );
195
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $date );
193
+						if (!empty($due_date)) {
194
+							$date = mysql2date(get_option('date_format'), $due_date);
195
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $date);
196 196
 							echo "<p class='description' style='color: #888;' title='$due_date'>$date</p>";
197 197
 						}
198 198
 					}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 			case 'recurring':
205 205
 
206
-				if ( $invoice->is_recurring() ) {
206
+				if ($invoice->is_recurring()) {
207 207
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
208 208
 				} else {
209 209
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
 
213 213
 			case 'number' :
214 214
 
215
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
216
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
217
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
215
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
216
+				$invoice_number  = sanitize_text_field($invoice->get_number());
217
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
218 218
 
219 219
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
220 220
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 	
225 225
 				$customer_name = $invoice->get_user_full_name();
226 226
 	
227
-				if ( empty( $customer_name ) ) {
227
+				if (empty($customer_name)) {
228 228
 					$customer_name = $invoice->get_email();
229 229
 				}
230 230
 	
231
-				if ( ! empty( $customer_name ) ) {
232
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
233
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
231
+				if (!empty($customer_name)) {
232
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
233
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
234 234
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
235 235
 				} else {
236 236
 					echo '<div>&mdash;</div>';
@@ -240,15 +240,15 @@  discard block
 block discarded – undo
240 240
 
241 241
 			case 'wpi_actions' :
242 242
 
243
-				if ( ! $invoice->is_draft() ) {
244
-					$url    = esc_url( $invoice->get_view_url() );
245
-					$print  = esc_attr__( 'Print invoice', 'invoicing' );
243
+				if (!$invoice->is_draft()) {
244
+					$url    = esc_url($invoice->get_view_url());
245
+					$print  = esc_attr__('Print invoice', 'invoicing');
246 246
 					echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
247 247
 				}
248 248
 
249
-				if ( $invoice->get_email() ) {
250
-					$url    = esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $invoice->get_id() ) ) );
251
-					$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
249
+				if ($invoice->get_email()) {
250
+					$url    = esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $invoice->get_id())));
251
+					$send   = esc_attr__('Send invoice to customer', 'invoicing');
252 252
 					echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
253 253
 				}
254 254
 				
@@ -260,50 +260,50 @@  discard block
 block discarded – undo
260 260
 	/**
261 261
 	 * Returns an array of payment forms table columns.
262 262
 	 */
263
-	public static function payment_form_columns( $columns ) {
263
+	public static function payment_form_columns($columns) {
264 264
 
265 265
 		$columns = array(
266 266
 			'cb'                => $columns['cb'],
267
-			'title'             => __( 'Name', 'invoicing' ),
268
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
269
-			'earnings'          => __( 'Revenue', 'invoicing' ),
270
-			'refunds'           => __( 'Refunded', 'invoicing' ),
271
-			'items'             => __( 'Items', 'invoicing' ),
272
-			'date'              => __( 'Date', 'invoicing' ),
267
+			'title'             => __('Name', 'invoicing'),
268
+			'shortcode'         => __('Shortcode', 'invoicing'),
269
+			'earnings'          => __('Revenue', 'invoicing'),
270
+			'refunds'           => __('Refunded', 'invoicing'),
271
+			'items'             => __('Items', 'invoicing'),
272
+			'date'              => __('Date', 'invoicing'),
273 273
 		);
274 274
 
275
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
275
+		return apply_filters('wpi_payment_form_table_columns', $columns);
276 276
 
277 277
 	}
278 278
 
279 279
 	/**
280 280
 	 * Displays payment form table columns.
281 281
 	 */
282
-	public static function display_payment_form_columns( $column_name, $post_id ) {
282
+	public static function display_payment_form_columns($column_name, $post_id) {
283 283
 
284 284
 		// Retrieve the payment form.
285
-		$form = new GetPaid_Payment_Form( $post_id );
285
+		$form = new GetPaid_Payment_Form($post_id);
286 286
 
287
-		switch ( $column_name ) {
287
+		switch ($column_name) {
288 288
 
289 289
 			case 'earnings' :
290
-				echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
290
+				echo wpinv_price(wpinv_format_amount($form->get_earned()));
291 291
 				break;
292 292
 
293 293
 			case 'refunds' :
294
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
294
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
295 295
 				break;
296 296
 
297 297
 			case 'refunds' :
298
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
298
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
299 299
 				break;
300 300
 
301 301
 			case 'shortcode' :
302 302
 
303
-				if ( $form->is_default() ) {
303
+				if ($form->is_default()) {
304 304
 					echo '&mdash;';
305 305
 				} else {
306
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
306
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
307 307
 				}
308 308
 
309 309
 				break;
@@ -312,29 +312,29 @@  discard block
 block discarded – undo
312 312
 
313 313
 				$items = $form->get_items();
314 314
 
315
-				if ( $form->is_default() || empty( $items ) ) {
315
+				if ($form->is_default() || empty($items)) {
316 316
 					echo '&mdash;';
317 317
 					return;
318 318
 				}
319 319
 
320 320
 				$_items = array();
321 321
 
322
-				foreach ( $items as $item ) {
322
+				foreach ($items as $item) {
323 323
 					$url = $item->get_edit_url();
324 324
 
325
-					if ( empty( $url ) ) {
326
-						$_items[] = sanitize_text_field( $item->get_name() );
325
+					if (empty($url)) {
326
+						$_items[] = sanitize_text_field($item->get_name());
327 327
 					} else {
328 328
 						$_items[] = sprintf(
329 329
 							'<a href="%s">%s</a>',
330
-							esc_url( $url ),
331
-							sanitize_text_field( $item->get_name() )
330
+							esc_url($url),
331
+							sanitize_text_field($item->get_name())
332 332
 						);
333 333
 					}
334 334
 
335 335
 				}
336 336
 
337
-				echo implode( '<br>', $_items );
337
+				echo implode('<br>', $_items);
338 338
 
339 339
 				break;
340 340
 
@@ -345,10 +345,10 @@  discard block
 block discarded – undo
345 345
 	/**
346 346
 	 * Filters post states.
347 347
 	 */
348
-	public static function filter_payment_form_state( $post_states, $post ) {
348
+	public static function filter_payment_form_state($post_states, $post) {
349 349
 
350
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
351
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
350
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
351
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
352 352
 		}
353 353
 	
354 354
 		return $post_states;
@@ -358,35 +358,35 @@  discard block
 block discarded – undo
358 358
 	/**
359 359
 	 * Returns an array of coupon table columns.
360 360
 	 */
361
-	public static function discount_columns( $columns ) {
361
+	public static function discount_columns($columns) {
362 362
 
363 363
 		$columns = array(
364 364
 			'cb'                => $columns['cb'],
365
-			'title'             => __( 'Name', 'invoicing' ),
366
-			'code'              => __( 'Code', 'invoicing' ),
367
-			'amount'            => __( 'Amount', 'invoicing' ),
368
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
369
-			'start_date'        => __( 'Start Date', 'invoicing' ),
370
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
365
+			'title'             => __('Name', 'invoicing'),
366
+			'code'              => __('Code', 'invoicing'),
367
+			'amount'            => __('Amount', 'invoicing'),
368
+			'usage'             => __('Usage / Limit', 'invoicing'),
369
+			'start_date'        => __('Start Date', 'invoicing'),
370
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
371 371
 		);
372 372
 
373
-		return apply_filters( 'wpi_discount_table_columns', $columns );
373
+		return apply_filters('wpi_discount_table_columns', $columns);
374 374
 	}
375 375
 
376 376
 	/**
377 377
 	 * Filters post states.
378 378
 	 */
379
-	public static function filter_discount_state( $post_states, $post ) {
379
+	public static function filter_discount_state($post_states, $post) {
380 380
 
381
-		if ( 'wpi_discount' == $post->post_type ) {
381
+		if ('wpi_discount' == $post->post_type) {
382 382
 
383
-			$discount = new WPInv_Discount( $post );
383
+			$discount = new WPInv_Discount($post);
384 384
 
385 385
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
386 386
 
387
-			if ( $status != 'publish' ) {
387
+			if ($status != 'publish') {
388 388
 				return array(
389
-					'discount_status' => wpinv_discount_status( $status ),
389
+					'discount_status' => wpinv_discount_status($status),
390 390
 				);
391 391
 			}
392 392
 
@@ -401,34 +401,34 @@  discard block
 block discarded – undo
401 401
 	/**
402 402
 	 * Returns an array of items table columns.
403 403
 	 */
404
-	public static function item_columns( $columns ) {
404
+	public static function item_columns($columns) {
405 405
 		global $wpinv_euvat;
406 406
 
407 407
 		$columns = array(
408 408
 			'cb'                => $columns['cb'],
409
-			'title'             => __( 'Name', 'invoicing' ),
410
-			'price'             => __( 'Price', 'invoicing' ),
411
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
412
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
413
-			'type'              => __( 'Type', 'invoicing' ),
414
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
409
+			'title'             => __('Name', 'invoicing'),
410
+			'price'             => __('Price', 'invoicing'),
411
+			'vat_rule'          => __('VAT rule', 'invoicing'),
412
+			'vat_class'         => __('VAT class', 'invoicing'),
413
+			'type'              => __('Type', 'invoicing'),
414
+			'shortcode'         => __('Shortcode', 'invoicing'),
415 415
 		);
416 416
 
417
-		if ( ! $wpinv_euvat->allow_vat_rules() ) {
418
-			unset( $columns['vat_rule'] );
417
+		if (!$wpinv_euvat->allow_vat_rules()) {
418
+			unset($columns['vat_rule']);
419 419
 		}
420 420
 
421
-		if ( ! $wpinv_euvat->allow_vat_classes() ) {
422
-			unset( $columns['vat_class'] );
421
+		if (!$wpinv_euvat->allow_vat_classes()) {
422
+			unset($columns['vat_class']);
423 423
 		}
424 424
 
425
-		return apply_filters( 'wpi_item_table_columns', $columns );
425
+		return apply_filters('wpi_item_table_columns', $columns);
426 426
 	}
427 427
 
428 428
 	/**
429 429
 	 * Returns an array of sortable items table columns.
430 430
 	 */
431
-	public static function sortable_item_columns( $columns ) {
431
+	public static function sortable_item_columns($columns) {
432 432
 
433 433
 		return array_merge(
434 434
 			$columns,
@@ -445,50 +445,50 @@  discard block
 block discarded – undo
445 445
 	/**
446 446
 	 * Displays items table columns.
447 447
 	 */
448
-	public static function display_item_columns( $column_name, $post_id ) {
448
+	public static function display_item_columns($column_name, $post_id) {
449 449
 		global $wpinv_euvat;
450 450
 
451
-		$item = new WPInv_Item( $post_id );
451
+		$item = new WPInv_Item($post_id);
452 452
 
453
-		switch ( $column_name ) {
453
+		switch ($column_name) {
454 454
 
455 455
 			case 'price' :
456 456
 
457
-				if ( ! $item->is_recurring() ) {
457
+				if (!$item->is_recurring()) {
458 458
 					echo $item->get_the_price();
459 459
 					break;
460 460
 				}
461 461
 
462 462
 				$price = wp_sprintf(
463
-					__( '%s / %s', 'invoicing' ),
463
+					__('%s / %s', 'invoicing'),
464 464
 					$item->get_the_price(),
465
-					WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_recurring_period(), $item->get_recurring_interval() )
465
+					WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->get_recurring_period(), $item->get_recurring_interval())
466 466
 				);
467 467
 
468
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
468
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
469 469
 					echo $price;
470 470
 					break;
471 471
 				}
472 472
 
473 473
 				echo $item->get_the_initial_price();
474 474
 
475
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
475
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
476 476
 				break;
477 477
 
478 478
 			case 'vat_rule' :
479
-				echo $wpinv_euvat->item_rule_label( $item->get_id() );
479
+				echo $wpinv_euvat->item_rule_label($item->get_id());
480 480
 				break;
481 481
 
482 482
 			case 'vat_class' :
483
-				echo $wpinv_euvat->item_class_label( $item->get_id() );
483
+				echo $wpinv_euvat->item_class_label($item->get_id());
484 484
 				break;
485 485
 
486 486
 			case 'shortcode' :
487
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
487
+				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
488 488
 				break;
489 489
 
490 490
 			case 'type' :
491
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
491
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
492 492
 				break;
493 493
 
494 494
 		}
@@ -498,21 +498,21 @@  discard block
 block discarded – undo
498 498
 	/**
499 499
 	 * Lets users filter items using taxes.
500 500
 	 */
501
-	public static function add_item_filters( $post_type ) {
501
+	public static function add_item_filters($post_type) {
502 502
 		global $wpinv_euvat;
503 503
 
504 504
 		// Abort if we're not dealing with items.
505
-		if ( $post_type != 'wpi_item' ) {
505
+		if ($post_type != 'wpi_item') {
506 506
 			return;
507 507
 		}
508 508
 
509 509
 		// Filter by vat rules.
510
-		if ( $wpinv_euvat->allow_vat_rules() ) {
510
+		if ($wpinv_euvat->allow_vat_rules()) {
511 511
 	
512 512
 			// Sanitize selected vat rule.
513
-			$vat_rule   = '';
514
-			if ( isset( $_GET['vat_rule'] ) && array_key_exists(  $_GET['vat_rule'], $wpinv_euvat->get_rules() ) ) {
515
-				$vat_rule   =  $_GET['vat_rule'];
513
+			$vat_rule = '';
514
+			if (isset($_GET['vat_rule']) && array_key_exists($_GET['vat_rule'], $wpinv_euvat->get_rules())) {
515
+				$vat_rule = $_GET['vat_rule'];
516 516
 			}
517 517
 
518 518
 			// Filter by VAT rule.
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 				array(
521 521
 					'options'          => array_merge(
522 522
 						array(
523
-							'' => __( 'All VAT rules', 'invoicing' )
523
+							'' => __('All VAT rules', 'invoicing')
524 524
 						),
525 525
 						$wpinv_euvat->get_rules()
526 526
 					),
@@ -537,19 +537,19 @@  discard block
 block discarded – undo
537 537
 		}
538 538
 
539 539
 		// Filter by vat class.
540
-		if ( $wpinv_euvat->allow_vat_classes() ) {
540
+		if ($wpinv_euvat->allow_vat_classes()) {
541 541
 	
542 542
 			// Sanitize selected vat rule.
543
-			$vat_class   = '';
544
-			if ( isset( $_GET['vat_class'] ) && array_key_exists(  $_GET['vat_class'], $wpinv_euvat->get_all_classes() ) ) {
545
-				$vat_class   =  $_GET['vat_class'];
543
+			$vat_class = '';
544
+			if (isset($_GET['vat_class']) && array_key_exists($_GET['vat_class'], $wpinv_euvat->get_all_classes())) {
545
+				$vat_class = $_GET['vat_class'];
546 546
 			}
547 547
 
548 548
 			echo wpinv_html_select(
549 549
 				array(
550 550
 					'options'          => array_merge(
551 551
 						array(
552
-							'' => __( 'All VAT classes', 'invoicing' )
552
+							'' => __('All VAT classes', 'invoicing')
553 553
 						),
554 554
 						$wpinv_euvat->get_all_classes()
555 555
 					),
@@ -565,16 +565,16 @@  discard block
 block discarded – undo
565 565
 		}
566 566
 
567 567
 		// Filter by item type.
568
-		$type   = '';
569
-		if( isset( $_GET['type'] ) && array_key_exists(  $_GET['type'], wpinv_get_item_types() ) ) {
570
-			$type   =  $_GET['type'];
568
+		$type = '';
569
+		if (isset($_GET['type']) && array_key_exists($_GET['type'], wpinv_get_item_types())) {
570
+			$type = $_GET['type'];
571 571
 		}
572 572
 
573 573
 		echo wpinv_html_select(
574 574
 			array(
575 575
 				'options'          => array_merge(
576 576
 					array(
577
-						'' => __( 'All item types', 'invoicing' )
577
+						'' => __('All item types', 'invoicing')
578 578
 					),
579 579
 					wpinv_get_item_types()
580 580
 				),
@@ -592,45 +592,45 @@  discard block
 block discarded – undo
592 592
 	/**
593 593
 	 * Filters the item query.
594 594
 	 */
595
-	public static function filter_item_query( $query ) {
595
+	public static function filter_item_query($query) {
596 596
 
597 597
 		// modify the query only if it admin and main query.
598
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
598
+		if (!(is_admin() && $query->is_main_query())) { 
599 599
 			return $query;
600 600
 		}
601 601
 
602 602
 		// we want to modify the query for our items.
603
-		if ( 'wpi_item' != $query->query['post_type'] ){
603
+		if ('wpi_item' != $query->query['post_type']) {
604 604
 			return $query;
605 605
 		}
606 606
 
607
-		if ( empty( $query->query_vars['meta_query'] ) ) {
607
+		if (empty($query->query_vars['meta_query'])) {
608 608
 			$query->query_vars['meta_query'] = array();
609 609
 		}
610 610
 
611 611
 		// Filter vat rule type
612
-        if ( ! empty( $_GET['vat_rule'] ) ) {
612
+        if (!empty($_GET['vat_rule'])) {
613 613
             $query->query_vars['meta_query'][] = array(
614 614
                 'key'     => '_wpinv_vat_rule',
615
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
615
+                'value'   => sanitize_text_field($_GET['vat_rule']),
616 616
                 'compare' => '='
617 617
             );
618 618
         }
619 619
 
620 620
         // Filter vat class
621
-        if ( ! empty( $_GET['vat_class'] ) ) {
621
+        if (!empty($_GET['vat_class'])) {
622 622
             $query->query_vars['meta_query'][] = array(
623 623
                 'key'     => '_wpinv_vat_class',
624
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
624
+                'value'   => sanitize_text_field($_GET['vat_class']),
625 625
                 'compare' => '='
626 626
             );
627 627
         }
628 628
 
629 629
         // Filter item type
630
-        if ( ! empty( $_GET['type'] ) ) {
630
+        if (!empty($_GET['type'])) {
631 631
             $query->query_vars['meta_query'][] = array(
632 632
                 'key'     => '_wpinv_type',
633
-                'value'   => sanitize_text_field( $_GET['type'] ),
633
+                'value'   => sanitize_text_field($_GET['type']),
634 634
                 'compare' => '='
635 635
             );
636 636
 		}
@@ -640,15 +640,15 @@  discard block
 block discarded – undo
640 640
 	/**
641 641
 	 * Reorders items.
642 642
 	 */
643
-	public static function reorder_items( $vars ) {
643
+	public static function reorder_items($vars) {
644 644
 		global $typenow;
645 645
 
646
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
646
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
647 647
 			return $vars;
648 648
 		}
649 649
 
650 650
 		// By item type.
651
-		if ( 'type' == $vars['orderby'] ) {
651
+		if ('type' == $vars['orderby']) {
652 652
 			return array_merge(
653 653
 				$vars,
654 654
 				array(
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		}
660 660
 
661 661
 		// By vat class.
662
-		if ( 'vat_class' == $vars['orderby'] ) {
662
+		if ('vat_class' == $vars['orderby']) {
663 663
 			return array_merge(
664 664
 				$vars,
665 665
 				array(
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 		}
671 671
 
672 672
 		// By vat rule.
673
-		if ( 'vat_rule' == $vars['orderby'] ) {
673
+		if ('vat_rule' == $vars['orderby']) {
674 674
 			return array_merge(
675 675
 				$vars,
676 676
 				array(
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		}
682 682
 
683 683
 		// By price.
684
-		if ( 'price' == $vars['orderby'] ) {
684
+		if ('price' == $vars['orderby']) {
685 685
 			return array_merge(
686 686
 				$vars,
687 687
 				array(
@@ -698,27 +698,27 @@  discard block
 block discarded – undo
698 698
 	/**
699 699
 	 * Fired when deleting a post.
700 700
 	 */
701
-	public static function delete_post( $post_id ) {
701
+	public static function delete_post($post_id) {
702 702
 
703
-		switch ( get_post_type( $post_id ) ) {
703
+		switch (get_post_type($post_id)) {
704 704
 
705 705
 			case 'wpi_item' :
706
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
706
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
707 707
 				break;
708 708
 
709 709
 			case 'wpi_payment_form' :
710
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
710
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
711 711
 				break;
712 712
 
713 713
 			case 'wpi_discount' :
714
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
714
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
715 715
 				break;
716 716
 
717 717
 			case 'wpi_invoice' :
718
-				$invoice = new WPInv_Invoice( $post_id );
719
-				do_action( "getpaid_before_delete_invoice", $invoice );
720
-				$invoice->get_data_store()->delete_items( $invoice );
721
-				$invoice->get_data_store()->delete_special_fields( $invoice );
718
+				$invoice = new WPInv_Invoice($post_id);
719
+				do_action("getpaid_before_delete_invoice", $invoice);
720
+				$invoice->get_data_store()->delete_items($invoice);
721
+				$invoice->get_data_store()->delete_special_fields($invoice);
722 722
 				break;
723 723
 		}
724 724
 	}
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 1 patch
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function wpinv_subscriptions_page() {
10 10
 
11
-	if ( ! empty( $_GET['id'] ) ) {
11
+	if (!empty($_GET['id'])) {
12 12
 
13 13
         wpinv_recurring_subscription_details();
14 14
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	<div class="wrap">
20 20
 
21 21
 		<h1>
22
-			<?php _e( 'Subscriptions', 'invoicing' ); ?>
22
+			<?php _e('Subscriptions', 'invoicing'); ?>
23 23
 		</h1>
24 24
 		<?php
25 25
 		$subscribers_table = new WPInv_Subscription_Lists_Table();
@@ -48,35 +48,35 @@  discard block
 block discarded – undo
48 48
 
49 49
 	$render = true;
50 50
 
51
-	if ( ! current_user_can( 'manage_invoicing' ) ) {
52
-		die( __( 'You are not permitted to view this data.', 'invoicing' ) );
51
+	if (!current_user_can('manage_invoicing')) {
52
+		die(__('You are not permitted to view this data.', 'invoicing'));
53 53
 	}
54 54
 
55
-	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
56
-        die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
55
+	if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
56
+        die(__('Invalid subscription ID Provided.', 'invoicing'));
57 57
 	}
58 58
 
59 59
 	$sub_id  = (int) $_GET['id'];
60
-	$sub     = new WPInv_Subscription( $sub_id );
61
-	$parent  = new WPInv_Invoice( $sub->parent_payment_id );
60
+	$sub     = new WPInv_Subscription($sub_id);
61
+	$parent  = new WPInv_Invoice($sub->parent_payment_id);
62 62
 
63
-	if ( empty( $sub ) ) {
64
-		die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
63
+	if (empty($sub)) {
64
+		die(__('Invalid subscription ID Provided.', 'invoicing'));
65 65
 	}
66 66
 
67 67
 	?>
68 68
 	<div class="wrap">
69
-		<h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2>
69
+		<h2><?php _e('Subscription Details', 'invoicing'); ?></h2>
70 70
 
71
-		<?php if ( $sub ) : ?>
71
+		<?php if ($sub) : ?>
72 72
 
73 73
 			<div id="wpinv-item-card-wrapper">
74 74
 
75
-				<?php do_action( 'wpinv_subscription_card_top', $sub ); ?>
75
+				<?php do_action('wpinv_subscription_card_top', $sub); ?>
76 76
 
77 77
 				<div class="info-wrapper item-section">
78 78
 
79
-					<form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>">
79
+					<form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>">
80 80
 
81 81
 						<div class="item-info">
82 82
 
@@ -84,124 +84,124 @@  discard block
 block discarded – undo
84 84
 								<tbody>
85 85
 									<tr>
86 86
 										<td class="row-title">
87
-											<label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label>
87
+											<label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label>
88 88
 										</td>
89 89
 										<td>
90 90
 											<?php
91
-											$frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency );
92
-											$billing   = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), $parent->get_currency() ) . ' / ' . $frequency;
93
-											$initial   = wpinv_price( wpinv_format_amount( $sub->initial_amount ), $parent->get_currency() );
94
-											printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing );
91
+											$frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency);
92
+											$billing   = wpinv_price(wpinv_format_amount($sub->recurring_amount), $parent->get_currency()) . ' / ' . $frequency;
93
+											$initial   = wpinv_price(wpinv_format_amount($sub->initial_amount), $parent->get_currency());
94
+											printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing);
95 95
 											?>
96 96
 										</td>
97 97
 									</tr>
98 98
 									<tr>
99 99
 										<td class="row-title">
100
-											<label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label>
100
+											<label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label>
101 101
 										</td>
102
-										<td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $sub->bill_times ); ?></td>
102
+										<td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? __('Until Cancelled', 'invoicing') : $sub->bill_times); ?></td>
103 103
 									</tr>
104 104
 									<tr>
105 105
 										<td class="row-title">
106
-											<label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label>
106
+											<label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label>
107 107
 										</td>
108 108
 										<td>
109
-											<?php $subscriber = get_userdata( $sub->customer_id ); ?>
110
-											<a href="<?php echo esc_url( get_edit_user_link( $sub->customer_id ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a>
109
+											<?php $subscriber = get_userdata($sub->customer_id); ?>
110
+											<a href="<?php echo esc_url(get_edit_user_link($sub->customer_id)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a>
111 111
 										</td>
112 112
 									</tr>
113 113
 									<tr>
114 114
 										<td class="row-title">
115
-											<label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label>
115
+											<label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label>
116 116
 										</td>
117 117
 										<td>
118
-                                            <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_clean( $parent->get_number() ); ?></a>&nbsp;&nbsp;&nbsp;<?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . esc_html( get_edit_post_link( $sub->parent_payment_id ) ) . '" target="_blank">' . wpinv_clean( $sub->parent_payment_id ) . '</a>' ); ?></td>
118
+                                            <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_clean($parent->get_number()); ?></a>&nbsp;&nbsp;&nbsp;<?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . esc_html(get_edit_post_link($sub->parent_payment_id)) . '" target="_blank">' . wpinv_clean($sub->parent_payment_id) . '</a>'); ?></td>
119 119
 									</tr>
120 120
 									<tr>
121 121
 										<td class="row-title">
122
-											<label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label>
122
+											<label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label>
123 123
 										</td>
124 124
 										<td>
125 125
 											<?php
126
-                                            echo wpinv_item_dropdown( array(
126
+                                            echo wpinv_item_dropdown(array(
127 127
                                                 'name'              => 'product_id',
128 128
                                                 'id'                => 'wpinv_invoice_item',
129 129
                                                 'with_packages'     => false,
130 130
                                                 'show_recurring'    => true,
131 131
                                                 'selected'          => $sub->product_id,
132 132
                                                 'class'             => 'wpinv-sub-product-id wpi_select2',
133
-                                            ) );
133
+                                            ));
134 134
 
135 135
                                             ?>
136
-											<a href="<?php echo esc_url( add_query_arg( array(
136
+											<a href="<?php echo esc_url(add_query_arg(array(
137 137
 													'post'   => $sub->product_id,
138 138
 													'action' => 'edit'
139
-												), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a>
139
+												), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a>
140 140
 										</td>
141 141
 									</tr>
142 142
 									<tr>
143 143
 										<td class="row-title">
144
-											<label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label>
144
+											<label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label>
145 145
 										</td>
146
-										<td><?php echo wpinv_get_gateway_admin_label( $parent->get_gateway() ); ?></td>
146
+										<td><?php echo wpinv_get_gateway_admin_label($parent->get_gateway()); ?></td>
147 147
 									</tr>
148 148
 									<tr>
149 149
 										<td class="row-title">
150
-											<label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label>
150
+											<label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label>
151 151
 										</td>
152 152
 										<td>
153 153
 											<span class="wpinv-sub-profile-id">
154
-												<?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?>
154
+												<?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?>
155 155
 											</span>
156
-											<input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" />
156
+											<input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" />
157 157
 											<span>&nbsp;&ndash;&nbsp;</span>
158
-											<a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a>
158
+											<a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a>
159 159
 										</td>
160 160
 									</tr>
161 161
 									<tr>
162 162
 										<td class="row-title">
163
-											<label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label>
163
+											<label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label>
164 164
 										</td>
165 165
 										<td>
166
-											<span class="wpinv-sub-transaction-id"><?php echo apply_filters( 'wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub ); ?></span>
167
-											<input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" />
166
+											<span class="wpinv-sub-transaction-id"><?php echo apply_filters('wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub); ?></span>
167
+											<input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" />
168 168
 											<span>&nbsp;&ndash;&nbsp;</span>
169
-											<a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a>
169
+											<a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a>
170 170
 										</td>
171 171
 									</tr>
172 172
 									<tr>
173 173
 										<td class="row-title">
174
-											<label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label>
174
+											<label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label>
175 175
 										</td>
176
-										<td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td>
176
+										<td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td>
177 177
 									</tr>
178 178
 									<tr>
179 179
 										<td class="row-title">
180 180
 											<label for="tablecell">
181
-												<?php if( 'trialling' == $sub->status ) : ?>
182
-													<?php _e( 'Trialling Until:', 'invoicing' ); ?>
181
+												<?php if ('trialling' == $sub->status) : ?>
182
+													<?php _e('Trialling Until:', 'invoicing'); ?>
183 183
 												<?php else: ?>
184
-													<?php _e( 'Expiration Date:', 'invoicing' ); ?>
184
+													<?php _e('Expiration Date:', 'invoicing'); ?>
185 185
 												<?php endif; ?>
186 186
 											</label>
187 187
 										</td>
188 188
 										<td>
189
-											<span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span>
189
+											<span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span>
190 190
 										</td>
191 191
 									</tr>
192 192
 									<tr>
193 193
 										<td class="row-title">
194
-											<label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label>
194
+											<label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label>
195 195
 										</td>
196 196
 										<td>
197 197
 											<select name="status" class="wpi_select2">
198
-												<option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option>
199
-												<option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option>
200
-												<option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option>
201
-												<option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option>
202
-												<option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option>
203
-												<option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option>
204
-												<option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option>
198
+												<option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option>
199
+												<option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option>
200
+												<option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option>
201
+												<option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option>
202
+												<option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option>
203
+												<option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option>
204
+												<option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option>
205 205
 											</select>
206 206
 										</td>
207 207
 									</tr>
@@ -209,79 +209,79 @@  discard block
 block discarded – undo
209 209
 							</table>
210 210
 						</div>
211 211
 						<div id="wpinv-sub-notices">
212
-							<div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div>
213
-							<div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div>
212
+							<div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div>
213
+							<div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div>
214 214
 						</div>
215 215
 						<div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;">
216
-							<?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?>
217
-							<input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/>
218
-							<input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" />
219
-							<?php if( $sub->can_cancel() ) : ?>
220
-								<a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a>
216
+							<?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?>
217
+							<input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/>
218
+							<input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" />
219
+							<?php if ($sub->can_cancel()) : ?>
220
+								<a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a>
221 221
 							<?php endif; ?>
222
-							&nbsp;<input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/>
222
+							&nbsp;<input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/>
223 223
 						</div>
224 224
 
225 225
 					</form>
226 226
 				</div>
227 227
 
228
-				<?php do_action( 'wpinv_subscription_before_stats', $sub ); ?>
228
+				<?php do_action('wpinv_subscription_before_stats', $sub); ?>
229 229
 
230
-				<?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?>
230
+				<?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?>
231 231
 
232 232
 				<div id="item-tables-wrapper" class="item-section">
233 233
 
234
-					<?php do_action( 'wpinv_subscription_before_tables', $sub ); ?>
234
+					<?php do_action('wpinv_subscription_before_tables', $sub); ?>
235 235
 
236
-					<h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3>
236
+					<h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3>
237 237
 					<?php $payments = $sub->get_child_payments(); ?>
238
-					<?php if ( 'manual' == $sub->gateway ) : ?>
239
-						<p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p>
238
+					<?php if ('manual' == $sub->gateway) : ?>
239
+						<p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p>
240 240
 					<?php endif; ?>
241 241
 					<table class="wp-list-table widefat striped payments">
242 242
 						<thead>
243 243
 						<tr>
244
-							<th><?php _e( 'ID', 'invoicing' ); ?></th>
245
-							<th><?php _e( 'Amount', 'invoicing' ); ?></th>
246
-							<th><?php _e( 'Date', 'invoicing' ); ?></th>
247
-							<th><?php _e( 'Status', 'invoicing' ); ?></th>
248
-                            <th><?php _e( 'Invoice', 'invoicing' ); ?></th>
249
-							<th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th>
244
+							<th><?php _e('ID', 'invoicing'); ?></th>
245
+							<th><?php _e('Amount', 'invoicing'); ?></th>
246
+							<th><?php _e('Date', 'invoicing'); ?></th>
247
+							<th><?php _e('Status', 'invoicing'); ?></th>
248
+                            <th><?php _e('Invoice', 'invoicing'); ?></th>
249
+							<th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th>
250 250
 						</tr>
251 251
 						</thead>
252 252
 						<tbody>
253
-						<?php if ( ! empty( $payments ) ) : ?>
254
-							<?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?>
253
+						<?php if (!empty($payments)) : ?>
254
+							<?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?>
255 255
 								<tr>
256 256
 									<td><?php echo $payment->ID; ?></td>
257
-									<td><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() ); ?></td>
258
-									<td><?php echo wpinv_clean( $invoice->get_date_created() ); ?></td>
259
-									<td><?php echo wpinv_clean( $invoice->get_status_nicename() ); ?></td>
257
+									<td><?php echo wpinv_price($invoice->get_total(), $invoice->get_currency()); ?></td>
258
+									<td><?php echo wpinv_clean($invoice->get_date_created()); ?></td>
259
+									<td><?php echo wpinv_clean($invoice->get_status_nicename()); ?></td>
260 260
 									<td>
261
-										<a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a>
262
-										<?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?>
261
+										<a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a>
262
+										<?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?>
263 263
 									</td>
264 264
 									<td class="column-wpi_actions">
265
-										<a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?>
265
+										<a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?>
266 266
 										</a>
267
-										<?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?>
267
+										<?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?>
268 268
 									</td>
269 269
 								</tr>
270 270
 							<?php endforeach; ?>
271 271
 						<?php else: ?>
272 272
 							<tr>
273
-								<td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td>
273
+								<td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td>
274 274
 							</tr>
275 275
 						<?php endif; ?>
276 276
 						</tbody>
277 277
 						<tfoot></tfoot>
278 278
 					</table>
279 279
 
280
-					<?php do_action( 'wpinv_subscription_after_tables', $sub ); ?>
280
+					<?php do_action('wpinv_subscription_after_tables', $sub); ?>
281 281
 
282 282
 				</div>
283 283
 
284
-				<?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?>
284
+				<?php do_action('wpinv_subscription_card_bottom', $sub); ?>
285 285
 			</div>
286 286
 
287 287
 		<?php endif; ?>
@@ -299,36 +299,36 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function wpinv_recurring_process_subscription_update() {
301 301
 
302
-	if( empty( $_POST['sub_id'] ) ) {
302
+	if (empty($_POST['sub_id'])) {
303 303
 		return;
304 304
 	}
305 305
 
306
-	if( empty( $_POST['wpinv_update_subscription'] ) ) {
306
+	if (empty($_POST['wpinv_update_subscription'])) {
307 307
 		return;
308 308
 	}
309 309
 
310
-	if( ! current_user_can( 'manage_invoicing') ) {
310
+	if (!current_user_can('manage_invoicing')) {
311 311
 		return;
312 312
 	}
313 313
 
314
-	if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
315
-		wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
314
+	if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) {
315
+		wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
316 316
 	}
317 317
 
318
-	$profile_id      = sanitize_text_field( $_POST['profile_id'] );
319
-	$transaction_id  = sanitize_text_field( $_POST['transaction_id'] );
320
-	$product_id      = absint( $_POST['product_id'] );
321
-	$subscription    = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
322
-	$subscription->update( array(
323
-		'status'         => sanitize_text_field( $_POST['status'] ),
318
+	$profile_id      = sanitize_text_field($_POST['profile_id']);
319
+	$transaction_id  = sanitize_text_field($_POST['transaction_id']);
320
+	$product_id      = absint($_POST['product_id']);
321
+	$subscription    = new WPInv_Subscription(absint($_POST['sub_id']));
322
+	$subscription->update(array(
323
+		'status'         => sanitize_text_field($_POST['status']),
324 324
 		'profile_id'     => $profile_id,
325 325
 		'product_id'     => $product_id,
326 326
 		'transaction_id' => $transaction_id,
327
-	) );
327
+	));
328 328
 
329
-	$status = sanitize_text_field( $_POST['status'] );
329
+	$status = sanitize_text_field($_POST['status']);
330 330
 
331
-	switch( $status ) {
331
+	switch ($status) {
332 332
 
333 333
 		case 'cancelled' :
334 334
 
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 
348 348
 	}
349 349
 
350
-	wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) );
350
+	wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id));
351 351
 	exit;
352 352
 
353 353
 }
354
-add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 );
354
+add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1);
355 355
 
356 356
 /**
357 357
  * Handles subscription deletion
@@ -362,30 +362,30 @@  discard block
 block discarded – undo
362 362
  */
363 363
 function wpinv_recurring_process_subscription_deletion() {
364 364
 
365
-	if( empty( $_POST['sub_id'] ) ) {
365
+	if (empty($_POST['sub_id'])) {
366 366
 		return;
367 367
 	}
368 368
 
369
-	if( empty( $_POST['wpinv_delete_subscription'] ) ) {
369
+	if (empty($_POST['wpinv_delete_subscription'])) {
370 370
 		return;
371 371
 	}
372 372
 
373
-	if( ! current_user_can( 'manage_invoicing') ) {
373
+	if (!current_user_can('manage_invoicing')) {
374 374
 		return;
375 375
 	}
376 376
 
377
-	if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
378
-		wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
377
+	if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) {
378
+		wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
379 379
 	}
380 380
 
381
-	$subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
381
+	$subscription = new WPInv_Subscription(absint($_POST['sub_id']));
382 382
 
383
-	delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' );
383
+	delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment');
384 384
 
385 385
 	$subscription->delete();
386 386
 
387
-	wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) );
387
+	wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted'));
388 388
 	exit;
389 389
 
390 390
 }
391
-add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 );
391
+add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2);
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
  * Displays a list of all subscriptions rules
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) exit;
6
+if (!defined('ABSPATH')) exit;
7 7
 
8
-if ( ! class_exists( 'WP_List_Table' ) ) {
8
+if (!class_exists('WP_List_Table')) {
9 9
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10 10
 }
11 11
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$this->prepare_query();
80 80
 
81
-		$this->base_url = remove_query_arg( 'status' );
81
+		$this->base_url = remove_query_arg('status');
82 82
 
83 83
 	}
84 84
 
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 		$query = array(
92 92
 			'number'  => $this->per_page,
93 93
 			'paged'   => $this->get_paged(),
94
-			'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all',
95
-			'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id',
96
-			'order'   => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC',
94
+			'status'  => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? $_GET['status'] : 'all',
95
+			'orderby' => (isset($_GET['orderby'])) ? $_GET['orderby'] : 'id',
96
+			'order'   => (isset($_GET['order'])) ? $_GET['order'] : 'DESC',
97 97
 		);
98 98
 
99 99
 		// Prepare class properties.
100
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
100
+		$this->query               = new GetPaid_Subscriptions_Query($query);
101 101
 		$this->total_count         = $this->query->get_total();
102 102
 		$this->current_total_count = $this->query->get_total();
103 103
 		$this->items               = $this->query->get_results();
104
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
104
+		$this->status_counts       = getpaid_get_subscription_status_counts($query);
105 105
 
106
-		if ( 'all' != $query['status'] ) {
107
-			unset( $query['status'] );
108
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
106
+		if ('all' != $query['status']) {
107
+			unset($query['status']);
108
+			$this->total_count = getpaid_get_subscriptions($query, 'count');
109 109
 		}
110 110
 
111 111
 	}
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	protected function get_views() {
124 124
 
125
-		$current  = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
125
+		$current  = isset($_GET['status']) ? $_GET['status'] : 'all';
126 126
 		$views    = array(
127 127
 
128 128
 			'all' => sprintf(
129 129
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
130
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
130
+				esc_url(add_query_arg('status', false, $this->base_url)),
131 131
 				$current === 'all' ? ' class="current"' : '',
132
-				__('All','invoicing' ),
132
+				__('All', 'invoicing'),
133 133
 				$this->total_count
134 134
 			)
135 135
 
136 136
 		);
137 137
 
138
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
138
+		foreach (array_filter($this->status_counts) as $status => $count) {
139 139
 
140
-			$views[ $status ] = sprintf(
140
+			$views[$status] = sprintf(
141 141
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
142
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
142
+				esc_url(add_query_arg('status', urlencode($status), $this->base_url)),
143 143
 				$current === $status ? ' class="current"' : '',
144
-				sanitize_text_field( getpaid_get_subscription_status_label( $status ) ),
144
+				sanitize_text_field(getpaid_get_subscription_status_label($status)),
145 145
 				$count
146 146
 			);
147 147
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @since       1.0.0
159 159
 	 * @return      string
160 160
 	 */
161
-	public function column_default( $item, $column_name ) {
162
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
161
+	public function column_default($item, $column_name) {
162
+		return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name);
163 163
 	}
164 164
 
165 165
 	/**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @param WPInv_Subscription $item
169 169
 	 * @return string
170 170
 	 */
171
-	public function column_cb( $item ) {
172
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
171
+	public function column_cb($item) {
172
+		return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id()));
173 173
 	}
174 174
 
175 175
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @since       1.0.0
180 180
 	 * @return      string
181 181
 	 */
182
-	public function column_status( $item ) {
182
+	public function column_status($item) {
183 183
 		return $item->get_status_label_html();
184 184
 	}
185 185
 
@@ -190,46 +190,46 @@  discard block
 block discarded – undo
190 190
 	 * @since       1.0.0
191 191
 	 * @return      string
192 192
 	 */
193
-	public function column_subscription( $item ) {
193
+	public function column_subscription($item) {
194 194
 
195
-		$username = __( '(Missing User)', 'invoicing' );
195
+		$username = __('(Missing User)', 'invoicing');
196 196
 
197
-		$user = get_userdata( $item->get_customer_id() );
198
-		if ( $user ) {
197
+		$user = get_userdata($item->get_customer_id());
198
+		if ($user) {
199 199
 
200 200
 			$username = sprintf(
201 201
 				'<a href="user-edit.php?user_id=%s">%s</a>',
202
-				absint( $user->ID ),
203
-				! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
202
+				absint($user->ID),
203
+				!empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email)
204 204
 			);
205 205
 
206 206
 		}
207 207
 
208 208
 		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
209 209
 		$column_content = sprintf(
210
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
211
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
212
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
210
+			_x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'),
211
+			'<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">',
212
+			'<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>',
213 213
 			$username
214 214
 		);
215 215
 
216 216
 		$row_actions = array();
217 217
 
218 218
 		// View subscription.
219
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
220
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
219
+		$view_url    = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions')));
220
+		$row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>';
221 221
 
222 222
 		// View invoice.
223
-		$invoice = get_post( $item->get_product_id() );
223
+		$invoice = get_post($item->get_product_id());
224 224
 
225
-		if ( ! empty( $invoice ) ) {
226
-			$view_url    = get_edit_post_link( $invoice );
227
-			$row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
225
+		if (!empty($invoice)) {
226
+			$view_url = get_edit_post_link($invoice);
227
+			$row_actions['invoice'] = '<a href="' . $view_url . '">' . __('View Invoice', 'invoicing') . '</a>';
228 228
 		}
229 229
 
230
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
230
+		$row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item));
231 231
 
232
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
232
+		return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions;
233 233
 	}
234 234
 
235 235
 	/**
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 	 * @since       1.0.0
240 240
 	 * @return      string
241 241
 	 */
242
-	public function column_renewal_date( $item ) {
242
+	public function column_renewal_date($item) {
243 243
 
244 244
 		$expiration = $item->get_expiration();
245
-		if ( ! $item->is_active() || empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
245
+		if (!$item->is_active() || empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
246 246
 			return "&mdash;";
247 247
 		}
248 248
 
249
-		return date_i18n( get_option( 'date_format' ), strtotime( $expiration ) );
249
+		return date_i18n(get_option('date_format'), strtotime($expiration));
250 250
 		
251 251
 	}
252 252
 
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
 	 * @since       1.0.0
258 258
 	 * @return      string
259 259
 	 */
260
-	public function column_start_date( $item ) {
260
+	public function column_start_date($item) {
261 261
 
262 262
 		$created = $item->get_date_created();
263
-		if ( empty( $created ) || '0000-00-00 00:00:00' == $created ) {
263
+		if (empty($created) || '0000-00-00 00:00:00' == $created) {
264 264
 			return "&mdash;";
265 265
 		}
266 266
 
267
-		return date_i18n( get_option( 'date_format' ), strtotime( $created ) );
267
+		return date_i18n(get_option('date_format'), strtotime($created));
268 268
 
269 269
 	}
270 270
 
@@ -275,40 +275,40 @@  discard block
 block discarded – undo
275 275
 	 * @since       1.0.19
276 276
 	 * @return      string
277 277
 	 */
278
-	public function column_amount( $item ) {
278
+	public function column_amount($item) {
279 279
 
280
-		$initial   = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_initial_amount() ) ), $item->get_parent_payment()->get_currency() );
281
-		$recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_recurring_amount() ) ), $item->get_parent_payment()->get_currency() );
282
-		$period    = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label( $item->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_period(),$item->get_frequency() );
280
+		$initial   = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($item->get_initial_amount())), $item->get_parent_payment()->get_currency());
281
+		$recurring = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($item->get_recurring_amount())), $item->get_parent_payment()->get_currency());
282
+		$period    = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label($item->get_period()) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->get_period(), $item->get_frequency());
283 283
 
284
-		if ( $item->has_trial_period() ) {
284
+		if ($item->has_trial_period()) {
285 285
 
286 286
 			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
287 287
 			$amount = sprintf(
288
-				_x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
288
+				_x('%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'),
289 289
 				$initial,
290
-				sanitize_text_field( $item->get_trial_period() ),
290
+				sanitize_text_field($item->get_trial_period()),
291 291
 				$recurring,
292
-				sanitize_text_field( strtolower( $period ) )
292
+				sanitize_text_field(strtolower($period))
293 293
 			);
294 294
 
295
-		} else if ( $initial != $recurring ) {
295
+		} else if ($initial != $recurring) {
296 296
 			
297 297
 			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio
298 298
 			$amount = sprintf(
299
-				_x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ),
299
+				_x('Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing'),
300 300
 				$initial,
301 301
 				$recurring,
302
-				sanitize_text_field( strtolower( $period ) )
302
+				sanitize_text_field(strtolower($period))
303 303
 			);
304 304
 
305 305
 		} else {
306 306
 
307 307
 			// translators: $1: is the recurring amount, $2: is the recurring period
308 308
 			$amount = sprintf(
309
-				_x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ),
309
+				_x('%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing'),
310 310
 				$initial,
311
-				sanitize_text_field( strtolower( $period ) )
311
+				sanitize_text_field(strtolower($period))
312 312
 			);
313 313
 
314 314
 		}
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 	 * @since       1.0.0
324 324
 	 * @return      string
325 325
 	 */
326
-	public function column_renewals( $item ) {
326
+	public function column_renewals($item) {
327 327
 		$max_bills = $item->get_bill_times();
328
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
328
+		return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
329 329
 	}
330 330
 
331 331
 	/**
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 	 * @since       1.0.0
336 336
 	 * @return      string
337 337
 	 */
338
-	function column_item( $item ) {
339
-		$_item = get_post( $item->get_product_id() );
338
+	function column_item($item) {
339
+		$_item = get_post($item->get_product_id());
340 340
 
341
-		if ( ! empty( $_item ) ) {
342
-			$link = get_edit_post_link( $_item );
343
-			$link = esc_url( $link );
344
-			$name = esc_html( get_the_title( $_item ) );
341
+		if (!empty($_item)) {
342
+			$link = get_edit_post_link($_item);
343
+			$link = esc_url($link);
344
+			$name = esc_html(get_the_title($_item));
345 345
 			return "<a href='$link'>$name</a>";
346 346
 		} else {
347
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() );
347
+			return sprintf(__('Item #%s', 'invoicing'), $item->get_product_id());
348 348
 		}
349 349
 
350 350
 	}
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @return      int
356 356
 	 */
357 357
 	public function get_paged() {
358
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
358
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
359 359
 	}
360 360
 
361 361
 	/**
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 		$hidden   = array();
369 369
 		$sortable = $this->get_sortable_columns();
370 370
 
371
-		$this->_column_headers = array( $columns, $hidden, $sortable );
371
+		$this->_column_headers = array($columns, $hidden, $sortable);
372 372
 
373 373
 		$this->set_pagination_args(
374 374
 			array(
375 375
 			'total_items' => $this->current_total_count,
376 376
 			'per_page'    => $this->per_page,
377
-			'total_pages' => ceil( $this->current_total_count / $this->per_page )
377
+			'total_pages' => ceil($this->current_total_count / $this->per_page)
378 378
 			)
379 379
 		);
380 380
 	}
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 	 *
385 385
 	 * @return array
386 386
 	 */
387
-	public function get_columns(){
387
+	public function get_columns() {
388 388
 		$columns = array(
389 389
 			'cb'                => '<input type="checkbox" />',
390
-			'subscription'      => __( 'Subscription', 'invoicing' ),
391
-			'start_date'        => __( 'Start Date', 'invoicing' ),
392
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
393
-			'renewals'          => __( 'Renewals', 'invoicing' ),
394
-			'item'              => __( 'Item', 'invoicing' ),
395
-			'status'            => __( 'Status', 'invoicing' ),
390
+			'subscription'      => __('Subscription', 'invoicing'),
391
+			'start_date'        => __('Start Date', 'invoicing'),
392
+			'renewal_date'      => __('Next Payment', 'invoicing'),
393
+			'renewals'          => __('Renewals', 'invoicing'),
394
+			'item'              => __('Item', 'invoicing'),
395
+			'status'            => __('Status', 'invoicing'),
396 396
 		);
397 397
 
398
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
398
+		return apply_filters('manage_getpaid_subscriptions_table_columns', $columns);
399 399
 	}
400 400
 
401 401
 	/**
@@ -405,15 +405,15 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	public function get_sortable_columns() {
407 407
 		$sortable = array(
408
-			'subscription' => array( 'id', true ),
409
-			'start_date'   => array( 'created', true ),
410
-			'renewal_date' => array( 'expiration', true ),
411
-			'renewals'     => array( 'bill_times', true ),
412
-			'item'         => array( 'product_id', true ),
413
-			'status'       => array( 'status', true ),
408
+			'subscription' => array('id', true),
409
+			'start_date'   => array('created', true),
410
+			'renewal_date' => array('expiration', true),
411
+			'renewals'     => array('bill_times', true),
412
+			'item'         => array('product_id', true),
413
+			'status'       => array('status', true),
414 414
 		);
415 415
 
416
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
416
+		return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable);
417 417
 	}
418 418
 
419 419
 	/**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @return bool
423 423
 	 */
424 424
 	public function has_items() {
425
-		return ! empty( $this->current_total_count );
425
+		return !empty($this->current_total_count);
426 426
 	}
427 427
 
428 428
 }
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 1 patch
Spacing   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * The Subscription Class
@@ -70,27 +70,27 @@  discard block
 block discarded – undo
70 70
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
71 71
 	 * @param  bool $deprecated
72 72
 	 */
73
-	function __construct( $subscription = 0, $deprecated = false ) {
73
+	function __construct($subscription = 0, $deprecated = false) {
74 74
 
75
-		parent::__construct( $subscription );
75
+		parent::__construct($subscription);
76 76
 
77
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
78
-			$this->set_id( $subscription );
79
-		} elseif ( $subscription instanceof self ) {
80
-			$this->set_id( $subscription->get_id() );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
83
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
84
-			$this->set_id( $subscription_id );
77
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
78
+			$this->set_id($subscription);
79
+		} elseif ($subscription instanceof self) {
80
+			$this->set_id($subscription->get_id());
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
84
+			$this->set_id($subscription_id);
85 85
 		} else {
86
-			$this->set_object_read( true );
86
+			$this->set_object_read(true);
87 87
 		}
88 88
 
89 89
 		// Load the datastore.
90
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
90
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
91 91
 
92
-		if ( $this->get_id() > 0 ) {
93
-			$this->data_store->read( $this );
92
+		if ($this->get_id() > 0) {
93
+			$this->data_store->read($this);
94 94
 		}
95 95
 
96 96
 	}
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
 	 * @since 1.0.19
106 106
 	 * @return int
107 107
 	 */
108
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
108
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
109 109
         global $wpdb;
110 110
 
111 111
 		// Trim the value.
112
-		$value = trim( $value );
112
+		$value = trim($value);
113 113
 
114
-		if ( empty( $value ) ) {
114
+		if (empty($value)) {
115 115
 			return 0;
116 116
 		}
117 117
 
118
-		if ( 'invoice_id' == $field ) {
118
+		if ('invoice_id' == $field) {
119 119
 			$field = 'parent_payment_id';
120 120
 		}
121 121
 
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
 		);
128 128
 
129 129
 		// Ensure a field has been passed.
130
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
130
+		if (empty($field) || !in_array($field, $fields)) {
131 131
 			return 0;
132 132
 		}
133 133
 
134 134
 		// Maybe retrieve from the cache.
135
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
136
-		if ( ! empty( $subscription_id ) ) {
135
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
136
+		if (!empty($subscription_id)) {
137 137
 			return $subscription_id;
138 138
 		}
139 139
 
140 140
         // Fetch from the db.
141 141
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
142 142
         $subscription_id  = (int) $wpdb->get_var(
143
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
143
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
144 144
         );
145 145
 
146
-		if ( empty( $subscription_id ) ) {
146
+		if (empty($subscription_id)) {
147 147
 			return 0;
148 148
 		}
149 149
 
150 150
 		// Update the cache with our data.
151
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
151
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
152 152
 
153 153
 		return $subscription_id;
154 154
 	}
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
      * Clears the subscription's cache.
158 158
      */
159 159
     public function clear_cache() {
160
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
162
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
163
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
160
+		wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids');
161
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids');
162
+		wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids');
163
+		wp_cache_delete($this->get_id(), 'getpaid_subscriptions');
164 164
 	}
165 165
 
166 166
 	/**
167 167
      * Checks if a subscription key is set.
168 168
      */
169
-    public function _isset( $key ) {
170
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
169
+    public function _isset($key) {
170
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
171 171
 	}
172 172
 
173 173
 	/*
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * @param  string $context View or edit context.
193 193
 	 * @return int
194 194
 	 */
195
-	public function get_customer_id( $context = 'view' ) {
196
-		return (int) $this->get_prop( 'customer_id', $context );
195
+	public function get_customer_id($context = 'view') {
196
+		return (int) $this->get_prop('customer_id', $context);
197 197
 	}
198 198
 
199 199
 	/**
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	 * @param  string $context View or edit context.
204 204
 	 * @return WP_User|false WP_User object on success, false on failure.
205 205
 	 */
206
-	public function get_customer( $context = 'view' ) {
207
-		return get_userdata( $this->get_customer_id( $context ) );
206
+	public function get_customer($context = 'view') {
207
+		return get_userdata($this->get_customer_id($context));
208 208
 	}
209 209
 
210 210
 	/**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @param  string $context View or edit context.
215 215
 	 * @return int
216 216
 	 */
217
-	public function get_parent_invoice_id( $context = 'view' ) {
218
-		return (int) $this->get_prop( 'parent_payment_id', $context );
217
+	public function get_parent_invoice_id($context = 'view') {
218
+		return (int) $this->get_prop('parent_payment_id', $context);
219 219
 	}
220 220
 
221 221
 	/**
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param  string $context View or edit context.
226 226
 	 * @return int
227 227
 	 */
228
-    public function get_parent_payment_id( $context = 'view' ) {
229
-        return $this->get_parent_invoice_id( $context );
228
+    public function get_parent_payment_id($context = 'view') {
229
+        return $this->get_parent_invoice_id($context);
230 230
 	}
231 231
 
232 232
 	/**
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
      * @since  1.0.0
236 236
      * @return int
237 237
      */
238
-    public function get_original_payment_id( $context = 'view' ) {
239
-        return $this->get_parent_invoice_id( $context );
238
+    public function get_original_payment_id($context = 'view') {
239
+        return $this->get_parent_invoice_id($context);
240 240
     }
241 241
 
242 242
 	/**
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * @param  string $context View or edit context.
247 247
 	 * @return WPInv_Invoice
248 248
 	 */
249
-	public function get_parent_invoice( $context = 'view' ) {
250
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
249
+	public function get_parent_invoice($context = 'view') {
250
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
251 251
 	}
252 252
 
253 253
 	/**
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $context View or edit context.
258 258
 	 * @return WPInv_Invoice
259 259
 	 */
260
-    public function get_parent_payment( $context = 'view' ) {
261
-        return $this->get_parent_invoice( $context );
260
+    public function get_parent_payment($context = 'view') {
261
+        return $this->get_parent_invoice($context);
262 262
 	}
263 263
 
264 264
 	/**
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @param  string $context View or edit context.
269 269
 	 * @return int
270 270
 	 */
271
-	public function get_product_id( $context = 'view' ) {
272
-		return (int) $this->get_prop( 'product_id', $context );
271
+	public function get_product_id($context = 'view') {
272
+		return (int) $this->get_prop('product_id', $context);
273 273
 	}
274 274
 
275 275
 	/**
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param  string $context View or edit context.
280 280
 	 * @return WPInv_Item
281 281
 	 */
282
-	public function get_product( $context = 'view' ) {
283
-		return new WPInv_Item( $this->get_product_id( $context ) );
282
+	public function get_product($context = 'view') {
283
+		return new WPInv_Item($this->get_product_id($context));
284 284
 	}
285 285
 
286 286
 	/**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return string
294 294
 	 */
295
-	public function get_gateway( $context = 'view' ) {
296
-		return $this->get_parent_invoice( $context )->get_gateway();
295
+	public function get_gateway($context = 'view') {
296
+		return $this->get_parent_invoice($context)->get_gateway();
297 297
 	}
298 298
 
299 299
 	/**
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return string
305 305
 	 */
306
-	public function get_period( $context = 'view' ) {
307
-		return $this->get_prop( 'period', $context );
306
+	public function get_period($context = 'view') {
307
+		return $this->get_prop('period', $context);
308 308
 	}
309 309
 
310 310
 	/**
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 	 * @param  string $context View or edit context.
315 315
 	 * @return int
316 316
 	 */
317
-	public function get_frequency( $context = 'view' ) {
318
-		return (int) $this->get_prop( 'frequency', $context );
317
+	public function get_frequency($context = 'view') {
318
+		return (int) $this->get_prop('frequency', $context);
319 319
 	}
320 320
 
321 321
 	/**
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 	 * @param  string $context View or edit context.
326 326
 	 * @return float
327 327
 	 */
328
-	public function get_initial_amount( $context = 'view' ) {
329
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
328
+	public function get_initial_amount($context = 'view') {
329
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
330 330
 	}
331 331
 
332 332
 	/**
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @param  string $context View or edit context.
337 337
 	 * @return float
338 338
 	 */
339
-	public function get_recurring_amount( $context = 'view' ) {
340
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
339
+	public function get_recurring_amount($context = 'view') {
340
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
341 341
 	}
342 342
 
343 343
 	/**
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 * @param  string $context View or edit context.
348 348
 	 * @return int
349 349
 	 */
350
-	public function get_bill_times( $context = 'view' ) {
351
-		return (int) $this->get_prop( 'bill_times', $context );
350
+	public function get_bill_times($context = 'view') {
351
+		return (int) $this->get_prop('bill_times', $context);
352 352
 	}
353 353
 
354 354
 	/**
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 * @param  string $context View or edit context.
359 359
 	 * @return string
360 360
 	 */
361
-	public function get_transaction_id( $context = 'view' ) {
362
-		return $this->get_prop( 'transaction_id', $context );
361
+	public function get_transaction_id($context = 'view') {
362
+		return $this->get_prop('transaction_id', $context);
363 363
 	}
364 364
 
365 365
 	/**
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 * @param  string $context View or edit context.
370 370
 	 * @return string
371 371
 	 */
372
-	public function get_created( $context = 'view' ) {
373
-		return $this->get_prop( 'created', $context );
372
+	public function get_created($context = 'view') {
373
+		return $this->get_prop('created', $context);
374 374
 	}
375 375
 
376 376
 	/**
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 	 * @param  string $context View or edit context.
381 381
 	 * @return string
382 382
 	 */
383
-	public function get_date_created( $context = 'view' ) {
384
-		return $this->get_created( $context );
383
+	public function get_date_created($context = 'view') {
384
+		return $this->get_created($context);
385 385
 	}
386 386
 
387 387
 	/**
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 */
393 393
 	public function get_time_created() {
394 394
 		$created = $this->get_date_created();
395
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
395
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
396 396
 	}
397 397
 
398 398
 	/**
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 	 * @param  string $context View or edit context.
403 403
 	 * @return string
404 404
 	 */
405
-	public function get_date_created_gmt( $context = 'view' ) {
406
-        $date = $this->get_date_created( $context );
405
+	public function get_date_created_gmt($context = 'view') {
406
+        $date = $this->get_date_created($context);
407 407
 
408
-        if ( $date ) {
409
-            $date = get_gmt_from_date( $date );
408
+        if ($date) {
409
+            $date = get_gmt_from_date($date);
410 410
         }
411 411
 		return $date;
412 412
 	}
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 * @param  string $context View or edit context.
419 419
 	 * @return string
420 420
 	 */
421
-	public function get_next_renewal_date( $context = 'view' ) {
422
-		return $this->get_prop( 'expiration', $context );
421
+	public function get_next_renewal_date($context = 'view') {
422
+		return $this->get_prop('expiration', $context);
423 423
 	}
424 424
 
425 425
 	/**
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 	 * @param  string $context View or edit context.
430 430
 	 * @return string
431 431
 	 */
432
-	public function get_expiration( $context = 'view' ) {
433
-		return $this->get_next_renewal_date( $context );
432
+	public function get_expiration($context = 'view') {
433
+		return $this->get_next_renewal_date($context);
434 434
 	}
435 435
 
436 436
 	/**
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
 	public function get_expiration_time() {
443 443
 		$expiration = $this->get_expiration();
444 444
 
445
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
446
-			return current_time( 'timestamp' );
445
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
446
+			return current_time('timestamp');
447 447
 		}
448 448
 
449
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
450
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
449
+		$expiration = strtotime($expiration, current_time('timestamp'));
450
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
451 451
 	}
452 452
 
453 453
 	/**
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 * @param  string $context View or edit context.
458 458
 	 * @return string
459 459
 	 */
460
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
461
-        $date = $this->get_next_renewal_date( $context );
460
+	public function get_next_renewal_date_gmt($context = 'view') {
461
+        $date = $this->get_next_renewal_date($context);
462 462
 
463
-        if ( $date ) {
464
-            $date = get_gmt_from_date( $date );
463
+        if ($date) {
464
+            $date = get_gmt_from_date($date);
465 465
         }
466 466
 		return $date;
467 467
 	}
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	 * @param  string $context View or edit context.
474 474
 	 * @return string
475 475
 	 */
476
-	public function get_trial_period( $context = 'view' ) {
477
-		return $this->get_prop( 'trial_period', $context );
476
+	public function get_trial_period($context = 'view') {
477
+		return $this->get_prop('trial_period', $context);
478 478
 	}
479 479
 
480 480
 	/**
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	 * @param  string $context View or edit context.
485 485
 	 * @return string
486 486
 	 */
487
-	public function get_status( $context = 'view' ) {
488
-		return $this->get_prop( 'status', $context );
487
+	public function get_status($context = 'view') {
488
+		return $this->get_prop('status', $context);
489 489
 	}
490 490
 
491 491
 	/**
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 	 * @param  string $context View or edit context.
496 496
 	 * @return string
497 497
 	 */
498
-	public function get_profile_id( $context = 'view' ) {
499
-		return $this->get_prop( 'profile_id', $context );
498
+	public function get_profile_id($context = 'view') {
499
+		return $this->get_prop('profile_id', $context);
500 500
 	}
501 501
 
502 502
 	/*
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 	 * @since 1.0.19
512 512
 	 * @param  int $value The customer's id.
513 513
 	 */
514
-	public function set_customer_id( $value ) {
515
-		$this->set_prop( 'customer_id', (int) $value );
514
+	public function set_customer_id($value) {
515
+		$this->set_prop('customer_id', (int) $value);
516 516
 	}
517 517
 
518 518
 	/**
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
 	 * @since 1.0.19
522 522
 	 * @param  int $value The parent invoice id.
523 523
 	 */
524
-	public function set_parent_invoice_id( $value ) {
525
-		$this->set_prop( 'parent_payment_id', (int) $value );
524
+	public function set_parent_invoice_id($value) {
525
+		$this->set_prop('parent_payment_id', (int) $value);
526 526
 	}
527 527
 
528 528
 	/**
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	 * @since 1.0.19
532 532
 	 * @param  int $value The parent invoice id.
533 533
 	 */
534
-    public function set_parent_payment_id( $value ) {
535
-        $this->set_parent_invoice_id( $value );
534
+    public function set_parent_payment_id($value) {
535
+        $this->set_parent_invoice_id($value);
536 536
 	}
537 537
 
538 538
 	/**
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
      * @since 1.0.19
542 542
 	 * @param  int $value The parent invoice id.
543 543
      */
544
-    public function set_original_payment_id( $value ) {
545
-        $this->set_parent_invoice_id( $value );
544
+    public function set_original_payment_id($value) {
545
+        $this->set_parent_invoice_id($value);
546 546
 	}
547 547
 
548 548
 	/**
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 	 * @since 1.0.19
552 552
 	 * @param  int $value The subscription product id.
553 553
 	 */
554
-	public function set_product_id( $value ) {
555
-		$this->set_prop( 'product_id', (int) $value );
554
+	public function set_product_id($value) {
555
+		$this->set_prop('product_id', (int) $value);
556 556
 	}
557 557
 
558 558
 	/**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @since 1.0.19
562 562
 	 * @param  string $value The renewal period.
563 563
 	 */
564
-	public function set_period( $value ) {
565
-		$this->set_prop( 'period', $value );
564
+	public function set_period($value) {
565
+		$this->set_prop('period', $value);
566 566
 	}
567 567
 
568 568
 	/**
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
 	 * @since 1.0.19
572 572
 	 * @param  int $value The subscription frequency.
573 573
 	 */
574
-	public function set_frequency( $value ) {
575
-		$value = empty( $value ) ? 1 : (int) $value;
576
-		$this->set_prop( 'frequency', absint( $value ) );
574
+	public function set_frequency($value) {
575
+		$value = empty($value) ? 1 : (int) $value;
576
+		$this->set_prop('frequency', absint($value));
577 577
 	}
578 578
 
579 579
 	/**
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 	 * @since 1.0.19
583 583
 	 * @param  float $value The initial subcription amount.
584 584
 	 */
585
-	public function set_initial_amount( $value ) {
586
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
585
+	public function set_initial_amount($value) {
586
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
587 587
 	}
588 588
 
589 589
 	/**
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 	 * @since 1.0.19
593 593
 	 * @param  float $value The recurring subcription amount.
594 594
 	 */
595
-	public function set_recurring_amount( $value ) {
596
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
595
+	public function set_recurring_amount($value) {
596
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
597 597
 	}
598 598
 
599 599
 	/**
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
 	 * @since 1.0.19
603 603
 	 * @param  int $value Bill times.
604 604
 	 */
605
-	public function set_bill_times( $value ) {
606
-		$this->set_prop( 'bill_times', (int) $value );
605
+	public function set_bill_times($value) {
606
+		$this->set_prop('bill_times', (int) $value);
607 607
 	}
608 608
 
609 609
 	/**
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 	 * @since 1.0.19
613 613
 	 * @param string $value Bill times.
614 614
 	 */
615
-	public function set_transaction_id( $value ) {
616
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
615
+	public function set_transaction_id($value) {
616
+		$this->set_prop('transaction_id', sanitize_text_field($value));
617 617
 	}
618 618
 
619 619
 	/**
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
 	 * @since 1.0.19
623 623
 	 * @param string $value strtotime compliant date.
624 624
 	 */
625
-	public function set_created( $value ) {
626
-        $date = strtotime( $value );
625
+	public function set_created($value) {
626
+        $date = strtotime($value);
627 627
 
628
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
629
-            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
628
+        if ($date && $value !== '0000-00-00 00:00:00') {
629
+            $this->set_prop('created', date('Y-m-d H:i:s', $date));
630 630
             return;
631 631
         }
632 632
 
633
-		$this->set_prop( 'created', '' );
633
+		$this->set_prop('created', '');
634 634
 
635 635
 	}
636 636
 
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 * @since 1.0.19
641 641
 	 * @param string $value strtotime compliant date.
642 642
 	 */
643
-	public function set_date_created( $value ) {
644
-		$this->set_created( $value );
643
+	public function set_date_created($value) {
644
+		$this->set_created($value);
645 645
     }
646 646
 
647 647
 	/**
@@ -650,15 +650,15 @@  discard block
 block discarded – undo
650 650
 	 * @since 1.0.19
651 651
 	 * @param string $value strtotime compliant date.
652 652
 	 */
653
-	public function set_next_renewal_date( $value ) {
654
-		$date = strtotime( $value );
653
+	public function set_next_renewal_date($value) {
654
+		$date = strtotime($value);
655 655
 
656
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
657
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
656
+        if ($date && $value !== '0000-00-00 00:00:00') {
657
+            $this->set_prop('expiration', date('Y-m-d H:i:s', $date));
658 658
             return;
659 659
 		}
660 660
 
661
-		$this->set_prop( 'expiration', '' );
661
+		$this->set_prop('expiration', '');
662 662
 
663 663
 	}
664 664
 
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 	 * @since 1.0.19
669 669
 	 * @param string $value strtotime compliant date.
670 670
 	 */
671
-	public function set_expiration( $value ) {
672
-		$this->set_next_renewal_date( $value );
671
+	public function set_expiration($value) {
672
+		$this->set_next_renewal_date($value);
673 673
     }
674 674
 
675 675
 	/**
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
 	 * @since 1.0.19
679 679
 	 * @param string $value trial period e.g 1 year.
680 680
 	 */
681
-	public function set_trial_period( $value ) {
682
-		$this->set_prop( 'trial_period', $value );
681
+	public function set_trial_period($value) {
682
+		$this->set_prop('trial_period', $value);
683 683
 	}
684 684
 
685 685
 	/**
@@ -688,19 +688,19 @@  discard block
 block discarded – undo
688 688
 	 * @since 1.0.19
689 689
 	 * @param string $new_status    New subscription status.
690 690
 	 */
691
-	public function set_status( $new_status ) {
691
+	public function set_status($new_status) {
692 692
 
693 693
 		// Abort if this is not a valid status;
694
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
694
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
695 695
 			return;
696 696
 		}
697 697
 
698 698
 		$old_status = $this->get_status();
699
-		$this->set_prop( 'status', $new_status );
699
+		$this->set_prop('status', $new_status);
700 700
 
701
-		if ( true === $this->object_read && $old_status !== $new_status ) {
701
+		if (true === $this->object_read && $old_status !== $new_status) {
702 702
 			$this->status_transition = array(
703
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
703
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
704 704
 				'to'     => $new_status,
705 705
 			);
706 706
 		}
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 * @since 1.0.19
714 714
 	 * @param  string $value the remote profile id.
715 715
 	 */
716
-	public function set_profile_id( $value ) {
717
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
716
+	public function set_profile_id($value) {
717
+		$this->set_prop('profile_id', sanitize_text_field($value));
718 718
 	}
719 719
 
720 720
 	/*
@@ -732,8 +732,8 @@  discard block
 block discarded – undo
732 732
 	 * @param string|array String or array of strings to check for.
733 733
 	 * @return bool
734 734
      */
735
-    public function has_status( $status ) {
736
-        return in_array( $this->get_status(), wpinv_parse_list( $status ) );
735
+    public function has_status($status) {
736
+        return in_array($this->get_status(), wpinv_parse_list($status));
737 737
 	}
738 738
 
739 739
 	/**
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
      */
744 744
     public function has_trial_period() {
745 745
 		$period = $this->get_trial_period();
746
-        return ! empty( $period );
746
+        return !empty($period);
747 747
 	}
748 748
 
749 749
 	/**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	 * @return bool
753 753
 	 */
754 754
 	public function is_active() {
755
-		return $this->has_status( 'active trialling' ) && $this->get_expiration_time() > current_time( 'mysql' );
755
+		return $this->has_status('active trialling') && $this->get_expiration_time() > current_time('mysql');
756 756
 	}
757 757
 
758 758
 	/**
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	 * @return bool
762 762
 	 */
763 763
 	public function is_expired() {
764
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
764
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql'));
765 765
 	}
766 766
 
767 767
 	/*
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 	/**
777 777
 	 * Backwards compatibilty.
778 778
 	 */
779
-	public function create( $data = array() ) {
779
+	public function create($data = array()) {
780 780
 
781 781
 		// Set the properties.
782
-		if ( is_array( $data ) ) {
783
-			$this->set_props( $data );
782
+		if (is_array($data)) {
783
+			$this->set_props($data);
784 784
 		}
785 785
 
786 786
 		// Save the item.
@@ -791,8 +791,8 @@  discard block
 block discarded – undo
791 791
 	/**
792 792
 	 * Backwards compatibilty.
793 793
 	 */
794
-	public function update( $args = array() ) {
795
-		return $this->create( $args );
794
+	public function update($args = array()) {
795
+		return $this->create($args);
796 796
 	}
797 797
 
798 798
     /**
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 			array(
807 807
             	'post_parent'    => $this->get_parent_payment_id(),
808 808
             	'numberposts'    => -1,
809
-            	'post_status'    => array( 'publish', 'wpi-processing', 'wpi-renewal' ),
809
+            	'post_status'    => array('publish', 'wpi-processing', 'wpi-renewal'),
810 810
             	'orderby'        => 'ID',
811 811
             	'order'          => 'DESC',
812 812
             	'post_type'      => 'wpi_invoice'
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 		);
832 832
 
833 833
 		// Maybe include parent invoice.
834
-        if ( ! $this->has_status( 'pending' ) ) {
834
+        if (!$this->has_status('pending')) {
835 835
             $count++;
836 836
         }
837 837
 
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
     public function get_times_billed() {
848 848
         $times_billed = $this->get_total_payments();
849 849
 
850
-        if ( $this->has_trial_period() && $times_billed > 0 ) {
850
+        if ($this->has_trial_period() && $times_billed > 0) {
851 851
             $times_billed--;
852 852
         }
853 853
 
@@ -862,49 +862,49 @@  discard block
 block discarded – undo
862 862
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
863 863
      * @return bool
864 864
      */
865
-    public function add_payment( $args = array(), $invoice = false ) {
865
+    public function add_payment($args = array(), $invoice = false) {
866 866
 
867 867
 		// Process each payment once.
868
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
868
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
869 869
             return false;
870 870
         }
871 871
 
872 872
 		// Are we creating a new invoice?
873
-		if ( empty( $invoice ) ) {
873
+		if (empty($invoice)) {
874 874
 			$invoice = $this->create_payment();
875 875
 
876
-			if ( empty( $invoice ) ) {
876
+			if (empty($invoice)) {
877 877
 				return false;
878 878
 			}
879 879
 
880
-			$invoice->set_status( 'wpi-renewal' );
880
+			$invoice->set_status('wpi-renewal');
881 881
 
882 882
 		}
883 883
 
884 884
 		// Maybe set a transaction id.
885
-		if ( ! empty( $args['transaction_id'] ) ) {
886
-			$invoice->set_transaction_id( $args['transaction_id'] );
885
+		if (!empty($args['transaction_id'])) {
886
+			$invoice->set_transaction_id($args['transaction_id']);
887 887
 		}
888 888
 
889 889
 		// Set the completed date.
890
-		$invoice->set_completed_date( current_time( 'mysql' ) );
890
+		$invoice->set_completed_date(current_time('mysql'));
891 891
 
892 892
 		// And the gateway.
893
-		if ( ! empty( $args['gateway'] ) ) {
894
-			$invoice->set_gateway( $args['gateway'] );
893
+		if (!empty($args['gateway'])) {
894
+			$invoice->set_gateway($args['gateway']);
895 895
 		}
896 896
 
897 897
 		$invoice->save();
898 898
 
899
-		if ( ! $invoice->get_id() ) {
899
+		if (!$invoice->get_id()) {
900 900
 			return 0;
901 901
 		}
902 902
 
903
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
904
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
905
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
903
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
904
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
905
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
906 906
 
907
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
907
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
908 908
 
909 909
         return $invoice->get_id();
910 910
 	}
@@ -919,20 +919,20 @@  discard block
 block discarded – undo
919 919
 
920 920
 		$parent_invoice = $this->get_parent_payment();
921 921
 
922
-		if ( ! $parent_invoice->get_id() ) {
922
+		if (!$parent_invoice->get_id()) {
923 923
 			return false;
924 924
 		}
925 925
 
926 926
 		// Duplicate the parent invoice.
927 927
 		$invoice = new WPInv_Invoice();
928
-		$invoice->set_props( $parent_invoice->get_data() );
929
-		$invoice->set_id( 0 );
930
-		$invoice->set_parent_id( $parent_invoice->get_id() );
931
-		$invoice->set_transaction_id( '' );
932
-		$invoice->set_key( $invoice->generate_key( 'renewal_' ) );
933
-		$invoice->set_number( '' );
934
-		$invoice->set_completed_date( '' );
935
-		$invoice->set_status( 'wpi-pending' );
928
+		$invoice->set_props($parent_invoice->get_data());
929
+		$invoice->set_id(0);
930
+		$invoice->set_parent_id($parent_invoice->get_id());
931
+		$invoice->set_transaction_id('');
932
+		$invoice->set_key($invoice->generate_key('renewal_'));
933
+		$invoice->set_number('');
934
+		$invoice->set_completed_date('');
935
+		$invoice->set_status('wpi-pending');
936 936
 		$invoice->recalculate_total();
937 937
 		$invoice->save();
938 938
 
@@ -948,20 +948,20 @@  discard block
 block discarded – undo
948 948
 	public function renew() {
949 949
 
950 950
 		// Complete subscription if applicable
951
-		if ( $this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times() ) {
951
+		if ($this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times()) {
952 952
 			return $this->complete();
953 953
 		}
954 954
 
955 955
 		// Calculate new expiration
956 956
 		$frequency      = $this->get_frequency();
957 957
 		$period         = $this->get_period();
958
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
958
+		$new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time());
959 959
 
960
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
961
-		$this->set_status( 'active' );
960
+		$this->set_expiration(date('Y-m-d H:i:s', $new_expiration));
961
+		$this->set_status('active');
962 962
 		return $this->save();
963 963
 
964
-		do_action( 'getpaid_subscription_renewed', $this );
964
+		do_action('getpaid_subscription_renewed', $this);
965 965
 
966 966
 	}
967 967
 
@@ -976,11 +976,11 @@  discard block
 block discarded – undo
976 976
 	public function complete() {
977 977
 
978 978
 		// Only mark a subscription as complete if it's not already cancelled.
979
-		if ( $this->has_status( 'cancelled' ) ) {
979
+		if ($this->has_status('cancelled')) {
980 980
 			return false;
981 981
 		}
982 982
 
983
-		$this->set_status( 'completed' );
983
+		$this->set_status('completed');
984 984
 		return $this->save();
985 985
 
986 986
 	}
@@ -992,14 +992,14 @@  discard block
 block discarded – undo
992 992
 	 * @param  bool $check_expiration
993 993
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
994 994
 	 */
995
-	public function expire( $check_expiration = false ) {
995
+	public function expire($check_expiration = false) {
996 996
 
997
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
997
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
998 998
 			// Do not mark as expired since real expiration date is in the future
999 999
 			return false;
1000 1000
 		}
1001 1001
 
1002
-		$this->set_status( 'expired' );
1002
+		$this->set_status('expired');
1003 1003
 		return $this->save();
1004 1004
 
1005 1005
 	}
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 	 * @return int Subscription id.
1012 1012
 	 */
1013 1013
 	public function failing() {
1014
-		$this->set_status( 'failing' );
1014
+		$this->set_status('failing');
1015 1015
 		return $this->save();
1016 1016
 	}
1017 1017
 
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
      * @return int Subscription id.
1023 1023
      */
1024 1024
     public function cancel() {
1025
-		$this->set_status( 'cancelled' );
1025
+		$this->set_status('cancelled');
1026 1026
 		return $this->save();
1027 1027
     }
1028 1028
 
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 	 * @return bool
1034 1034
 	 */
1035 1035
 	public function can_cancel() {
1036
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1036
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1037 1037
 	}
1038 1038
 
1039 1039
     /**
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
      * @return      array
1045 1045
      */
1046 1046
     public function get_cancellable_statuses() {
1047
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1047
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1048 1048
     }
1049 1049
 
1050 1050
 	/**
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 	 * @return string
1055 1055
 	 */
1056 1056
 	public function get_cancel_url() {
1057
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->get_id() ) ), 'wpinv-recurring-cancel' );
1058
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1057
+		$url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'cancel_subscription', 'sub_id' => $this->get_id())), 'wpinv-recurring-cancel');
1058
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1059 1059
 	}
1060 1060
 
1061 1061
 	/**
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 	 * @return bool
1069 1069
 	 */
1070 1070
 	public function can_renew() {
1071
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1071
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1072 1072
 	}
1073 1073
 
1074 1074
 	/**
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 	 * @return string
1079 1079
 	 */
1080 1080
 	public function get_renew_url() {
1081
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'wpinv-recurring-renew' );
1082
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1081
+		$url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'wpinv-recurring-renew');
1082
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1083 1083
 	}
1084 1084
 
1085 1085
 	/**
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 	 * @return bool
1090 1090
 	 */
1091 1091
 	public function can_update() {
1092
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1092
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1093 1093
 	}
1094 1094
 
1095 1095
 	/**
@@ -1099,8 +1099,8 @@  discard block
 block discarded – undo
1099 1099
 	 * @return string
1100 1100
 	 */
1101 1101
 	public function get_update_url() {
1102
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1103
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1102
+		$url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id()));
1103
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1104 1104
 	}
1105 1105
 
1106 1106
 	/**
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 	 * @return string
1111 1111
 	 */
1112 1112
 	public function get_status_label() {
1113
-		return getpaid_get_subscription_status_label( $this->get_status() );
1113
+		return getpaid_get_subscription_status_label($this->get_status());
1114 1114
 	}
1115 1115
 
1116 1116
 	/**
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 	 */
1122 1122
 	public function get_status_class() {
1123 1123
 		$statuses = getpaid_get_subscription_status_classes();
1124
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary';
1124
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'text-white bg-secondary';
1125 1125
 	}
1126 1126
 
1127 1127
     /**
@@ -1132,9 +1132,9 @@  discard block
 block discarded – undo
1132 1132
      */
1133 1133
     public function get_status_label_html() {
1134 1134
 
1135
-		$status_label = sanitize_text_field( $this->get_status_label() );
1136
-		$class        = esc_attr( $this->get_status_class() );
1137
-		$status       = sanitize_html_class( $this->get_status_label() );
1135
+		$status_label = sanitize_text_field($this->get_status_label());
1136
+		$class        = esc_attr($this->get_status_class());
1137
+		$status       = sanitize_html_class($this->get_status_label());
1138 1138
 
1139 1139
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded $class $status'>$status_label</span></span>";
1140 1140
     }
@@ -1146,9 +1146,9 @@  discard block
 block discarded – undo
1146 1146
      * @param  string $txn_id The transaction ID from the merchant processor
1147 1147
      * @return bool
1148 1148
      */
1149
-    public function payment_exists( $txn_id = '' ) {
1150
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1151
-        return ! empty( $invoice_id );
1149
+    public function payment_exists($txn_id = '') {
1150
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1151
+        return !empty($invoice_id);
1152 1152
 	}
1153 1153
 
1154 1154
 	/**
@@ -1160,35 +1160,35 @@  discard block
 block discarded – undo
1160 1160
 		// Reset status transition variable.
1161 1161
 		$this->status_transition = false;
1162 1162
 
1163
-		if ( $status_transition ) {
1163
+		if ($status_transition) {
1164 1164
 			try {
1165 1165
 
1166 1166
 				// Fire a hook for the status change.
1167
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1168
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1167
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1168
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1169 1169
 
1170
-				if ( ! empty( $status_transition['from'] ) ) {
1170
+				if (!empty($status_transition['from'])) {
1171 1171
 
1172 1172
 					/* translators: 1: old subscription status 2: new subscription status */
1173
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1173
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1174 1174
 
1175 1175
 					// Fire another hook.
1176
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1177
-					do_action( 'getpaid_subscription_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
1176
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1177
+					do_action('getpaid_subscription_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this);
1178 1178
 
1179 1179
 					// Note the transition occurred.
1180
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1180
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1181 1181
 
1182 1182
 				} else {
1183 1183
 					/* translators: %s: new invoice status */
1184
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1184
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1185 1185
 
1186 1186
 					// Note the transition occurred.
1187
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1187
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1188 1188
 
1189 1189
 				}
1190
-			} catch ( Exception $e ) {
1191
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1190
+			} catch (Exception $e) {
1191
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1192 1192
 			}
1193 1193
 		}
1194 1194
 
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Spacing   +752 added lines, -752 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -133,40 +133,40 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135 135
 	 */
136
-    public function __construct( $invoice = false ) {
136
+    public function __construct($invoice = false) {
137 137
 
138
-        parent::__construct( $invoice );
138
+        parent::__construct($invoice);
139 139
 
140
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
-			$this->set_id( $invoice );
142
-		} elseif ( $invoice instanceof self ) {
143
-			$this->set_id( $invoice->get_id() );
144
-		} elseif ( ! empty( $invoice->ID ) ) {
145
-			$this->set_id( $invoice->ID );
146
-		} elseif ( is_array( $invoice ) ) {
147
-			$this->set_props( $invoice );
140
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) {
141
+			$this->set_id($invoice);
142
+		} elseif ($invoice instanceof self) {
143
+			$this->set_id($invoice->get_id());
144
+		} elseif (!empty($invoice->ID)) {
145
+			$this->set_id($invoice->ID);
146
+		} elseif (is_array($invoice)) {
147
+			$this->set_props($invoice);
148 148
 
149
-			if ( isset( $invoice['ID'] ) ) {
150
-				$this->set_id( $invoice['ID'] );
149
+			if (isset($invoice['ID'])) {
150
+				$this->set_id($invoice['ID']);
151 151
 			}
152 152
 
153
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
-			$this->set_id( $invoice_id );
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		}else {
160
-			$this->set_object_read( true );
153
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
154
+			$this->set_id($invoice_id);
155
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
156
+			$this->set_id($invoice_id);
157
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
158
+			$this->set_id($invoice_id);
159
+		} else {
160
+			$this->set_object_read(true);
161 161
 		}
162 162
 
163 163
         // Load the datastore.
164
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
164
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
165 165
 
166
-		if ( $this->get_id() > 0 ) {
167
-            $this->post = get_post( $this->get_id() );
166
+		if ($this->get_id() > 0) {
167
+            $this->post = get_post($this->get_id());
168 168
             $this->ID   = $this->get_id();
169
-			$this->data_store->read( $this );
169
+			$this->data_store->read($this);
170 170
         }
171 171
 
172 172
     }
@@ -181,38 +181,38 @@  discard block
 block discarded – undo
181 181
 	 * @since 1.0.15
182 182
 	 * @return int
183 183
 	 */
184
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
184
+	public static function get_invoice_id_by_field($value, $field = 'key') {
185 185
         global $wpdb;
186 186
 
187 187
 		// Trim the value.
188
-		$value = trim( $value );
188
+		$value = trim($value);
189 189
 
190
-		if ( empty( $value ) ) {
190
+		if (empty($value)) {
191 191
 			return 0;
192 192
 		}
193 193
 
194 194
         // Valid fields.
195
-        $fields = array( 'key', 'number', 'transaction_id' );
195
+        $fields = array('key', 'number', 'transaction_id');
196 196
 
197 197
 		// Ensure a field has been passed.
198
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
198
+		if (empty($field) || !in_array($field, $fields)) {
199 199
 			return 0;
200 200
 		}
201 201
 
202 202
 		// Maybe retrieve from the cache.
203
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
-		if ( false !== $invoice_id ) {
203
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
204
+		if (false !== $invoice_id) {
205 205
 			return $invoice_id;
206 206
 		}
207 207
 
208 208
         // Fetch from the db.
209 209
         $table       = $wpdb->prefix . 'getpaid_invoices';
210 210
         $invoice_id  = (int) $wpdb->get_var(
211
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
211
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
212 212
         );
213 213
 
214 214
 		// Update the cache with our data
215
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
216 216
 
217 217
 		return $invoice_id;
218 218
     }
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
     /**
221 221
      * Checks if an invoice key is set.
222 222
      */
223
-    public function _isset( $key ) {
224
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
223
+    public function _isset($key) {
224
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
225 225
     }
226 226
 
227 227
     /*
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * @param  string $context View or edit context.
247 247
 	 * @return int
248 248
 	 */
249
-	public function get_parent_id( $context = 'view' ) {
250
-		return (int) $this->get_prop( 'parent_id', $context );
249
+	public function get_parent_id($context = 'view') {
250
+		return (int) $this->get_prop('parent_id', $context);
251 251
     }
252 252
 
253 253
     /**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @return WPInv_Invoice
258 258
 	 */
259 259
     public function get_parent_payment() {
260
-        return new WPInv_Invoice( $this->get_parent_id() );
260
+        return new WPInv_Invoice($this->get_parent_id());
261 261
     }
262 262
 
263 263
     /**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param  string $context View or edit context.
278 278
 	 * @return string
279 279
 	 */
280
-	public function get_status( $context = 'view' ) {
281
-		return $this->get_prop( 'status', $context );
280
+	public function get_status($context = 'view') {
281
+		return $this->get_prop('status', $context);
282 282
 	}
283 283
 	
284 284
 	/**
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function get_all_statuses() {
291 291
 
292
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
292
+		$statuses = wpinv_get_invoice_statuses(true, true, $this);
293 293
 
294 294
 		// For backwards compatibility.
295
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
295
+		if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
296 296
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
297 297
 		}
298 298
 
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
     public function get_status_nicename() {
309 309
 		$statuses = $this->get_all_statuses();
310 310
 
311
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
311
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
312 312
 
313
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
313
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
314 314
     }
315 315
 
316 316
     /**
@@ -320,27 +320,27 @@  discard block
 block discarded – undo
320 320
 	 * @param  string $context View or edit context.
321 321
 	 * @return string
322 322
 	 */
323
-	public function get_version( $context = 'view' ) {
324
-		return $this->get_prop( 'version', $context );
323
+	public function get_version($context = 'view') {
324
+		return $this->get_prop('version', $context);
325 325
 	}
326 326
 
327 327
 	/**
328 328
 	 * @deprecated
329 329
 	 */
330
-	public function get_invoice_date( $formatted = true ) {
330
+	public function get_invoice_date($formatted = true) {
331 331
         $date_completed = $this->get_date_completed();
332 332
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
333 333
 
334
-        if ( $invoice_date == '' ) {
334
+        if ($invoice_date == '') {
335 335
             $date_created   = $this->get_date_created();
336 336
             $invoice_date   = $date_created != '0000-00-00 00:00:00' ? $date_created : '';
337 337
         }
338 338
 
339
-        if ( $formatted && $invoice_date ) {
340
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
339
+        if ($formatted && $invoice_date) {
340
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
341 341
         }
342 342
 
343
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this );
343
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this);
344 344
     }
345 345
 
346 346
     /**
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 	 * @param  string $context View or edit context.
351 351
 	 * @return string
352 352
 	 */
353
-	public function get_date_created( $context = 'view' ) {
354
-		return $this->get_prop( 'date_created', $context );
353
+	public function get_date_created($context = 'view') {
354
+		return $this->get_prop('date_created', $context);
355 355
 	}
356 356
 	
357 357
 	/**
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 	 * @param  string $context View or edit context.
362 362
 	 * @return string
363 363
 	 */
364
-	public function get_created_date( $context = 'view' ) {
365
-		return $this->get_date_created( $context );
364
+	public function get_created_date($context = 'view') {
365
+		return $this->get_date_created($context);
366 366
     }
367 367
 
368 368
     /**
@@ -372,11 +372,11 @@  discard block
 block discarded – undo
372 372
 	 * @param  string $context View or edit context.
373 373
 	 * @return string
374 374
 	 */
375
-	public function get_date_created_gmt( $context = 'view' ) {
376
-        $date = $this->get_date_created( $context );
375
+	public function get_date_created_gmt($context = 'view') {
376
+        $date = $this->get_date_created($context);
377 377
 
378
-        if ( $date ) {
379
-            $date = get_gmt_from_date( $date );
378
+        if ($date) {
379
+            $date = get_gmt_from_date($date);
380 380
         }
381 381
 		return $date;
382 382
     }
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 	 * @param  string $context View or edit context.
389 389
 	 * @return string
390 390
 	 */
391
-	public function get_date_modified( $context = 'view' ) {
392
-		return $this->get_prop( 'date_modified', $context );
391
+	public function get_date_modified($context = 'view') {
392
+		return $this->get_prop('date_modified', $context);
393 393
 	}
394 394
 
395 395
 	/**
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
 	 * @param  string $context View or edit context.
400 400
 	 * @return string
401 401
 	 */
402
-	public function get_modified_date( $context = 'view' ) {
403
-		return $this->get_date_modified( $context );
402
+	public function get_modified_date($context = 'view') {
403
+		return $this->get_date_modified($context);
404 404
     }
405 405
 
406 406
     /**
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
 	 * @param  string $context View or edit context.
411 411
 	 * @return string
412 412
 	 */
413
-	public function get_date_modified_gmt( $context = 'view' ) {
414
-        $date = $this->get_date_modified( $context );
413
+	public function get_date_modified_gmt($context = 'view') {
414
+        $date = $this->get_date_modified($context);
415 415
 
416
-        if ( $date ) {
417
-            $date = get_gmt_from_date( $date );
416
+        if ($date) {
417
+            $date = get_gmt_from_date($date);
418 418
         }
419 419
 		return $date;
420 420
     }
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	 * @param  string $context View or edit context.
427 427
 	 * @return string
428 428
 	 */
429
-	public function get_due_date( $context = 'view' ) {
430
-		return $this->get_prop( 'due_date', $context );
429
+	public function get_due_date($context = 'view') {
430
+		return $this->get_prop('due_date', $context);
431 431
     }
432 432
 
433 433
     /**
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	 * @param  string $context View or edit context.
438 438
 	 * @return string
439 439
 	 */
440
-	public function get_date_due( $context = 'view' ) {
441
-		return $this->get_due_date( $context );
440
+	public function get_date_due($context = 'view') {
441
+		return $this->get_due_date($context);
442 442
     }
443 443
 
444 444
     /**
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 	 * @param  string $context View or edit context.
449 449
 	 * @return string
450 450
 	 */
451
-	public function get_due_date_gmt( $context = 'view' ) {
452
-        $date = $this->get_due_date( $context );
451
+	public function get_due_date_gmt($context = 'view') {
452
+        $date = $this->get_due_date($context);
453 453
 
454
-        if ( $date ) {
455
-            $date = get_gmt_from_date( $date );
454
+        if ($date) {
455
+            $date = get_gmt_from_date($date);
456 456
         }
457 457
 		return $date;
458 458
     }
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return string
466 466
 	 */
467
-	public function get_gmt_date_due( $context = 'view' ) {
468
-		return $this->get_due_date_gmt( $context );
467
+	public function get_gmt_date_due($context = 'view') {
468
+		return $this->get_due_date_gmt($context);
469 469
     }
470 470
 
471 471
     /**
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 	 * @param  string $context View or edit context.
476 476
 	 * @return string
477 477
 	 */
478
-	public function get_completed_date( $context = 'view' ) {
479
-		return $this->get_prop( 'completed_date', $context );
478
+	public function get_completed_date($context = 'view') {
479
+		return $this->get_prop('completed_date', $context);
480 480
     }
481 481
 
482 482
     /**
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
 	 * @param  string $context View or edit context.
487 487
 	 * @return string
488 488
 	 */
489
-	public function get_date_completed( $context = 'view' ) {
490
-		return $this->get_completed_date( $context );
489
+	public function get_date_completed($context = 'view') {
490
+		return $this->get_completed_date($context);
491 491
     }
492 492
 
493 493
     /**
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
 	 * @param  string $context View or edit context.
498 498
 	 * @return string
499 499
 	 */
500
-	public function get_completed_date_gmt( $context = 'view' ) {
501
-        $date = $this->get_completed_date( $context );
500
+	public function get_completed_date_gmt($context = 'view') {
501
+        $date = $this->get_completed_date($context);
502 502
 
503
-        if ( $date ) {
504
-            $date = get_gmt_from_date( $date );
503
+        if ($date) {
504
+            $date = get_gmt_from_date($date);
505 505
         }
506 506
 		return $date;
507 507
     }
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 	 * @param  string $context View or edit context.
514 514
 	 * @return string
515 515
 	 */
516
-	public function get_gmt_completed_date( $context = 'view' ) {
517
-		return $this->get_completed_date_gmt( $context );
516
+	public function get_gmt_completed_date($context = 'view') {
517
+		return $this->get_completed_date_gmt($context);
518 518
     }
519 519
 
520 520
     /**
@@ -524,12 +524,12 @@  discard block
 block discarded – undo
524 524
 	 * @param  string $context View or edit context.
525 525
 	 * @return string
526 526
 	 */
527
-	public function get_number( $context = 'view' ) {
528
-        $number = $this->get_prop( 'number', $context );
527
+	public function get_number($context = 'view') {
528
+        $number = $this->get_prop('number', $context);
529 529
 
530
-        if ( empty( $number ) ) {
530
+        if (empty($number)) {
531 531
             $number = $this->generate_number();
532
-            $this->set_number( $number );
532
+            $this->set_number($number);
533 533
         }
534 534
 
535 535
 		return $number;
@@ -542,12 +542,12 @@  discard block
 block discarded – undo
542 542
 	 * @param  string $context View or edit context.
543 543
 	 * @return string
544 544
 	 */
545
-	public function get_key( $context = 'view' ) {
546
-        $key = $this->get_prop( 'key', $context );
545
+	public function get_key($context = 'view') {
546
+        $key = $this->get_prop('key', $context);
547 547
 
548
-        if ( empty( $key ) ) {
549
-            $key = $this->generate_key( $this->get_type() . '_' );
550
-            $this->set_key( $key );
548
+        if (empty($key)) {
549
+            $key = $this->generate_key($this->get_type() . '_');
550
+            $this->set_key($key);
551 551
         }
552 552
 
553 553
 		return $key;
@@ -560,23 +560,23 @@  discard block
 block discarded – undo
560 560
 	 * @param  string $context View or edit context.
561 561
 	 * @return string
562 562
 	 */
563
-	public function get_type( $context = 'view' ) {
564
-        return $this->get_prop( 'type', $context );
563
+	public function get_type($context = 'view') {
564
+        return $this->get_prop('type', $context);
565 565
 	}
566 566
 
567 567
 	/**
568 568
 	 * @deprecated
569 569
 	 */
570
-	public function get_invoice_quote_type( $post_id ) {
571
-        if ( empty( $post_id ) ) {
570
+	public function get_invoice_quote_type($post_id) {
571
+        if (empty($post_id)) {
572 572
             return '';
573 573
         }
574 574
 
575
-        $type = get_post_type( $post_id );
575
+        $type = get_post_type($post_id);
576 576
 
577
-        if ( 'wpi_invoice' === $type ) {
577
+        if ('wpi_invoice' === $type) {
578 578
             $post_type = __('Invoice', 'invoicing');
579
-        } else{
579
+        } else {
580 580
             $post_type = __('Quote', 'invoicing');
581 581
         }
582 582
 
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 	 * @param  string $context View or edit context.
591 591
 	 * @return string
592 592
 	 */
593
-	public function get_post_type( $context = 'view' ) {
594
-        return $this->get_prop( 'post_type', $context );
593
+	public function get_post_type($context = 'view') {
594
+        return $this->get_prop('post_type', $context);
595 595
     }
596 596
 
597 597
     /**
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
 	 * @param  string $context View or edit context.
602 602
 	 * @return string
603 603
 	 */
604
-	public function get_mode( $context = 'view' ) {
605
-        return $this->get_prop( 'mode', $context );
604
+	public function get_mode($context = 'view') {
605
+        return $this->get_prop('mode', $context);
606 606
     }
607 607
 
608 608
     /**
@@ -612,12 +612,12 @@  discard block
 block discarded – undo
612 612
 	 * @param  string $context View or edit context.
613 613
 	 * @return string
614 614
 	 */
615
-	public function get_path( $context = 'view' ) {
616
-        $path = $this->get_prop( 'path', $context );
615
+	public function get_path($context = 'view') {
616
+        $path = $this->get_prop('path', $context);
617 617
 
618
-        if ( empty( $path ) ) {
619
-            $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type );
620
-            $path   = sanitize_title( $prefix . $this->get_id() );
618
+        if (empty($path)) {
619
+            $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type);
620
+            $path   = sanitize_title($prefix . $this->get_id());
621 621
         }
622 622
 
623 623
 		return $path;
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
 	 * @param  string $context View or edit context.
631 631
 	 * @return string
632 632
 	 */
633
-	public function get_name( $context = 'view' ) {
634
-        $name = $this->get_prop( 'title', $context );
633
+	public function get_name($context = 'view') {
634
+        $name = $this->get_prop('title', $context);
635 635
 
636
-		return empty( $name ) ? $this->get_number( $context ) : $name;
636
+		return empty($name) ? $this->get_number($context) : $name;
637 637
     }
638 638
 
639 639
     /**
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
 	 * @param  string $context View or edit context.
644 644
 	 * @return string
645 645
 	 */
646
-	public function get_title( $context = 'view' ) {
647
-		return $this->get_name( $context );
646
+	public function get_title($context = 'view') {
647
+		return $this->get_name($context);
648 648
     }
649 649
 
650 650
     /**
@@ -654,8 +654,8 @@  discard block
 block discarded – undo
654 654
 	 * @param  string $context View or edit context.
655 655
 	 * @return string
656 656
 	 */
657
-	public function get_description( $context = 'view' ) {
658
-		return $this->get_prop( 'description', $context );
657
+	public function get_description($context = 'view') {
658
+		return $this->get_prop('description', $context);
659 659
     }
660 660
 
661 661
     /**
@@ -665,8 +665,8 @@  discard block
 block discarded – undo
665 665
 	 * @param  string $context View or edit context.
666 666
 	 * @return string
667 667
 	 */
668
-	public function get_excerpt( $context = 'view' ) {
669
-		return $this->get_description( $context );
668
+	public function get_excerpt($context = 'view') {
669
+		return $this->get_description($context);
670 670
     }
671 671
 
672 672
     /**
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
 	 * @param  string $context View or edit context.
677 677
 	 * @return string
678 678
 	 */
679
-	public function get_summary( $context = 'view' ) {
680
-		return $this->get_description( $context );
679
+	public function get_summary($context = 'view') {
680
+		return $this->get_description($context);
681 681
     }
682 682
 
683 683
     /**
@@ -687,25 +687,25 @@  discard block
 block discarded – undo
687 687
      * @param  string $context View or edit context.
688 688
 	 * @return array
689 689
 	 */
690
-    public function get_user_info( $context = 'view' ) {
690
+    public function get_user_info($context = 'view') {
691 691
 
692 692
         $user_info = array(
693
-            'user_id'    => $this->get_user_id( $context ),
694
-            'email'      => $this->get_email( $context ),
695
-            'first_name' => $this->get_first_name( $context ),
696
-            'last_name'  => $this->get_last_name( $context ),
697
-            'address'    => $this->get_address( $context ),
698
-            'phone'      => $this->get_phone( $context ),
699
-            'city'       => $this->get_city( $context ),
700
-            'country'    => $this->get_country( $context ),
701
-            'state'      => $this->get_state( $context ),
702
-            'zip'        => $this->get_zip( $context ),
703
-            'company'    => $this->get_company( $context ),
704
-            'vat_number' => $this->get_vat_number( $context ),
705
-            'discount'   => $this->get_discount_code( $context ),
693
+            'user_id'    => $this->get_user_id($context),
694
+            'email'      => $this->get_email($context),
695
+            'first_name' => $this->get_first_name($context),
696
+            'last_name'  => $this->get_last_name($context),
697
+            'address'    => $this->get_address($context),
698
+            'phone'      => $this->get_phone($context),
699
+            'city'       => $this->get_city($context),
700
+            'country'    => $this->get_country($context),
701
+            'state'      => $this->get_state($context),
702
+            'zip'        => $this->get_zip($context),
703
+            'company'    => $this->get_company($context),
704
+            'vat_number' => $this->get_vat_number($context),
705
+            'discount'   => $this->get_discount_code($context),
706 706
 		);
707 707
 
708
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
708
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
709 709
 
710 710
     }
711 711
 
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 	 * @param  string $context View or edit context.
717 717
 	 * @return int
718 718
 	 */
719
-	public function get_author( $context = 'view' ) {
720
-		return (int) $this->get_prop( 'author', $context );
719
+	public function get_author($context = 'view') {
720
+		return (int) $this->get_prop('author', $context);
721 721
     }
722 722
 
723 723
     /**
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
 	 * @param  string $context View or edit context.
728 728
 	 * @return int
729 729
 	 */
730
-	public function get_user_id( $context = 'view' ) {
731
-		return $this->get_author( $context );
730
+	public function get_user_id($context = 'view') {
731
+		return $this->get_author($context);
732 732
     }
733 733
 
734 734
      /**
@@ -738,8 +738,8 @@  discard block
 block discarded – undo
738 738
 	 * @param  string $context View or edit context.
739 739
 	 * @return int
740 740
 	 */
741
-	public function get_customer_id( $context = 'view' ) {
742
-		return $this->get_author( $context );
741
+	public function get_customer_id($context = 'view') {
742
+		return $this->get_author($context);
743 743
     }
744 744
 
745 745
     /**
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 	 * @param  string $context View or edit context.
750 750
 	 * @return string
751 751
 	 */
752
-	public function get_ip( $context = 'view' ) {
753
-		return $this->get_prop( 'user_ip', $context );
752
+	public function get_ip($context = 'view') {
753
+		return $this->get_prop('user_ip', $context);
754 754
     }
755 755
 
756 756
     /**
@@ -760,8 +760,8 @@  discard block
 block discarded – undo
760 760
 	 * @param  string $context View or edit context.
761 761
 	 * @return string
762 762
 	 */
763
-	public function get_user_ip( $context = 'view' ) {
764
-		return $this->get_ip( $context );
763
+	public function get_user_ip($context = 'view') {
764
+		return $this->get_ip($context);
765 765
     }
766 766
 
767 767
      /**
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
 	 * @param  string $context View or edit context.
772 772
 	 * @return string
773 773
 	 */
774
-	public function get_customer_ip( $context = 'view' ) {
775
-		return $this->get_ip( $context );
774
+	public function get_customer_ip($context = 'view') {
775
+		return $this->get_ip($context);
776 776
     }
777 777
 
778 778
     /**
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 	 * @param  string $context View or edit context.
783 783
 	 * @return string
784 784
 	 */
785
-	public function get_first_name( $context = 'view' ) {
786
-		return $this->get_prop( 'first_name', $context );
785
+	public function get_first_name($context = 'view') {
786
+		return $this->get_prop('first_name', $context);
787 787
     }
788 788
 
789 789
     /**
@@ -793,8 +793,8 @@  discard block
 block discarded – undo
793 793
 	 * @param  string $context View or edit context.
794 794
 	 * @return int
795 795
 	 */
796
-	public function get_user_first_name( $context = 'view' ) {
797
-		return $this->get_first_name( $context );
796
+	public function get_user_first_name($context = 'view') {
797
+		return $this->get_first_name($context);
798 798
     }
799 799
 
800 800
      /**
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 	 * @param  string $context View or edit context.
805 805
 	 * @return int
806 806
 	 */
807
-	public function get_customer_first_name( $context = 'view' ) {
808
-		return $this->get_first_name( $context );
807
+	public function get_customer_first_name($context = 'view') {
808
+		return $this->get_first_name($context);
809 809
     }
810 810
 
811 811
     /**
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
 	 * @param  string $context View or edit context.
816 816
 	 * @return string
817 817
 	 */
818
-	public function get_last_name( $context = 'view' ) {
819
-		return $this->get_prop( 'last_name', $context );
818
+	public function get_last_name($context = 'view') {
819
+		return $this->get_prop('last_name', $context);
820 820
     }
821 821
 
822 822
     /**
@@ -826,8 +826,8 @@  discard block
 block discarded – undo
826 826
 	 * @param  string $context View or edit context.
827 827
 	 * @return int
828 828
 	 */
829
-	public function get_user_last_name( $context = 'view' ) {
830
-		return $this->get_last_name( $context );
829
+	public function get_user_last_name($context = 'view') {
830
+		return $this->get_last_name($context);
831 831
     }
832 832
 
833 833
     /**
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	 * @param  string $context View or edit context.
838 838
 	 * @return int
839 839
 	 */
840
-	public function get_customer_last_name( $context = 'view' ) {
841
-		return $this->get_last_name( $context );
840
+	public function get_customer_last_name($context = 'view') {
841
+		return $this->get_last_name($context);
842 842
     }
843 843
 
844 844
     /**
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 	 * @param  string $context View or edit context.
849 849
 	 * @return string
850 850
 	 */
851
-	public function get_full_name( $context = 'view' ) {
852
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
851
+	public function get_full_name($context = 'view') {
852
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
853 853
     }
854 854
 
855 855
     /**
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
 	 * @param  string $context View or edit context.
860 860
 	 * @return int
861 861
 	 */
862
-	public function get_user_full_name( $context = 'view' ) {
863
-		return $this->get_full_name( $context );
862
+	public function get_user_full_name($context = 'view') {
863
+		return $this->get_full_name($context);
864 864
     }
865 865
 
866 866
     /**
@@ -870,8 +870,8 @@  discard block
 block discarded – undo
870 870
 	 * @param  string $context View or edit context.
871 871
 	 * @return int
872 872
 	 */
873
-	public function get_customer_full_name( $context = 'view' ) {
874
-		return $this->get_full_name( $context );
873
+	public function get_customer_full_name($context = 'view') {
874
+		return $this->get_full_name($context);
875 875
     }
876 876
 
877 877
     /**
@@ -881,8 +881,8 @@  discard block
 block discarded – undo
881 881
 	 * @param  string $context View or edit context.
882 882
 	 * @return string
883 883
 	 */
884
-	public function get_phone( $context = 'view' ) {
885
-		return $this->get_prop( 'phone', $context );
884
+	public function get_phone($context = 'view') {
885
+		return $this->get_prop('phone', $context);
886 886
     }
887 887
 
888 888
     /**
@@ -892,8 +892,8 @@  discard block
 block discarded – undo
892 892
 	 * @param  string $context View or edit context.
893 893
 	 * @return int
894 894
 	 */
895
-	public function get_phone_number( $context = 'view' ) {
896
-		return $this->get_phone( $context );
895
+	public function get_phone_number($context = 'view') {
896
+		return $this->get_phone($context);
897 897
     }
898 898
 
899 899
     /**
@@ -903,8 +903,8 @@  discard block
 block discarded – undo
903 903
 	 * @param  string $context View or edit context.
904 904
 	 * @return int
905 905
 	 */
906
-	public function get_user_phone( $context = 'view' ) {
907
-		return $this->get_phone( $context );
906
+	public function get_user_phone($context = 'view') {
907
+		return $this->get_phone($context);
908 908
     }
909 909
 
910 910
     /**
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
 	 * @param  string $context View or edit context.
915 915
 	 * @return int
916 916
 	 */
917
-	public function get_customer_phone( $context = 'view' ) {
918
-		return $this->get_phone( $context );
917
+	public function get_customer_phone($context = 'view') {
918
+		return $this->get_phone($context);
919 919
     }
920 920
 
921 921
     /**
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	 * @param  string $context View or edit context.
926 926
 	 * @return string
927 927
 	 */
928
-	public function get_email( $context = 'view' ) {
929
-		return $this->get_prop( 'email', $context );
928
+	public function get_email($context = 'view') {
929
+		return $this->get_prop('email', $context);
930 930
     }
931 931
 
932 932
     /**
@@ -936,8 +936,8 @@  discard block
 block discarded – undo
936 936
 	 * @param  string $context View or edit context.
937 937
 	 * @return string
938 938
 	 */
939
-	public function get_email_address( $context = 'view' ) {
940
-		return $this->get_email( $context );
939
+	public function get_email_address($context = 'view') {
940
+		return $this->get_email($context);
941 941
     }
942 942
 
943 943
     /**
@@ -947,8 +947,8 @@  discard block
 block discarded – undo
947 947
 	 * @param  string $context View or edit context.
948 948
 	 * @return int
949 949
 	 */
950
-	public function get_user_email( $context = 'view' ) {
951
-		return $this->get_email( $context );
950
+	public function get_user_email($context = 'view') {
951
+		return $this->get_email($context);
952 952
     }
953 953
 
954 954
     /**
@@ -958,8 +958,8 @@  discard block
 block discarded – undo
958 958
 	 * @param  string $context View or edit context.
959 959
 	 * @return int
960 960
 	 */
961
-	public function get_customer_email( $context = 'view' ) {
962
-		return $this->get_email( $context );
961
+	public function get_customer_email($context = 'view') {
962
+		return $this->get_email($context);
963 963
     }
964 964
 
965 965
     /**
@@ -969,9 +969,9 @@  discard block
 block discarded – undo
969 969
 	 * @param  string $context View or edit context.
970 970
 	 * @return string
971 971
 	 */
972
-	public function get_country( $context = 'view' ) {
973
-		$country = $this->get_prop( 'country', $context );
974
-		return empty( $country ) ? wpinv_get_default_country() : $country;
972
+	public function get_country($context = 'view') {
973
+		$country = $this->get_prop('country', $context);
974
+		return empty($country) ? wpinv_get_default_country() : $country;
975 975
     }
976 976
 
977 977
     /**
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
 	 * @param  string $context View or edit context.
982 982
 	 * @return int
983 983
 	 */
984
-	public function get_user_country( $context = 'view' ) {
985
-		return $this->get_country( $context );
984
+	public function get_user_country($context = 'view') {
985
+		return $this->get_country($context);
986 986
     }
987 987
 
988 988
     /**
@@ -992,8 +992,8 @@  discard block
 block discarded – undo
992 992
 	 * @param  string $context View or edit context.
993 993
 	 * @return int
994 994
 	 */
995
-	public function get_customer_country( $context = 'view' ) {
996
-		return $this->get_country( $context );
995
+	public function get_customer_country($context = 'view') {
996
+		return $this->get_country($context);
997 997
     }
998 998
 
999 999
     /**
@@ -1003,9 +1003,9 @@  discard block
 block discarded – undo
1003 1003
 	 * @param  string $context View or edit context.
1004 1004
 	 * @return string
1005 1005
 	 */
1006
-	public function get_state( $context = 'view' ) {
1007
-		$state = $this->get_prop( 'state', $context );
1008
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1006
+	public function get_state($context = 'view') {
1007
+		$state = $this->get_prop('state', $context);
1008
+		return empty($state) ? wpinv_get_default_state() : $state;
1009 1009
     }
1010 1010
 
1011 1011
     /**
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
 	 * @param  string $context View or edit context.
1016 1016
 	 * @return int
1017 1017
 	 */
1018
-	public function get_user_state( $context = 'view' ) {
1019
-		return $this->get_state( $context );
1018
+	public function get_user_state($context = 'view') {
1019
+		return $this->get_state($context);
1020 1020
     }
1021 1021
 
1022 1022
     /**
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 	 * @param  string $context View or edit context.
1027 1027
 	 * @return int
1028 1028
 	 */
1029
-	public function get_customer_state( $context = 'view' ) {
1030
-		return $this->get_state( $context );
1029
+	public function get_customer_state($context = 'view') {
1030
+		return $this->get_state($context);
1031 1031
     }
1032 1032
 
1033 1033
     /**
@@ -1037,8 +1037,8 @@  discard block
 block discarded – undo
1037 1037
 	 * @param  string $context View or edit context.
1038 1038
 	 * @return string
1039 1039
 	 */
1040
-	public function get_city( $context = 'view' ) {
1041
-		return $this->get_prop( 'city', $context );
1040
+	public function get_city($context = 'view') {
1041
+		return $this->get_prop('city', $context);
1042 1042
     }
1043 1043
 
1044 1044
     /**
@@ -1048,8 +1048,8 @@  discard block
 block discarded – undo
1048 1048
 	 * @param  string $context View or edit context.
1049 1049
 	 * @return string
1050 1050
 	 */
1051
-	public function get_user_city( $context = 'view' ) {
1052
-		return $this->get_city( $context );
1051
+	public function get_user_city($context = 'view') {
1052
+		return $this->get_city($context);
1053 1053
     }
1054 1054
 
1055 1055
     /**
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 	 * @param  string $context View or edit context.
1060 1060
 	 * @return string
1061 1061
 	 */
1062
-	public function get_customer_city( $context = 'view' ) {
1063
-		return $this->get_city( $context );
1062
+	public function get_customer_city($context = 'view') {
1063
+		return $this->get_city($context);
1064 1064
     }
1065 1065
 
1066 1066
     /**
@@ -1070,8 +1070,8 @@  discard block
 block discarded – undo
1070 1070
 	 * @param  string $context View or edit context.
1071 1071
 	 * @return string
1072 1072
 	 */
1073
-	public function get_zip( $context = 'view' ) {
1074
-		return $this->get_prop( 'zip', $context );
1073
+	public function get_zip($context = 'view') {
1074
+		return $this->get_prop('zip', $context);
1075 1075
     }
1076 1076
 
1077 1077
     /**
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
 	 * @param  string $context View or edit context.
1082 1082
 	 * @return string
1083 1083
 	 */
1084
-	public function get_user_zip( $context = 'view' ) {
1085
-		return $this->get_zip( $context );
1084
+	public function get_user_zip($context = 'view') {
1085
+		return $this->get_zip($context);
1086 1086
     }
1087 1087
 
1088 1088
     /**
@@ -1092,8 +1092,8 @@  discard block
 block discarded – undo
1092 1092
 	 * @param  string $context View or edit context.
1093 1093
 	 * @return string
1094 1094
 	 */
1095
-	public function get_customer_zip( $context = 'view' ) {
1096
-		return $this->get_zip( $context );
1095
+	public function get_customer_zip($context = 'view') {
1096
+		return $this->get_zip($context);
1097 1097
     }
1098 1098
 
1099 1099
     /**
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
 	 * @param  string $context View or edit context.
1104 1104
 	 * @return string
1105 1105
 	 */
1106
-	public function get_company( $context = 'view' ) {
1107
-		return $this->get_prop( 'company', $context );
1106
+	public function get_company($context = 'view') {
1107
+		return $this->get_prop('company', $context);
1108 1108
     }
1109 1109
 
1110 1110
     /**
@@ -1114,8 +1114,8 @@  discard block
 block discarded – undo
1114 1114
 	 * @param  string $context View or edit context.
1115 1115
 	 * @return string
1116 1116
 	 */
1117
-	public function get_user_company( $context = 'view' ) {
1118
-		return $this->get_company( $context );
1117
+	public function get_user_company($context = 'view') {
1118
+		return $this->get_company($context);
1119 1119
     }
1120 1120
 
1121 1121
     /**
@@ -1125,8 +1125,8 @@  discard block
 block discarded – undo
1125 1125
 	 * @param  string $context View or edit context.
1126 1126
 	 * @return string
1127 1127
 	 */
1128
-	public function get_customer_company( $context = 'view' ) {
1129
-		return $this->get_company( $context );
1128
+	public function get_customer_company($context = 'view') {
1129
+		return $this->get_company($context);
1130 1130
     }
1131 1131
 
1132 1132
     /**
@@ -1136,8 +1136,8 @@  discard block
 block discarded – undo
1136 1136
 	 * @param  string $context View or edit context.
1137 1137
 	 * @return string
1138 1138
 	 */
1139
-	public function get_vat_number( $context = 'view' ) {
1140
-		return $this->get_prop( 'vat_number', $context );
1139
+	public function get_vat_number($context = 'view') {
1140
+		return $this->get_prop('vat_number', $context);
1141 1141
     }
1142 1142
 
1143 1143
     /**
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
 	 * @param  string $context View or edit context.
1148 1148
 	 * @return string
1149 1149
 	 */
1150
-	public function get_user_vat_number( $context = 'view' ) {
1151
-		return $this->get_vat_number( $context );
1150
+	public function get_user_vat_number($context = 'view') {
1151
+		return $this->get_vat_number($context);
1152 1152
     }
1153 1153
 
1154 1154
     /**
@@ -1158,8 +1158,8 @@  discard block
 block discarded – undo
1158 1158
 	 * @param  string $context View or edit context.
1159 1159
 	 * @return string
1160 1160
 	 */
1161
-	public function get_customer_vat_number( $context = 'view' ) {
1162
-		return $this->get_vat_number( $context );
1161
+	public function get_customer_vat_number($context = 'view') {
1162
+		return $this->get_vat_number($context);
1163 1163
     }
1164 1164
 
1165 1165
     /**
@@ -1169,8 +1169,8 @@  discard block
 block discarded – undo
1169 1169
 	 * @param  string $context View or edit context.
1170 1170
 	 * @return string
1171 1171
 	 */
1172
-	public function get_vat_rate( $context = 'view' ) {
1173
-		return $this->get_prop( 'vat_rate', $context );
1172
+	public function get_vat_rate($context = 'view') {
1173
+		return $this->get_prop('vat_rate', $context);
1174 1174
     }
1175 1175
 
1176 1176
     /**
@@ -1180,8 +1180,8 @@  discard block
 block discarded – undo
1180 1180
 	 * @param  string $context View or edit context.
1181 1181
 	 * @return string
1182 1182
 	 */
1183
-	public function get_user_vat_rate( $context = 'view' ) {
1184
-		return $this->get_vat_rate( $context );
1183
+	public function get_user_vat_rate($context = 'view') {
1184
+		return $this->get_vat_rate($context);
1185 1185
     }
1186 1186
 
1187 1187
     /**
@@ -1191,8 +1191,8 @@  discard block
 block discarded – undo
1191 1191
 	 * @param  string $context View or edit context.
1192 1192
 	 * @return string
1193 1193
 	 */
1194
-	public function get_customer_vat_rate( $context = 'view' ) {
1195
-		return $this->get_vat_rate( $context );
1194
+	public function get_customer_vat_rate($context = 'view') {
1195
+		return $this->get_vat_rate($context);
1196 1196
     }
1197 1197
 
1198 1198
     /**
@@ -1202,8 +1202,8 @@  discard block
 block discarded – undo
1202 1202
 	 * @param  string $context View or edit context.
1203 1203
 	 * @return string
1204 1204
 	 */
1205
-	public function get_address( $context = 'view' ) {
1206
-		return $this->get_prop( 'address', $context );
1205
+	public function get_address($context = 'view') {
1206
+		return $this->get_prop('address', $context);
1207 1207
     }
1208 1208
 
1209 1209
     /**
@@ -1213,8 +1213,8 @@  discard block
 block discarded – undo
1213 1213
 	 * @param  string $context View or edit context.
1214 1214
 	 * @return string
1215 1215
 	 */
1216
-	public function get_user_address( $context = 'view' ) {
1217
-		return $this->get_address( $context );
1216
+	public function get_user_address($context = 'view') {
1217
+		return $this->get_address($context);
1218 1218
     }
1219 1219
 
1220 1220
     /**
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 	 * @param  string $context View or edit context.
1225 1225
 	 * @return string
1226 1226
 	 */
1227
-	public function get_customer_address( $context = 'view' ) {
1228
-		return $this->get_address( $context );
1227
+	public function get_customer_address($context = 'view') {
1228
+		return $this->get_address($context);
1229 1229
     }
1230 1230
 
1231 1231
     /**
@@ -1235,8 +1235,8 @@  discard block
 block discarded – undo
1235 1235
 	 * @param  string $context View or edit context.
1236 1236
 	 * @return bool
1237 1237
 	 */
1238
-	public function get_is_viewed( $context = 'view' ) {
1239
-		return (bool) $this->get_prop( 'is_viewed', $context );
1238
+	public function get_is_viewed($context = 'view') {
1239
+		return (bool) $this->get_prop('is_viewed', $context);
1240 1240
 	}
1241 1241
 
1242 1242
 	/**
@@ -1246,8 +1246,8 @@  discard block
 block discarded – undo
1246 1246
 	 * @param  string $context View or edit context.
1247 1247
 	 * @return bool
1248 1248
 	 */
1249
-	public function get_email_cc( $context = 'view' ) {
1250
-		return $this->get_prop( 'email_cc', $context );
1249
+	public function get_email_cc($context = 'view') {
1250
+		return $this->get_prop('email_cc', $context);
1251 1251
 	}
1252 1252
 
1253 1253
 	/**
@@ -1257,8 +1257,8 @@  discard block
 block discarded – undo
1257 1257
 	 * @param  string $context View or edit context.
1258 1258
 	 * @return bool
1259 1259
 	 */
1260
-	public function get_template( $context = 'view' ) {
1261
-		return $this->get_prop( 'template', $context );
1260
+	public function get_template($context = 'view') {
1261
+		return $this->get_prop('template', $context);
1262 1262
 	}
1263 1263
 
1264 1264
 	/**
@@ -1268,8 +1268,8 @@  discard block
 block discarded – undo
1268 1268
 	 * @param  string $context View or edit context.
1269 1269
 	 * @return bool
1270 1270
 	 */
1271
-	public function get_address_confirmed( $context = 'view' ) {
1272
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1271
+	public function get_address_confirmed($context = 'view') {
1272
+		return (bool) $this->get_prop('address_confirmed', $context);
1273 1273
     }
1274 1274
 
1275 1275
     /**
@@ -1279,8 +1279,8 @@  discard block
 block discarded – undo
1279 1279
 	 * @param  string $context View or edit context.
1280 1280
 	 * @return bool
1281 1281
 	 */
1282
-	public function get_user_address_confirmed( $context = 'view' ) {
1283
-		return $this->get_address_confirmed( $context );
1282
+	public function get_user_address_confirmed($context = 'view') {
1283
+		return $this->get_address_confirmed($context);
1284 1284
     }
1285 1285
 
1286 1286
     /**
@@ -1290,8 +1290,8 @@  discard block
 block discarded – undo
1290 1290
 	 * @param  string $context View or edit context.
1291 1291
 	 * @return bool
1292 1292
 	 */
1293
-	public function get_customer_address_confirmed( $context = 'view' ) {
1294
-		return $this->get_address_confirmed( $context );
1293
+	public function get_customer_address_confirmed($context = 'view') {
1294
+		return $this->get_address_confirmed($context);
1295 1295
     }
1296 1296
 
1297 1297
     /**
@@ -1301,12 +1301,12 @@  discard block
 block discarded – undo
1301 1301
 	 * @param  string $context View or edit context.
1302 1302
 	 * @return float
1303 1303
 	 */
1304
-	public function get_subtotal( $context = 'view' ) {
1305
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1304
+	public function get_subtotal($context = 'view') {
1305
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1306 1306
 
1307 1307
         // Backwards compatibility.
1308
-        if ( is_bool( $context ) && $context ) {
1309
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1308
+        if (is_bool($context) && $context) {
1309
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1310 1310
         }
1311 1311
 
1312 1312
         return $subtotal;
@@ -1319,8 +1319,8 @@  discard block
 block discarded – undo
1319 1319
 	 * @param  string $context View or edit context.
1320 1320
 	 * @return float
1321 1321
 	 */
1322
-	public function get_total_discount( $context = 'view' ) {
1323
-		return (float) $this->get_prop( 'total_discount', $context );
1322
+	public function get_total_discount($context = 'view') {
1323
+		return (float) $this->get_prop('total_discount', $context);
1324 1324
     }
1325 1325
 
1326 1326
     /**
@@ -1330,18 +1330,18 @@  discard block
 block discarded – undo
1330 1330
 	 * @param  string $context View or edit context.
1331 1331
 	 * @return float
1332 1332
 	 */
1333
-	public function get_total_tax( $context = 'view' ) {
1334
-		return (float) $this->get_prop( 'total_tax', $context );
1333
+	public function get_total_tax($context = 'view') {
1334
+		return (float) $this->get_prop('total_tax', $context);
1335 1335
 	}
1336 1336
 
1337 1337
 	/**
1338 1338
 	 * @deprecated
1339 1339
 	 */
1340
-	public function get_final_tax( $currency = false ) {
1340
+	public function get_final_tax($currency = false) {
1341 1341
 		$tax = $this->get_total_tax();
1342 1342
 
1343
-        if ( $currency ) {
1344
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1343
+        if ($currency) {
1344
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1345 1345
         }
1346 1346
 
1347 1347
         return $tax;
@@ -1354,8 +1354,8 @@  discard block
 block discarded – undo
1354 1354
 	 * @param  string $context View or edit context.
1355 1355
 	 * @return float
1356 1356
 	 */
1357
-	public function get_total_fees( $context = 'view' ) {
1358
-		return (float) $this->get_prop( 'total_fees', $context );
1357
+	public function get_total_fees($context = 'view') {
1358
+		return (float) $this->get_prop('total_fees', $context);
1359 1359
     }
1360 1360
 
1361 1361
     /**
@@ -1365,8 +1365,8 @@  discard block
 block discarded – undo
1365 1365
 	 * @param  string $context View or edit context.
1366 1366
 	 * @return float
1367 1367
 	 */
1368
-	public function get_fees_total( $context = 'view' ) {
1369
-		return $this->get_total_fees( $context );
1368
+	public function get_fees_total($context = 'view') {
1369
+		return $this->get_total_fees($context);
1370 1370
     }
1371 1371
 
1372 1372
     /**
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 	 */
1378 1378
 	public function get_total() {
1379 1379
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1380
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1380
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1381 1381
 	}
1382 1382
 	
1383 1383
 	/**
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 	 */
1400 1400
     public function get_initial_total() {
1401 1401
 
1402
-		if ( empty( $this->totals ) ) {
1402
+		if (empty($this->totals)) {
1403 1403
 			$this->recalculate_total();
1404 1404
 		}
1405 1405
 
@@ -1409,11 +1409,11 @@  discard block
 block discarded – undo
1409 1409
 		$subtotal = $this->totals['subtotal']['initial'];
1410 1410
 		$total    = $tax + $fee - $discount + $subtotal;
1411 1411
 
1412
-		if ( 0 > $total ) {
1412
+		if (0 > $total) {
1413 1413
 			$total = 0;
1414 1414
 		}
1415 1415
 
1416
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1416
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1417 1417
 	}
1418 1418
 
1419 1419
 	/**
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 	 */
1426 1426
     public function get_recurring_total() {
1427 1427
 
1428
-		if ( empty( $this->totals ) ) {
1428
+		if (empty($this->totals)) {
1429 1429
 			$this->recalculate_total();
1430 1430
 		}
1431 1431
 
@@ -1435,11 +1435,11 @@  discard block
 block discarded – undo
1435 1435
 		$subtotal = $this->totals['subtotal']['recurring'];
1436 1436
 		$total    = $tax + $fee - $discount + $subtotal;
1437 1437
 
1438
-		if ( 0 > $total ) {
1438
+		if (0 > $total) {
1439 1439
 			$total = 0;
1440 1440
 		}
1441 1441
 
1442
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1442
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1443 1443
 	}
1444 1444
 
1445 1445
 	/**
@@ -1450,10 +1450,10 @@  discard block
 block discarded – undo
1450 1450
 	 * @param string $currency Whether to include the currency.
1451 1451
      * @return float
1452 1452
 	 */
1453
-    public function get_recurring_details( $field = '', $currency = false ) {
1453
+    public function get_recurring_details($field = '', $currency = false) {
1454 1454
 
1455 1455
 		// Maybe recalculate totals.
1456
-		if ( empty( $this->totals ) ) {
1456
+		if (empty($this->totals)) {
1457 1457
 			$this->recalculate_total();
1458 1458
 		}
1459 1459
 
@@ -1473,8 +1473,8 @@  discard block
 block discarded – undo
1473 1473
 			$currency
1474 1474
 		);
1475 1475
 
1476
-        if ( isset( $data[$field] ) ) {
1477
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1476
+        if (isset($data[$field])) {
1477
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1478 1478
         }
1479 1479
 
1480 1480
         return $data;
@@ -1487,8 +1487,8 @@  discard block
 block discarded – undo
1487 1487
 	 * @param  string $context View or edit context.
1488 1488
 	 * @return array
1489 1489
 	 */
1490
-	public function get_fees( $context = 'view' ) {
1491
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1490
+	public function get_fees($context = 'view') {
1491
+		return wpinv_parse_list($this->get_prop('fees', $context));
1492 1492
     }
1493 1493
 
1494 1494
     /**
@@ -1498,8 +1498,8 @@  discard block
 block discarded – undo
1498 1498
 	 * @param  string $context View or edit context.
1499 1499
 	 * @return array
1500 1500
 	 */
1501
-	public function get_discounts( $context = 'view' ) {
1502
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1501
+	public function get_discounts($context = 'view') {
1502
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1503 1503
     }
1504 1504
 
1505 1505
     /**
@@ -1509,8 +1509,8 @@  discard block
 block discarded – undo
1509 1509
 	 * @param  string $context View or edit context.
1510 1510
 	 * @return array
1511 1511
 	 */
1512
-	public function get_taxes( $context = 'view' ) {
1513
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1512
+	public function get_taxes($context = 'view') {
1513
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1514 1514
     }
1515 1515
 
1516 1516
     /**
@@ -1520,8 +1520,8 @@  discard block
 block discarded – undo
1520 1520
 	 * @param  string $context View or edit context.
1521 1521
 	 * @return GetPaid_Form_Item[]
1522 1522
 	 */
1523
-	public function get_items( $context = 'view' ) {
1524
-        return $this->get_prop( 'items', $context );
1523
+	public function get_items($context = 'view') {
1524
+        return $this->get_prop('items', $context);
1525 1525
     }
1526 1526
 
1527 1527
     /**
@@ -1531,8 +1531,8 @@  discard block
 block discarded – undo
1531 1531
 	 * @param  string $context View or edit context.
1532 1532
 	 * @return int
1533 1533
 	 */
1534
-	public function get_payment_form( $context = 'view' ) {
1535
-		return intval( $this->get_prop( 'payment_form', $context ) );
1534
+	public function get_payment_form($context = 'view') {
1535
+		return intval($this->get_prop('payment_form', $context));
1536 1536
     }
1537 1537
 
1538 1538
     /**
@@ -1542,8 +1542,8 @@  discard block
 block discarded – undo
1542 1542
 	 * @param  string $context View or edit context.
1543 1543
 	 * @return string
1544 1544
 	 */
1545
-	public function get_submission_id( $context = 'view' ) {
1546
-		return $this->get_prop( 'submission_id', $context );
1545
+	public function get_submission_id($context = 'view') {
1546
+		return $this->get_prop('submission_id', $context);
1547 1547
     }
1548 1548
 
1549 1549
     /**
@@ -1553,8 +1553,8 @@  discard block
 block discarded – undo
1553 1553
 	 * @param  string $context View or edit context.
1554 1554
 	 * @return string
1555 1555
 	 */
1556
-	public function get_discount_code( $context = 'view' ) {
1557
-		return $this->get_prop( 'discount_code', $context );
1556
+	public function get_discount_code($context = 'view') {
1557
+		return $this->get_prop('discount_code', $context);
1558 1558
     }
1559 1559
 
1560 1560
     /**
@@ -1564,8 +1564,8 @@  discard block
 block discarded – undo
1564 1564
 	 * @param  string $context View or edit context.
1565 1565
 	 * @return string
1566 1566
 	 */
1567
-	public function get_gateway( $context = 'view' ) {
1568
-		return $this->get_prop( 'gateway', $context );
1567
+	public function get_gateway($context = 'view') {
1568
+		return $this->get_prop('gateway', $context);
1569 1569
     }
1570 1570
 
1571 1571
     /**
@@ -1575,8 +1575,8 @@  discard block
 block discarded – undo
1575 1575
 	 * @return string
1576 1576
 	 */
1577 1577
     public function get_gateway_title() {
1578
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1579
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1578
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1579
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1580 1580
     }
1581 1581
 
1582 1582
     /**
@@ -1586,8 +1586,8 @@  discard block
 block discarded – undo
1586 1586
 	 * @param  string $context View or edit context.
1587 1587
 	 * @return string
1588 1588
 	 */
1589
-	public function get_transaction_id( $context = 'view' ) {
1590
-		return $this->get_prop( 'transaction_id', $context );
1589
+	public function get_transaction_id($context = 'view') {
1590
+		return $this->get_prop('transaction_id', $context);
1591 1591
     }
1592 1592
 
1593 1593
     /**
@@ -1597,9 +1597,9 @@  discard block
 block discarded – undo
1597 1597
 	 * @param  string $context View or edit context.
1598 1598
 	 * @return string
1599 1599
 	 */
1600
-	public function get_currency( $context = 'view' ) {
1601
-        $currency = $this->get_prop( 'currency', $context );
1602
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1600
+	public function get_currency($context = 'view') {
1601
+        $currency = $this->get_prop('currency', $context);
1602
+        return empty($currency) ? wpinv_get_currency() : $currency;
1603 1603
     }
1604 1604
 
1605 1605
     /**
@@ -1609,8 +1609,8 @@  discard block
 block discarded – undo
1609 1609
 	 * @param  string $context View or edit context.
1610 1610
 	 * @return bool
1611 1611
 	 */
1612
-	public function get_disable_taxes( $context = 'view' ) {
1613
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1612
+	public function get_disable_taxes($context = 'view') {
1613
+        return (bool) $this->get_prop('disable_taxes', $context);
1614 1614
     }
1615 1615
 
1616 1616
     /**
@@ -1620,12 +1620,12 @@  discard block
 block discarded – undo
1620 1620
 	 * @param  string $context View or edit context.
1621 1621
 	 * @return int
1622 1622
 	 */
1623
-    public function get_subscription_id( $context = 'view' ) {
1624
-        $subscription_id = $this->get_prop( 'subscription_id', $context );
1623
+    public function get_subscription_id($context = 'view') {
1624
+        $subscription_id = $this->get_prop('subscription_id', $context);
1625 1625
 
1626
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1626
+        if (empty($subscription_id) && $this->is_renewal()) {
1627 1627
             $parent = $this->get_parent();
1628
-            return $parent->get_subscription_id( $context );
1628
+            return $parent->get_subscription_id($context);
1629 1629
         }
1630 1630
 
1631 1631
         return $subscription_id;
@@ -1638,20 +1638,20 @@  discard block
 block discarded – undo
1638 1638
 	 * @param  string $context View or edit context.
1639 1639
 	 * @return array
1640 1640
 	 */
1641
-    public function get_payment_meta( $context = 'view' ) {
1641
+    public function get_payment_meta($context = 'view') {
1642 1642
 
1643 1643
         return array(
1644
-            'price'        => $this->get_total( $context ),
1645
-            'date'         => $this->get_date_created( $context ),
1646
-            'user_email'   => $this->get_email( $context ),
1647
-            'invoice_key'  => $this->get_key( $context ),
1648
-            'currency'     => $this->get_currency( $context ),
1649
-            'items'        => $this->get_items( $context ),
1650
-            'user_info'    => $this->get_user_info( $context ),
1644
+            'price'        => $this->get_total($context),
1645
+            'date'         => $this->get_date_created($context),
1646
+            'user_email'   => $this->get_email($context),
1647
+            'invoice_key'  => $this->get_key($context),
1648
+            'currency'     => $this->get_currency($context),
1649
+            'items'        => $this->get_items($context),
1650
+            'user_info'    => $this->get_user_info($context),
1651 1651
             'cart_details' => $this->get_cart_details(),
1652
-            'status'       => $this->get_status( $context ),
1653
-            'fees'         => $this->get_fees( $context ),
1654
-            'taxes'        => $this->get_taxes( $context ),
1652
+            'status'       => $this->get_status($context),
1653
+            'fees'         => $this->get_fees($context),
1654
+            'taxes'        => $this->get_taxes($context),
1655 1655
         );
1656 1656
 
1657 1657
     }
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
         $items        = $this->get_items();
1667 1667
         $cart_details = array();
1668 1668
 
1669
-        foreach ( $items as $item_id => $item ) {
1669
+        foreach ($items as $item_id => $item) {
1670 1670
             $cart_details[] = $item->prepare_data_for_saving();
1671 1671
         }
1672 1672
 
@@ -1678,11 +1678,11 @@  discard block
 block discarded – undo
1678 1678
 	 *
1679 1679
 	 * @return null|GetPaid_Form_Item|int
1680 1680
 	 */
1681
-	public function get_recurring( $object = false ) {
1681
+	public function get_recurring($object = false) {
1682 1682
 
1683 1683
 		// Are we returning an object?
1684
-        if ( $object ) {
1685
-            return $this->get_item( $this->recurring_item );
1684
+        if ($object) {
1685
+            return $this->get_item($this->recurring_item);
1686 1686
         }
1687 1687
 
1688 1688
         return $this->recurring_item;
@@ -1697,15 +1697,15 @@  discard block
 block discarded – undo
1697 1697
 	public function get_subscription_name() {
1698 1698
 
1699 1699
 		// Retrieve the recurring name
1700
-        $item = $this->get_recurring( true );
1700
+        $item = $this->get_recurring(true);
1701 1701
 
1702 1702
 		// Abort if it does not exist.
1703
-        if ( empty( $item ) ) {
1703
+        if (empty($item)) {
1704 1704
             return '';
1705 1705
         }
1706 1706
 
1707 1707
 		// Return the item name.
1708
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1708
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1709 1709
 	}
1710 1710
 
1711 1711
 	/**
@@ -1715,9 +1715,9 @@  discard block
 block discarded – undo
1715 1715
 	 * @return string
1716 1716
 	 */
1717 1717
 	public function get_view_url() {
1718
-        $invoice_url = get_permalink( $this->get_id() );
1719
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1720
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1718
+        $invoice_url = get_permalink($this->get_id());
1719
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1720
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1721 1721
 	}
1722 1722
 
1723 1723
 	/**
@@ -1726,25 +1726,25 @@  discard block
 block discarded – undo
1726 1726
 	 * @since 1.0.19
1727 1727
 	 * @return string
1728 1728
 	 */
1729
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1729
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1730 1730
 
1731 1731
 		// Retrieve the checkout url.
1732 1732
         $pay_url = wpinv_get_checkout_uri();
1733 1733
 
1734 1734
 		// Maybe force ssl.
1735
-        if ( is_ssl() ) {
1736
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1735
+        if (is_ssl()) {
1736
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1737 1737
         }
1738 1738
 
1739 1739
 		// Add the invoice key.
1740
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1740
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1741 1741
 
1742 1742
 		// (Maybe?) add a secret
1743
-        if ( $secret ) {
1744
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1743
+        if ($secret) {
1744
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1745 1745
         }
1746 1746
 
1747
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1747
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1748 1748
 	}
1749 1749
 	
1750 1750
 	/**
@@ -1759,14 +1759,14 @@  discard block
 block discarded – undo
1759 1759
         $receipt_url = wpinv_get_success_page_uri();
1760 1760
 
1761 1761
 		// Maybe force ssl.
1762
-        if ( is_ssl() ) {
1763
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1762
+        if (is_ssl()) {
1763
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1764 1764
         }
1765 1765
 
1766 1766
 		// Add the invoice key.
1767
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1767
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1768 1768
 
1769
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1769
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1770 1770
     }
1771 1771
 
1772 1772
     /**
@@ -1779,8 +1779,8 @@  discard block
 block discarded – undo
1779 1779
 	 * @param  string $context View or edit context.
1780 1780
 	 * @return mixed Value of the given invoice property (if set).
1781 1781
 	 */
1782
-	public function get( $key, $context = 'view' ) {
1783
-        return $this->get_prop( $key, $context );
1782
+	public function get($key, $context = 'view') {
1783
+        return $this->get_prop($key, $context);
1784 1784
 	}
1785 1785
 
1786 1786
     /*
@@ -1803,11 +1803,11 @@  discard block
 block discarded – undo
1803 1803
 	 * @param  mixed $value new value.
1804 1804
 	 * @return mixed Value of the given invoice property (if set).
1805 1805
 	 */
1806
-	public function set( $key, $value ) {
1806
+	public function set($key, $value) {
1807 1807
 
1808 1808
         $setter = "set_$key";
1809
-        if ( is_callable( array( $this, $setter ) ) ) {
1810
-            $this->{$setter}( $value );
1809
+        if (is_callable(array($this, $setter))) {
1810
+            $this->{$setter}($value);
1811 1811
         }
1812 1812
 
1813 1813
 	}
@@ -1821,47 +1821,47 @@  discard block
 block discarded – undo
1821 1821
 	 * @param bool   $manual_update Is this a manual status change?.
1822 1822
 	 * @return array details of change.
1823 1823
 	 */
1824
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1824
+	public function set_status($new_status, $note = '', $manual_update = false) {
1825 1825
 		$old_status = $this->get_status();
1826 1826
 
1827 1827
 		$statuses = $this->get_all_statuses();
1828 1828
 
1829
-		if ( isset( $statuses[ 'draft' ] ) ) {
1830
-			unset( $statuses[ 'draft' ] );
1829
+		if (isset($statuses['draft'])) {
1830
+			unset($statuses['draft']);
1831 1831
 		}
1832 1832
 
1833
-		$this->set_prop( 'status', $new_status );
1833
+		$this->set_prop('status', $new_status);
1834 1834
 
1835 1835
 		// If setting the status, ensure it's set to a valid status.
1836
-		if ( true === $this->object_read ) {
1836
+		if (true === $this->object_read) {
1837 1837
 
1838 1838
 			// Only allow valid new status.
1839
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1839
+			if (!array_key_exists($new_status, $statuses)) {
1840 1840
 				$new_status = 'wpi-pending';
1841 1841
 			}
1842 1842
 
1843 1843
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1844
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1844
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1845 1845
 				$old_status = 'wpi-pending';
1846 1846
 			}
1847 1847
 
1848 1848
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1849
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1849
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1850 1850
 				$old_status = 'wpi-pending';
1851 1851
 			}
1852 1852
 
1853 1853
 		}
1854 1854
 
1855
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1855
+		if (true === $this->object_read && $old_status !== $new_status) {
1856 1856
 			$this->status_transition = array(
1857
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1857
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1858 1858
 				'to'     => $new_status,
1859 1859
 				'note'   => $note,
1860 1860
 				'manual' => (bool) $manual_update,
1861 1861
 			);
1862 1862
 
1863
-			if ( $manual_update ) {
1864
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1863
+			if ($manual_update) {
1864
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1865 1865
 			}
1866 1866
 
1867 1867
 			$this->maybe_set_date_paid();
@@ -1884,8 +1884,8 @@  discard block
 block discarded – undo
1884 1884
 	 */
1885 1885
 	public function maybe_set_date_paid() {
1886 1886
 
1887
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1888
-			$this->set_date_completed( current_time( 'mysql' ) );
1887
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1888
+			$this->set_date_completed(current_time('mysql'));
1889 1889
 		}
1890 1890
 	}
1891 1891
 
@@ -1894,11 +1894,11 @@  discard block
 block discarded – undo
1894 1894
 	 *
1895 1895
 	 * @since 1.0.19
1896 1896
 	 */
1897
-	public function set_parent_id( $value ) {
1898
-		if ( $value && ( $value === $this->get_id() ) ) {
1897
+	public function set_parent_id($value) {
1898
+		if ($value && ($value === $this->get_id())) {
1899 1899
 			return;
1900 1900
 		}
1901
-		$this->set_prop( 'parent_id', absint( $value ) );
1901
+		$this->set_prop('parent_id', absint($value));
1902 1902
     }
1903 1903
 
1904 1904
     /**
@@ -1906,8 +1906,8 @@  discard block
 block discarded – undo
1906 1906
 	 *
1907 1907
 	 * @since 1.0.19
1908 1908
 	 */
1909
-	public function set_version( $value ) {
1910
-		$this->set_prop( 'version', $value );
1909
+	public function set_version($value) {
1910
+		$this->set_prop('version', $value);
1911 1911
     }
1912 1912
 
1913 1913
     /**
@@ -1917,15 +1917,15 @@  discard block
 block discarded – undo
1917 1917
 	 * @param string $value Value to set.
1918 1918
      * @return bool Whether or not the date was set.
1919 1919
 	 */
1920
-	public function set_date_created( $value ) {
1921
-        $date = strtotime( $value );
1920
+	public function set_date_created($value) {
1921
+        $date = strtotime($value);
1922 1922
 
1923
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1924
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1923
+        if ($date && $value !== '0000-00-00 00:00:00') {
1924
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1925 1925
             return true;
1926 1926
         }
1927 1927
 
1928
-        return $this->set_prop( 'date_created', '' );
1928
+        return $this->set_prop('date_created', '');
1929 1929
 
1930 1930
     }
1931 1931
 
@@ -1936,15 +1936,15 @@  discard block
 block discarded – undo
1936 1936
 	 * @param string $value Value to set.
1937 1937
      * @return bool Whether or not the date was set.
1938 1938
 	 */
1939
-	public function set_due_date( $value ) {
1940
-        $date = strtotime( $value );
1939
+	public function set_due_date($value) {
1940
+        $date = strtotime($value);
1941 1941
 
1942
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1943
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1942
+        if ($date && $value !== '0000-00-00 00:00:00') {
1943
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1944 1944
             return true;
1945 1945
         }
1946 1946
 
1947
-		$this->set_prop( 'due_date', '' );
1947
+		$this->set_prop('due_date', '');
1948 1948
         return false;
1949 1949
 
1950 1950
     }
@@ -1955,8 +1955,8 @@  discard block
 block discarded – undo
1955 1955
 	 * @since 1.0.19
1956 1956
 	 * @param  string $value New name.
1957 1957
 	 */
1958
-	public function set_date_due( $value ) {
1959
-		$this->set_due_date( $value );
1958
+	public function set_date_due($value) {
1959
+		$this->set_due_date($value);
1960 1960
     }
1961 1961
 
1962 1962
     /**
@@ -1966,15 +1966,15 @@  discard block
 block discarded – undo
1966 1966
 	 * @param string $value Value to set.
1967 1967
      * @return bool Whether or not the date was set.
1968 1968
 	 */
1969
-	public function set_completed_date( $value ) {
1970
-        $date = strtotime( $value );
1969
+	public function set_completed_date($value) {
1970
+        $date = strtotime($value);
1971 1971
 
1972
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
1973
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
1972
+        if ($date && $value !== '0000-00-00 00:00:00') {
1973
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
1974 1974
             return true;
1975 1975
         }
1976 1976
 
1977
-		$this->set_prop( 'completed_date', '' );
1977
+		$this->set_prop('completed_date', '');
1978 1978
         return false;
1979 1979
 
1980 1980
     }
@@ -1985,8 +1985,8 @@  discard block
 block discarded – undo
1985 1985
 	 * @since 1.0.19
1986 1986
 	 * @param  string $value New name.
1987 1987
 	 */
1988
-	public function set_date_completed( $value ) {
1989
-		$this->set_completed_date( $value );
1988
+	public function set_date_completed($value) {
1989
+		$this->set_completed_date($value);
1990 1990
     }
1991 1991
 
1992 1992
     /**
@@ -1996,15 +1996,15 @@  discard block
 block discarded – undo
1996 1996
 	 * @param string $value Value to set.
1997 1997
      * @return bool Whether or not the date was set.
1998 1998
 	 */
1999
-	public function set_date_modified( $value ) {
2000
-        $date = strtotime( $value );
1999
+	public function set_date_modified($value) {
2000
+        $date = strtotime($value);
2001 2001
 
2002
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2003
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2002
+        if ($date && $value !== '0000-00-00 00:00:00') {
2003
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2004 2004
             return true;
2005 2005
         }
2006 2006
 
2007
-		$this->set_prop( 'date_modified', '' );
2007
+		$this->set_prop('date_modified', '');
2008 2008
         return false;
2009 2009
 
2010 2010
     }
@@ -2015,9 +2015,9 @@  discard block
 block discarded – undo
2015 2015
 	 * @since 1.0.19
2016 2016
 	 * @param  string $value New number.
2017 2017
 	 */
2018
-	public function set_number( $value ) {
2019
-        $number = sanitize_text_field( $value );
2020
-		$this->set_prop( 'number', $number );
2018
+	public function set_number($value) {
2019
+        $number = sanitize_text_field($value);
2020
+		$this->set_prop('number', $number);
2021 2021
     }
2022 2022
 
2023 2023
     /**
@@ -2026,9 +2026,9 @@  discard block
 block discarded – undo
2026 2026
 	 * @since 1.0.19
2027 2027
 	 * @param  string $value Type.
2028 2028
 	 */
2029
-	public function set_type( $value ) {
2030
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2031
-		$this->set_prop( 'type', $type );
2029
+	public function set_type($value) {
2030
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2031
+		$this->set_prop('type', $type);
2032 2032
 	}
2033 2033
 
2034 2034
     /**
@@ -2037,10 +2037,10 @@  discard block
 block discarded – undo
2037 2037
 	 * @since 1.0.19
2038 2038
 	 * @param  string $value Post type.
2039 2039
 	 */
2040
-	public function set_post_type( $value ) {
2041
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2042
-			$this->set_type( $value );
2043
-            $this->set_prop( 'post_type', $value );
2040
+	public function set_post_type($value) {
2041
+        if (getpaid_is_invoice_post_type($value)) {
2042
+			$this->set_type($value);
2043
+            $this->set_prop('post_type', $value);
2044 2044
         }
2045 2045
     }
2046 2046
 
@@ -2050,9 +2050,9 @@  discard block
 block discarded – undo
2050 2050
 	 * @since 1.0.19
2051 2051
 	 * @param  string $value New key.
2052 2052
 	 */
2053
-	public function set_key( $value ) {
2054
-        $key = sanitize_text_field( $value );
2055
-		$this->set_prop( 'key', $key );
2053
+	public function set_key($value) {
2054
+        $key = sanitize_text_field($value);
2055
+		$this->set_prop('key', $key);
2056 2056
     }
2057 2057
 
2058 2058
     /**
@@ -2061,9 +2061,9 @@  discard block
 block discarded – undo
2061 2061
 	 * @since 1.0.19
2062 2062
 	 * @param  string $value mode.
2063 2063
 	 */
2064
-	public function set_mode( $value ) {
2065
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2066
-            $this->set_prop( 'value', $value );
2064
+	public function set_mode($value) {
2065
+        if (!in_array($value, array('live', 'test'))) {
2066
+            $this->set_prop('value', $value);
2067 2067
         }
2068 2068
     }
2069 2069
 
@@ -2073,8 +2073,8 @@  discard block
 block discarded – undo
2073 2073
 	 * @since 1.0.19
2074 2074
 	 * @param  string $value path.
2075 2075
 	 */
2076
-	public function set_path( $value ) {
2077
-        $this->set_prop( 'path', $value );
2076
+	public function set_path($value) {
2077
+        $this->set_prop('path', $value);
2078 2078
     }
2079 2079
 
2080 2080
     /**
@@ -2083,9 +2083,9 @@  discard block
 block discarded – undo
2083 2083
 	 * @since 1.0.19
2084 2084
 	 * @param  string $value New name.
2085 2085
 	 */
2086
-	public function set_name( $value ) {
2087
-        $name = sanitize_text_field( $value );
2088
-		$this->set_prop( 'name', $name );
2086
+	public function set_name($value) {
2087
+        $name = sanitize_text_field($value);
2088
+		$this->set_prop('name', $name);
2089 2089
     }
2090 2090
 
2091 2091
     /**
@@ -2094,8 +2094,8 @@  discard block
 block discarded – undo
2094 2094
 	 * @since 1.0.19
2095 2095
 	 * @param  string $value New name.
2096 2096
 	 */
2097
-	public function set_title( $value ) {
2098
-		$this->set_name( $value );
2097
+	public function set_title($value) {
2098
+		$this->set_name($value);
2099 2099
     }
2100 2100
 
2101 2101
     /**
@@ -2104,9 +2104,9 @@  discard block
 block discarded – undo
2104 2104
 	 * @since 1.0.19
2105 2105
 	 * @param  string $value New description.
2106 2106
 	 */
2107
-	public function set_description( $value ) {
2108
-        $description = wp_kses_post( $value );
2109
-		return $this->set_prop( 'description', $description );
2107
+	public function set_description($value) {
2108
+        $description = wp_kses_post($value);
2109
+		return $this->set_prop('description', $description);
2110 2110
     }
2111 2111
 
2112 2112
     /**
@@ -2115,8 +2115,8 @@  discard block
 block discarded – undo
2115 2115
 	 * @since 1.0.19
2116 2116
 	 * @param  string $value New description.
2117 2117
 	 */
2118
-	public function set_excerpt( $value ) {
2119
-		$this->set_description( $value );
2118
+	public function set_excerpt($value) {
2119
+		$this->set_description($value);
2120 2120
     }
2121 2121
 
2122 2122
     /**
@@ -2125,8 +2125,8 @@  discard block
 block discarded – undo
2125 2125
 	 * @since 1.0.19
2126 2126
 	 * @param  string $value New description.
2127 2127
 	 */
2128
-	public function set_summary( $value ) {
2129
-		$this->set_description( $value );
2128
+	public function set_summary($value) {
2129
+		$this->set_description($value);
2130 2130
     }
2131 2131
 
2132 2132
     /**
@@ -2135,12 +2135,12 @@  discard block
 block discarded – undo
2135 2135
 	 * @since 1.0.19
2136 2136
 	 * @param  int $value New author.
2137 2137
 	 */
2138
-	public function set_author( $value ) {
2139
-		$user = get_user_by( 'id', (int) $value );
2138
+	public function set_author($value) {
2139
+		$user = get_user_by('id', (int) $value);
2140 2140
 
2141
-		if ( $user && $user->ID ) {
2142
-			$this->set_prop( 'author', $user->ID );
2143
-			$this->set_prop( 'email', $user->user_email );
2141
+		if ($user && $user->ID) {
2142
+			$this->set_prop('author', $user->ID);
2143
+			$this->set_prop('email', $user->user_email);
2144 2144
 		}
2145 2145
 		
2146 2146
     }
@@ -2151,8 +2151,8 @@  discard block
 block discarded – undo
2151 2151
 	 * @since 1.0.19
2152 2152
 	 * @param  int $value New user id.
2153 2153
 	 */
2154
-	public function set_user_id( $value ) {
2155
-		$this->set_author( $value );
2154
+	public function set_user_id($value) {
2155
+		$this->set_author($value);
2156 2156
     }
2157 2157
 
2158 2158
     /**
@@ -2161,8 +2161,8 @@  discard block
 block discarded – undo
2161 2161
 	 * @since 1.0.19
2162 2162
 	 * @param  int $value New user id.
2163 2163
 	 */
2164
-	public function set_customer_id( $value ) {
2165
-		$this->set_author( $value );
2164
+	public function set_customer_id($value) {
2165
+		$this->set_author($value);
2166 2166
     }
2167 2167
 
2168 2168
     /**
@@ -2171,8 +2171,8 @@  discard block
 block discarded – undo
2171 2171
 	 * @since 1.0.19
2172 2172
 	 * @param  string $value ip address.
2173 2173
 	 */
2174
-	public function set_ip( $value ) {
2175
-		$this->set_prop( 'ip', $value );
2174
+	public function set_ip($value) {
2175
+		$this->set_prop('ip', $value);
2176 2176
     }
2177 2177
 
2178 2178
     /**
@@ -2181,8 +2181,8 @@  discard block
 block discarded – undo
2181 2181
 	 * @since 1.0.19
2182 2182
 	 * @param  string $value ip address.
2183 2183
 	 */
2184
-	public function set_user_ip( $value ) {
2185
-		$this->set_ip( $value );
2184
+	public function set_user_ip($value) {
2185
+		$this->set_ip($value);
2186 2186
     }
2187 2187
 
2188 2188
     /**
@@ -2191,8 +2191,8 @@  discard block
 block discarded – undo
2191 2191
 	 * @since 1.0.19
2192 2192
 	 * @param  string $value first name.
2193 2193
 	 */
2194
-	public function set_first_name( $value ) {
2195
-		$this->set_prop( 'first_name', $value );
2194
+	public function set_first_name($value) {
2195
+		$this->set_prop('first_name', $value);
2196 2196
     }
2197 2197
 
2198 2198
     /**
@@ -2201,8 +2201,8 @@  discard block
 block discarded – undo
2201 2201
 	 * @since 1.0.19
2202 2202
 	 * @param  string $value first name.
2203 2203
 	 */
2204
-	public function set_user_first_name( $value ) {
2205
-		$this->set_first_name( $value );
2204
+	public function set_user_first_name($value) {
2205
+		$this->set_first_name($value);
2206 2206
     }
2207 2207
 
2208 2208
     /**
@@ -2211,8 +2211,8 @@  discard block
 block discarded – undo
2211 2211
 	 * @since 1.0.19
2212 2212
 	 * @param  string $value first name.
2213 2213
 	 */
2214
-	public function set_customer_first_name( $value ) {
2215
-		$this->set_first_name( $value );
2214
+	public function set_customer_first_name($value) {
2215
+		$this->set_first_name($value);
2216 2216
     }
2217 2217
 
2218 2218
     /**
@@ -2221,8 +2221,8 @@  discard block
 block discarded – undo
2221 2221
 	 * @since 1.0.19
2222 2222
 	 * @param  string $value last name.
2223 2223
 	 */
2224
-	public function set_last_name( $value ) {
2225
-		$this->set_prop( 'last_name', $value );
2224
+	public function set_last_name($value) {
2225
+		$this->set_prop('last_name', $value);
2226 2226
     }
2227 2227
 
2228 2228
     /**
@@ -2231,8 +2231,8 @@  discard block
 block discarded – undo
2231 2231
 	 * @since 1.0.19
2232 2232
 	 * @param  string $value last name.
2233 2233
 	 */
2234
-	public function set_user_last_name( $value ) {
2235
-		$this->set_last_name( $value );
2234
+	public function set_user_last_name($value) {
2235
+		$this->set_last_name($value);
2236 2236
     }
2237 2237
 
2238 2238
     /**
@@ -2241,8 +2241,8 @@  discard block
 block discarded – undo
2241 2241
 	 * @since 1.0.19
2242 2242
 	 * @param  string $value last name.
2243 2243
 	 */
2244
-	public function set_customer_last_name( $value ) {
2245
-		$this->set_last_name( $value );
2244
+	public function set_customer_last_name($value) {
2245
+		$this->set_last_name($value);
2246 2246
     }
2247 2247
 
2248 2248
     /**
@@ -2251,8 +2251,8 @@  discard block
 block discarded – undo
2251 2251
 	 * @since 1.0.19
2252 2252
 	 * @param  string $value phone.
2253 2253
 	 */
2254
-	public function set_phone( $value ) {
2255
-		$this->set_prop( 'phone', $value );
2254
+	public function set_phone($value) {
2255
+		$this->set_prop('phone', $value);
2256 2256
     }
2257 2257
 
2258 2258
     /**
@@ -2261,8 +2261,8 @@  discard block
 block discarded – undo
2261 2261
 	 * @since 1.0.19
2262 2262
 	 * @param  string $value phone.
2263 2263
 	 */
2264
-	public function set_user_phone( $value ) {
2265
-		$this->set_phone( $value );
2264
+	public function set_user_phone($value) {
2265
+		$this->set_phone($value);
2266 2266
     }
2267 2267
 
2268 2268
     /**
@@ -2271,8 +2271,8 @@  discard block
 block discarded – undo
2271 2271
 	 * @since 1.0.19
2272 2272
 	 * @param  string $value phone.
2273 2273
 	 */
2274
-	public function set_customer_phone( $value ) {
2275
-		$this->set_phone( $value );
2274
+	public function set_customer_phone($value) {
2275
+		$this->set_phone($value);
2276 2276
     }
2277 2277
 
2278 2278
     /**
@@ -2281,8 +2281,8 @@  discard block
 block discarded – undo
2281 2281
 	 * @since 1.0.19
2282 2282
 	 * @param  string $value phone.
2283 2283
 	 */
2284
-	public function set_phone_number( $value ) {
2285
-		$this->set_phone( $value );
2284
+	public function set_phone_number($value) {
2285
+		$this->set_phone($value);
2286 2286
     }
2287 2287
 
2288 2288
     /**
@@ -2291,8 +2291,8 @@  discard block
 block discarded – undo
2291 2291
 	 * @since 1.0.19
2292 2292
 	 * @param  string $value email address.
2293 2293
 	 */
2294
-	public function set_email( $value ) {
2295
-		$this->set_prop( 'email', $value );
2294
+	public function set_email($value) {
2295
+		$this->set_prop('email', $value);
2296 2296
     }
2297 2297
 
2298 2298
     /**
@@ -2301,8 +2301,8 @@  discard block
 block discarded – undo
2301 2301
 	 * @since 1.0.19
2302 2302
 	 * @param  string $value email address.
2303 2303
 	 */
2304
-	public function set_user_email( $value ) {
2305
-		$this->set_email( $value );
2304
+	public function set_user_email($value) {
2305
+		$this->set_email($value);
2306 2306
     }
2307 2307
 
2308 2308
     /**
@@ -2311,8 +2311,8 @@  discard block
 block discarded – undo
2311 2311
 	 * @since 1.0.19
2312 2312
 	 * @param  string $value email address.
2313 2313
 	 */
2314
-	public function set_email_address( $value ) {
2315
-		$this->set_email( $value );
2314
+	public function set_email_address($value) {
2315
+		$this->set_email($value);
2316 2316
     }
2317 2317
 
2318 2318
     /**
@@ -2321,8 +2321,8 @@  discard block
 block discarded – undo
2321 2321
 	 * @since 1.0.19
2322 2322
 	 * @param  string $value email address.
2323 2323
 	 */
2324
-	public function set_customer_email( $value ) {
2325
-		$this->set_email( $value );
2324
+	public function set_customer_email($value) {
2325
+		$this->set_email($value);
2326 2326
     }
2327 2327
 
2328 2328
     /**
@@ -2331,8 +2331,8 @@  discard block
 block discarded – undo
2331 2331
 	 * @since 1.0.19
2332 2332
 	 * @param  string $value country.
2333 2333
 	 */
2334
-	public function set_country( $value ) {
2335
-		$this->set_prop( 'country', $value );
2334
+	public function set_country($value) {
2335
+		$this->set_prop('country', $value);
2336 2336
     }
2337 2337
 
2338 2338
     /**
@@ -2341,8 +2341,8 @@  discard block
 block discarded – undo
2341 2341
 	 * @since 1.0.19
2342 2342
 	 * @param  string $value country.
2343 2343
 	 */
2344
-	public function set_user_country( $value ) {
2345
-		$this->set_country( $value );
2344
+	public function set_user_country($value) {
2345
+		$this->set_country($value);
2346 2346
     }
2347 2347
 
2348 2348
     /**
@@ -2351,8 +2351,8 @@  discard block
 block discarded – undo
2351 2351
 	 * @since 1.0.19
2352 2352
 	 * @param  string $value country.
2353 2353
 	 */
2354
-	public function set_customer_country( $value ) {
2355
-		$this->set_country( $value );
2354
+	public function set_customer_country($value) {
2355
+		$this->set_country($value);
2356 2356
     }
2357 2357
 
2358 2358
     /**
@@ -2361,8 +2361,8 @@  discard block
 block discarded – undo
2361 2361
 	 * @since 1.0.19
2362 2362
 	 * @param  string $value state.
2363 2363
 	 */
2364
-	public function set_state( $value ) {
2365
-		$this->set_prop( 'state', $value );
2364
+	public function set_state($value) {
2365
+		$this->set_prop('state', $value);
2366 2366
     }
2367 2367
 
2368 2368
     /**
@@ -2371,8 +2371,8 @@  discard block
 block discarded – undo
2371 2371
 	 * @since 1.0.19
2372 2372
 	 * @param  string $value state.
2373 2373
 	 */
2374
-	public function set_user_state( $value ) {
2375
-		$this->set_state( $value );
2374
+	public function set_user_state($value) {
2375
+		$this->set_state($value);
2376 2376
     }
2377 2377
 
2378 2378
     /**
@@ -2381,8 +2381,8 @@  discard block
 block discarded – undo
2381 2381
 	 * @since 1.0.19
2382 2382
 	 * @param  string $value state.
2383 2383
 	 */
2384
-	public function set_customer_state( $value ) {
2385
-		$this->set_state( $value );
2384
+	public function set_customer_state($value) {
2385
+		$this->set_state($value);
2386 2386
     }
2387 2387
 
2388 2388
     /**
@@ -2391,8 +2391,8 @@  discard block
 block discarded – undo
2391 2391
 	 * @since 1.0.19
2392 2392
 	 * @param  string $value city.
2393 2393
 	 */
2394
-	public function set_city( $value ) {
2395
-		$this->set_prop( 'city', $value );
2394
+	public function set_city($value) {
2395
+		$this->set_prop('city', $value);
2396 2396
     }
2397 2397
 
2398 2398
     /**
@@ -2401,8 +2401,8 @@  discard block
 block discarded – undo
2401 2401
 	 * @since 1.0.19
2402 2402
 	 * @param  string $value city.
2403 2403
 	 */
2404
-	public function set_user_city( $value ) {
2405
-		$this->set_city( $value );
2404
+	public function set_user_city($value) {
2405
+		$this->set_city($value);
2406 2406
     }
2407 2407
 
2408 2408
     /**
@@ -2411,8 +2411,8 @@  discard block
 block discarded – undo
2411 2411
 	 * @since 1.0.19
2412 2412
 	 * @param  string $value city.
2413 2413
 	 */
2414
-	public function set_customer_city( $value ) {
2415
-		$this->set_city( $value );
2414
+	public function set_customer_city($value) {
2415
+		$this->set_city($value);
2416 2416
     }
2417 2417
 
2418 2418
     /**
@@ -2421,8 +2421,8 @@  discard block
 block discarded – undo
2421 2421
 	 * @since 1.0.19
2422 2422
 	 * @param  string $value zip.
2423 2423
 	 */
2424
-	public function set_zip( $value ) {
2425
-		$this->set_prop( 'zip', $value );
2424
+	public function set_zip($value) {
2425
+		$this->set_prop('zip', $value);
2426 2426
     }
2427 2427
 
2428 2428
     /**
@@ -2431,8 +2431,8 @@  discard block
 block discarded – undo
2431 2431
 	 * @since 1.0.19
2432 2432
 	 * @param  string $value zip.
2433 2433
 	 */
2434
-	public function set_user_zip( $value ) {
2435
-		$this->set_zip( $value );
2434
+	public function set_user_zip($value) {
2435
+		$this->set_zip($value);
2436 2436
     }
2437 2437
 
2438 2438
     /**
@@ -2441,8 +2441,8 @@  discard block
 block discarded – undo
2441 2441
 	 * @since 1.0.19
2442 2442
 	 * @param  string $value zip.
2443 2443
 	 */
2444
-	public function set_customer_zip( $value ) {
2445
-		$this->set_zip( $value );
2444
+	public function set_customer_zip($value) {
2445
+		$this->set_zip($value);
2446 2446
     }
2447 2447
 
2448 2448
     /**
@@ -2451,8 +2451,8 @@  discard block
 block discarded – undo
2451 2451
 	 * @since 1.0.19
2452 2452
 	 * @param  string $value company.
2453 2453
 	 */
2454
-	public function set_company( $value ) {
2455
-		$this->set_prop( 'company', $value );
2454
+	public function set_company($value) {
2455
+		$this->set_prop('company', $value);
2456 2456
     }
2457 2457
 
2458 2458
     /**
@@ -2461,8 +2461,8 @@  discard block
 block discarded – undo
2461 2461
 	 * @since 1.0.19
2462 2462
 	 * @param  string $value company.
2463 2463
 	 */
2464
-	public function set_user_company( $value ) {
2465
-		$this->set_company( $value );
2464
+	public function set_user_company($value) {
2465
+		$this->set_company($value);
2466 2466
     }
2467 2467
 
2468 2468
     /**
@@ -2471,8 +2471,8 @@  discard block
 block discarded – undo
2471 2471
 	 * @since 1.0.19
2472 2472
 	 * @param  string $value company.
2473 2473
 	 */
2474
-	public function set_customer_company( $value ) {
2475
-		$this->set_company( $value );
2474
+	public function set_customer_company($value) {
2475
+		$this->set_company($value);
2476 2476
     }
2477 2477
 
2478 2478
     /**
@@ -2481,8 +2481,8 @@  discard block
 block discarded – undo
2481 2481
 	 * @since 1.0.19
2482 2482
 	 * @param  string $value var number.
2483 2483
 	 */
2484
-	public function set_vat_number( $value ) {
2485
-		$this->set_prop( 'vat_number', $value );
2484
+	public function set_vat_number($value) {
2485
+		$this->set_prop('vat_number', $value);
2486 2486
     }
2487 2487
 
2488 2488
     /**
@@ -2491,8 +2491,8 @@  discard block
 block discarded – undo
2491 2491
 	 * @since 1.0.19
2492 2492
 	 * @param  string $value var number.
2493 2493
 	 */
2494
-	public function set_user_vat_number( $value ) {
2495
-		$this->set_vat_number( $value );
2494
+	public function set_user_vat_number($value) {
2495
+		$this->set_vat_number($value);
2496 2496
     }
2497 2497
 
2498 2498
     /**
@@ -2501,8 +2501,8 @@  discard block
 block discarded – undo
2501 2501
 	 * @since 1.0.19
2502 2502
 	 * @param  string $value var number.
2503 2503
 	 */
2504
-	public function set_customer_vat_number( $value ) {
2505
-		$this->set_vat_number( $value );
2504
+	public function set_customer_vat_number($value) {
2505
+		$this->set_vat_number($value);
2506 2506
     }
2507 2507
 
2508 2508
     /**
@@ -2511,8 +2511,8 @@  discard block
 block discarded – undo
2511 2511
 	 * @since 1.0.19
2512 2512
 	 * @param  string $value var rate.
2513 2513
 	 */
2514
-	public function set_vat_rate( $value ) {
2515
-		$this->set_prop( 'vat_rate', $value );
2514
+	public function set_vat_rate($value) {
2515
+		$this->set_prop('vat_rate', $value);
2516 2516
     }
2517 2517
 
2518 2518
     /**
@@ -2521,8 +2521,8 @@  discard block
 block discarded – undo
2521 2521
 	 * @since 1.0.19
2522 2522
 	 * @param  string $value var number.
2523 2523
 	 */
2524
-	public function set_user_vat_rate( $value ) {
2525
-		$this->set_vat_rate( $value );
2524
+	public function set_user_vat_rate($value) {
2525
+		$this->set_vat_rate($value);
2526 2526
     }
2527 2527
 
2528 2528
     /**
@@ -2531,8 +2531,8 @@  discard block
 block discarded – undo
2531 2531
 	 * @since 1.0.19
2532 2532
 	 * @param  string $value var number.
2533 2533
 	 */
2534
-	public function set_customer_vat_rate( $value ) {
2535
-		$this->set_vat_rate( $value );
2534
+	public function set_customer_vat_rate($value) {
2535
+		$this->set_vat_rate($value);
2536 2536
     }
2537 2537
 
2538 2538
     /**
@@ -2541,8 +2541,8 @@  discard block
 block discarded – undo
2541 2541
 	 * @since 1.0.19
2542 2542
 	 * @param  string $value address.
2543 2543
 	 */
2544
-	public function set_address( $value ) {
2545
-		$this->set_prop( 'address', $value );
2544
+	public function set_address($value) {
2545
+		$this->set_prop('address', $value);
2546 2546
     }
2547 2547
 
2548 2548
     /**
@@ -2551,8 +2551,8 @@  discard block
 block discarded – undo
2551 2551
 	 * @since 1.0.19
2552 2552
 	 * @param  string $value address.
2553 2553
 	 */
2554
-	public function set_user_address( $value ) {
2555
-		$this->set_address( $value );
2554
+	public function set_user_address($value) {
2555
+		$this->set_address($value);
2556 2556
     }
2557 2557
 
2558 2558
     /**
@@ -2561,8 +2561,8 @@  discard block
 block discarded – undo
2561 2561
 	 * @since 1.0.19
2562 2562
 	 * @param  string $value address.
2563 2563
 	 */
2564
-	public function set_customer_address( $value ) {
2565
-		$this->set_address( $value );
2564
+	public function set_customer_address($value) {
2565
+		$this->set_address($value);
2566 2566
     }
2567 2567
 
2568 2568
     /**
@@ -2571,8 +2571,8 @@  discard block
 block discarded – undo
2571 2571
 	 * @since 1.0.19
2572 2572
 	 * @param  int|bool $value confirmed.
2573 2573
 	 */
2574
-	public function set_is_viewed( $value ) {
2575
-		$this->set_prop( 'is_viewed', $value );
2574
+	public function set_is_viewed($value) {
2575
+		$this->set_prop('is_viewed', $value);
2576 2576
 	}
2577 2577
 
2578 2578
 	/**
@@ -2581,8 +2581,8 @@  discard block
 block discarded – undo
2581 2581
 	 * @since 1.0.19
2582 2582
 	 * @param  string $value email recipients.
2583 2583
 	 */
2584
-	public function set_email_cc( $value ) {
2585
-		$this->set_prop( 'email_cc', $value );
2584
+	public function set_email_cc($value) {
2585
+		$this->set_prop('email_cc', $value);
2586 2586
 	}
2587 2587
 
2588 2588
 	/**
@@ -2591,9 +2591,9 @@  discard block
 block discarded – undo
2591 2591
 	 * @since 1.0.19
2592 2592
 	 * @param  string $value email recipients.
2593 2593
 	 */
2594
-	public function set_template( $value ) {
2595
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2596
-			$this->set_prop( 'template', $value );
2594
+	public function set_template($value) {
2595
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2596
+			$this->set_prop('template', $value);
2597 2597
 		}
2598 2598
 	}
2599 2599
 
@@ -2603,8 +2603,8 @@  discard block
 block discarded – undo
2603 2603
 	 * @since 1.0.19
2604 2604
 	 * @param  int|bool $value confirmed.
2605 2605
 	 */
2606
-	public function set_address_confirmed( $value ) {
2607
-		$this->set_prop( 'address_confirmed', $value );
2606
+	public function set_address_confirmed($value) {
2607
+		$this->set_prop('address_confirmed', $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  int|bool $value confirmed.
2615 2615
 	 */
2616
-	public function set_user_address_confirmed( $value ) {
2617
-		$this->set_address_confirmed( $value );
2616
+	public function set_user_address_confirmed($value) {
2617
+		$this->set_address_confirmed($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_customer_address_confirmed( $value ) {
2627
-		$this->set_address_confirmed( $value );
2626
+	public function set_customer_address_confirmed($value) {
2627
+		$this->set_address_confirmed($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  float $value sub total.
2635 2635
 	 */
2636
-	public function set_subtotal( $value ) {
2637
-		$this->set_prop( 'subtotal', $value );
2636
+	public function set_subtotal($value) {
2637
+		$this->set_prop('subtotal', $value);
2638 2638
     }
2639 2639
 
2640 2640
     /**
@@ -2643,8 +2643,8 @@  discard block
 block discarded – undo
2643 2643
 	 * @since 1.0.19
2644 2644
 	 * @param  float $value discount total.
2645 2645
 	 */
2646
-	public function set_total_discount( $value ) {
2647
-		$this->set_prop( 'total_discount', $value );
2646
+	public function set_total_discount($value) {
2647
+		$this->set_prop('total_discount', $value);
2648 2648
     }
2649 2649
 
2650 2650
     /**
@@ -2653,8 +2653,8 @@  discard block
 block discarded – undo
2653 2653
 	 * @since 1.0.19
2654 2654
 	 * @param  float $value discount total.
2655 2655
 	 */
2656
-	public function set_discount( $value ) {
2657
-		$this->set_total_discount( $value );
2656
+	public function set_discount($value) {
2657
+		$this->set_total_discount($value);
2658 2658
     }
2659 2659
 
2660 2660
     /**
@@ -2663,8 +2663,8 @@  discard block
 block discarded – undo
2663 2663
 	 * @since 1.0.19
2664 2664
 	 * @param  float $value tax total.
2665 2665
 	 */
2666
-	public function set_total_tax( $value ) {
2667
-		$this->set_prop( 'total_tax', $value );
2666
+	public function set_total_tax($value) {
2667
+		$this->set_prop('total_tax', $value);
2668 2668
     }
2669 2669
 
2670 2670
     /**
@@ -2673,8 +2673,8 @@  discard block
 block discarded – undo
2673 2673
 	 * @since 1.0.19
2674 2674
 	 * @param  float $value tax total.
2675 2675
 	 */
2676
-	public function set_tax_total( $value ) {
2677
-		$this->set_total_tax( $value );
2676
+	public function set_tax_total($value) {
2677
+		$this->set_total_tax($value);
2678 2678
     }
2679 2679
 
2680 2680
     /**
@@ -2683,8 +2683,8 @@  discard block
 block discarded – undo
2683 2683
 	 * @since 1.0.19
2684 2684
 	 * @param  float $value fees total.
2685 2685
 	 */
2686
-	public function set_total_fees( $value ) {
2687
-		$this->set_prop( 'total_fees', $value );
2686
+	public function set_total_fees($value) {
2687
+		$this->set_prop('total_fees', $value);
2688 2688
     }
2689 2689
 
2690 2690
     /**
@@ -2693,8 +2693,8 @@  discard block
 block discarded – undo
2693 2693
 	 * @since 1.0.19
2694 2694
 	 * @param  float $value fees total.
2695 2695
 	 */
2696
-	public function set_fees_total( $value ) {
2697
-		$this->set_total_fees( $value );
2696
+	public function set_fees_total($value) {
2697
+		$this->set_total_fees($value);
2698 2698
     }
2699 2699
 
2700 2700
     /**
@@ -2703,18 +2703,18 @@  discard block
 block discarded – undo
2703 2703
 	 * @since 1.0.19
2704 2704
 	 * @param  array $value fees.
2705 2705
 	 */
2706
-	public function set_fees( $value ) {
2706
+	public function set_fees($value) {
2707 2707
 
2708
-        $this->set_prop( 'fees', array() );
2708
+        $this->set_prop('fees', array());
2709 2709
 
2710 2710
         // Ensure that we have an array.
2711
-        if ( ! is_array( $value ) ) {
2711
+        if (!is_array($value)) {
2712 2712
             return;
2713 2713
         }
2714 2714
 
2715
-        foreach ( $value as $name => $data ) {
2716
-            if ( isset( $data['amount'] ) ) {
2717
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2715
+        foreach ($value as $name => $data) {
2716
+            if (isset($data['amount'])) {
2717
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2718 2718
             }
2719 2719
         }
2720 2720
 
@@ -2726,8 +2726,8 @@  discard block
 block discarded – undo
2726 2726
 	 * @since 1.0.19
2727 2727
 	 * @param  array $value taxes.
2728 2728
 	 */
2729
-	public function set_taxes( $value ) {
2730
-		$this->set_prop( 'taxes', $value );
2729
+	public function set_taxes($value) {
2730
+		$this->set_prop('taxes', $value);
2731 2731
     }
2732 2732
 
2733 2733
     /**
@@ -2736,17 +2736,17 @@  discard block
 block discarded – undo
2736 2736
 	 * @since 1.0.19
2737 2737
 	 * @param  array $value discounts.
2738 2738
 	 */
2739
-	public function set_discounts( $value ) {
2740
-		$this->set_prop( 'discounts', array() );
2739
+	public function set_discounts($value) {
2740
+		$this->set_prop('discounts', array());
2741 2741
 
2742 2742
         // Ensure that we have an array.
2743
-        if ( ! is_array( $value ) ) {
2743
+        if (!is_array($value)) {
2744 2744
             return;
2745 2745
         }
2746 2746
 
2747
-        foreach ( $value as $name => $data ) {
2748
-            if ( isset( $data['amount'] ) ) {
2749
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2747
+        foreach ($value as $name => $data) {
2748
+            if (isset($data['amount'])) {
2749
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2750 2750
             }
2751 2751
         }
2752 2752
     }
@@ -2757,18 +2757,18 @@  discard block
 block discarded – undo
2757 2757
 	 * @since 1.0.19
2758 2758
 	 * @param  GetPaid_Form_Item[] $value items.
2759 2759
 	 */
2760
-	public function set_items( $value ) {
2760
+	public function set_items($value) {
2761 2761
 
2762 2762
         // Remove existing items.
2763
-        $this->set_prop( 'items', array() );
2763
+        $this->set_prop('items', array());
2764 2764
 
2765 2765
         // Ensure that we have an array.
2766
-        if ( ! is_array( $value ) ) {
2766
+        if (!is_array($value)) {
2767 2767
             return;
2768 2768
         }
2769 2769
 
2770
-        foreach ( $value as $item ) {
2771
-            $this->add_item( $item );
2770
+        foreach ($value as $item) {
2771
+            $this->add_item($item);
2772 2772
         }
2773 2773
 
2774 2774
     }
@@ -2779,8 +2779,8 @@  discard block
 block discarded – undo
2779 2779
 	 * @since 1.0.19
2780 2780
 	 * @param  int $value payment form.
2781 2781
 	 */
2782
-	public function set_payment_form( $value ) {
2783
-		$this->set_prop( 'payment_form', $value );
2782
+	public function set_payment_form($value) {
2783
+		$this->set_prop('payment_form', $value);
2784 2784
     }
2785 2785
 
2786 2786
     /**
@@ -2789,8 +2789,8 @@  discard block
 block discarded – undo
2789 2789
 	 * @since 1.0.19
2790 2790
 	 * @param  string $value submission id.
2791 2791
 	 */
2792
-	public function set_submission_id( $value ) {
2793
-		$this->set_prop( 'submission_id', $value );
2792
+	public function set_submission_id($value) {
2793
+		$this->set_prop('submission_id', $value);
2794 2794
     }
2795 2795
 
2796 2796
     /**
@@ -2799,8 +2799,8 @@  discard block
 block discarded – undo
2799 2799
 	 * @since 1.0.19
2800 2800
 	 * @param  string $value discount code.
2801 2801
 	 */
2802
-	public function set_discount_code( $value ) {
2803
-		$this->set_prop( 'discount_code', $value );
2802
+	public function set_discount_code($value) {
2803
+		$this->set_prop('discount_code', $value);
2804 2804
     }
2805 2805
 
2806 2806
     /**
@@ -2809,8 +2809,8 @@  discard block
 block discarded – undo
2809 2809
 	 * @since 1.0.19
2810 2810
 	 * @param  string $value gateway.
2811 2811
 	 */
2812
-	public function set_gateway( $value ) {
2813
-		$this->set_prop( 'gateway', $value );
2812
+	public function set_gateway($value) {
2813
+		$this->set_prop('gateway', $value);
2814 2814
     }
2815 2815
 
2816 2816
     /**
@@ -2819,9 +2819,9 @@  discard block
 block discarded – undo
2819 2819
 	 * @since 1.0.19
2820 2820
 	 * @param  string $value transaction id.
2821 2821
 	 */
2822
-	public function set_transaction_id( $value ) {
2823
-		if ( ! empty( $value ) ) {
2824
-			$this->set_prop( 'transaction_id', $value );
2822
+	public function set_transaction_id($value) {
2823
+		if (!empty($value)) {
2824
+			$this->set_prop('transaction_id', $value);
2825 2825
 		}
2826 2826
     }
2827 2827
 
@@ -2831,8 +2831,8 @@  discard block
 block discarded – undo
2831 2831
 	 * @since 1.0.19
2832 2832
 	 * @param  string $value currency id.
2833 2833
 	 */
2834
-	public function set_currency( $value ) {
2835
-		$this->set_prop( 'currency', $value );
2834
+	public function set_currency($value) {
2835
+		$this->set_prop('currency', $value);
2836 2836
     }
2837 2837
 
2838 2838
 	/**
@@ -2841,8 +2841,8 @@  discard block
 block discarded – undo
2841 2841
 	 * @since 1.0.19
2842 2842
 	 * @param  bool $value value.
2843 2843
 	 */
2844
-	public function set_disable_taxes( $value ) {
2845
-		$this->set_prop( 'disable_taxes', (bool) $value );
2844
+	public function set_disable_taxes($value) {
2845
+		$this->set_prop('disable_taxes', (bool) $value);
2846 2846
 	}
2847 2847
 
2848 2848
     /**
@@ -2851,8 +2851,8 @@  discard block
 block discarded – undo
2851 2851
 	 * @since 1.0.19
2852 2852
 	 * @param  string $value subscription id.
2853 2853
 	 */
2854
-	public function set_subscription_id( $value ) {
2855
-		$this->set_prop( 'subscription_id', $value );
2854
+	public function set_subscription_id($value) {
2855
+		$this->set_prop('subscription_id', $value);
2856 2856
     }
2857 2857
 
2858 2858
     /*
@@ -2869,28 +2869,28 @@  discard block
 block discarded – undo
2869 2869
      */
2870 2870
     public function is_parent() {
2871 2871
         $parent = $this->get_parent_id();
2872
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2872
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2873 2873
     }
2874 2874
 
2875 2875
     /**
2876 2876
      * Checks if this is a renewal invoice.
2877 2877
      */
2878 2878
     public function is_renewal() {
2879
-        return ! $this->is_parent();
2879
+        return !$this->is_parent();
2880 2880
     }
2881 2881
 
2882 2882
     /**
2883 2883
      * Checks if this is a recurring invoice.
2884 2884
      */
2885 2885
     public function is_recurring() {
2886
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2886
+        return $this->is_renewal() || !empty($this->recurring_item);
2887 2887
     }
2888 2888
 
2889 2889
     /**
2890 2890
      * Checks if this is a taxable invoice.
2891 2891
      */
2892 2892
     public function is_taxable() {
2893
-        return ! $this->get_disable_taxes();
2893
+        return !$this->get_disable_taxes();
2894 2894
 	}
2895 2895
 
2896 2896
 	/**
@@ -2901,57 +2901,57 @@  discard block
 block discarded – undo
2901 2901
 
2902 2902
         $requires_vat = false;
2903 2903
 
2904
-        if ( $this->country ) {
2904
+        if ($this->country) {
2905 2905
             $wpi_country        = $this->country;
2906
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2906
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2907 2907
         }
2908 2908
 
2909
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2909
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2910 2910
 	}
2911 2911
 
2912 2912
 	/**
2913 2913
 	 * Checks to see if the invoice requires payment.
2914 2914
 	 */
2915 2915
 	public function is_free() {
2916
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2916
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2917 2917
 
2918
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2918
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2919 2919
 			$is_free = false;
2920 2920
 		}
2921 2921
 
2922
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2922
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2923 2923
     }
2924 2924
 
2925 2925
     /**
2926 2926
      * Checks if the invoice is paid.
2927 2927
      */
2928 2928
     public function is_paid() {
2929
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2930
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2929
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2930
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2931 2931
 	}
2932 2932
 
2933 2933
 	/**
2934 2934
      * Checks if the invoice needs payment.
2935 2935
      */
2936 2936
 	public function needs_payment() {
2937
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2938
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2937
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2938
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2939 2939
     }
2940 2940
 
2941 2941
 	/**
2942 2942
      * Checks if the invoice is refunded.
2943 2943
      */
2944 2944
 	public function is_refunded() {
2945
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2946
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2945
+        $is_refunded = $this->has_status('wpi-refunded');
2946
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2947 2947
 	}
2948 2948
 
2949 2949
 	/**
2950 2950
      * Checks if the invoice is held.
2951 2951
      */
2952 2952
 	public function is_held() {
2953
-        $is_held = $this->has_status( 'wpi-onhold' );
2954
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2953
+        $is_held = $this->has_status('wpi-onhold');
2954
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2955 2955
 	}
2956 2956
 
2957 2957
 	/**
@@ -2959,30 +2959,30 @@  discard block
 block discarded – undo
2959 2959
      */
2960 2960
 	public function is_due() {
2961 2961
 		$due_date = $this->get_due_date();
2962
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2962
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
2963 2963
 	}
2964 2964
 
2965 2965
 	/**
2966 2966
      * Checks if the invoice is draft.
2967 2967
      */
2968 2968
 	public function is_draft() {
2969
-        return $this->has_status( 'draft, auto-draft' );
2969
+        return $this->has_status('draft, auto-draft');
2970 2970
 	}
2971 2971
 
2972 2972
     /**
2973 2973
      * Checks if the invoice has a given status.
2974 2974
      */
2975
-    public function has_status( $status ) {
2976
-        $status = wpinv_parse_list( $status );
2977
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2975
+    public function has_status($status) {
2976
+        $status = wpinv_parse_list($status);
2977
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
2978 2978
 	}
2979 2979
 
2980 2980
 	/**
2981 2981
      * Checks if the invoice is of a given type.
2982 2982
      */
2983
-    public function is_type( $type ) {
2984
-        $type = wpinv_parse_list( $type );
2985
-        return in_array( $this->get_type(), $type );
2983
+    public function is_type($type) {
2984
+        $type = wpinv_parse_list($type);
2985
+        return in_array($this->get_type(), $type);
2986 2986
     }
2987 2987
 
2988 2988
     /**
@@ -3014,8 +3014,8 @@  discard block
 block discarded – undo
3014 3014
      *
3015 3015
      */
3016 3016
 	public function is_initial_free() {
3017
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3018
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3017
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3018
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3019 3019
     }
3020 3020
 	
3021 3021
 	/**
@@ -3025,11 +3025,11 @@  discard block
 block discarded – undo
3025 3025
     public function item_has_free_trial() {
3026 3026
 
3027 3027
         // Ensure we have a recurring item.
3028
-        if ( ! $this->is_recurring() ) {
3028
+        if (!$this->is_recurring()) {
3029 3029
             return false;
3030 3030
         }
3031 3031
 
3032
-        $item = $this->get_recurring( true );
3032
+        $item = $this->get_recurring(true);
3033 3033
         return $item->has_free_trial();
3034 3034
 	}
3035 3035
 
@@ -3037,7 +3037,7 @@  discard block
 block discarded – undo
3037 3037
      * Check if the free trial is a result of a discount.
3038 3038
      */
3039 3039
     public function is_free_trial_from_discount() {
3040
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3040
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3041 3041
 	}
3042 3042
 	
3043 3043
 	/**
@@ -3046,17 +3046,17 @@  discard block
 block discarded – undo
3046 3046
     public function discount_first_payment_only() {
3047 3047
 
3048 3048
 		$discount_code = $this->get_discount_code();
3049
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3049
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3050 3050
             return true;
3051 3051
         }
3052 3052
 
3053
-        $discount = wpinv_get_discount_obj( $discount_code );
3053
+        $discount = wpinv_get_discount_obj($discount_code);
3054 3054
 
3055
-        if ( ! $discount || ! $discount->exists() ) {
3055
+        if (!$discount || !$discount->exists()) {
3056 3056
             return true;
3057 3057
         }
3058 3058
 
3059
-        return ! $discount->get_is_recurring();
3059
+        return !$discount->get_is_recurring();
3060 3060
     }
3061 3061
 
3062 3062
     /*
@@ -3074,27 +3074,27 @@  discard block
 block discarded – undo
3074 3074
      * @param GetPaid_Form_Item|array $item
3075 3075
      * @return WP_Error|Bool
3076 3076
      */
3077
-    public function add_item( $item ) {
3077
+    public function add_item($item) {
3078 3078
 
3079
-		if ( is_array( $item ) ) {
3080
-			$item = $this->process_array_item( $item );
3079
+		if (is_array($item)) {
3080
+			$item = $this->process_array_item($item);
3081 3081
 		}
3082 3082
 
3083
-		if ( is_numeric( $item ) ) {
3084
-			$item = new GetPaid_Form_Item( $item );
3083
+		if (is_numeric($item)) {
3084
+			$item = new GetPaid_Form_Item($item);
3085 3085
 		}
3086 3086
 
3087 3087
         // Make sure that it is available for purchase.
3088
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3089
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3088
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3089
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3090 3090
         }
3091 3091
 
3092 3092
         // Do we have a recurring item?
3093
-		if ( $item->is_recurring() ) {
3093
+		if ($item->is_recurring()) {
3094 3094
 
3095 3095
 			// An invoice can only contain one recurring item.
3096
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3097
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3096
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3097
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3098 3098
 			}
3099 3099
 
3100 3100
 			$this->recurring_item = $item->get_id();
@@ -3105,9 +3105,9 @@  discard block
 block discarded – undo
3105 3105
 
3106 3106
         // Retrieve all items.
3107 3107
         $items = $this->get_items();
3108
-        $items[ (int) $item->get_id() ] = $item;
3108
+        $items[(int) $item->get_id()] = $item;
3109 3109
 
3110
-        $this->set_prop( 'items', $items );
3110
+        $this->set_prop('items', $items);
3111 3111
 		return true;
3112 3112
 	}
3113 3113
 	
@@ -3117,26 +3117,26 @@  discard block
 block discarded – undo
3117 3117
 	 * @since 1.0.19
3118 3118
 	 * @return GetPaid_Form_Item
3119 3119
 	 */
3120
-	protected function process_array_item( $array ) {
3120
+	protected function process_array_item($array) {
3121 3121
 
3122
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3123
-		$item    = new GetPaid_Form_Item( $item_id );
3122
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3123
+		$item    = new GetPaid_Form_Item($item_id);
3124 3124
 
3125 3125
 		// Set item data.
3126
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3127
-			if ( isset( $array[ "item_$key" ] ) ) {
3126
+		foreach (array('name', 'price', 'description') as $key) {
3127
+			if (isset($array["item_$key"])) {
3128 3128
 				$method = "set_$key";
3129
-				$item->$method( $array[ "item_$key" ] );
3129
+				$item->$method($array["item_$key"]);
3130 3130
 			}
3131 3131
 		}
3132 3132
 
3133
-		if ( isset( $array['quantity'] ) ) {
3134
-			$item->set_quantity( $array['quantity'] );
3133
+		if (isset($array['quantity'])) {
3134
+			$item->set_quantity($array['quantity']);
3135 3135
 		}
3136 3136
 
3137 3137
 		// Set item meta.
3138
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3139
-			$item->set_item_meta( $array['meta'] );
3138
+		if (isset($array['meta']) && is_array($array['meta'])) {
3139
+			$item->set_item_meta($array['meta']);
3140 3140
 		}
3141 3141
 
3142 3142
 		return $item;
@@ -3148,10 +3148,10 @@  discard block
 block discarded – undo
3148 3148
 	 *
3149 3149
 	 * @since 1.0.19
3150 3150
 	 */
3151
-	public function get_item( $item_id ) {
3151
+	public function get_item($item_id) {
3152 3152
 		$items   = $this->get_items();
3153 3153
 		$item_id = (int) $item_id;
3154
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3154
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3155 3155
     }
3156 3156
 
3157 3157
     /**
@@ -3159,17 +3159,17 @@  discard block
 block discarded – undo
3159 3159
 	 *
3160 3160
 	 * @since 1.0.19
3161 3161
 	 */
3162
-	public function remove_item( $item_id ) {
3162
+	public function remove_item($item_id) {
3163 3163
 		$items   = $this->get_items();
3164 3164
 		$item_id = (int) $item_id;
3165 3165
 
3166
-        if ( $item_id == $this->recurring_item ) {
3166
+        if ($item_id == $this->recurring_item) {
3167 3167
             $this->recurring_item = null;
3168 3168
         }
3169 3169
 
3170
-        if ( isset( $items[ $item_id ] ) ) {
3171
-            unset( $items[ $item_id ] );
3172
-            $this->set_prop( 'items', $items );
3170
+        if (isset($items[$item_id])) {
3171
+            unset($items[$item_id]);
3172
+            $this->set_prop('items', $items);
3173 3173
         }
3174 3174
     }
3175 3175
 
@@ -3180,27 +3180,27 @@  discard block
 block discarded – undo
3180 3180
      * @param float $value
3181 3181
      * @return WP_Error|Bool
3182 3182
      */
3183
-    public function add_fee( $fee, $value, $recurring = false ) {
3183
+    public function add_fee($fee, $value, $recurring = false) {
3184 3184
 
3185
-        $amount = wpinv_sanitize_amount( $value );
3185
+        $amount = wpinv_sanitize_amount($value);
3186 3186
         $fees   = $this->get_fees();
3187 3187
 
3188
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3188
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3189 3189
 
3190
-            $amount = $fees[ $fee ]['amount'] += $amount;
3191
-			$fees[ $fee ] = array(
3190
+            $amount = $fees[$fee]['amount'] += $amount;
3191
+			$fees[$fee] = array(
3192 3192
 				'amount'    => $amount,
3193 3193
                 'recurring' => (bool) $recurring,
3194 3194
             );
3195 3195
 
3196 3196
 		} else {
3197
-			$fees[ $fee ] = array(
3197
+			$fees[$fee] = array(
3198 3198
                 'amount'    => $amount,
3199 3199
                 'recurring' => (bool) $recurring,
3200 3200
             );
3201 3201
 		}
3202 3202
 
3203
-        $this->set_prop( 'fees', $fee );
3203
+        $this->set_prop('fees', $fee);
3204 3204
 
3205 3205
     }
3206 3206
 
@@ -3209,9 +3209,9 @@  discard block
 block discarded – undo
3209 3209
 	 *
3210 3210
 	 * @since 1.0.19
3211 3211
 	 */
3212
-	public function get_fee( $fee ) {
3212
+	public function get_fee($fee) {
3213 3213
         $fees = $this->get_fees();
3214
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3214
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3215 3215
     }
3216 3216
 
3217 3217
     /**
@@ -3219,11 +3219,11 @@  discard block
 block discarded – undo
3219 3219
 	 *
3220 3220
 	 * @since 1.0.19
3221 3221
 	 */
3222
-	public function remove_fee( $fee ) {
3222
+	public function remove_fee($fee) {
3223 3223
         $fees = $this->get_fees();
3224
-        if ( isset( $fees[ $fee ] ) ) {
3225
-            unset( $fees[ $fee ] );
3226
-            $this->set_prop( 'fees', $fees );
3224
+        if (isset($fees[$fee])) {
3225
+            unset($fees[$fee]);
3226
+            $this->set_prop('fees', $fees);
3227 3227
         }
3228 3228
     }
3229 3229
 
@@ -3234,27 +3234,27 @@  discard block
 block discarded – undo
3234 3234
      * @param float $value
3235 3235
      * @return WP_Error|Bool
3236 3236
      */
3237
-    public function add_discount( $discount, $value, $recurring = false ) {
3237
+    public function add_discount($discount, $value, $recurring = false) {
3238 3238
 
3239
-        $amount    = wpinv_sanitize_amount( $value );
3239
+        $amount    = wpinv_sanitize_amount($value);
3240 3240
         $discounts = $this->get_discounts();
3241 3241
 
3242
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3242
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3243 3243
 
3244
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3245
-			$discounts[ $discount ] = array(
3244
+            $amount = $discounts[$discount]['amount'] += $amount;
3245
+			$discounts[$discount] = array(
3246 3246
                 'amount'    => $amount,
3247 3247
                 'recurring' => (bool) $recurring,
3248 3248
             );
3249 3249
 
3250 3250
 		} else {
3251
-			$discounts[ $discount ] = array(
3251
+			$discounts[$discount] = array(
3252 3252
                 'amount'    => $amount,
3253 3253
                 'recurring' => (bool) $recurring,
3254 3254
             );
3255 3255
 		}
3256 3256
 
3257
-        $this->set_prop( 'discounts', $discount );
3257
+        $this->set_prop('discounts', $discount);
3258 3258
 
3259 3259
     }
3260 3260
 
@@ -3263,15 +3263,15 @@  discard block
 block discarded – undo
3263 3263
 	 *
3264 3264
 	 * @since 1.0.19
3265 3265
 	 */
3266
-	public function get_discount( $discount = false ) {
3266
+	public function get_discount($discount = false) {
3267 3267
 
3268 3268
 		// Backwards compatibilty.
3269
-		if ( empty( $discount ) ) {
3269
+		if (empty($discount)) {
3270 3270
 			return $this->get_total_discount();
3271 3271
 		}
3272 3272
 
3273 3273
         $discounts = $this->get_discounts();
3274
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3274
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3275 3275
     }
3276 3276
 
3277 3277
     /**
@@ -3279,11 +3279,11 @@  discard block
 block discarded – undo
3279 3279
 	 *
3280 3280
 	 * @since 1.0.19
3281 3281
 	 */
3282
-	public function remove_discount( $discount ) {
3282
+	public function remove_discount($discount) {
3283 3283
         $discounts = $this->get_discounts();
3284
-        if ( isset( $discounts[ $discount ] ) ) {
3285
-            unset( $discounts[ $discount ] );
3286
-            $this->set_prop( 'discounts', $discounts );
3284
+        if (isset($discounts[$discount])) {
3285
+            unset($discounts[$discount]);
3286
+            $this->set_prop('discounts', $discounts);
3287 3287
         }
3288 3288
     }
3289 3289
 
@@ -3293,31 +3293,31 @@  discard block
 block discarded – undo
3293 3293
      * @param string $tax
3294 3294
      * @param float $value
3295 3295
      */
3296
-    public function add_tax( $tax, $value, $recurring = true ) {
3296
+    public function add_tax($tax, $value, $recurring = true) {
3297 3297
 
3298
-        if ( ! $this->is_taxable() ) {
3298
+        if (!$this->is_taxable()) {
3299 3299
             return;
3300 3300
         }
3301 3301
 
3302
-        $amount    = wpinv_sanitize_amount( $value );
3302
+        $amount    = wpinv_sanitize_amount($value);
3303 3303
         $taxes     = $this->get_taxes();
3304 3304
 
3305
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3305
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3306 3306
 
3307
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3308
-			$taxes[ $tax ] = array(
3307
+            $amount = $taxes[$tax]['amount'] += $amount;
3308
+			$taxes[$tax] = array(
3309 3309
                 'amount'    => $amount,
3310 3310
                 'recurring' => (bool) $recurring,
3311 3311
             );
3312 3312
 
3313 3313
 		} else {
3314
-			$taxes[ $tax ] = array(
3314
+			$taxes[$tax] = array(
3315 3315
                 'amount'    => $amount,
3316 3316
                 'recurring' => (bool) $recurring,
3317 3317
             );
3318 3318
 		}
3319 3319
 
3320
-        $this->set_prop( 'taxes', $tax );
3320
+        $this->set_prop('taxes', $tax);
3321 3321
 
3322 3322
     }
3323 3323
 
@@ -3326,15 +3326,15 @@  discard block
 block discarded – undo
3326 3326
 	 *
3327 3327
 	 * @since 1.0.19
3328 3328
 	 */
3329
-	public function get_tax( $tax = null ) {
3329
+	public function get_tax($tax = null) {
3330 3330
 
3331 3331
 		// Backwards compatility.
3332
-		if ( empty( $tax ) ) {
3332
+		if (empty($tax)) {
3333 3333
 			return $this->get_total_tax();
3334 3334
 		}
3335 3335
 
3336 3336
         $taxes = $this->get_taxes();
3337
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3337
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3338 3338
     }
3339 3339
 
3340 3340
     /**
@@ -3342,11 +3342,11 @@  discard block
 block discarded – undo
3342 3342
 	 *
3343 3343
 	 * @since 1.0.19
3344 3344
 	 */
3345
-	public function remove_tax( $tax ) {
3345
+	public function remove_tax($tax) {
3346 3346
         $taxes = $this->get_discounts();
3347
-        if ( isset( $taxes[ $tax ] ) ) {
3348
-            unset( $taxes[ $tax ] );
3349
-            $this->set_prop( 'taxes', $taxes );
3347
+        if (isset($taxes[$tax])) {
3348
+            unset($taxes[$tax]);
3349
+            $this->set_prop('taxes', $taxes);
3350 3350
         }
3351 3351
     }
3352 3352
 
@@ -3357,19 +3357,19 @@  discard block
 block discarded – undo
3357 3357
 	 * @return float The recalculated subtotal
3358 3358
 	 */
3359 3359
 	public function recalculate_subtotal() {
3360
-        $items     = $this->get_items();
3360
+        $items = $this->get_items();
3361 3361
 		$subtotal  = 0;
3362 3362
 		$recurring = 0;
3363 3363
 
3364
-        foreach ( $items as $item ) {
3364
+        foreach ($items as $item) {
3365 3365
 			$subtotal  += $item->get_sub_total();
3366 3366
 			$recurring += $item->get_recurring_sub_total();
3367 3367
         }
3368 3368
 
3369
-		if ( $this->is_renewal() ) {
3370
-			$this->set_subtotal( $recurring );
3369
+		if ($this->is_renewal()) {
3370
+			$this->set_subtotal($recurring);
3371 3371
 		} else {
3372
-			$this->set_subtotal( $subtotal );
3372
+			$this->set_subtotal($subtotal);
3373 3373
 		}
3374 3374
 
3375 3375
 		$this->totals['subtotal'] = array(
@@ -3391,9 +3391,9 @@  discard block
 block discarded – undo
3391 3391
 		$discount  = 0;
3392 3392
 		$recurring = 0;
3393 3393
 
3394
-        foreach ( $discounts as $data ) {
3394
+        foreach ($discounts as $data) {
3395 3395
 
3396
-			if ( $data['recurring'] ) {
3396
+			if ($data['recurring']) {
3397 3397
 				$recurring += $data['amount'];
3398 3398
 			} else {
3399 3399
 				$discount += $data['amount'];
@@ -3401,10 +3401,10 @@  discard block
 block discarded – undo
3401 3401
 
3402 3402
 		}
3403 3403
 
3404
-		if ( $this->is_renewal() ) {
3405
-			$this->set_total_discount( $recurring );
3404
+		if ($this->is_renewal()) {
3405
+			$this->set_total_discount($recurring);
3406 3406
 		} else {
3407
-			$this->set_total_discount( $discount );
3407
+			$this->set_total_discount($discount);
3408 3408
 		}
3409 3409
 
3410 3410
 		$this->totals['discount'] = array(
@@ -3423,13 +3423,13 @@  discard block
 block discarded – undo
3423 3423
 	 * @return float The recalculated tax
3424 3424
 	 */
3425 3425
 	public function recalculate_total_tax() {
3426
-        $taxes     = $this->get_taxes();
3426
+        $taxes = $this->get_taxes();
3427 3427
 		$tax       = 0;
3428 3428
 		$recurring = 0;
3429 3429
 
3430
-        foreach ( $taxes as $data ) {
3430
+        foreach ($taxes as $data) {
3431 3431
 
3432
-			if ( $data['recurring'] ) {
3432
+			if ($data['recurring']) {
3433 3433
 				$recurring += $data['amount'];
3434 3434
 			} else {
3435 3435
 				$tax += $data['amount'];
@@ -3437,10 +3437,10 @@  discard block
 block discarded – undo
3437 3437
 
3438 3438
 		}
3439 3439
 
3440
-		if ( $this->is_renewal() ) {
3441
-			$this->set_total_tax( $recurring );
3440
+		if ($this->is_renewal()) {
3441
+			$this->set_total_tax($recurring);
3442 3442
 		} else {
3443
-			$this->set_total_tax( $tax );
3443
+			$this->set_total_tax($tax);
3444 3444
 		}
3445 3445
 
3446 3446
 		$this->totals['tax'] = array(
@@ -3463,9 +3463,9 @@  discard block
 block discarded – undo
3463 3463
 		$fee       = 0;
3464 3464
 		$recurring = 0;
3465 3465
 
3466
-        foreach ( $fees as $data ) {
3466
+        foreach ($fees as $data) {
3467 3467
 
3468
-			if ( $data['recurring'] ) {
3468
+			if ($data['recurring']) {
3469 3469
 				$recurring += $data['amount'];
3470 3470
 			} else {
3471 3471
 				$fee += $data['amount'];
@@ -3473,10 +3473,10 @@  discard block
 block discarded – undo
3473 3473
 
3474 3474
 		}
3475 3475
 
3476
-        if ( $this->is_renewal() ) {
3477
-			$this->set_total_fees( $recurring );
3476
+        if ($this->is_renewal()) {
3477
+			$this->set_total_fees($recurring);
3478 3478
 		} else {
3479
-			$this->set_total_fees( $fee );
3479
+			$this->set_total_fees($fee);
3480 3480
 		}
3481 3481
 
3482 3482
 		$this->totals['fee'] = array(
@@ -3484,7 +3484,7 @@  discard block
 block discarded – undo
3484 3484
 			'recurring' => $recurring,
3485 3485
 		);
3486 3486
 
3487
-        $this->set_total_fees( $fee );
3487
+        $this->set_total_fees($fee);
3488 3488
         return $this->is_renewal() ? $recurring : $fee;
3489 3489
     }
3490 3490
 
@@ -3505,9 +3505,9 @@  discard block
 block discarded – undo
3505 3505
 	/**
3506 3506
 	 * @deprecated
3507 3507
 	 */
3508
-    public function recalculate_totals( $temp = false ) {
3509
-        $this->update_items( $temp );
3510
-        $this->save( true );
3508
+    public function recalculate_totals($temp = false) {
3509
+        $this->update_items($temp);
3510
+        $this->save(true);
3511 3511
         return $this;
3512 3512
     }
3513 3513
 
@@ -3525,36 +3525,36 @@  discard block
 block discarded – undo
3525 3525
 	 * @return int|false The new note's ID on success, false on failure.
3526 3526
      *
3527 3527
      */
3528
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3528
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3529 3529
 
3530 3530
         // Bail if no note specified or this invoice is not yet saved.
3531
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3531
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3532 3532
             return false;
3533 3533
         }
3534 3534
 
3535 3535
 		// If this is an admin comment or it has been added by the user.
3536
-		if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3537
-			$user         = get_user_by( 'id', get_current_user_id() );
3536
+		if (is_user_logged_in() && (wpinv_current_user_can_manage_invoicing() || $added_by_user)) {
3537
+			$user = get_user_by('id', get_current_user_id());
3538 3538
             $author       = $user->display_name;
3539 3539
             $author_email = $user->user_email;
3540 3540
 		} 
3541 3541
 
3542
-		if ( $system ) {
3543
-			$author       = 'System';
3542
+		if ($system) {
3543
+			$author = 'System';
3544 3544
             $author_email = '[email protected]';
3545 3545
 		}
3546 3546
 
3547
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3547
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3548 3548
 
3549 3549
 	}
3550 3550
 
3551 3551
 	/**
3552 3552
      * Generates a unique key for the invoice.
3553 3553
      */
3554
-    public function generate_key( $string = '' ) {
3555
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3554
+    public function generate_key($string = '') {
3555
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3556 3556
         return strtolower(
3557
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3557
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3558 3558
         );
3559 3559
     }
3560 3560
 
@@ -3564,11 +3564,11 @@  discard block
 block discarded – undo
3564 3564
     public function generate_number() {
3565 3565
         $number = $this->get_id();
3566 3566
 
3567
-        if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) {
3568
-            $number = wpinv_get_next_invoice_number( $this->post_type );
3567
+        if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) {
3568
+            $number = wpinv_get_next_invoice_number($this->post_type);
3569 3569
         }
3570 3570
 
3571
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3571
+		$number = wpinv_format_invoice_number($number, $this->post_type);
3572 3572
 
3573 3573
 		return $number;
3574 3574
 	}
@@ -3582,47 +3582,47 @@  discard block
 block discarded – undo
3582 3582
 		// Reset status transition variable.
3583 3583
 		$this->status_transition = false;
3584 3584
 
3585
-		if ( $status_transition ) {
3585
+		if ($status_transition) {
3586 3586
 			try {
3587 3587
 
3588 3588
 				// Fire a hook for the status change.
3589
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3589
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
3590 3590
 
3591 3591
 				// @deprecated this is deprecated and will be removed in the future.
3592
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3592
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3593 3593
 
3594
-				if ( ! empty( $status_transition['from'] ) ) {
3594
+				if (!empty($status_transition['from'])) {
3595 3595
 
3596 3596
 					/* translators: 1: old invoice status 2: new invoice status */
3597
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3597
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3598 3598
 
3599 3599
 					// Fire another hook.
3600
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3601
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3600
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
3601
+					do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this);
3602 3602
 
3603 3603
 					// @deprecated this is deprecated and will be removed in the future.
3604
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3604
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3605 3605
 
3606 3606
 					// Note the transition occurred.
3607
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3607
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3608 3608
 
3609 3609
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3610 3610
 					if (
3611
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3612
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3611
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3612
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3613 3613
 					) {
3614
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3614
+						do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition);
3615 3615
 					}
3616 3616
 				} else {
3617 3617
 					/* translators: %s: new invoice status */
3618
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3618
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3619 3619
 
3620 3620
 					// Note the transition occurred.
3621
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3621
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3622 3622
 
3623 3623
 				}
3624
-			} catch ( Exception $e ) {
3625
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3624
+			} catch (Exception $e) {
3625
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3626 3626
 			}
3627 3627
 		}
3628 3628
 	}
@@ -3630,13 +3630,13 @@  discard block
 block discarded – undo
3630 3630
 	/**
3631 3631
 	 * Updates an invoice status.
3632 3632
 	 */
3633
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3633
+	public function update_status($new_status = false, $note = '', $manual = false) {
3634 3634
 
3635 3635
 		// Fires before updating a status.
3636
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3636
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3637 3637
 
3638 3638
 		// Update the status.
3639
-		$this->set_status( $new_status, $note, $manual );
3639
+		$this->set_status($new_status, $note, $manual);
3640 3640
 
3641 3641
 		// Save the order.
3642 3642
 		return $this->save();
@@ -3647,18 +3647,18 @@  discard block
 block discarded – undo
3647 3647
 	 * @deprecated
3648 3648
 	 */
3649 3649
 	public function refresh_item_ids() {
3650
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3651
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3650
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3651
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3652 3652
 	}
3653 3653
 
3654 3654
 	/**
3655 3655
 	 * @deprecated
3656 3656
 	 */
3657
-	public function update_items( $temp = false ) {
3657
+	public function update_items($temp = false) {
3658 3658
 
3659
-		$this->set_items( $this->get_items() );
3659
+		$this->set_items($this->get_items());
3660 3660
 
3661
-		if ( ! $temp ) {
3661
+		if (!$temp) {
3662 3662
 			$this->save();
3663 3663
 		}
3664 3664
 
@@ -3672,11 +3672,11 @@  discard block
 block discarded – undo
3672 3672
 
3673 3673
         $discount_code = $this->get_discount_code();
3674 3674
 
3675
-        if ( empty( $discount_code ) ) {
3675
+        if (empty($discount_code)) {
3676 3676
             return false;
3677 3677
         }
3678 3678
 
3679
-        $discount = wpinv_get_discount_obj( $discount_code );
3679
+        $discount = wpinv_get_discount_obj($discount_code);
3680 3680
 
3681 3681
         // Ensure it is active.
3682 3682
         return $discount->exists();
@@ -3687,7 +3687,7 @@  discard block
 block discarded – undo
3687 3687
 	 * Refunds an invoice.
3688 3688
 	 */
3689 3689
     public function refund() {
3690
-		$this->set_status( 'wpi-refunded' );
3690
+		$this->set_status('wpi-refunded');
3691 3691
         $this->save();
3692 3692
 	}
3693 3693
 
@@ -3696,56 +3696,56 @@  discard block
 block discarded – undo
3696 3696
 	 * 
3697 3697
 	 * @param string $transaction_id
3698 3698
 	 */
3699
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3699
+    public function mark_paid($transaction_id = null, $note = '') {
3700 3700
 
3701 3701
 		// Set the transaction id.
3702
-		if ( empty( $transaction_id ) ) {
3702
+		if (empty($transaction_id)) {
3703 3703
 			$transaction_id = $this->generate_key('trans_');
3704 3704
 		}
3705 3705
 
3706
-		if ( ! $this->get_transaction_id() ) {
3707
-			$this->set_transaction_id( $transaction_id );
3706
+		if (!$this->get_transaction_id()) {
3707
+			$this->set_transaction_id($transaction_id);
3708 3708
 		}
3709 3709
 
3710
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3710
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3711 3711
 			return $this->save();
3712 3712
 		}
3713 3713
 
3714 3714
 		// Set the completed date.
3715
-		$this->set_date_completed( current_time( 'mysql' ) );
3715
+		$this->set_date_completed(current_time('mysql'));
3716 3716
 
3717 3717
 		// Set the new status.
3718
-		if ( $this->is_renewal() ) {
3718
+		if ($this->is_renewal()) {
3719 3719
 
3720 3720
 			$_note = sprintf(
3721
-				__( 'Renewed via %s', 'invoicing' ),
3722
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3721
+				__('Renewed via %s', 'invoicing'),
3722
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3723 3723
 			);
3724 3724
 
3725
-			if ( 'none' == $this->get_gateway() ) {
3725
+			if ('none' == $this->get_gateway()) {
3726 3726
 				$_note = $note;
3727 3727
 			}
3728 3728
 
3729
-			$this->set_status( 'wpi-renewal', $_note );
3729
+			$this->set_status('wpi-renewal', $_note);
3730 3730
 
3731 3731
 		} else {
3732 3732
 
3733 3733
 			$_note = sprintf(
3734
-				__( 'Paid via %s', 'invoicing' ),
3735
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3734
+				__('Paid via %s', 'invoicing'),
3735
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3736 3736
 			);
3737 3737
 
3738
-			if ( 'none' == $this->get_gateway() ) {
3738
+			if ('none' == $this->get_gateway()) {
3739 3739
 				$_note = $note;
3740 3740
 			}
3741 3741
 
3742
-			$this->set_status( 'publish',$_note );
3742
+			$this->set_status('publish', $_note);
3743 3743
 
3744 3744
 		}
3745 3745
 
3746 3746
 		// Set checkout mode.
3747
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3748
-		$this->set_mode( $mode );
3747
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3748
+		$this->set_mode($mode);
3749 3749
 
3750 3750
 		// Save the invoice.
3751 3751
         $this->save();
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -7,86 +7,86 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_item_quantities_enabled() {
15
-    $ret = wpinv_get_option( 'item_quantities', true );
15
+    $ret = wpinv_get_option('item_quantities', true);
16 16
 
17
-    return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret );
17
+    return (bool) apply_filters('wpinv_item_quantities_enabled', $ret);
18 18
 }
19 19
 
20 20
 function wpinv_get_ip() {
21 21
     $ip = '127.0.0.1';
22 22
 
23
-    if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
24
-        $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
25
-    } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
26
-        $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
27
-    } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) {
28
-        $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
23
+    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
24
+        $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']);
25
+    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
26
+        $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']);
27
+    } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
28
+        $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']);
29 29
     }
30 30
 
31
-    return apply_filters( 'wpinv_get_ip', $ip );
31
+    return apply_filters('wpinv_get_ip', $ip);
32 32
 }
33 33
 
34 34
 function wpinv_get_user_agent() {
35
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
36
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
35
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
36
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
37 37
     } else {
38 38
         $user_agent = '';
39 39
     }
40 40
 
41
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
41
+    return apply_filters('wpinv_get_user_agent', $user_agent);
42 42
 }
43 43
 
44
-function wpinv_sanitize_amount( $amount, $decimals = NULL ) {
44
+function wpinv_sanitize_amount($amount, $decimals = NULL) {
45 45
     $is_negative   = false;
46 46
     $thousands_sep = wpinv_thousands_separator();
47 47
     $decimal_sep   = wpinv_decimal_separator();
48
-    if ( $decimals === NULL ) {
48
+    if ($decimals === NULL) {
49 49
         $decimals = wpinv_decimals();
50 50
     }
51 51
 
52 52
     // Sanitize the amount
53
-    if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) {
54
-        if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
55
-            $amount = str_replace( $thousands_sep, '', $amount );
56
-        } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) {
57
-            $amount = str_replace( '.', '', $amount );
53
+    if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) {
54
+        if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) {
55
+            $amount = str_replace($thousands_sep, '', $amount);
56
+        } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) {
57
+            $amount = str_replace('.', '', $amount);
58 58
         }
59 59
 
60
-        $amount = str_replace( $decimal_sep, '.', $amount );
61
-    } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
62
-        $amount = str_replace( $thousands_sep, '', $amount );
60
+        $amount = str_replace($decimal_sep, '.', $amount);
61
+    } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
62
+        $amount = str_replace($thousands_sep, '', $amount);
63 63
     }
64 64
 
65
-    if( $amount < 0 ) {
65
+    if ($amount < 0) {
66 66
         $is_negative = true;
67 67
     }
68 68
 
69
-    $amount   = preg_replace( '/[^0-9\.]/', '', $amount );
69
+    $amount   = preg_replace('/[^0-9\.]/', '', $amount);
70 70
 
71
-    $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount );
72
-    $amount   = number_format( (double) $amount, absint( $decimals ), '.', '' );
71
+    $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount);
72
+    $amount   = number_format((double) $amount, absint($decimals), '.', '');
73 73
 
74
-    if( $is_negative ) {
74
+    if ($is_negative) {
75 75
         $amount *= -1;
76 76
     }
77 77
 
78
-    return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals );
78
+    return apply_filters('wpinv_sanitize_amount', $amount, $decimals);
79 79
 }
80
-add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
80
+add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1);
81 81
 
82
-function wpinv_round_amount( $amount, $decimals = NULL ) {
83
-    if ( $decimals === NULL ) {
82
+function wpinv_round_amount($amount, $decimals = NULL) {
83
+    if ($decimals === NULL) {
84 84
         $decimals = wpinv_decimals();
85 85
     }
86 86
     
87
-    $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) );
87
+    $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals)));
88 88
 
89
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
89
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
90 90
 }
91 91
 
92 92
 /**
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
  * @since 1.0.19
96 96
  * @return array
97 97
  */
98
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
98
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
99 99
 	$invoice_statuses = array(
100
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
101
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
102
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
103
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
104
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
105
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
106
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
107
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
100
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
101
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
102
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
103
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
104
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
105
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
106
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
107
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
108 108
     );
109 109
 
110
-    if ( $draft ) {
111
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
110
+    if ($draft) {
111
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
112 112
     }
113 113
 
114
-    if ( $trashed ) {
115
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
114
+    if ($trashed) {
115
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
116 116
     }
117 117
 
118
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
118
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
119 119
 }
120 120
 
121
-function wpinv_status_nicename( $status ) {
122
-    $statuses = wpinv_get_invoice_statuses( true, true );
123
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' );
121
+function wpinv_status_nicename($status) {
122
+    $statuses = wpinv_get_invoice_statuses(true, true);
123
+    $status   = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing');
124 124
 
125 125
     return $status;
126 126
 }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  * Retrieves the default currency code.
130 130
  */
131 131
 function wpinv_get_currency() {
132
-    return apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
132
+    return apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
133 133
 }
134 134
 
135 135
 /**
@@ -137,61 +137,61 @@  discard block
 block discarded – undo
137 137
  * 
138 138
  * @param string|null $currency The currency code. Defaults to the default currency.
139 139
  */
140
-function wpinv_currency_symbol( $currency = null ) {
140
+function wpinv_currency_symbol($currency = null) {
141 141
 
142 142
     // Prepare the currency.
143
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
143
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
144 144
 
145 145
     // Fetch all symbols.
146 146
     $symbols = wpinv_get_currency_symbols();
147 147
 
148 148
     // Fetch this currencies symbol.
149
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
149
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
150 150
 
151 151
     // Filter the symbol.
152
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
152
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
153 153
 }
154 154
 
155 155
 function wpinv_currency_position() {
156
-    $position = wpinv_get_option( 'currency_position', 'left' );
156
+    $position = wpinv_get_option('currency_position', 'left');
157 157
     
158
-    return apply_filters( 'wpinv_currency_position', $position );
158
+    return apply_filters('wpinv_currency_position', $position);
159 159
 }
160 160
 
161 161
 function wpinv_thousands_separator() {
162
-    $thousand_sep = wpinv_get_option( 'thousands_separator', ',' );
162
+    $thousand_sep = wpinv_get_option('thousands_separator', ',');
163 163
     
164
-    return apply_filters( 'wpinv_thousands_separator', $thousand_sep );
164
+    return apply_filters('wpinv_thousands_separator', $thousand_sep);
165 165
 }
166 166
 
167 167
 function wpinv_decimal_separator() {
168
-    $decimal_sep = wpinv_get_option( 'decimal_separator', '.' );
168
+    $decimal_sep = wpinv_get_option('decimal_separator', '.');
169 169
     
170
-    return apply_filters( 'wpinv_decimal_separator', $decimal_sep );
170
+    return apply_filters('wpinv_decimal_separator', $decimal_sep);
171 171
 }
172 172
 
173 173
 function wpinv_decimals() {
174
-    $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) );
174
+    $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2));
175 175
     
176
-    return absint( $decimals );
176
+    return absint($decimals);
177 177
 }
178 178
 
179 179
 /**
180 180
  * Retrieves a list of all supported currencies.
181 181
  */
182 182
 function wpinv_get_currencies() {
183
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
183
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
184 184
 }
185 185
 
186 186
 /**
187 187
  * Retrieves a list of all currency symbols.
188 188
  */
189 189
 function wpinv_get_currency_symbols() {
190
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
190
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
191 191
 }
192 192
 
193
-function wpinv_price( $amount = '', $currency = '' ) {
194
-    if( empty( $currency ) ) {
193
+function wpinv_price($amount = '', $currency = '') {
194
+    if (empty($currency)) {
195 195
         $currency = wpinv_get_currency();
196 196
     }
197 197
 
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 
200 200
     $negative = $amount < 0;
201 201
 
202
-    if ( $negative ) {
203
-        $amount = substr( $amount, 1 );
202
+    if ($negative) {
203
+        $amount = substr($amount, 1);
204 204
     }
205 205
 
206
-    $symbol = wpinv_currency_symbol( $currency );
206
+    $symbol = wpinv_currency_symbol($currency);
207 207
 
208
-    if ( $position == 'left' || $position == 'left_space' ) {
209
-        switch ( $currency ) {
208
+    if ($position == 'left' || $position == 'left_space') {
209
+        switch ($currency) {
210 210
             case "GBP" :
211 211
             case "BRL" :
212 212
             case "EUR" :
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
             case "NZD" :
219 219
             case "SGD" :
220 220
             case "JPY" :
221
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
221
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
222 222
                 break;
223 223
             default :
224 224
                 //$price = $currency . ' ' . $amount;
225
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
225
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
226 226
                 break;
227 227
         }
228 228
     } else {
229
-        switch ( $currency ) {
229
+        switch ($currency) {
230 230
             case "GBP" :
231 231
             case "BRL" :
232 232
             case "EUR" :
@@ -237,83 +237,83 @@  discard block
 block discarded – undo
237 237
             case "MXN" :
238 238
             case "SGD" :
239 239
             case "JPY" :
240
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
240
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
241 241
                 break;
242 242
             default :
243 243
                 //$price = $amount . ' ' . $currency;
244
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
244
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
245 245
                 break;
246 246
         }
247 247
     }
248 248
     
249
-    if ( $negative ) {
249
+    if ($negative) {
250 250
         $price = '-' . $price;
251 251
     }
252 252
     
253
-    $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount );
253
+    $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount);
254 254
 
255 255
     return $price;
256 256
 }
257 257
 
258
-function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) {
258
+function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) {
259 259
     $thousands_sep = wpinv_thousands_separator();
260 260
     $decimal_sep   = wpinv_decimal_separator();
261 261
 
262
-    if ( $decimals === NULL ) {
262
+    if ($decimals === NULL) {
263 263
         $decimals = wpinv_decimals();
264 264
     }
265 265
 
266
-    if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) {
267
-        $whole = substr( $amount, 0, $sep_found );
268
-        $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
266
+    if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) {
267
+        $whole = substr($amount, 0, $sep_found);
268
+        $part = substr($amount, $sep_found + 1, (strlen($amount) - 1));
269 269
         $amount = $whole . '.' . $part;
270 270
     }
271 271
 
272
-    if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
273
-        $amount = str_replace( ',', '', $amount );
272
+    if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
273
+        $amount = str_replace(',', '', $amount);
274 274
     }
275 275
 
276
-    if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
277
-        $amount = str_replace( ' ', '', $amount );
276
+    if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) {
277
+        $amount = str_replace(' ', '', $amount);
278 278
     }
279 279
 
280
-    if ( empty( $amount ) ) {
280
+    if (empty($amount)) {
281 281
         $amount = 0;
282 282
     }
283 283
     
284
-    $decimals  = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate );
285
-    $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep );
284
+    $decimals  = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate);
285
+    $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep);
286 286
     
287
-    if ( $calculate ) {
288
-        if ( $thousands_sep === "," ) {
289
-            $formatted = str_replace( ",", "", $formatted );
287
+    if ($calculate) {
288
+        if ($thousands_sep === ",") {
289
+            $formatted = str_replace(",", "", $formatted);
290 290
         }
291 291
         
292
-        if ( $decimal_sep === "," ) {
293
-            $formatted = str_replace( ",", ".", $formatted );
292
+        if ($decimal_sep === ",") {
293
+            $formatted = str_replace(",", ".", $formatted);
294 294
         }
295 295
     }
296 296
 
297
-    return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate );
297
+    return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate);
298 298
 }
299
-add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
299
+add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1);
300 300
 
301
-function wpinv_sanitize_key( $key ) {
301
+function wpinv_sanitize_key($key) {
302 302
     $raw_key = $key;
303
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
303
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
304 304
 
305
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
305
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
306 306
 }
307 307
 
308
-function wpinv_get_file_extension( $str ) {
309
-    $parts = explode( '.', $str );
310
-    return end( $parts );
308
+function wpinv_get_file_extension($str) {
309
+    $parts = explode('.', $str);
310
+    return end($parts);
311 311
 }
312 312
 
313
-function wpinv_string_is_image_url( $str ) {
314
-    $ext = wpinv_get_file_extension( $str );
313
+function wpinv_string_is_image_url($str) {
314
+    $ext = wpinv_get_file_extension($str);
315 315
 
316
-    switch ( strtolower( $ext ) ) {
316
+    switch (strtolower($ext)) {
317 317
         case 'jpeg';
318 318
         case 'jpg';
319 319
             $return = true;
@@ -329,33 +329,33 @@  discard block
 block discarded – undo
329 329
             break;
330 330
     }
331 331
 
332
-    return (bool)apply_filters( 'wpinv_string_is_image', $return, $str );
332
+    return (bool) apply_filters('wpinv_string_is_image', $return, $str);
333 333
 }
334 334
 
335
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
336
-    $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG );
335
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
336
+    $should_log = apply_filters('wpinv_log_errors', WP_DEBUG);
337 337
     
338
-    if ( true === $should_log ) {
338
+    if (true === $should_log) {
339 339
         $label = '';
340
-        if ( $file && $file !== '' ) {
341
-            $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' );
340
+        if ($file && $file !== '') {
341
+            $label .= basename($file) . ($line ? '(' . $line . ')' : '');
342 342
         }
343 343
         
344
-        if ( $title && $title !== '' ) {
344
+        if ($title && $title !== '') {
345 345
             $label = $label !== '' ? $label . ' ' : '';
346 346
             $label .= $title . ' ';
347 347
         }
348 348
         
349
-        $label = $label !== '' ? trim( $label ) . ' : ' : '';
349
+        $label = $label !== '' ? trim($label) . ' : ' : '';
350 350
         
351
-        if ( is_array( $log ) || is_object( $log ) ) {
352
-            error_log( $label . print_r( $log, true ) );
351
+        if (is_array($log) || is_object($log)) {
352
+            error_log($label . print_r($log, true));
353 353
         } else {
354
-            error_log( $label . $log );
354
+            error_log($label . $log);
355 355
         }
356 356
 
357
-        error_log( wp_debug_backtrace_summary() );
358
-        if ( $exit ) {
357
+        error_log(wp_debug_backtrace_summary());
358
+        if ($exit) {
359 359
             exit;
360 360
         }
361 361
     }
@@ -363,32 +363,32 @@  discard block
 block discarded – undo
363 363
 
364 364
 function wpinv_is_ajax_disabled() {
365 365
     $retval = false;
366
-    return apply_filters( 'wpinv_is_ajax_disabled', $retval );
366
+    return apply_filters('wpinv_is_ajax_disabled', $retval);
367 367
 }
368 368
 
369
-function wpinv_get_current_page_url( $nocache = false ) {
369
+function wpinv_get_current_page_url($nocache = false) {
370 370
     global $wp;
371 371
 
372
-    if ( get_option( 'permalink_structure' ) ) {
373
-        $base = trailingslashit( home_url( $wp->request ) );
372
+    if (get_option('permalink_structure')) {
373
+        $base = trailingslashit(home_url($wp->request));
374 374
     } else {
375
-        $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
376
-        $base = remove_query_arg( array( 'post_type', 'name' ), $base );
375
+        $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
376
+        $base = remove_query_arg(array('post_type', 'name'), $base);
377 377
     }
378 378
 
379 379
     $scheme = is_ssl() ? 'https' : 'http';
380
-    $uri    = set_url_scheme( $base, $scheme );
380
+    $uri    = set_url_scheme($base, $scheme);
381 381
 
382
-    if ( is_front_page() ) {
383
-        $uri = home_url( '/' );
384
-    } elseif ( wpinv_is_checkout( array(), false ) ) {
382
+    if (is_front_page()) {
383
+        $uri = home_url('/');
384
+    } elseif (wpinv_is_checkout(array(), false)) {
385 385
         $uri = wpinv_get_checkout_uri();
386 386
     }
387 387
 
388
-    $uri = apply_filters( 'wpinv_get_current_page_url', $uri );
388
+    $uri = apply_filters('wpinv_get_current_page_url', $uri);
389 389
 
390
-    if ( $nocache ) {
391
-        $uri = wpinv_add_cache_busting( $uri );
390
+    if ($nocache) {
391
+        $uri = wpinv_add_cache_busting($uri);
392 392
     }
393 393
 
394 394
     return $uri;
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
  * @param string $name  Constant name.
402 402
  * @param mixed  $value Value.
403 403
  */
404
-function getpaid_maybe_define_constant( $name, $value ) {
405
-	if ( ! defined( $name ) ) {
406
-		define( $name, $value );
404
+function getpaid_maybe_define_constant($name, $value) {
405
+	if (!defined($name)) {
406
+		define($name, $value);
407 407
 	}
408 408
 }
409 409
 
410 410
 function wpinv_get_php_arg_separator_output() {
411
-	return ini_get( 'arg_separator.output' );
411
+	return ini_get('arg_separator.output');
412 412
 }
413 413
 
414
-function wpinv_rgb_from_hex( $color ) {
415
-    $color = str_replace( '#', '', $color );
414
+function wpinv_rgb_from_hex($color) {
415
+    $color = str_replace('#', '', $color);
416 416
 
417 417
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
418
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
419
-    if ( empty( $color ) ) {
418
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
419
+    if (empty($color)) {
420 420
         return NULL;
421 421
     }
422 422
 
423
-    $color = str_split( $color );
423
+    $color = str_split($color);
424 424
 
425 425
     $rgb      = array();
426
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
427
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
428
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
426
+    $rgb['R'] = hexdec($color[0] . $color[1]);
427
+    $rgb['G'] = hexdec($color[2] . $color[3]);
428
+    $rgb['B'] = hexdec($color[4] . $color[5]);
429 429
 
430 430
     return $rgb;
431 431
 }
432 432
 
433
-function wpinv_hex_darker( $color, $factor = 30 ) {
434
-    $base  = wpinv_rgb_from_hex( $color );
433
+function wpinv_hex_darker($color, $factor = 30) {
434
+    $base  = wpinv_rgb_from_hex($color);
435 435
     $color = '#';
436 436
 
437
-    foreach ( $base as $k => $v ) {
437
+    foreach ($base as $k => $v) {
438 438
         $amount      = $v / 100;
439
-        $amount      = round( $amount * $factor );
439
+        $amount      = round($amount * $factor);
440 440
         $new_decimal = $v - $amount;
441 441
 
442
-        $new_hex_component = dechex( $new_decimal );
443
-        if ( strlen( $new_hex_component ) < 2 ) {
442
+        $new_hex_component = dechex($new_decimal);
443
+        if (strlen($new_hex_component) < 2) {
444 444
             $new_hex_component = "0" . $new_hex_component;
445 445
         }
446 446
         $color .= $new_hex_component;
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
     return $color;
450 450
 }
451 451
 
452
-function wpinv_hex_lighter( $color, $factor = 30 ) {
453
-    $base  = wpinv_rgb_from_hex( $color );
452
+function wpinv_hex_lighter($color, $factor = 30) {
453
+    $base  = wpinv_rgb_from_hex($color);
454 454
     $color = '#';
455 455
 
456
-    foreach ( $base as $k => $v ) {
456
+    foreach ($base as $k => $v) {
457 457
         $amount      = 255 - $v;
458 458
         $amount      = $amount / 100;
459
-        $amount      = round( $amount * $factor );
459
+        $amount      = round($amount * $factor);
460 460
         $new_decimal = $v + $amount;
461 461
 
462
-        $new_hex_component = dechex( $new_decimal );
463
-        if ( strlen( $new_hex_component ) < 2 ) {
462
+        $new_hex_component = dechex($new_decimal);
463
+        if (strlen($new_hex_component) < 2) {
464 464
             $new_hex_component = "0" . $new_hex_component;
465 465
         }
466 466
         $color .= $new_hex_component;
@@ -469,22 +469,22 @@  discard block
 block discarded – undo
469 469
     return $color;
470 470
 }
471 471
 
472
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
473
-    $hex = str_replace( '#', '', $color );
472
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
473
+    $hex = str_replace('#', '', $color);
474 474
 
475
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
476
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
477
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
475
+    $c_r = hexdec(substr($hex, 0, 2));
476
+    $c_g = hexdec(substr($hex, 2, 2));
477
+    $c_b = hexdec(substr($hex, 4, 2));
478 478
 
479
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
479
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
480 480
 
481 481
     return $brightness > 155 ? $dark : $light;
482 482
 }
483 483
 
484
-function wpinv_format_hex( $hex ) {
485
-    $hex = trim( str_replace( '#', '', $hex ) );
484
+function wpinv_format_hex($hex) {
485
+    $hex = trim(str_replace('#', '', $hex));
486 486
 
487
-    if ( strlen( $hex ) == 3 ) {
487
+    if (strlen($hex) == 3) {
488 488
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
489 489
     }
490 490
 
@@ -504,12 +504,12 @@  discard block
 block discarded – undo
504 504
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
505 505
  * @return string
506 506
  */
507
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
508
-    if ( function_exists( 'mb_strimwidth' ) ) {
509
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
507
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
508
+    if (function_exists('mb_strimwidth')) {
509
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
510 510
     }
511 511
     
512
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
512
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
513 513
 }
514 514
 
515 515
 /**
@@ -521,28 +521,28 @@  discard block
 block discarded – undo
521 521
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
522 522
  * @return int Returns the number of characters in string.
523 523
  */
524
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
525
-    if ( function_exists( 'mb_strlen' ) ) {
526
-        return mb_strlen( $str, $encoding );
524
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
525
+    if (function_exists('mb_strlen')) {
526
+        return mb_strlen($str, $encoding);
527 527
     }
528 528
         
529
-    return strlen( $str );
529
+    return strlen($str);
530 530
 }
531 531
 
532
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
533
-    if ( function_exists( 'mb_strtolower' ) ) {
534
-        return mb_strtolower( $str, $encoding );
532
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
533
+    if (function_exists('mb_strtolower')) {
534
+        return mb_strtolower($str, $encoding);
535 535
     }
536 536
     
537
-    return strtolower( $str );
537
+    return strtolower($str);
538 538
 }
539 539
 
540
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
541
-    if ( function_exists( 'mb_strtoupper' ) ) {
542
-        return mb_strtoupper( $str, $encoding );
540
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
541
+    if (function_exists('mb_strtoupper')) {
542
+        return mb_strtoupper($str, $encoding);
543 543
     }
544 544
     
545
-    return strtoupper( $str );
545
+    return strtoupper($str);
546 546
 }
547 547
 
548 548
 /**
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
557 557
  * @return int Returns the position of the first occurrence of search in the string.
558 558
  */
559
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
560
-    if ( function_exists( 'mb_strpos' ) ) {
561
-        return mb_strpos( $str, $find, $offset, $encoding );
559
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
560
+    if (function_exists('mb_strpos')) {
561
+        return mb_strpos($str, $find, $offset, $encoding);
562 562
     }
563 563
         
564
-    return strpos( $str, $find, $offset );
564
+    return strpos($str, $find, $offset);
565 565
 }
566 566
 
567 567
 /**
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
576 576
  * @return int Returns the position of the last occurrence of search.
577 577
  */
578
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
579
-    if ( function_exists( 'mb_strrpos' ) ) {
580
-        return mb_strrpos( $str, $find, $offset, $encoding );
578
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
579
+    if (function_exists('mb_strrpos')) {
580
+        return mb_strrpos($str, $find, $offset, $encoding);
581 581
     }
582 582
         
583
-    return strrpos( $str, $find, $offset );
583
+    return strrpos($str, $find, $offset);
584 584
 }
585 585
 
586 586
 /**
@@ -595,16 +595,16 @@  discard block
 block discarded – undo
595 595
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
596 596
  * @return string
597 597
  */
598
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
599
-    if ( function_exists( 'mb_substr' ) ) {
600
-        if ( $length === null ) {
601
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
598
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
599
+    if (function_exists('mb_substr')) {
600
+        if ($length === null) {
601
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
602 602
         } else {
603
-            return mb_substr( $str, $start, $length, $encoding );
603
+            return mb_substr($str, $start, $length, $encoding);
604 604
         }
605 605
     }
606 606
         
607
-    return substr( $str, $start, $length );
607
+    return substr($str, $start, $length);
608 608
 }
609 609
 
610 610
 /**
@@ -616,48 +616,48 @@  discard block
 block discarded – undo
616 616
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
617 617
  * @return string The width of string.
618 618
  */
619
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
620
-    if ( function_exists( 'mb_strwidth' ) ) {
621
-        return mb_strwidth( $str, $encoding );
619
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
620
+    if (function_exists('mb_strwidth')) {
621
+        return mb_strwidth($str, $encoding);
622 622
     }
623 623
     
624
-    return wpinv_utf8_strlen( $str, $encoding );
624
+    return wpinv_utf8_strlen($str, $encoding);
625 625
 }
626 626
 
627
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
628
-    if ( function_exists( 'mb_strlen' ) ) {
629
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
627
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
628
+    if (function_exists('mb_strlen')) {
629
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
630 630
         $str_end = "";
631 631
         
632
-        if ( $lower_str_end ) {
633
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
632
+        if ($lower_str_end) {
633
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
634 634
         } else {
635
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
635
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
636 636
         }
637 637
 
638 638
         return $first_letter . $str_end;
639 639
     }
640 640
     
641
-    return ucfirst( $str );
641
+    return ucfirst($str);
642 642
 }
643 643
 
644
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
645
-    if ( function_exists( 'mb_convert_case' ) ) {
646
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
644
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
645
+    if (function_exists('mb_convert_case')) {
646
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
647 647
     }
648 648
     
649
-    return ucwords( $str );
649
+    return ucwords($str);
650 650
 }
651 651
 
652
-function wpinv_period_in_days( $period, $unit ) {
653
-    $period = absint( $period );
652
+function wpinv_period_in_days($period, $unit) {
653
+    $period = absint($period);
654 654
     
655
-    if ( $period > 0 ) {
656
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
655
+    if ($period > 0) {
656
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
657 657
             $period = $period * 7;
658
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
658
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
659 659
             $period = $period * 30;
660
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
660
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
661 661
             $period = $period * 365;
662 662
         }
663 663
     }
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
     return $period;
666 666
 }
667 667
 
668
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
669
-    if ( function_exists( 'cal_days_in_month' ) ) {
670
-        return cal_days_in_month( $calendar, $month, $year );
668
+function wpinv_cal_days_in_month($calendar, $month, $year) {
669
+    if (function_exists('cal_days_in_month')) {
670
+        return cal_days_in_month($calendar, $month, $year);
671 671
     }
672 672
 
673 673
     // Fallback in case the calendar extension is not loaded in PHP
674 674
     // Only supports Gregorian calendar
675
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
675
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
676 676
 }
677 677
 
678 678
 /**
@@ -683,11 +683,11 @@  discard block
 block discarded – undo
683 683
  *
684 684
  * @return string
685 685
  */
686
-function wpi_help_tip( $tip, $allow_html = false ) {
687
-    if ( $allow_html ) {
688
-        $tip = wpi_sanitize_tooltip( $tip );
686
+function wpi_help_tip($tip, $allow_html = false) {
687
+    if ($allow_html) {
688
+        $tip = wpi_sanitize_tooltip($tip);
689 689
     } else {
690
-        $tip = esc_attr( $tip );
690
+        $tip = esc_attr($tip);
691 691
     }
692 692
 
693 693
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -701,8 +701,8 @@  discard block
 block discarded – undo
701 701
  * @param string $var
702 702
  * @return string
703 703
  */
704
-function wpi_sanitize_tooltip( $var ) {
705
-    return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
704
+function wpi_sanitize_tooltip($var) {
705
+    return htmlspecialchars(wp_kses(html_entity_decode($var), array(
706 706
         'br'     => array(),
707 707
         'em'     => array(),
708 708
         'strong' => array(),
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
         'li'     => array(),
713 713
         'ol'     => array(),
714 714
         'p'      => array(),
715
-    ) ) );
715
+    )));
716 716
 }
717 717
 
718 718
 /**
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
  */
723 723
 function wpinv_get_screen_ids() {
724 724
 
725
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
725
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
726 726
 
727 727
     $screen_ids = array(
728 728
         'toplevel_page_' . $screen_id,
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
         'invoicing_page_wpi-addons',
741 741
     );
742 742
 
743
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
743
+    return apply_filters('wpinv_screen_ids', $screen_ids);
744 744
 }
745 745
 
746 746
 /**
@@ -751,14 +751,14 @@  discard block
 block discarded – undo
751 751
  * @param array|string $list List of values.
752 752
  * @return array Sanitized array of values.
753 753
  */
754
-function wpinv_parse_list( $list ) {
754
+function wpinv_parse_list($list) {
755 755
 
756
-    if ( empty( $list ) ) {
756
+    if (empty($list)) {
757 757
         $list = array();
758 758
     }
759 759
 
760
-	if ( ! is_array( $list ) ) {
761
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
760
+	if (!is_array($list)) {
761
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
762 762
 	}
763 763
 
764 764
 	return $list;
@@ -772,16 +772,16 @@  discard block
 block discarded – undo
772 772
  * @param string $key Type of data to fetch.
773 773
  * @return mixed Fetched data.
774 774
  */
775
-function wpinv_get_data( $key ) {
775
+function wpinv_get_data($key) {
776 776
 
777 777
     // Try fetching it from the cache.
778
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
779
-    if( $data ) {
778
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
779
+    if ($data) {
780 780
         return $data;
781 781
     }
782 782
 
783
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
784
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
783
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
784
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
785 785
 
786 786
 	return $data;
787 787
 }
@@ -795,10 +795,10 @@  discard block
 block discarded – undo
795 795
  * @param bool $first_empty Whether or not the first item in the list should be empty
796 796
  * @return mixed Fetched data.
797 797
  */
798
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
798
+function wpinv_maybe_add_empty_option($options, $first_empty) {
799 799
 
800
-    if ( ! empty( $options ) && $first_empty ) {
801
-        return array_merge( array( '' => '' ), $options );
800
+    if (!empty($options) && $first_empty) {
801
+        return array_merge(array('' => ''), $options);
802 802
     }
803 803
     return $options;
804 804
 
@@ -810,21 +810,21 @@  discard block
 block discarded – undo
810 810
  * @param mixed $var Data to sanitize.
811 811
  * @return string|array
812 812
  */
813
-function wpinv_clean( $var ) {
813
+function wpinv_clean($var) {
814 814
 
815
-	if ( is_array( $var ) ) {
816
-		return array_map( 'wpinv_clean', $var );
815
+	if (is_array($var)) {
816
+		return array_map('wpinv_clean', $var);
817 817
     }
818 818
 
819
-    if ( is_object( $var ) ) {
820
-		$object_vars = get_object_vars( $var );
821
-		foreach ( $object_vars as $property_name => $property_value ) {
822
-			$var->$property_name = wpinv_clean( $property_value );
819
+    if (is_object($var)) {
820
+		$object_vars = get_object_vars($var);
821
+		foreach ($object_vars as $property_name => $property_value) {
822
+			$var->$property_name = wpinv_clean($property_value);
823 823
         }
824 824
         return $var;
825 825
 	}
826 826
     
827
-    return is_string( $var ) ? sanitize_text_field( $var ) : $var;
827
+    return is_string($var) ? sanitize_text_field($var) : $var;
828 828
 }
829 829
 
830 830
 /**
@@ -833,43 +833,43 @@  discard block
 block discarded – undo
833 833
  * @param string $str Data to convert.
834 834
  * @return string|array
835 835
  */
836
-function getpaid_convert_price_string_to_options( $str ) {
836
+function getpaid_convert_price_string_to_options($str) {
837 837
 
838
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
839
-    $options     = array();
838
+	$raw_options = array_map('trim', explode(',', $str));
839
+    $options = array();
840 840
 
841
-    foreach ( $raw_options as $option ) {
841
+    foreach ($raw_options as $option) {
842 842
 
843
-        if ( '' == $option ) {
843
+        if ('' == $option) {
844 844
             continue;
845 845
         }
846 846
 
847
-        $option = array_map( 'trim', explode( '|', $option ) );
847
+        $option = array_map('trim', explode('|', $option));
848 848
 
849 849
         $price = null;
850 850
         $label = null;
851 851
 
852
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
853
-            $label  = $option[0];
852
+        if (isset($option[0]) && '' != $option[0]) {
853
+            $label = $option[0];
854 854
         }
855 855
 
856
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
856
+        if (isset($option[1]) && '' != $option[1]) {
857 857
             $price = $option[1];
858 858
         }
859 859
 
860
-        if ( ! isset( $price ) ) {
860
+        if (!isset($price)) {
861 861
             $price = $label;
862 862
         }
863 863
 
864
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
864
+        if (!isset($price) || !is_numeric($price)) {
865 865
             continue;
866 866
         }
867 867
 
868
-        if ( ! isset( $label ) ) {
868
+        if (!isset($label)) {
869 869
             $label = $price;
870 870
         }
871 871
 
872
-        $options[ $price ] = $label;
872
+        $options[$price] = $label;
873 873
     }
874 874
 
875 875
     return $options;
@@ -878,23 +878,23 @@  discard block
 block discarded – undo
878 878
 /**
879 879
  * Returns the help tip.
880 880
  */
881
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
882
-    $additional_classes = sanitize_html_class( $additional_classes );
883
-    $tip                = esc_attr__( $tip );
881
+function getpaid_get_help_tip($tip, $additional_classes = '') {
882
+    $additional_classes = sanitize_html_class($additional_classes);
883
+    $tip                = esc_attr__($tip);
884 884
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
885 885
 }
886 886
 
887 887
 /**
888 888
  * Formats a date
889 889
  */
890
-function getpaid_format_date( $date ) {
890
+function getpaid_format_date($date) {
891 891
 
892
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
892
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
893 893
         return '';
894 894
     }
895 895
 
896 896
 
897
-    return date_i18n( get_option( 'date_format' ), strtotime( $date ) );
897
+    return date_i18n(get_option('date_format'), strtotime($date));
898 898
 
899 899
 }
900 900
 
@@ -905,16 +905,16 @@  discard block
 block discarded – undo
905 905
  * @param  integer $limit Limit size in characters.
906 906
  * @return string
907 907
  */
908
-function getpaid_limit_length( $string, $limit ) {
908
+function getpaid_limit_length($string, $limit) {
909 909
     $str_limit = $limit - 3;
910 910
 
911
-	if ( function_exists( 'mb_strimwidth' ) ) {
912
-		if ( mb_strlen( $string ) > $limit ) {
913
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
911
+	if (function_exists('mb_strimwidth')) {
912
+		if (mb_strlen($string) > $limit) {
913
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
914 914
 		}
915 915
 	} else {
916
-		if ( strlen( $string ) > $limit ) {
917
-			$string = substr( $string, 0, $str_limit ) . '...';
916
+		if (strlen($string) > $limit) {
917
+			$string = substr($string, 0, $str_limit) . '...';
918 918
 		}
919 919
 	}
920 920
     return $string;
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
  * @since 1.0.19
929 929
  */
930 930
 function getpaid_api() {
931
-    return getpaid()->get( 'api' );
931
+    return getpaid()->get('api');
932 932
 }
933 933
 
934 934
 /**
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
  * @since 1.0.19
939 939
  */
940 940
 function getpaid_post_types() {
941
-    return getpaid()->get( 'post_types' );
941
+    return getpaid()->get('post_types');
942 942
 }
943 943
 
944 944
 /**
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
  * @since 1.0.19
949 949
  */
950 950
 function getpaid_session() {
951
-    return getpaid()->get( 'session' );
951
+    return getpaid()->get('session');
952 952
 }
953 953
 
954 954
 /**
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
  * @since 1.0.19
959 959
  */
960 960
 function getpaid_notes() {
961
-    return getpaid()->get( 'notes' );
961
+    return getpaid()->get('notes');
962 962
 }
963 963
 
964 964
 /**
@@ -970,28 +970,28 @@  discard block
 block discarded – undo
970 970
  * 
971 971
  * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query
972 972
  */
973
-function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
973
+function getpaid_get_subscriptions($args = array(), $return = 'results') {
974 974
 
975
-    $args = wp_parse_args( $args, array() );
975
+    $args = wp_parse_args($args, array());
976 976
 
977 977
     // Do not retrieve all fields if we just want the count.
978
-    if ( 'count' == $return ) {
978
+    if ('count' == $return) {
979 979
         $args['fields'] = 'id';
980 980
         $args['number'] = 1;
981 981
     }
982 982
 
983 983
     // Do not count all matches if we just want the results.
984
-    if ( 'results' == $return ) {
984
+    if ('results' == $return) {
985 985
         $args['count_total'] = false;
986 986
     }
987 987
 
988
-    $query = new GetPaid_Subscriptions_Query( $args );
988
+    $query = new GetPaid_Subscriptions_Query($args);
989 989
 
990
-    if ( 'results' == $return ) {
990
+    if ('results' == $return) {
991 991
         return $query->get_results();
992 992
     }
993 993
 
994
-    if ( 'count' == $return ) {
994
+    if ('count' == $return) {
995 995
         return $query->get_total();
996 996
     }
997 997
 
@@ -1008,13 +1008,13 @@  discard block
 block discarded – undo
1008 1008
     return apply_filters(
1009 1009
         'getpaid_get_subscription_statuses',
1010 1010
         array(
1011
-            'pending'    => __( 'Pending', 'invoicing' ),
1012
-            'trialling'  => __( 'Trialing', 'invoicing' ),
1013
-            'active'     => __( 'Active', 'invoicing' ),
1014
-            'failing'    => __( 'Failing', 'invoicing' ),
1015
-            'expired'    => __( 'Expired', 'invoicing' ),
1016
-            'completed'  => __( 'Complete', 'invoicing' ),
1017
-            'cancelled'  =>__( 'Cancelled', 'invoicing' ),
1011
+            'pending'    => __('Pending', 'invoicing'),
1012
+            'trialling'  => __('Trialing', 'invoicing'),
1013
+            'active'     => __('Active', 'invoicing'),
1014
+            'failing'    => __('Failing', 'invoicing'),
1015
+            'expired'    => __('Expired', 'invoicing'),
1016
+            'completed'  => __('Complete', 'invoicing'),
1017
+            'cancelled'  =>__('Cancelled', 'invoicing'),
1018 1018
         )
1019 1019
     );
1020 1020
 
@@ -1025,9 +1025,9 @@  discard block
 block discarded – undo
1025 1025
  * 
1026 1026
  * @return string
1027 1027
  */
1028
-function getpaid_get_subscription_status_label( $status ) {
1028
+function getpaid_get_subscription_status_label($status) {
1029 1029
     $statuses = getpaid_get_subscription_statuses();
1030
-    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( $status );
1030
+    return isset($statuses[$status]) ? $statuses[$status] : ucfirst($status);
1031 1031
 }
1032 1032
 
1033 1033
 /**
@@ -1057,14 +1057,14 @@  discard block
 block discarded – undo
1057 1057
  * 
1058 1058
  * @return int
1059 1059
  */
1060
-function getpaid_get_subscription_status_counts( $args = array() ) {
1060
+function getpaid_get_subscription_status_counts($args = array()) {
1061 1061
 
1062
-    $statuses = array_keys( getpaid_get_subscription_statuses() );
1062
+    $statuses = array_keys(getpaid_get_subscription_statuses());
1063 1063
     $counts   = array();
1064 1064
 
1065
-    foreach ( $statuses as $status ) {
1066
-        $_args             = wp_parse_args( "status=$status", $args );
1067
-        $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
1065
+    foreach ($statuses as $status) {
1066
+        $_args             = wp_parse_args("status=$status", $args);
1067
+        $counts[$status] = getpaid_get_subscriptions($_args, 'count');
1068 1068
     }
1069 1069
 
1070 1070
     return $counts;
@@ -1076,18 +1076,18 @@  discard block
 block discarded – undo
1076 1076
  * 
1077 1077
  * @return array
1078 1078
  */
1079
-function getpaid_get_subscription_period_label( $period ) {
1079
+function getpaid_get_subscription_period_label($period) {
1080 1080
 
1081 1081
     $periods = array(
1082
-        'd'     => __( 'day', 'invoicing' ),
1083
-        'day'   => __( 'day', 'invoicing' ),
1084
-        'w'     => __( 'week', 'invoicing' ),
1085
-        'week'  => __( 'week', 'invoicing' ),
1086
-        'm'     => __( 'month', 'invoicing' ),
1087
-        'month' => __( 'month', 'invoicing' ),
1088
-        'y'     => __( 'year', 'invoicing' ),
1089
-        'year'  => __( 'year', 'invoicing' ),
1082
+        'd'     => __('day', 'invoicing'),
1083
+        'day'   => __('day', 'invoicing'),
1084
+        'w'     => __('week', 'invoicing'),
1085
+        'week'  => __('week', 'invoicing'),
1086
+        'm'     => __('month', 'invoicing'),
1087
+        'month' => __('month', 'invoicing'),
1088
+        'y'     => __('year', 'invoicing'),
1089
+        'year'  => __('year', 'invoicing'),
1090 1090
     );
1091 1091
 
1092
-    return isset( $periods[ $period ] ) ? strtolower( $periods[ $period ] ) : strtolower( $periods['d'] );
1092
+    return isset($periods[$period]) ? strtolower($periods[$period]) : strtolower($periods['d']);
1093 1093
 }
Please login to merge, or discard this patch.